Browse Source

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

nickysn 6 years ago
parent
commit
01669ebf70
3 changed files with 18 additions and 33 deletions
  1. 14 6
      rtl/bsd/system.pp
  2. 2 14
      rtl/openbsd/x86_64/prt0.as
  3. 2 13
      rtl/openbsd/x86_64/si_prc.inc

+ 14 - 6
rtl/bsd/system.pp

@@ -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}
-begin
-   Fpexit(cint(ExitCode));
-end;
-{$else darwin}
+{$if defined(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;

+ 2 - 14
rtl/openbsd/x86_64/prt0.as

@@ -127,21 +127,9 @@ ___start:
 
 
 _haltproc:
 _haltproc:
            movq $1,%rax
            movq $1,%rax
-           movzwq operatingsystem_result(%rip),%rbx
-           pushq   %rbx
-           call .Lactualsyscall
-           addq  $8,%rsp
+           movzwq operatingsystem_result(%rip),%rdi
+           syscall
            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

+ 2 - 13
rtl/openbsd/x86_64/si_prc.inc

@@ -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
-    pushq   %rbx
-    call    .Lactualsyscall
-    addq    $8,%rsp
+    movl    operatingsystem_result(%rip),%edi
+    syscall
     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';