* 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';
{$endif}
{$if defined(openbsd)}
procedure haltproc; cdecl; external name '_haltproc';
{$endif}
procedure System_exit;
{$ifndef darwin}
begin
Fpexit(cint(ExitCode));
end;
{$else darwin}
{$if defined(darwin)}
begin
{ make sure the libc atexit handlers are called, needed for e.g. profiling }
normalexit(cint(ExitCode));
end;
{$endif darwin}
{$elseif defined(openbsd)}
begin
haltproc;
end;
{$else}
begin
Fpexit(cint(ExitCode));
end;
{$endif}
Function ParamCount: Longint;

View File

@ -127,21 +127,9 @@ ___start:
_haltproc:
movq $1,%rax
movzwq operatingsystem_result(%rip),%rbx
pushq %rbx
call .Lactualsyscall
addq $8,%rsp
movzwq operatingsystem_result(%rip),%rdi
syscall
jmp _haltproc
.Lactualsyscall:
int $0x80
jb .LErrorcode
xor %rbx,%rbx
ret
.LErrorcode:
movq %rax,%rbx
movq $-1,%rax
ret
.LFE9:
.size ___start, .-___start
.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';
asm
movq $1,%rax
movl operatingsystem_result(%rip),%ebx
pushq %rbx
call .Lactualsyscall
addq $8,%rsp
movl operatingsystem_result(%rip),%edi
syscall
jmp _FPC_proc_haltproc
.Lactualsyscall:
int $0x80
jb .LErrorcode
xor %rbx,%rbx
ret
.LErrorcode:
movq %rax,%rbx
movq $-1,%rax
end;
function _strrchr(str: PChar; character: LongInt): PChar; public name '_strrchr';