mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 10:19:17 +02:00
* use the actual _haltproc procedure, defined in the startup code on OpenBSD
* fixed the x86_64 syscall invocation in the OpenBSD _haltproc git-svn-id: trunk@41762 -
This commit is contained in:
parent
7638a9b7e1
commit
01669ebf70
@ -105,17 +105,25 @@ end;
|
|||||||
procedure normalexit(status: cint); cdecl; external 'c' name 'exit';
|
procedure normalexit(status: cint); cdecl; external 'c' name 'exit';
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
|
{$if defined(openbsd)}
|
||||||
|
procedure haltproc; cdecl; external name '_haltproc';
|
||||||
|
{$endif}
|
||||||
|
|
||||||
procedure System_exit;
|
procedure System_exit;
|
||||||
{$ifndef darwin}
|
{$if defined(darwin)}
|
||||||
begin
|
|
||||||
Fpexit(cint(ExitCode));
|
|
||||||
end;
|
|
||||||
{$else darwin}
|
|
||||||
begin
|
begin
|
||||||
{ make sure the libc atexit handlers are called, needed for e.g. profiling }
|
{ make sure the libc atexit handlers are called, needed for e.g. profiling }
|
||||||
normalexit(cint(ExitCode));
|
normalexit(cint(ExitCode));
|
||||||
end;
|
end;
|
||||||
{$endif darwin}
|
{$elseif defined(openbsd)}
|
||||||
|
begin
|
||||||
|
haltproc;
|
||||||
|
end;
|
||||||
|
{$else}
|
||||||
|
begin
|
||||||
|
Fpexit(cint(ExitCode));
|
||||||
|
end;
|
||||||
|
{$endif}
|
||||||
|
|
||||||
|
|
||||||
Function ParamCount: Longint;
|
Function ParamCount: Longint;
|
||||||
|
@ -127,21 +127,9 @@ ___start:
|
|||||||
|
|
||||||
_haltproc:
|
_haltproc:
|
||||||
movq $1,%rax
|
movq $1,%rax
|
||||||
movzwq operatingsystem_result(%rip),%rbx
|
movzwq operatingsystem_result(%rip),%rdi
|
||||||
pushq %rbx
|
syscall
|
||||||
call .Lactualsyscall
|
|
||||||
addq $8,%rsp
|
|
||||||
jmp _haltproc
|
jmp _haltproc
|
||||||
|
|
||||||
.Lactualsyscall:
|
|
||||||
int $0x80
|
|
||||||
jb .LErrorcode
|
|
||||||
xor %rbx,%rbx
|
|
||||||
ret
|
|
||||||
.LErrorcode:
|
|
||||||
movq %rax,%rbx
|
|
||||||
movq $-1,%rax
|
|
||||||
ret
|
|
||||||
.LFE9:
|
.LFE9:
|
||||||
.size ___start, .-___start
|
.size ___start, .-___start
|
||||||
.type _strrchr, @function
|
.type _strrchr, @function
|
||||||
|
@ -68,20 +68,9 @@ procedure _FPC_proc___start(argc: LongInt; argv: PPChar; envp: Pointer; para1, p
|
|||||||
procedure _FPC_proc_haltproc; assembler; nostackframe; public name '_haltproc';
|
procedure _FPC_proc_haltproc; assembler; nostackframe; public name '_haltproc';
|
||||||
asm
|
asm
|
||||||
movq $1,%rax
|
movq $1,%rax
|
||||||
movl operatingsystem_result(%rip),%ebx
|
movl operatingsystem_result(%rip),%edi
|
||||||
pushq %rbx
|
syscall
|
||||||
call .Lactualsyscall
|
|
||||||
addq $8,%rsp
|
|
||||||
jmp _FPC_proc_haltproc
|
jmp _FPC_proc_haltproc
|
||||||
|
|
||||||
.Lactualsyscall:
|
|
||||||
int $0x80
|
|
||||||
jb .LErrorcode
|
|
||||||
xor %rbx,%rbx
|
|
||||||
ret
|
|
||||||
.LErrorcode:
|
|
||||||
movq %rax,%rbx
|
|
||||||
movq $-1,%rax
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function _strrchr(str: PChar; character: LongInt): PChar; public name '_strrchr';
|
function _strrchr(str: PChar; character: LongInt): PChar; public name '_strrchr';
|
||||||
|
Loading…
Reference in New Issue
Block a user