* 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:
nickysn 2019-03-21 18:16:23 +00:00
parent 7638a9b7e1
commit 01669ebf70
3 changed files with 18 additions and 33 deletions

View File

@ -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;

View File

@ -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

View File

@ -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';