Browse Source

# revisions: 41760,41761,41762,41763,41764,41765,41766,41769,41772,41773,41774,41775,41776,41777,41778,41779,41780,41781,41783

git-svn-id: branches/fixes_3_2@41990 -
marco 6 years ago
parent
commit
23fbaa2726

+ 0 - 4
.gitattributes

@@ -10110,7 +10110,6 @@ rtl/openbsd/errno.inc svneol=native#text/plain
 rtl/openbsd/errnostr.inc svneol=native#text/plain
 rtl/openbsd/errnostr.inc svneol=native#text/plain
 rtl/openbsd/i386/bsyscall.inc svneol=native#text/plain
 rtl/openbsd/i386/bsyscall.inc svneol=native#text/plain
 rtl/openbsd/i386/cprt0.as svneol=native#text/plain
 rtl/openbsd/i386/cprt0.as svneol=native#text/plain
-rtl/openbsd/i386/dllprt0.as svneol=native#text/plain
 rtl/openbsd/i386/openbsd_ident.inc svneol=native#text/plain
 rtl/openbsd/i386/openbsd_ident.inc svneol=native#text/plain
 rtl/openbsd/i386/prt0.as svneol=native#text/plain
 rtl/openbsd/i386/prt0.as svneol=native#text/plain
 rtl/openbsd/i386/si_c.inc svneol=native#text/plain
 rtl/openbsd/i386/si_c.inc svneol=native#text/plain
@@ -10146,9 +10145,6 @@ rtl/openbsd/unxfunc.inc svneol=native#text/plain
 rtl/openbsd/unxsysc.inc svneol=native#text/plain
 rtl/openbsd/unxsysc.inc svneol=native#text/plain
 rtl/openbsd/x86_64/bsyscall.inc svneol=native#text/plain
 rtl/openbsd/x86_64/bsyscall.inc svneol=native#text/plain
 rtl/openbsd/x86_64/cprt0.as svneol=native#text/plain
 rtl/openbsd/x86_64/cprt0.as svneol=native#text/plain
-rtl/openbsd/x86_64/crt0.s svneol=native#text/plain
-rtl/openbsd/x86_64/dllprt0.as svneol=native#text/plain
-rtl/openbsd/x86_64/gprt0.as svneol=native#text/plain
 rtl/openbsd/x86_64/openbsd_ident.inc svneol=native#text/plain
 rtl/openbsd/x86_64/openbsd_ident.inc svneol=native#text/plain
 rtl/openbsd/x86_64/prt0.as svneol=native#text/plain
 rtl/openbsd/x86_64/prt0.as svneol=native#text/plain
 rtl/openbsd/x86_64/si_c.inc svneol=native#text/plain
 rtl/openbsd/x86_64/si_c.inc svneol=native#text/plain

+ 1 - 1
compiler/systems.pas

@@ -339,7 +339,7 @@ interface
        systems_internal_sysinit = [system_i386_win32,system_x86_64_win64,
        systems_internal_sysinit = [system_i386_win32,system_x86_64_win64,
                                    system_i386_linux,system_powerpc64_linux,system_sparc64_linux,system_x86_64_linux,
                                    system_i386_linux,system_powerpc64_linux,system_sparc64_linux,system_x86_64_linux,
                                    system_m68k_atari,system_m68k_palmos,
                                    system_m68k_atari,system_m68k_palmos,
-                                   system_x86_64_openbsd
+                                   system_i386_openbsd,system_x86_64_openbsd
 
 
                                   ]+systems_darwin+systems_amigalike;
                                   ]+systems_darwin+systems_amigalike;
 
 

+ 5 - 2
compiler/x86/cgx86.pas

@@ -3137,13 +3137,11 @@ unit cgx86;
         {$endif}
         {$endif}
            system_i386_freebsd,
            system_i386_freebsd,
            system_i386_netbsd,
            system_i386_netbsd,
-//         system_i386_openbsd,
            system_i386_wdosx :
            system_i386_wdosx :
              begin
              begin
                 Case target_info.system Of
                 Case target_info.system Of
                  system_i386_freebsd : mcountprefix:='.';
                  system_i386_freebsd : mcountprefix:='.';
                  system_i386_netbsd : mcountprefix:='__';
                  system_i386_netbsd : mcountprefix:='__';
-//               system_i386_openbsd : mcountprefix:='.';
                 else
                 else
                  mcountPrefix:='';
                  mcountPrefix:='';
                 end;
                 end;
@@ -3171,6 +3169,11 @@ unit cgx86;
              begin
              begin
                a_call_name(list,'mcount',false);
                a_call_name(list,'mcount',false);
              end;
              end;
+           system_i386_openbsd,
+           system_x86_64_openbsd:
+             begin
+               a_call_name(list,'__mcount',false);
+             end;
         end;
         end;
       end;
       end;
 
 

+ 5 - 0
rtl/bsd/sysctl.pp

@@ -115,6 +115,11 @@ function FPsysctl (Name: pchar; namelen:cuint; oldp:pointer;oldlenp:psize_t; new
 function FPsysctl (Name: pcint; namelen:cuint; oldp:pointer;oldlenp:psize_t; newp:pointer;newlen:size_t):cint;
 function FPsysctl (Name: pcint; namelen:cuint; oldp:pointer;oldlenp:psize_t; newp:pointer;newlen:size_t):cint;
 {$endif}
 {$endif}
 
 
+{$ifdef OpenBSD}
+const
+  syscall_nr___sysctl = syscall_nr_sysctl;
+{$endif OpenBSD}
+
 Begin
 Begin
         if (pcint(name)[0] <> CTL_USER) Then
         if (pcint(name)[0] <> CTL_USER) Then
            exit(do_syscall(syscall_nr___sysctl,TSysParam(name), namelen, TSysParam(oldp), TSysParam(oldlenp), TSysParam(newp), TSysParam(newlen)))
            exit(do_syscall(syscall_nr___sysctl,TSysParam(name), namelen, TSysParam(oldp), TSysParam(oldlenp), TSysParam(newp), TSysParam(newlen)))

+ 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 - 10
rtl/openbsd/Makefile

@@ -340,22 +340,15 @@ BSDPROCINC=$(BSDINC)/$(CPU_TARGET)
 UNIXINC=$(RTL)/unix
 UNIXINC=$(RTL)/unix
 UNITPREFIX=rtl
 UNITPREFIX=rtl
 TARGETPROCINC=$(RTL)/openbsd/$(CPU_TARGET)
 TARGETPROCINC=$(RTL)/openbsd/$(CPU_TARGET)
-ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
 SYSTEMUNIT=system
 SYSTEMUNIT=system
 LINUXUNIT=
 LINUXUNIT=
 PRT0=prt0
 PRT0=prt0
-else
-SYSTEMUNIT=sysbsd
-LINUXUNIT=
-override FPCOPT+=-dUNIX
-PRT0=prt0_10
-endif
 ifdef RELEASE
 ifdef RELEASE
 override FPCOPT+=-Ur
 override FPCOPT+=-Ur
 endif
 endif
 CPU_UNITS=
 CPU_UNITS=
 SYSINIT_UNITS=
 SYSINIT_UNITS=
-LOADERS=prt0 cprt0 dllprt0
+LOADERS=prt0 cprt0
 ifeq ($(ARCH),x86_64)
 ifeq ($(ARCH),x86_64)
 CPU_UNITS=x86 ports cpu
 CPU_UNITS=x86 ports cpu
 SYSINIT_UNITS=si_prc si_c si_dll si_g
 SYSINIT_UNITS=si_prc si_c si_dll si_g
@@ -3014,6 +3007,7 @@ ifdef CLEAN_FILES
 	-$(DEL) $(CLEAN_FILES)
 	-$(DEL) $(CLEAN_FILES)
 endif
 endif
 	-$(DELTREE) units
 	-$(DELTREE) units
+	-$(DELTREE) bin
 	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
 	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
 ifneq ($(PPUEXT),.ppu)
 ifneq ($(PPUEXT),.ppu)
 	-$(DEL) *.o *.ppu *.a
 	-$(DEL) *.o *.ppu *.a
@@ -3173,8 +3167,6 @@ prt0$(OEXT) : $(CPU_TARGET)/$(PRT0).as
 	$(AS) -o $(UNITTARGETDIRPREFIX)prt0$(OEXT) $(CPU_TARGET)/$(PRT0).as
 	$(AS) -o $(UNITTARGETDIRPREFIX)prt0$(OEXT) $(CPU_TARGET)/$(PRT0).as
 cprt0$(OEXT) : $(CPU_TARGET)/cprt0.as
 cprt0$(OEXT) : $(CPU_TARGET)/cprt0.as
 	$(AS) -o $(UNITTARGETDIRPREFIX)cprt0$(OEXT) $(CPU_TARGET)/cprt0.as
 	$(AS) -o $(UNITTARGETDIRPREFIX)cprt0$(OEXT) $(CPU_TARGET)/cprt0.as
-dllprt0$(OEXT) : $(CPU_TARGET)/dllprt0.as
-	$(AS) -o $(UNITTARGETDIRPREFIX)dllprt0$(OEXT) $(CPU_TARGET)/dllprt0.as
 si_prc$(PPUEXT) : si_prc.pp si_intf.inc si_impl.inc $(ARCH)/openbsd_ident.inc $(ARCH)/si_prc.inc $(SYSTEMUNIT)$(PPUEXT)
 si_prc$(PPUEXT) : si_prc.pp si_intf.inc si_impl.inc $(ARCH)/openbsd_ident.inc $(ARCH)/si_prc.inc $(SYSTEMUNIT)$(PPUEXT)
 	$(COMPILER) $<
 	$(COMPILER) $<
 si_c$(PPUEXT) : si_c.pp si_intf.inc si_impl.inc $(ARCH)/openbsd_ident.inc $(ARCH)/si_c.inc $(SYSTEMUNIT)$(PPUEXT)
 si_c$(PPUEXT) : si_c.pp si_intf.inc si_impl.inc $(ARCH)/openbsd_ident.inc $(ARCH)/si_c.inc $(SYSTEMUNIT)$(PPUEXT)

+ 1 - 11
rtl/openbsd/Makefile.fpc

@@ -64,16 +64,9 @@ UNIXINC=$(RTL)/unix
 UNITPREFIX=rtl
 UNITPREFIX=rtl
 TARGETPROCINC=$(RTL)/openbsd/$(CPU_TARGET)
 TARGETPROCINC=$(RTL)/openbsd/$(CPU_TARGET)
 
 
-ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
 SYSTEMUNIT=system
 SYSTEMUNIT=system
 LINUXUNIT=
 LINUXUNIT=
 PRT0=prt0
 PRT0=prt0
-else
-SYSTEMUNIT=sysbsd
-LINUXUNIT=
-override FPCOPT+=-dUNIX
-PRT0=prt0_10
-endif
 
 
 # Use new feature from 1.0.5 version
 # Use new feature from 1.0.5 version
 # that generates release PPU files
 # that generates release PPU files
@@ -85,7 +78,7 @@ endif
 CPU_UNITS=
 CPU_UNITS=
 SYSINIT_UNITS=
 SYSINIT_UNITS=
 
 
-LOADERS=prt0 cprt0 dllprt0
+LOADERS=prt0 cprt0
 
 
 ifeq ($(ARCH),x86_64)
 ifeq ($(ARCH),x86_64)
 CPU_UNITS=x86 ports cpu
 CPU_UNITS=x86 ports cpu
@@ -138,9 +131,6 @@ prt0$(OEXT) : $(CPU_TARGET)/$(PRT0).as
 cprt0$(OEXT) : $(CPU_TARGET)/cprt0.as
 cprt0$(OEXT) : $(CPU_TARGET)/cprt0.as
         $(AS) -o $(UNITTARGETDIRPREFIX)cprt0$(OEXT) $(CPU_TARGET)/cprt0.as
         $(AS) -o $(UNITTARGETDIRPREFIX)cprt0$(OEXT) $(CPU_TARGET)/cprt0.as
 
 
-dllprt0$(OEXT) : $(CPU_TARGET)/dllprt0.as
-        $(AS) -o $(UNITTARGETDIRPREFIX)dllprt0$(OEXT) $(CPU_TARGET)/dllprt0.as
-
 
 
 #
 #
 # $(SYSINIT_UNITS) Units
 # $(SYSINIT_UNITS) Units

+ 0 - 209
rtl/openbsd/i386/dllprt0.as

@@ -1,209 +0,0 @@
-	.section ".note.openbsd.ident", "a"
-	.p2align 2
-	.long	8
-	.long	4
-	.long	1
-	.ascii "OpenBSD\0"
-	.long	0
-	.previous
-	.file	"crt0.c"
-gcc2_compiled.:
-	.globl	__progname
-	.section	.rodata
-.LC0:
-	.string	""
-	.section	.data.rel.local,"aw",@progbits
-	.align 4
-	.type	__progname, @object
-	.size	__progname, 4
-__progname:
-	.long	.LC0
-#APP
-	.text
-	.align  4
-	.globl  __start
-	.globl  _start
-_start:
-__start:
-	pushl	%ebx			#ps_strings
-	pushl   %ecx                    # obj
-	pushl   %edx                    # cleanup
-	movl    12(%esp),%eax
-	leal    20(%esp,%eax,4),%ecx
-	leal    16(%esp),%edx
-	pushl   %ecx
-	pushl   %edx
-	pushl   %eax
-	call    ___start 
-#NO_APP
-	.text
-	.globl	___start
-	.type	___start, @function
-___start:
-	pushl	%ebp
-	movl	%esp, %ebp
-	pushl	%ebx
-	subl	$36, %esp
-	call	__i686.get_pc_thunk.bx
-	addl	$_GLOBAL_OFFSET_TABLE_, %ebx
-	movl	environ@GOT(%ebx), %edx
-	movl	16(%ebp), %eax
-	movl	%eax, (%edx)
-	movl	operatingsystem_parameter_envp@GOT(%ebx), %edx
-	movl	16(%ebp), %eax
-	movl	%eax, (%edx)
-	movl	operatingsystem_parameter_argc@GOT(%ebx), %edx
-	movl	8(%ebp), %eax
-	movl	%eax, (%edx)
-	movl	operatingsystem_parameter_argv@GOT(%ebx), %edx
-	movl	12(%ebp), %eax
-	movl	%eax, (%edx)
-	movl	12(%ebp), %eax
-	movl	(%eax), %eax
-	movl	%eax, -8(%ebp)
-	cmpl	$0, -8(%ebp)
-	je	.L2
-	movl	$47, 4(%esp)
-	movl	-8(%ebp), %eax
-	movl	%eax, (%esp)
-	call	_strrchr
-	movl	%eax, %edx
-	movl	__progname@GOT(%ebx), %eax
-	movl	%edx, (%eax)
-	movl	__progname@GOT(%ebx), %eax
-	movl	(%eax), %eax
-	testl	%eax, %eax
-	jne	.L4
-	movl	__progname@GOT(%ebx), %edx
-	movl	-8(%ebp), %eax
-	movl	%eax, (%edx)
-	jmp	.L6
-.L4:
-	movl	__progname@GOT(%ebx), %eax
-	movl	(%eax), %eax
-	leal	1(%eax), %edx
-	movl	__progname@GOT(%ebx), %eax
-	movl	%edx, (%eax)
-.L6:
-	movl	__progname_storage@GOT(%ebx), %eax
-	movl	%eax, -12(%ebp)
-	jmp	.L7
-.L8:
-	movl	__progname@GOT(%ebx), %eax
-	movl	(%eax), %ecx
-	movzbl	(%ecx), %edx
-	movl	-12(%ebp), %eax
-	movb	%dl, (%eax)
-	addl	$1, -12(%ebp)
-	leal	1(%ecx), %edx
-	movl	__progname@GOT(%ebx), %eax
-	movl	%edx, (%eax)
-.L7:
-	movl	__progname@GOT(%ebx), %eax
-	movl	(%eax), %eax
-	movzbl	(%eax), %eax
-	testb	%al, %al
-	je	.L9
-	movl	__progname_storage@GOT(%ebx), %eax
-	leal	255(%eax), %eax
-	cmpl	%eax, -12(%ebp)
-	jb	.L8
-.L9:
-	movl	-12(%ebp), %eax
-	movb	$0, (%eax)
-	movl	__progname@GOT(%ebx), %edx
-	movl	__progname_storage@GOT(%ebx), %eax
-	movl	%eax, (%edx)
-.L2:
-	call	__init@PLT
-	movl	environ@GOT(%ebx), %eax
-	movl	(%eax), %eax
-	movl	%eax, 8(%esp)
-	movl	12(%ebp), %eax
-	movl	%eax, 4(%esp)
-	movl	8(%ebp), %eax
-	movl	%eax, (%esp)
-	call	main@PLT
-#	pushl environ
-#	pushl %esi
-#	pushl 8(%ebp)
-	finit
-	fwait
-	fldcw ___fpucw
-	xorl  %ebp,%ebp
-	call main
-	pushl %eax
-	call exit
-        .p2align 2,0x90
-
-#	movl	%eax, (%esp)
-#	call	exit@PLT
-	.size	___start, .-___start
-
-.globl _haltproc
-.type _haltproc,@function
-
-_haltproc:
-	mov $1,%eax
-	call	__i686.get_pc_thunk.bx
-	addl	$_GLOBAL_OFFSET_TABLE_, %ebx
-	movl operatingsystem_result@GOT(%ebx), %esi
-        movzwl (%esi),%edx
-        pushl %edx
-        call .Lactualsyscall
-        addl  $4,%esp
-        jmp   _haltproc
-
-.Lactualsyscall:
-        int $0x80
-        jb .LErrorcode
-        xor %ebx,%ebx
-        ret
-.LErrorcode:
-        mov %eax,%ebx
-        mov $-1,%eax
-	ret
-	.type	_strrchr, @function
-_strrchr:
-	pushl	%ebp
-	movl	%esp, %ebp
-	subl	$12, %esp
-	movl	12(%ebp), %eax
-	movb	%al, -9(%ebp)
-	movl	$0, -4(%ebp)
-.L13:
-	movl	8(%ebp), %edx
-	movzbl	(%edx), %eax
-	cmpb	-9(%ebp), %al
-	jne	.L14
-	movl	8(%ebp), %eax
-	movl	%eax, -4(%ebp)
-.L14:
-	movl	8(%ebp), %edx
-	movzbl	(%edx), %eax
-	testb	%al, %al
-	jne	.L16
-	movl	-4(%ebp), %eax
-	movl	%eax, -8(%ebp)
-	jmp	.L12
-.L16:
-	addl	$1, 8(%ebp)
-	jmp	.L13
-.L12:
-	movl	-8(%ebp), %eax
-	leave
-	ret
-	.size	_strrchr, .-_strrchr
-	.comm	environ,4,4
-	.comm	operatingsystem_parameter_envp,4,4
-	.comm	operatingsystem_parameter_argc,4,4
-	.comm	operatingsystem_parameter_argv,4,4
-	.comm	__progname_storage,256,32
-	.ident	"GCC: (GNU) 4.2.1 20070719 "
-	.section	.gnu.linkonce.t.__i686.get_pc_thunk.bx,"ax",@progbits
-	.globl	__i686.get_pc_thunk.bx
-	.hidden	__i686.get_pc_thunk.bx
-	.type	__i686.get_pc_thunk.bx, @function
-__i686.get_pc_thunk.bx:
-	movl	(%esp), %ebx
-	ret

+ 67 - 0
rtl/openbsd/i386/si_c.inc

@@ -14,4 +14,71 @@
 
 
  **********************************************************************}
  **********************************************************************}
 
 
+{$asmmode att}
+
+procedure __init; cdecl; external name '__init';
+procedure c_exit(exit_code: cint); cdecl; noreturn; external name 'exit';
+
+procedure _FPC_proc___start(argc: LongInt; argv: PPChar; envp: Pointer; para1, para2, para3: QWord); cdecl; forward;
+
+procedure _FPC_proc_start; assembler; nostackframe; public name '_start'; public name '__start';
+  asm
+    pushl   %ebx                    { ps_strings }
+    pushl   %ecx                    { obj }
+    pushl   %edx                    { cleanup }
+    movl    12(%esp),%eax
+    leal    20(%esp,%eax,4),%ecx
+    leal    16(%esp),%edx
+    pushl   %ecx
+    pushl   %edx
+    pushl   %eax
+    call    _FPC_proc___start
+  end;
+
+function _strrchr(str: PChar; character: LongInt): PChar; forward;
+
+procedure _FPC_proc___start(argc: LongInt; argv: PPChar; envp: Pointer; para1, para2, para3: QWord); cdecl;
+  var
+    I: SizeUInt;
+  begin
+    environ:=envp;
+    operatingsystem_parameter_envp:=envp;
+    operatingsystem_parameter_argc:=argc;
+    operatingsystem_parameter_argv:=argv;
+    if argv[0]<>nil then
+      begin
+        __progname:=_strrchr(argv[0], Ord('/'));
+        if __progname<>nil then
+          Inc(__progname)
+        else
+          __progname:=argv[0];
+        I:=Low(__progname_storage);
+        while (I<High(__progname_storage)) and (__progname[I]<>#0) do
+          begin
+            __progname_storage[I]:=__progname[I-Low(__progname_storage)];
+            Inc(I);
+          end;
+        __progname_storage[I]:=#0;
+        __progname:=@__progname_storage;
+      end;
+    __init;
+    PascalMain;
+    c_exit(operatingsystem_result);
+  end;
+
+procedure _FPC_proc_haltproc; cdecl; noreturn; public name '_haltproc';
+  begin
+    c_exit(operatingsystem_result);
+  end;
+
+function _strrchr(str: PChar; character: LongInt): PChar; public name '_strrchr';
+  begin
+    _strrchr:=nil;
+    repeat
+      if str^=Chr(character) then
+        _strrchr:=str;
+      if str^<>#0 then
+        Inc(str);
+    until str^=#0;
+  end;
 
 

+ 38 - 0
rtl/openbsd/i386/si_dll.inc

@@ -14,4 +14,42 @@
 
 
  **********************************************************************}
  **********************************************************************}
 
 
+{$asmmode att}
 
 
+{$ifdef VER3_0}
+procedure _init; cdecl; external name '_init';
+{$else VER3_0}
+procedure _init; cdecl; weakexternal name '_init';
+{$endif VER3_0}
+
+procedure _FPC_shared_lib_start; cdecl; public name 'FPC_LIB_START';
+  begin
+    { todo: figure out if there's any way to obtain these in OpenBSD shared libraries }
+    environ:=nil;
+    operatingsystem_parameter_envp:=nil;
+    operatingsystem_parameter_argc:=0;
+    operatingsystem_parameter_argv:=nil;
+    if Assigned(@_init) then
+      _init;
+    PascalMain;
+  end;
+
+{ this routine is only called when the halt() routine of the RTL embedded in
+  the shared library is called }
+procedure _FPC_shared_lib_haltproc; cdecl; public name '_haltproc';
+  var
+    ExitCode: LongInt;
+  begin
+    ExitCode:=operatingsystem_result;
+    asm
+.Lendless:
+      pushl   ExitCode
+      mov     $1,%eax
+      call    .Lactualsyscall
+      jmp     .Lendless
+
+.Lactualsyscall:
+      int     $0x80
+      ret
+    end;
+  end;

+ 80 - 0
rtl/openbsd/i386/si_g.inc

@@ -14,3 +14,83 @@
 
 
  **********************************************************************}
  **********************************************************************}
 
 
+{$asmmode att}
+
+var
+  _etext: Byte; external name '_etext';
+  _eprol: Byte; external name '_eprol';
+
+procedure _mcleanup; cdecl; external name '_mcleanup';
+function atexit(proc: TCdeclProcedure): cint; cdecl; external name 'atexit';
+procedure _monstartup(lowpc, highpc: u_long); cdecl; external name '_monstartup';
+procedure __init; cdecl; external name '__init';
+procedure c_exit(exit_code: cint); cdecl; noreturn; external name 'exit';
+
+procedure _FPC_proc___start(argc: LongInt; argv: PPChar; envp: Pointer; para1, para2, para3: QWord); cdecl; forward;
+
+procedure _FPC_proc_start; assembler; nostackframe; public name '_start'; public name '__start';
+  asm
+    pushl   %ebx                    { ps_strings }
+    pushl   %ecx                    { obj }
+    pushl   %edx                    { cleanup }
+    movl    12(%esp),%eax
+    leal    20(%esp,%eax,4),%ecx
+    leal    16(%esp),%edx
+    pushl   %ecx
+    pushl   %edx
+    pushl   %eax
+    call    _FPC_proc___start
+  end;
+
+function _strrchr(str: PChar; character: LongInt): PChar; forward;
+
+procedure _FPC_proc___start(argc: LongInt; argv: PPChar; envp: Pointer; para1, para2, para3: QWord); cdecl;
+  var
+    I: SizeUInt;
+  begin
+    environ:=envp;
+    operatingsystem_parameter_envp:=envp;
+    operatingsystem_parameter_argc:=argc;
+    operatingsystem_parameter_argv:=argv;
+    if argv[0]<>nil then
+      begin
+        __progname:=_strrchr(argv[0], Ord('/'));
+        if __progname<>nil then
+          Inc(__progname)
+        else
+          __progname:=argv[0];
+        I:=Low(__progname_storage);
+        while (I<High(__progname_storage)) and (__progname[I]<>#0) do
+          begin
+            __progname_storage[I]:=__progname[I-Low(__progname_storage)];
+            Inc(I);
+          end;
+        __progname_storage[I]:=#0;
+        __progname:=@__progname_storage;
+      end;
+    atexit(@_mcleanup);
+    _monstartup(u_long(@_eprol),u_long(@_etext));
+    __init;
+    PascalMain;
+    c_exit(operatingsystem_result);
+  end;
+
+procedure _FPC_proc_haltproc; cdecl; noreturn; public name '_haltproc';
+  begin
+    c_exit(operatingsystem_result);
+  end;
+
+function _strrchr(str: PChar; character: LongInt): PChar; public name '_strrchr';
+  begin
+    _strrchr:=nil;
+    repeat
+      if str^=Chr(character) then
+        _strrchr:=str;
+      if str^<>#0 then
+        Inc(str);
+    until str^=#0;
+  end;
+
+procedure MD_EPROL_LABEL; assembler; nostackframe; public name '_eprol';
+  asm
+  end;

+ 78 - 0
rtl/openbsd/i386/si_prc.inc

@@ -14,4 +14,82 @@
 
 
  **********************************************************************}
  **********************************************************************}
 
 
+{$asmmode att}
 
 
+procedure _FPC_proc___start(argc: LongInt; argv: PPChar; envp: Pointer; para1, para2, para3: QWord); cdecl; forward;
+
+procedure _FPC_proc_start; assembler; nostackframe; public name '_start'; public name '__start';
+  asm
+    pushl   %ebx                    { ps_strings }
+    pushl   %ecx                    { obj }
+    pushl   %edx                    { cleanup }
+    movl    12(%esp),%eax
+    leal    20(%esp,%eax,4),%ecx
+    leal    16(%esp),%edx
+    pushl   %ecx
+    pushl   %edx
+    pushl   %eax
+    call    _FPC_proc___start
+  end;
+
+procedure _FPC_proc_haltproc; cdecl; noreturn; forward;
+function _strrchr(str: PChar; character: LongInt): PChar; forward;
+
+procedure _FPC_proc___start(argc: LongInt; argv: PPChar; envp: Pointer; para1, para2, para3: QWord); cdecl;
+  var
+    I: SizeUInt;
+  begin
+    environ:=envp;
+    operatingsystem_parameter_envp:=envp;
+    operatingsystem_parameter_argc:=argc;
+    operatingsystem_parameter_argv:=argv;
+    if argv[0]<>nil then
+      begin
+        __progname:=_strrchr(argv[0], Ord('/'));
+        if __progname<>nil then
+          Inc(__progname)
+        else
+          __progname:=argv[0];
+        I:=Low(__progname_storage);
+        while (I<High(__progname_storage)) and (__progname[I]<>#0) do
+          begin
+            __progname_storage[I]:=__progname[I-Low(__progname_storage)];
+            Inc(I);
+          end;
+        __progname_storage[I]:=#0;
+        __progname:=@__progname_storage;
+      end;
+    PascalMain;
+    asm
+      jmp     _FPC_proc_haltproc
+    end;
+  end;
+
+procedure _FPC_proc_haltproc; cdecl; noreturn; public name '_haltproc';
+  var
+    ExitCode: LongInt;
+  begin
+    ExitCode:=operatingsystem_result;
+    asm
+.Lendless:
+      pushl   ExitCode
+      mov     $1,%eax
+      call    .Lactualsyscall
+      jmp     .Lendless
+
+.Lactualsyscall:
+      int     $0x80
+      ret
+    end;
+  end;
+
+function _strrchr(str: PChar; character: LongInt): PChar; public name '_strrchr';
+  begin
+    _strrchr:=nil;
+    repeat
+      if str^=Chr(character) then
+        _strrchr:=str;
+      if str^<>#0 then
+        Inc(str);
+    until str^=#0;
+  end;

+ 1 - 63
rtl/openbsd/setsysnr.inc

@@ -34,7 +34,7 @@ Begin
   len    := sizeof (release) - 1;
   len    := sizeof (release) - 1;
   oerrno := geterrno;
   oerrno := geterrno;
 
 
-  if (do_syscall(syscall_nr___sysctl,TSysParam(@mib), 2, TSysParam(@release[1]),
+  if (do_syscall(syscall_nr_sysctl,TSysParam(@mib), 2, TSysParam(@release[1]),
        TSysParam(@len), TSysParam(NIL), 0) = -1) Then
        TSysParam(@len), TSysParam(NIL), 0) = -1) Then
     Begin
     Begin
       if (geterrno = ESysENOMEM) Then
       if (geterrno = ESysENOMEM) Then
@@ -65,73 +65,11 @@ Begin
 
 
   version:=version_major * 1000 + version_minor;
   version:=version_major * 1000 + version_minor;
 
 
-  if version >= 5005 then
-    begin
-      syscall_nr_waitpid := syscall_nr_wait4_55;
-      syscall_nr_setitimer := syscall_nr_setitimer_55;
-      syscall_nr_getitimer := syscall_nr_getitimer_55;
-      syscall_nr_gettimeofday := syscall_nr_gettimeofday_55;
-      syscall_nr_settimeofday := syscall_nr_settimeofday_55;
-      syscall_nr_clock_gettime := syscall_nr_clock_gettime_55;
-      syscall_nr_clock_settime := syscall_nr_clock_settime_55;
-      syscall_nr_clock_getres := syscall_nr_clock_getres_55;
-      syscall_nr_select := syscall_nr_select_55;
-      syscall_nr_getrusage := syscall_nr_getrusage_55;
-      syscall_nr_utimes := syscall_nr_utimes_55;
-      syscall_nr_futimes := syscall_nr_futimes_55;
-      syscall_nr_nanosleep := syscall_nr_nanosleep_55;
-      syscall_nr_kevent := syscall_nr_kevent_55;
-    end;
-  if version>= 5004 then
-    begin
-      syscall_nr_statfs := syscall_nr_statfs_54;
-      syscall_nr_fstatfs := syscall_nr_fstatfs_54;
-      syscall_nr_fhstatfs := syscall_nr_fhstatfs_54;
-    end
-  else if version >= 4004 then
-    begin
-      syscall_nr_statfs := syscall_nr_statfs_44;
-      syscall_nr_fstatfs := syscall_nr_fstatfs_44;
-      syscall_nr_fhstatfs := syscall_nr_fhstatfs_44;
-    end
-  else if version < 2006 then
-    begin
-      syscall_nr_statfs := syscall_nr_statfs_20;
-      syscall_nr_fstatfs := syscall_nr_fstatfs_20;
-      syscall_nr_pipe := syscall_nr_pipe_20;
-    end;
-
-  if version>= 5005 then
-    begin
-      syscall_nr_stat := syscall_nr_stat_55;
-      syscall_nr_fstat := syscall_nr_fstat_55;
-      syscall_nr_lstat := syscall_nr_lstat_55;
-      syscall_nr_fstatat := syscall_nr_fstatat_55;
-    end
-  else if version < 3006 then
-    begin
-      syscall_nr_stat := syscall_nr_stat_20;
-      syscall_nr_fstat := syscall_nr_fstat_20;
-      syscall_nr_lstat := syscall_nr_lstat_20;
-      syscall_nr_fhstat := syscall_nr_fhstat_20;
-    end;
-  if version < 3005 then
-    syscall_nr_sigaltstack := syscall_nr_sigaltstack_20;
-  if version = 5001 then
-    syscall_nr___tfork := syscall_nr___tfork_51
-  else if version > 5001 then
-    syscall_nr___tfork := syscall_nr___tfork_52;
-
   if version >= 5005 then
   if version >= 5005 then
     begin
     begin
       { FIXME: what should we do here? }
       { FIXME: what should we do here? }
       syscall_nr_getdirentries := -1;
       syscall_nr_getdirentries := -1;
       use_getdirentries_syscall:=false;
       use_getdirentries_syscall:=false;
-    end
-  else if version >= 4009 then
-    begin
-      syscall_nr_getdirentries := syscall_nr_getdirentries_49;
-      use_openbsd_getdirentries_49:=true;
     end;
     end;
 
 
 end;
 end;

+ 50 - 148
rtl/openbsd/sysnr.inc

@@ -18,7 +18,7 @@
  * created from; OpenBSD: syscalls.master,v 1.104 2010/10/28 15:02:41 millert Exp
  * created from; OpenBSD: syscalls.master,v 1.104 2010/10/28 15:02:41 millert Exp
  *  (OpenBSD/i386 4.9 release)
  *  (OpenBSD/i386 4.9 release)
 
 
-  Checked with syscall.h release tags from 2.0 to 5.6 2014/10/14
+  Checked with syscall.h release tags from 2.0 to 6.4 2018/07/30
 
 
 }
 }
 
 
@@ -30,22 +30,19 @@ Const
 (* 4 *)    syscall_nr_write = 4;
 (* 4 *)    syscall_nr_write = 4;
 (* 5 *)    syscall_nr_open = 5;
 (* 5 *)    syscall_nr_open = 5;
 (* 6 *)    syscall_nr_close = 6;
 (* 6 *)    syscall_nr_close = 6;
-(* 7 *)    syscall_nr_wait4 = 7; (* up to 5.4 release *)
 (* 7 *)    syscall_nr_getentropy = 7; (* from 5.6 release *)
 (* 7 *)    syscall_nr_getentropy = 7; (* from 5.6 release *)
-(* 8 *)    syscall_nr___tfork_52 = 8; (* from 5.2 release *)
+(* 8 *)    syscall_nr___tfork = 8; (* from 5.2 release *)
 (* 9 *)    syscall_nr_link = 9;
 (* 9 *)    syscall_nr_link = 9;
 (* 10 *)    syscall_nr_unlink = 10;
 (* 10 *)    syscall_nr_unlink = 10;
-(* 11 *)    syscall_nr_wait4_55 = 11; (* from 5.5 release *)
+(* 11 *)    syscall_nr_wait4 = 11; (* from 5.5 release *)
 (* 12 *)    syscall_nr_chdir = 12;
 (* 12 *)    syscall_nr_chdir = 12;
 (* 13 *)    syscall_nr_fchdir = 13;
 (* 13 *)    syscall_nr_fchdir = 13;
 (* 14 *)    syscall_nr_mknod = 14;
 (* 14 *)    syscall_nr_mknod = 14;
 (* 15 *)    syscall_nr_chmod = 15;
 (* 15 *)    syscall_nr_chmod = 15;
 (* 16 *)    syscall_nr_chown = 16;
 (* 16 *)    syscall_nr_chown = 16;
 (* 17 *)    syscall_nr_break = 17;
 (* 17 *)    syscall_nr_break = 17;
-(* 18 *)    syscall_nr_getfsstat_20 = 18; (* up to 2.5 release *)
-(* 18 *)    syscall_nr_ogetfsstat = 18; (* from 2.6 up to 2.9 release *)
 (* 18 *)    syscall_nr_getdtablecount = 18; (* from 5.2 release *)
 (* 18 *)    syscall_nr_getdtablecount = 18; (* from 5.2 release *)
-(* 19 *)    syscall_nr_getrusage_55 = 19; (* from 5.5 release *)
+(* 19 *)    syscall_nr_getrusage = 19; (* from 5.5 release *)
 (* 20 *)    syscall_nr_getpid = 20;
 (* 20 *)    syscall_nr_getpid = 20;
 (* 21 *)    syscall_nr_mount = 21;
 (* 21 *)    syscall_nr_mount = 21;
 (* 22 *)    syscall_nr_unmount = 22;
 (* 22 *)    syscall_nr_unmount = 22;
@@ -63,27 +60,21 @@ Const
 (* 34 *)    syscall_nr_chflags = 34;
 (* 34 *)    syscall_nr_chflags = 34;
 (* 35 *)    syscall_nr_fchflags = 35;
 (* 35 *)    syscall_nr_fchflags = 35;
 (* 36 *)    syscall_nr_sync = 36;
 (* 36 *)    syscall_nr_sync = 36;
-(* 37 *)    syscall_nr_kill = 37;
-(* 38 *)    syscall_nr_stat_55 = 38; (* from 5.5 release *)
+(* 38 *)    syscall_nr_stat = 38; (* from 5.5 release *)
 (* 39 *)    syscall_nr_getppid = 39;
 (* 39 *)    syscall_nr_getppid = 39;
-(* 40 *)    syscall_nr_lstat_55 = 40; (* from 5.5 release *)
+(* 40 *)    syscall_nr_lstat = 40; (* from 5.5 release *)
 (* 41 *)    syscall_nr_dup = 41;
 (* 41 *)    syscall_nr_dup = 41;
-(* 42 *)    syscall_nr_pipe_20 = 42; (* up to 2.5 release *)
-(* 42 *)    syscall_nr_opipe = 42; (* from 2.6 up to 4.9 release *)
-(* 42 *)    syscall_nr_fstatat_55 = 42; (* from 5.5 release *)
+(* 42 *)    syscall_nr_fstatat = 42; (* from 5.5 release *)
 (* 43 *)    syscall_nr_getegid = 43;
 (* 43 *)    syscall_nr_getegid = 43;
 (* 44 *)    syscall_nr_profil = 44;
 (* 44 *)    syscall_nr_profil = 44;
 (* 45 *)    syscall_nr_ktrace = 45;
 (* 45 *)    syscall_nr_ktrace = 45;
 (* 46 *)    syscall_nr_sigaction = 46;
 (* 46 *)    syscall_nr_sigaction = 46;
 (* 47 *)    syscall_nr_getgid = 47;
 (* 47 *)    syscall_nr_getgid = 47;
 (* 48 *)    syscall_nr_sigprocmask = 48;
 (* 48 *)    syscall_nr_sigprocmask = 48;
-(* 49 *)    syscall_nr_getlogin = 49;
 (* 50 *)    syscall_nr_setlogin = 50;
 (* 50 *)    syscall_nr_setlogin = 50;
 (* 51 *)    syscall_nr_acct = 51;
 (* 51 *)    syscall_nr_acct = 51;
 (* 52 *)    syscall_nr_sigpending = 52;
 (* 52 *)    syscall_nr_sigpending = 52;
-(* 53 *)    syscall_nr_sigaltstack_20 = 53; (* up to 3.4 release *)
-(* 53 *)    syscall_nr_osigaltstack = 53; (* from 3.5 up to 4.3 release *)
-(* 53 *)    syscall_nr_fstat_55 = 53; (* from 5.5 release *)
+(* 53 *)    syscall_nr_fstat = 53; (* from 5.5 release *)
 (* 54 *)    syscall_nr_ioctl = 54;
 (* 54 *)    syscall_nr_ioctl = 54;
 (* 55 *)    syscall_nr_reboot = 55;
 (* 55 *)    syscall_nr_reboot = 55;
 (* 56 *)    syscall_nr_revoke = 56;
 (* 56 *)    syscall_nr_revoke = 56;
@@ -92,66 +83,64 @@ Const
 (* 59 *)    syscall_nr_execve = 59;
 (* 59 *)    syscall_nr_execve = 59;
 (* 60 *)    syscall_nr_umask = 60;
 (* 60 *)    syscall_nr_umask = 60;
 (* 61 *)    syscall_nr_chroot = 61;
 (* 61 *)    syscall_nr_chroot = 61;
-(* 62 *)    syscall_nr_getfsstat_54 = 62; (* from 5.4 release *)
-(* 63 *)    syscall_nr_statfs_54 = 63; (* from 5.4 release *)
-(* 64 *)    syscall_nr_fstatfs_54 = 64; (* from 5.4 release *)
-(* 65 *)    syscall_nr_msync_20 = 65; (* up to 2.2 release *)
-(* 65 *)    syscall_nr_omsync = 65; (* from 2.3 up to 3.3 release *)
-(* 65 *)    syscall_nr_fhstatfs_54 = 65; (* from 5.4 release *)
+(* 62 *)    syscall_nr_getfsstat = 62; (* from 5.4 release *)
+(* 63 *)    syscall_nr_statfs = 63; (* from 5.4 release *)
+(* 64 *)    syscall_nr_fstatfs = 64; (* from 5.4 release *)
+(* 65 *)    syscall_nr_fhstatfs = 65; (* from 5.4 release *)
 (* 66 *)    syscall_nr_vfork = 66;
 (* 66 *)    syscall_nr_vfork = 66;
-(* 67 *)    syscall_nr_gettimeofday_55 = 67; (* from 5.5 release *)
-(* 68 *)    syscall_nr_settimeofday_55 = 68; (* from 5.5 release *)
-(* 69 *)    syscall_nr_sbrk = 69; (* up to 4.9 release *)
-(* 69 *)    syscall_nr_setitimer_55 = 69; (* from 5.5 release *)
-(* 70 *)    syscall_nr_sstk = 70; (* up to 4.9 release *)
-(* 70 *)    syscall_nr_getitimer_55 = 70; (* from 5.5 release *)
-(* 71 *)    syscall_nr_select_55 = 71; (* from 5.5 release *)
-(* 72 *)    syscall_nr_vadvise = 72; (* up to 4.2 release *)
-(* 72 *)    syscall_nr_kevent_55 = 72; (* from 5.5 release *)
+(* 67 *)    syscall_nr_gettimeofday = 67; (* from 5.5 release *)
+(* 68 *)    syscall_nr_settimeofday = 68; (* from 5.5 release *)
+(* 69 *)    syscall_nr_setitimer = 69; (* from 5.5 release *)
+(* 70 *)    syscall_nr_getitimer = 70; (* from 5.5 release *)
+(* 71 *)    syscall_nr_select = 71; (* from 5.5 release *)
+(* 72 *)    syscall_nr_kevent = 72; (* from 5.5 release *)
 (* 73 *)    syscall_nr_munmap = 73;
 (* 73 *)    syscall_nr_munmap = 73;
 (* 74 *)    syscall_nr_mprotect = 74;
 (* 74 *)    syscall_nr_mprotect = 74;
 (* 75 *)    syscall_nr_madvise = 75;
 (* 75 *)    syscall_nr_madvise = 75;
-(* 76 *)    syscall_nr_utimes_55 = 76; (* from 5.5 release *)
-(* 77 *)    syscall_nr_futimes_55 = 77; (* from 5.5 release *)
+(* 76 *)    syscall_nr_utimes = 76; (* from 5.5 release *)
+(* 77 *)    syscall_nr_futimes = 77; (* from 5.5 release *)
 (* 78 *)    syscall_nr_mincore = 78;
 (* 78 *)    syscall_nr_mincore = 78;
 (* 79 *)    syscall_nr_getgroups = 79;
 (* 79 *)    syscall_nr_getgroups = 79;
 (* 80 *)    syscall_nr_setgroups = 80;
 (* 80 *)    syscall_nr_setgroups = 80;
 (* 81 *)    syscall_nr_getpgrp = 81;
 (* 81 *)    syscall_nr_getpgrp = 81;
 (* 82 *)    syscall_nr_setpgid = 82;
 (* 82 *)    syscall_nr_setpgid = 82;
-(* 83 *)    syscall_nr_setitimer_20 = 83; (* up to 5.4 release *)
-(* 83 *)    syscall_nr_sendsyslog = 83; (* from 5.6 release *)
-(* 84 *)    syscall_nr_utimensat_55 = 84; (* from 5.5 release *)
-(* 85 *)    syscall_nr_swapon = 85; (* up to 3.3 release *)
-(* 85 *)    syscall_nr_futimens_55 = 85; (* from  5.5 release *)
-(* 86 *)    syscall_nr_getitimer_20 = 86;
-(* 87 *)    syscall_nr_clock_gettime_55 = 87; (* from  5.5 release *)
-(* 88 *)    syscall_nr_clock_settime_55 = 88; (* from  5.5 release *)
-(* 89 *)    syscall_nr_clock_getres_55 = 89; (* from  5.5 release *)
+(* 83 *)    syscall_nr_futex = 83; (* from 6.2 release *)
+(* 84 *)    syscall_nr_utimensat = 84; (* from 5.5 release *)
+(* 85 *)    syscall_nr_futimens = 85; (* from  5.5 release *)
+(* 86 *)    syscall_nr_kbind = 86; (* from 5.8 release *)
+(* 87 *)    syscall_nr_clock_gettime = 87; (* from  5.5 release *)
+(* 88 *)    syscall_nr_clock_settime = 88; (* from  5.5 release *)
+(* 89 *)    syscall_nr_clock_getres = 89; (* from  5.5 release *)
 (* 90 *)    syscall_nr_dup2 = 90;
 (* 90 *)    syscall_nr_dup2 = 90;
-(* 91 *)    syscall_nr_nanosleep_55 = 91; (* from  5.5 release *)
+(* 91 *)    syscall_nr_nanosleep = 91; (* from  5.5 release *)
 (* 92 *)    syscall_nr_fcntl = 92;
 (* 92 *)    syscall_nr_fcntl = 92;
-(* 93 *)    syscall_nr_select_20 = 93; (* up to 5.4 release *)
-(* 94 *)    syscall_nr___thrsleep_55 = 94; (* from 5.5 release *)
+(* 93 *)    syscall_nr_accept4 = 93;  (* from 5.7 release *)
+(* 94 *)    syscall_nr___thrsleep = 94; (* from 5.5 release *)
 (* 95 *)    syscall_nr_fsync = 95;
 (* 95 *)    syscall_nr_fsync = 95;
 (* 96 *)    syscall_nr_setpriority = 96;
 (* 96 *)    syscall_nr_setpriority = 96;
 (* 97 *)    syscall_nr_socket = 97;
 (* 97 *)    syscall_nr_socket = 97;
 (* 98 *)    syscall_nr_connect = 98;
 (* 98 *)    syscall_nr_connect = 98;
 (* 99 *)    syscall_nr_getdents = 99;
 (* 99 *)    syscall_nr_getdents = 99;
 (* 100 *)    syscall_nr_getpriority = 100;
 (* 100 *)    syscall_nr_getpriority = 100;
+(* 101 *)    syscall_nr_pipe2 = 101; (* from 5.7 release *)
+(* 102 *)    syscall_nr_dup3 = 102; (* from 5.7 release *)
 (* 103 *)    syscall_nr_sigreturn = 103;
 (* 103 *)    syscall_nr_sigreturn = 103;
 (* 104 *)    syscall_nr_bind = 104;
 (* 104 *)    syscall_nr_bind = 104;
 (* 105 *)    syscall_nr_setsockopt = 105;
 (* 105 *)    syscall_nr_setsockopt = 105;
 (* 106 *)    syscall_nr_listen = 106;
 (* 106 *)    syscall_nr_listen = 106;
+(* 107 *)    syscall_nr_chflagsat = 107; (* from 5.7 release *)
+(* 108 *)    syscall_nr_pledge = 108; (* from 5.9 release *)
 (* 109 *)    syscall_nr_ppoll = 109;
 (* 109 *)    syscall_nr_ppoll = 109;
 (* 110 *)    syscall_nr_pselect = 110;
 (* 110 *)    syscall_nr_pselect = 110;
 (* 111 *)    syscall_nr_sigsuspend = 111;
 (* 111 *)    syscall_nr_sigsuspend = 111;
-(* 115 *)    syscall_nr_vtrace = 115;
-(* 116 *)    syscall_nr_gettimeofday_20 = 116; (* up to 5.4 release *)
-(* 117 *)    syscall_nr_getrusage_20 = 117; (* up to 5.4 release *)
+(* 112 *)    syscall_nr_sendsyslog = 112; (* from 6.0 release *)
+(* 113 *)    syscall_nr_fktrace = 113; (* from 6.2 release *)
+(* 114 *)    syscall_nr_unveil = 114; (* from 6.4 release *)
 (* 118 *)    syscall_nr_getsockopt = 118;
 (* 118 *)    syscall_nr_getsockopt = 118;
+(* 119 *)    syscall_nr_thrkill = 119; (* from 5.9 release *)
 (* 120 *)    syscall_nr_readv = 120;
 (* 120 *)    syscall_nr_readv = 120;
 (* 121 *)    syscall_nr_writev = 121;
 (* 121 *)    syscall_nr_writev = 121;
-(* 122 *)    syscall_nr_settimeofday_20 = 122; (* up to 5.4 release *)
+(* 122 *)    syscall_nr_kill = 122; (* from 5.9 release *)
 (* 123 *)    syscall_nr_fchown = 123;
 (* 123 *)    syscall_nr_fchown = 123;
 (* 124 *)    syscall_nr_fchmod = 124;
 (* 124 *)    syscall_nr_fchmod = 124;
 (* 126 *)    syscall_nr_setreuid = 126;
 (* 126 *)    syscall_nr_setreuid = 126;
@@ -164,15 +153,11 @@ Const
 (* 135 *)    syscall_nr_socketpair = 135;
 (* 135 *)    syscall_nr_socketpair = 135;
 (* 136 *)    syscall_nr_mkdir = 136;
 (* 136 *)    syscall_nr_mkdir = 136;
 (* 137 *)    syscall_nr_rmdir = 137;
 (* 137 *)    syscall_nr_rmdir = 137;
-(* 138 *)    syscall_nr_utimes_20 = 138; (* up to 5.4 release *)
 (* 140 *)    syscall_nr_adjtime = 140;
 (* 140 *)    syscall_nr_adjtime = 140;
+(* 141 *)    syscall_nr_getlogin_r = 141; (* from 6.0 release *)
 (* 147 *)    syscall_nr_setsid = 147;
 (* 147 *)    syscall_nr_setsid = 147;
 (* 148 *)    syscall_nr_quotactl = 148;
 (* 148 *)    syscall_nr_quotactl = 148;
 (* 155 *)    syscall_nr_nfssvc = 155;
 (* 155 *)    syscall_nr_nfssvc = 155;
-(* 157 *)    syscall_nr_statfs_20 = 157; (* up to 2.5 release *)
-(* 157 *)    syscall_nr_ostatfs = 157; (* from 2.6 to 2.9 release *)
-(* 158 *)    syscall_nr_fstatfs_20 = 158; (* up to 2.5 release *)
-(* 158 *)    syscall_nr_ofstatfs = 158; (* from 2.6 to 2.9 release *)
 (* 161 *)    syscall_nr_getfh = 161;
 (* 161 *)    syscall_nr_getfh = 161;
 (* 165 *)    syscall_nr_sysarch = 165;
 (* 165 *)    syscall_nr_sysarch = 165;
 (* 169 *)    syscall_nr_semsys = 169; (* old compat_10, but required for ipcbsd.inc rtl-extra compilation *)
 (* 169 *)    syscall_nr_semsys = 169; (* old compat_10, but required for ipcbsd.inc rtl-extra compilation *)
@@ -185,74 +170,39 @@ Const
 (* 181 *)    syscall_nr_setgid = 181;
 (* 181 *)    syscall_nr_setgid = 181;
 (* 182 *)    syscall_nr_setegid = 182;
 (* 182 *)    syscall_nr_setegid = 182;
 (* 183 *)    syscall_nr_seteuid = 183;
 (* 183 *)    syscall_nr_seteuid = 183;
-(* 184 *)    syscall_nr_lfs_bmapv = 184;
-(* 185 *)    syscall_nr_lfs_markv = 185;
-(* 186 *)    syscall_nr_lfs_segclean = 186;
-(* 187 *)    syscall_nr_lfs_segwait = 187;
-(* 188 *)    syscall_nr_stat_20 = 188; (* up to 3.5 release *)
-(* 189 *)    syscall_nr_fstat_20 = 189; (* up to 3.5 release *)
-(* 190 *)    syscall_nr_lstat_20 = 190; (* up to 3.5 release *)
 (* 191 *)    syscall_nr_pathconf = 191;
 (* 191 *)    syscall_nr_pathconf = 191;
 (* 192 *)    syscall_nr_fpathconf = 192;
 (* 192 *)    syscall_nr_fpathconf = 192;
 (* 193 *)    syscall_nr_swapctl = 193;
 (* 193 *)    syscall_nr_swapctl = 193;
 (* 194 *)    syscall_nr_getrlimit = 194;
 (* 194 *)    syscall_nr_getrlimit = 194;
 (* 195 *)    syscall_nr_setrlimit = 195;
 (* 195 *)    syscall_nr_setrlimit = 195;
-(* 196 *)    syscall_nr_getdirentries_20 = 196; (* up to 4.8 release *)
-(* 196 *)    syscall_nr_ogetdirentries = 196; (* 4.9 release only *)
 (* 197 *)    syscall_nr_mmap = 197;
 (* 197 *)    syscall_nr_mmap = 197;
 (* 198 *)    syscall_nr___syscall = 198;
 (* 198 *)    syscall_nr___syscall = 198;
 (* 199 *)    syscall_nr_lseek = 199;
 (* 199 *)    syscall_nr_lseek = 199;
 (* 200 *)    syscall_nr_truncate = 200;
 (* 200 *)    syscall_nr_truncate = 200;
 (* 201 *)    syscall_nr_ftruncate = 201;
 (* 201 *)    syscall_nr_ftruncate = 201;
-(* 202 *)    syscall_nr___sysctl = 202;
+(* 202 *)    syscall_nr_sysctl = 202; (* from 5.9 release *)
 (* 203 *)    syscall_nr_mlock = 203;
 (* 203 *)    syscall_nr_mlock = 203;
 (* 204 *)    syscall_nr_munlock = 204;
 (* 204 *)    syscall_nr_munlock = 204;
 (* 205 *)    syscall_nr_undelete = 205;
 (* 205 *)    syscall_nr_undelete = 205;
-(* 206 *)    syscall_nr_futimes_20 = 206; (* up to 5.4 release *)
 (* 207 *)    syscall_nr_getpgid = 207;
 (* 207 *)    syscall_nr_getpgid = 207;
-(* 208 *)    syscall_nr_xfspioctl = 208; (* from 2.4 up to 4.5 release *)
-(* 208 *)    syscall_nr_nnpfspioctl = 208; (* from 4.6 up to 5.2 release *)
 (* 209 *)    syscall_nr_utrace = 209;
 (* 209 *)    syscall_nr_utrace = 209;
-(* 220 *)    syscall_nr___semctl_20 = 220; (* up to 2.3 release *)
-(* 220 *)    syscall_nr___osemctl = 220; (* from 2.4 up to 2.9 release *)
 (* 221 *)    syscall_nr_semget = 221;
 (* 221 *)    syscall_nr_semget = 221;
-(* 222 *)    syscall_nr_semop_20 = 222;
-(* 223 *)    syscall_nr_semconfig = 223;
-(* 224 *)    syscall_nr_msgctl_20 = 224; (* up to 2.3 release *)
-(* 224 *)    syscall_nr_omsgctl = 224; (* from 2.4 up to 2.9 release *)
 (* 225 *)    syscall_nr_msgget = 225;
 (* 225 *)    syscall_nr_msgget = 225;
 (* 226 *)    syscall_nr_msgsnd = 226;
 (* 226 *)    syscall_nr_msgsnd = 226;
 (* 227 *)    syscall_nr_msgrcv = 227;
 (* 227 *)    syscall_nr_msgrcv = 227;
 (* 228 *)    syscall_nr_shmat = 228;
 (* 228 *)    syscall_nr_shmat = 228;
-(* 229 *)    syscall_nr_shmctl_20 = 229; (* up to 2.3 release *)
-(* 229 *)    syscall_nr_oshmctl = 229; (* from 2.4 up to 2.9 release *)
 (* 230 *)    syscall_nr_shmdt = 230;
 (* 230 *)    syscall_nr_shmdt = 230;
-(* 231 *)    syscall_nr_shmget_20 = 231; (* up to 3.5 release *)
-(* 232 *)    syscall_nr_clock_gettime_20 = 232; (* up to 5.4 release *)
-(* 233 *)    syscall_nr_clock_settime_20 = 233; (* up to 5.4 release *)
-(* 234 *)    syscall_nr_clock_getres_20 = 234; (* up to 5.4 release *)
-(* 240 *)    syscall_nr_nanosleep_20 = 240; (* up to 5.4 release *)
 (* 250 *)    syscall_nr_minherit = 250;
 (* 250 *)    syscall_nr_minherit = 250;
-(* 251 *)    syscall_nr_rfork = 251;
 (* 252 *)    syscall_nr_poll = 252;
 (* 252 *)    syscall_nr_poll = 252;
 (* 253 *)    syscall_nr_issetugid = 253;
 (* 253 *)    syscall_nr_issetugid = 253;
 (* 254 *)    syscall_nr_lchown = 254;
 (* 254 *)    syscall_nr_lchown = 254;
 (* 255 *)    syscall_nr_getsid = 255;
 (* 255 *)    syscall_nr_getsid = 255;
 (* 256 *)    syscall_nr_msync = 256;
 (* 256 *)    syscall_nr_msync = 256;
-(* 257 *)    syscall_nr___semctl_24 = 257; (* from 2.4 up to 3.5 release *)
-(* 258 *)    syscall_nr_shmctl_24 = 258; (* from 2.4 up to 3.5 release *)
-(* 259 *)    syscall_nr_msgctl_24 = 259; (* from 2.4 up to 3.5 release *)
-(* 260 *)    syscall_nr_getfsstat_26 = 260; (* from 2.6 up to 4.3 release *)
-(* 261 *)    syscall_nr_statfs_26 = 261; (* from 2.6 up to 4.3 release *)
-(* 262 *)    syscall_nr_fstatfs_26 = 262; (* from 2.6 up to 4.3 release *)
-(* 263 *)    syscall_nr_pipe_26 = 263; (* from 2.6 release *)
+(* 263 *)    syscall_nr_pipe = 263; (* from 2.6 release *)
 (* 264 *)    syscall_nr_fhopen = 264;
 (* 264 *)    syscall_nr_fhopen = 264;
-(* 265 *)    syscall_nr_fhstat_20 = 265; (* up to 3.5 release *)
-(* 266 *)    syscall_nr_fhstatfs_20 = 266; (* up to 4.4 release *)
 (* 267 *)    syscall_nr_preadv = 267;
 (* 267 *)    syscall_nr_preadv = 267;
 (* 268 *)    syscall_nr_pwritev = 268;
 (* 268 *)    syscall_nr_pwritev = 268;
 (* 269 *)    syscall_nr_kqueue = 269;
 (* 269 *)    syscall_nr_kqueue = 269;
-(* 270 *)    syscall_nr_kevent_29 = 270; (*from 2.9 up to 5.4 release *)
 (* 271 *)    syscall_nr_mlockall = 271;
 (* 271 *)    syscall_nr_mlockall = 271;
 (* 272 *)    syscall_nr_munlockall = 272;
 (* 272 *)    syscall_nr_munlockall = 272;
 (* 273 *)    syscall_nr_getpeereid = 273;
 (* 273 *)    syscall_nr_getpeereid = 273;
@@ -269,41 +219,25 @@ Const
 (* 284 *)    syscall_nr_setresgid = 284;
 (* 284 *)    syscall_nr_setresgid = 284;
 (* 286 *)    syscall_nr_mquery = 286;
 (* 286 *)    syscall_nr_mquery = 286;
 (* 287 *)    syscall_nr_closefrom = 287;
 (* 287 *)    syscall_nr_closefrom = 287;
-(* 288 *)    syscall_nr_sigaltstack_35 = 288; (* from 3.5 release *)
-(* 289 *)    syscall_nr_shmget_36 = 289; (* from 3.6 release *)
-(* 290 *)    syscall_nr_semop_36 = 290; (* from 3.6 release *)
-(* 291 *)    syscall_nr_stat_36 = 291; (* from 3.6 up to 5.4 release *)
-(* 292 *)    syscall_nr_fstat_36 = 292; (* from 3.6 up to 5.4 release *)
-(* 293 *)    syscall_nr_lstat_36 = 293; (* from 3.6 up to 5.4 release *)
-(* 294 *)    syscall_nr_fhstat_36 = 294; (* from 3.6 release *)
-(* 295 *)    syscall_nr___semctl_36 = 295; (* from 3.6 release *)
-(* 296 *)    syscall_nr_shmctl_36 = 296; (* from 3.6 release *)
-(* 297 *)    syscall_nr_msgctl_36 = 297; (* from 3.6 release *)
+(* 288 *)    syscall_nr_sigaltstack = 288; (* from 3.5 release *)
+(* 289 *)    syscall_nr_shmget = 289; (* from 3.6 release *)
+(* 290 *)    syscall_nr_semop = 290; (* from 3.6 release *)
+(* 294 *)    syscall_nr_fhstat = 294; (* from 3.6 release *)
+(* 295 *)    syscall_nr___semctl = 295; (* from 3.6 release *)
+(* 296 *)    syscall_nr_shmctl = 296; (* from 3.6 release *)
+(* 297 *)    syscall_nr_msgctl = 297; (* from 3.6 release *)
 (* 298 *)    syscall_nr_sched_yield = 298;
 (* 298 *)    syscall_nr_sched_yield = 298;
 (* 299 *)    syscall_nr_getthrid = 299;
 (* 299 *)    syscall_nr_getthrid = 299;
-(* 300 *)    syscall_nr_thrsleep = 300; (* from 3.9 up to 5.0 release *)
-(* 300 *)    syscall_nr___thrsleep_51 = 300; (* from 5.1 up to 5.4 release *)
-(* 301 *)    syscall_nr_thrwakeup = 301; (* from 3.9 up to 5.0 release *)
 (* 301 *)    syscall_nr___thrwakeup = 301; (* from 5.1 release *)
 (* 301 *)    syscall_nr___thrwakeup = 301; (* from 5.1 release *)
-(* 302 *)    syscall_nr_threxit = 302; (* from 3.9 up to 5.0 release *)
 (* 302 *)    syscall_nr___threxit = 302; (* from 5.1 release *)
 (* 302 *)    syscall_nr___threxit = 302; (* from 5.1 release *)
-(* 303 *)    syscall_nr_thrsigdivert = 303; (* from 3.9 up to 5.0 release *)
 (* 303 *)    syscall_nr___thrsigdivert = 303; (* from 5.1 release *)
 (* 303 *)    syscall_nr___thrsigdivert = 303; (* from 5.1 release *)
 (* 304 *)    syscall_nr___getcwd = 304;
 (* 304 *)    syscall_nr___getcwd = 304;
 (* 305 *)    syscall_nr_adjfreq = 305;
 (* 305 *)    syscall_nr_adjfreq = 305;
-(* 306 *)    syscall_nr_getfsstat_44 = 306; (* from 4.4 up to 5.3 release *)
-(* 307 *)    syscall_nr_statfs_44 = 307; (* from 4.4 up to 5.3 release *)
-(* 308 *)    syscall_nr_fstatfs_44 = 308; (* from 4.4 up to 5.3 release *)
-(* 309 *)    syscall_nr_fhstatfs_44 = 309; (* from 4.4 up to 5.3 release *)
-(* 310 *)    syscall_nr_setrdomain = 310; (* 4.7 release only *)
 (* 310 *)    syscall_nr_setrtable = 310; (* from 4.8 release *)
 (* 310 *)    syscall_nr_setrtable = 310; (* from 4.8 release *)
-(* 311 *)    syscall_nr_getrdomain = 311; (* 4.7 release only *)
 (* 311 *)    syscall_nr_getrtable = 311; (* from 4.8 release *)
 (* 311 *)    syscall_nr_getrtable = 311; (* from 4.8 release *)
-(* 312 *)    syscall_nr_getdirentries_49 = 312; (* from 4.9 up to 5.4 release *)
 (* 313 *)    syscall_nr_faccessat = 313;
 (* 313 *)    syscall_nr_faccessat = 313;
 (* 314 *)    syscall_nr_fchmodat = 314;
 (* 314 *)    syscall_nr_fchmodat = 314;
 (* 315 *)    syscall_nr_fchownat = 315;
 (* 315 *)    syscall_nr_fchownat = 315;
-(* 316 *)    syscall_nr_fstatat_50 = 316; (* from 5.0 release *)
 (* 317 *)    syscall_nr_linkat = 317;
 (* 317 *)    syscall_nr_linkat = 317;
 (* 318 *)    syscall_nr_mkdirat = 318;
 (* 318 *)    syscall_nr_mkdirat = 318;
 (* 319 *)    syscall_nr_mkfifoat = 319;
 (* 319 *)    syscall_nr_mkfifoat = 319;
@@ -313,9 +247,6 @@ Const
 (* 323 *)    syscall_nr_renameat = 323;
 (* 323 *)    syscall_nr_renameat = 323;
 (* 324 *)    syscall_nr_symlinkat = 324;
 (* 324 *)    syscall_nr_symlinkat = 324;
 (* 325 *)    syscall_nr_unlinkat = 325;
 (* 325 *)    syscall_nr_unlinkat = 325;
-(* 326 *)    syscall_nr_utimensat_50 = 326;
-(* 327 *)    syscall_nr_futimens_50 = 327;
-(* 328 *)    syscall_nr___tfork_51 = 328; (* 5.1 release only *)
 (* 329 *)    syscall_nr___set_tcb = 329;
 (* 329 *)    syscall_nr___set_tcb = 329;
 (* 330 *)    syscall_nr___get_tcb = 330;
 (* 330 *)    syscall_nr___get_tcb = 330;
 
 
@@ -324,36 +255,7 @@ Const
 var
 var
   syscall_nr_waitpid : longint = syscall_nr_wait4;  // 7, added: ease of notation purposes
   syscall_nr_waitpid : longint = syscall_nr_wait4;  // 7, added: ease of notation purposes
   
   
-  syscall_nr_setitimer : longint = syscall_nr_setitimer_20;
-  syscall_nr_getitimer : longint = syscall_nr_getitimer_20;
-  syscall_nr_select : longint = syscall_nr_select_20;
-  syscall_nr_gettimeofday : longint = syscall_nr_gettimeofday_20;
-  syscall_nr_settimeofday : longint = syscall_nr_settimeofday_20;
-  syscall_nr_clock_gettime : longint = syscall_nr_clock_gettime_20;
-  syscall_nr_clock_settime : longint = syscall_nr_clock_settime_20;
-  syscall_nr_clock_getres : longint = syscall_nr_clock_getres_20;
-  syscall_nr_getrusage : longint = syscall_nr_getrusage_20;
-  syscall_nr_utimes : longint = syscall_nr_utimes_20;
-  syscall_nr_futimes : longint = syscall_nr_futimes_20;
-  syscall_nr_statfs : longint = syscall_nr_statfs_26;
-  syscall_nr_fstatfs : longint = syscall_nr_fstatfs_26;
-  syscall_nr_stat : longint = syscall_nr_stat_36;
-  syscall_nr_fstat : longint = syscall_nr_fstat_36;
-  syscall_nr_lstat : longint = syscall_nr_lstat_36;
-  syscall_nr_fhstat : longint = syscall_nr_fhstat_36;
-  syscall_nr_fstatat : longint = syscall_nr_fstatat_50;
-  syscall_nr_fhstatfs : longint = syscall_nr_fhstatfs_20;
-  syscall_nr_nanosleep : longint = syscall_nr_nanosleep_20;
-  syscall_nr_kevent : longint = syscall_nr_kevent_29;
-  syscall_nr_pipe : longint = syscall_nr_pipe_26;
-  syscall_nr_sigaltstack : longint = syscall_nr_sigaltstack_35;
-  syscall_nr___tfork : longint = -1;
-  syscall_nr_msgctl : longint = syscall_nr_msgctl_36;
-  syscall_nr_semop : longint = syscall_nr_semop_36;
-  syscall_nr___semctl : longint = syscall_nr___semctl_36;
-  syscall_nr_shmctl : longint = syscall_nr_shmctl_36;
-  syscall_nr_shmget : longint = syscall_nr_shmget_36;
-  syscall_nr_getdirentries : longint = syscall_nr_getdirentries_20;
+  syscall_nr_getdirentries : longint = {syscall_nr_getdirentries_20}-1;
 { The variables above need to be changed at startup }
 { The variables above need to be changed at startup }
 
 
 {$define FPC_HAS_SETSYSNR_INC}
 {$define FPC_HAS_SETSYSNR_INC}

+ 0 - 209
rtl/openbsd/x86_64/crt0.s

@@ -1,209 +0,0 @@
-	.file	"crt0.c"
-	.globl	__progname
-	.section	.rodata
-.LC0:
-	.string	""
-	.section	.data.rel.local,"aw",@progbits
-	.align 8
-	.type	__progname, @object
-	.size	__progname, 8
-__progname:
-	.quad	.LC0
-#APP
-	 .text				;	.align	8			;	.globl	__start			;	.globl	_start			;_start:					;__start:				;	movq	%rbx,%r9		;	movq	%rcx,%r8		;	movq	%rdx,%rcx		;	movq	(%rsp),%rdi		;	leaq	16(%rsp,%rdi,8),%rdx	;	leaq	8(%rsp),%rsi		;	subq	$8,%rsp			;	andq	$~15,%rsp		;	addq	$8,%rsp			;	jmp	___start		;
-#NO_APP
-	.text
-	.globl	___start
-	.type	___start, @function
-___start:
-.LFB9:
-	pushq	%rbp
-.LCFI0:
-	movq	%rsp, %rbp
-.LCFI1:
-	subq	$64, %rsp
-.LCFI2:
-	movl	%edi, -20(%rbp)
-	movq	%rsi, -32(%rbp)
-	movq	%rdx, -40(%rbp)
-	movq	%rcx, -48(%rbp)
-	movq	%r8, -56(%rbp)
-	movq	%r9, -64(%rbp)
-	movq	environ@GOTPCREL(%rip), %rdx
-	movq	-40(%rbp), %rax
-	movq	%rax, (%rdx)
-	movq	operatingsystem_parameter_envp@GOTPCREL(%rip), %rdx
-	movq	-40(%rbp), %rax
-	movq	%rax, (%rdx)
-	movl	-20(%rbp), %eax
-	movslq	%eax,%rdx
-	movq	operatingsystem_parameter_argc@GOTPCREL(%rip), %rax
-	movq	%rdx, (%rax)
-	movq	operatingsystem_parameter_argv@GOTPCREL(%rip), %rdx
-	movq	-32(%rbp), %rax
-	movq	%rax, (%rdx)
-	movq	-32(%rbp), %rax
-	movq	(%rax), %rax
-	movq	%rax, -8(%rbp)
-	cmpq	$0, -8(%rbp)
-	je	.L2
-	movq	-8(%rbp), %rdi
-	movl	$47, %esi
-	call	_strrchr
-	movq	%rax, %rdx
-	movq	__progname@GOTPCREL(%rip), %rax
-	movq	%rdx, (%rax)
-	movq	__progname@GOTPCREL(%rip), %rax
-	movq	(%rax), %rax
-	testq	%rax, %rax
-	jne	.L4
-	movq	__progname@GOTPCREL(%rip), %rdx
-	movq	-8(%rbp), %rax
-	movq	%rax, (%rdx)
-	jmp	.L6
-.L4:
-	movq	__progname@GOTPCREL(%rip), %rax
-	movq	(%rax), %rax
-	leaq	1(%rax), %rdx
-	movq	__progname@GOTPCREL(%rip), %rax
-	movq	%rdx, (%rax)
-.L6:
-	movq	__progname_storage@GOTPCREL(%rip), %rax
-	movq	%rax, -16(%rbp)
-	jmp	.L7
-.L8:
-	movq	__progname@GOTPCREL(%rip), %rax
-	movq	(%rax), %rcx
-	movzbl	(%rcx), %edx
-	movq	-16(%rbp), %rax
-	movb	%dl, (%rax)
-	addq	$1, -16(%rbp)
-	leaq	1(%rcx), %rdx
-	movq	__progname@GOTPCREL(%rip), %rax
-	movq	%rdx, (%rax)
-.L7:
-	movq	__progname@GOTPCREL(%rip), %rax
-	movq	(%rax), %rax
-	movzbl	(%rax), %eax
-	testb	%al, %al
-	je	.L9
-	movq	__progname_storage@GOTPCREL(%rip), %rax
-	leaq	255(%rax), %rax
-	cmpq	%rax, -16(%rbp)
-	jb	.L8
-.L9:
-	movq	-16(%rbp), %rax
-	movb	$0, (%rax)
-	movq	__progname@GOTPCREL(%rip), %rdx
-	movq	__progname_storage@GOTPCREL(%rip), %rax
-	movq	%rax, (%rdx)
-.L2:
-	movl	$0, %eax
-	call	__init@PLT
-	movq	environ@GOTPCREL(%rip), %rax
-	movq	(%rax), %rdx
-	movq	-32(%rbp), %rsi
-	movl	-20(%rbp), %edi
-	movl	$0, %eax
-	call	main@PLT
-	movl	%eax, %edi
-	call	exit@PLT
-.LFE9:
-	.size	___start, .-___start
-	.type	_strrchr, @function
-_strrchr:
-.LFB10:
-	pushq	%rbp
-.LCFI3:
-	movq	%rsp, %rbp
-.LCFI4:
-	movq	%rdi, -24(%rbp)
-	movb	%sil, -25(%rbp)
-	movq	$0, -8(%rbp)
-.L13:
-	movq	-24(%rbp), %rdx
-	movzbl	(%rdx), %eax
-	cmpb	-25(%rbp), %al
-	jne	.L14
-	movq	-24(%rbp), %rax
-	movq	%rax, -8(%rbp)
-.L14:
-	movq	-24(%rbp), %rdx
-	movzbl	(%rdx), %eax
-	testb	%al, %al
-	jne	.L16
-	movq	-8(%rbp), %rax
-	movq	%rax, -16(%rbp)
-	jmp	.L12
-.L16:
-	addq	$1, -24(%rbp)
-	jmp	.L13
-.L12:
-	movq	-16(%rbp), %rax
-	leave
-	ret
-.LFE10:
-	.size	_strrchr, .-_strrchr
-	.comm	environ,8,8
-	.comm	operatingsystem_parameter_envp,8,8
-	.comm	operatingsystem_parameter_argc,8,8
-	.comm	operatingsystem_parameter_argv,8,8
-	.comm	__progname_storage,256,32
-	.section	.eh_frame,"a",@progbits
-.Lframe1:
-	.long	.LECIE1-.LSCIE1
-.LSCIE1:
-	.long	0x0
-	.byte	0x1
-	.string	"zR"
-	.uleb128 0x1
-	.sleb128 -8
-	.byte	0x10
-	.uleb128 0x1
-	.byte	0x1b
-	.byte	0xc
-	.uleb128 0x7
-	.uleb128 0x8
-	.byte	0x90
-	.uleb128 0x1
-	.align 8
-.LECIE1:
-.LSFDE1:
-	.long	.LEFDE1-.LASFDE1
-.LASFDE1:
-	.long	.LASFDE1-.Lframe1
-	.long	.LFB9-.
-	.long	.LFE9-.LFB9
-	.uleb128 0x0
-	.byte	0x4
-	.long	.LCFI0-.LFB9
-	.byte	0xe
-	.uleb128 0x10
-	.byte	0x86
-	.uleb128 0x2
-	.byte	0x4
-	.long	.LCFI1-.LCFI0
-	.byte	0xd
-	.uleb128 0x6
-	.align 8
-.LEFDE1:
-.LSFDE3:
-	.long	.LEFDE3-.LASFDE3
-.LASFDE3:
-	.long	.LASFDE3-.Lframe1
-	.long	.LFB10-.
-	.long	.LFE10-.LFB10
-	.uleb128 0x0
-	.byte	0x4
-	.long	.LCFI3-.LFB10
-	.byte	0xe
-	.uleb128 0x10
-	.byte	0x86
-	.uleb128 0x2
-	.byte	0x4
-	.long	.LCFI4-.LCFI3
-	.byte	0xd
-	.uleb128 0x6
-	.align 8
-.LEFDE3:
-	.ident	"GCC: (GNU) 4.2.1 20070719 "

+ 0 - 256
rtl/openbsd/x86_64/dllprt0.as

@@ -1,256 +0,0 @@
-	.section ".note.openbsd.ident", "a"
-	.p2align 2
-	.long	8
-	.long	4
-	.long	1
-	.ascii "OpenBSD\0"
-	.long	0
-	.previous
-	.file	"crt0.c"
-	.globl	__progname
-	.section	.rodata
-.LC0:
-	.string	""
-	.section	.data.rel.local,"aw",@progbits
-	.align 8
-	.type	__progname, @object
-	.size	__progname, 8
-__progname:
-	.quad	.LC0
-#APP
-	 .text				
-	.align	8			
-	.globl	__start			
-	.globl	_start			
-_start:					
-__start:				
-	movq	%rbx,%r9		
-	movq	%rcx,%r8		
-	movq	%rdx,%rcx		
-	movq	(%rsp),%rdi		
-	leaq	16(%rsp,%rdi,8),%rdx	
-	leaq	8(%rsp),%rsi		
-	subq	$8,%rsp			
-	andq	$~15,%rsp		
-	addq	$8,%rsp			
-	jmp	___start		
-#NO_APP
-	.text
-	.globl	___start
-	.type	___start, @function
-___start:
-.LFB9:
-	pushq	%rbp
-.LCFI0:
-	movq	%rsp, %rbp
-.LCFI1:
-	subq	$64, %rsp
-.LCFI2:
-	movl	%edi, -20(%rbp)
-	movq	%rsi, -32(%rbp)
-	movq	%rdx, -40(%rbp)
-	movq	%rcx, -48(%rbp)
-	movq	%r8, -56(%rbp)
-	movq	%r9, -64(%rbp)
-	movq	environ@GOTPCREL(%rip), %rdx
-	movq	-40(%rbp), %rax
-	movq	%rax, (%rdx)
-	movq	operatingsystem_parameter_envp@GOTPCREL(%rip), %rdx
-	movq	-40(%rbp), %rax
-	movq	%rax, (%rdx)
-	movl	-20(%rbp), %eax
-	movslq	%eax,%rdx
-	movq	operatingsystem_parameter_argc@GOTPCREL(%rip), %rax
-	movq	%rdx, (%rax)
-	movq	operatingsystem_parameter_argv@GOTPCREL(%rip), %rdx
-	movq	-32(%rbp), %rax
-	movq	%rax, (%rdx)
-	movq	-32(%rbp), %rax
-	movq	(%rax), %rax
-	movq	%rax, -8(%rbp)
-	cmpq	$0, -8(%rbp)
-	je	.L2
-	movq	-8(%rbp), %rdi
-	movl	$47, %esi
-	call	_strrchr
-	movq	%rax, %rdx
-	movq	__progname@GOTPCREL(%rip), %rax
-	movq	%rdx, (%rax)
-	movq	__progname@GOTPCREL(%rip), %rax
-	movq	(%rax), %rax
-	testq	%rax, %rax
-	jne	.L4
-	movq	__progname@GOTPCREL(%rip), %rdx
-	movq	-8(%rbp), %rax
-	movq	%rax, (%rdx)
-	jmp	.L6
-.L4:
-	movq	__progname@GOTPCREL(%rip), %rax
-	movq	(%rax), %rax
-	leaq	1(%rax), %rdx
-	movq	__progname@GOTPCREL(%rip), %rax
-	movq	%rdx, (%rax)
-.L6:
-	movq	__progname_storage@GOTPCREL(%rip), %rax
-	movq	%rax, -16(%rbp)
-	jmp	.L7
-.L8:
-	movq	__progname@GOTPCREL(%rip), %rax
-	movq	(%rax), %rcx
-	movzbl	(%rcx), %edx
-	movq	-16(%rbp), %rax
-	movb	%dl, (%rax)
-	addq	$1, -16(%rbp)
-	leaq	1(%rcx), %rdx
-	movq	__progname@GOTPCREL(%rip), %rax
-	movq	%rdx, (%rax)
-.L7:
-	movq	__progname@GOTPCREL(%rip), %rax
-	movq	(%rax), %rax
-	movzbl	(%rax), %eax
-	testb	%al, %al
-	je	.L9
-	movq	__progname_storage@GOTPCREL(%rip), %rax
-	leaq	255(%rax), %rax
-	cmpq	%rax, -16(%rbp)
-	jb	.L8
-.L9:
-	movq	-16(%rbp), %rax
-	movb	$0, (%rax)
-	movq	__progname@GOTPCREL(%rip), %rdx
-	movq	__progname_storage@GOTPCREL(%rip), %rax
-	movq	%rax, (%rdx)
-.L2:
-	movl	$0, %eax
-	call	_init@PLT
-	movq	environ@GOTPCREL(%rip), %rax
-	movq	(%rax), %rdx
-	movq	-32(%rbp), %rsi
-	movl	-20(%rbp), %edi
-	movl	$0, %eax
-	call	main@PLT
-	# movl	%eax, %edi
-	# call	exit
-	jmp 	_haltproc@PLT
-        .p2align 2,0x90
-
-.globl _haltproc
-.type _haltproc,@function
-
-_haltproc:
-           movq $1,%rax
-           movzwq operatingsystem_result(%rip),%rbx
-           pushq   %rbx
-           call .Lactualsyscall
-           addq  $8,%rsp
-           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
-_strrchr:
-.LFB10:
-	pushq	%rbp
-.LCFI3:
-	movq	%rsp, %rbp
-.LCFI4:
-	movq	%rdi, -24(%rbp)
-	movb	%sil, -25(%rbp)
-	movq	$0, -8(%rbp)
-.L13:
-	movq	-24(%rbp), %rdx
-	movzbl	(%rdx), %eax
-	cmpb	-25(%rbp), %al
-	jne	.L14
-	movq	-24(%rbp), %rax
-	movq	%rax, -8(%rbp)
-.L14:
-	movq	-24(%rbp), %rdx
-	movzbl	(%rdx), %eax
-	testb	%al, %al
-	jne	.L16
-	movq	-8(%rbp), %rax
-	movq	%rax, -16(%rbp)
-	jmp	.L12
-.L16:
-	addq	$1, -24(%rbp)
-	jmp	.L13
-.L12:
-	movq	-16(%rbp), %rax
-	leave
-	ret
-.LFE10:
-	.size	_strrchr, .-_strrchr
-	.comm	environ,8,8
-	.comm	operatingsystem_parameter_envp,8,8
-	.comm	operatingsystem_parameter_argc,8,8
-	.comm	operatingsystem_parameter_argv,8,8
-	.comm	__progname_storage,256,32
-	.section	.eh_frame,"a",@progbits
-.Lframe1:
-	.long	.LECIE1-.LSCIE1
-.LSCIE1:
-	.long	0x0
-	.byte	0x1
-	.string	"zR"
-	.uleb128 0x1
-	.sleb128 -8
-	.byte	0x10
-	.uleb128 0x1
-	.byte	0x1b
-	.byte	0xc
-	.uleb128 0x7
-	.uleb128 0x8
-	.byte	0x90
-	.uleb128 0x1
-	.align 8
-.LECIE1:
-.LSFDE1:
-	.long	.LEFDE1-.LASFDE1
-.LASFDE1:
-	.long	.LASFDE1-.Lframe1
-	.long	.LFB9-.
-	.long	.LFE9-.LFB9
-	.uleb128 0x0
-	.byte	0x4
-	.long	.LCFI0-.LFB9
-	.byte	0xe
-	.uleb128 0x10
-	.byte	0x86
-	.uleb128 0x2
-	.byte	0x4
-	.long	.LCFI1-.LCFI0
-	.byte	0xd
-	.uleb128 0x6
-	.align 8
-.LEFDE1:
-.LSFDE3:
-	.long	.LEFDE3-.LASFDE3
-.LASFDE3:
-	.long	.LASFDE3-.Lframe1
-	.long	.LFB10-.
-	.long	.LFE10-.LFB10
-	.uleb128 0x0
-	.byte	0x4
-	.long	.LCFI3-.LFB10
-	.byte	0xe
-	.uleb128 0x10
-	.byte	0x86
-	.uleb128 0x2
-	.byte	0x4
-	.long	.LCFI4-.LCFI3
-	.byte	0xd
-	.uleb128 0x6
-	.align 8
-.LEFDE3:
-	.ident	"GCC: (GNU) 4.2.1 20070719 "

+ 0 - 244
rtl/openbsd/x86_64/gprt0.as

@@ -1,244 +0,0 @@
-	.section ".note.openbsd.ident", "a"
-	.p2align 2
-	.long	8
-	.long	4
-	.long	1
-	.ascii "OpenBSD\0"
-	.long	0
-	.previous
-	.file	"crt0.c"
-	.globl	__progname
-	.section	.rodata
-.LC0:
-	.string	""
-	.data
-	.align 8
-	.type	__progname, @object
-	.size	__progname, 8
-__progname:
-	.quad	.LC0
-#APP
-	 .text				
-	.align	8			
-	.globl	__start			
-	.globl	_start			
-_start:					
-__start:				
-	movq	%rbx,%r9		
-	movq	%rcx,%r8		
-	movq	%rdx,%rcx		
-	movq	(%rsp),%rdi		
-	leaq	16(%rsp,%rdi,8),%rdx	
-	leaq	8(%rsp),%rsi		
-	subq	$8,%rsp			
-	andq	$~15,%rsp		
-	addq	$8,%rsp			
-	jmp	___start		
-
-#NO_APP
-	.text
-	.globl	___start
-	.type	___start, @function
-___start:
-.LFB9:
-	pushq	%rbp
-.LCFI0:
-	movq	%rsp, %rbp
-.LCFI1:
-	subq	$64, %rsp
-.LCFI2:
-	movl	%edi, -20(%rbp)
-	movq	%rsi, -32(%rbp)
-	movq	%rdx, -40(%rbp)
-	movq	%rcx, -48(%rbp)
-	movq	%r8, -56(%rbp)
-	movq	%r9, -64(%rbp)
-	movq	-40(%rbp), %rax
-	movq	%rax, environ(%rip)
-	movq    %rax,operatingsystem_parameter_envp
-	movq	-32(%rbp), %rax
-	movq	(%rax), %rax
-	movq	%rax, -8(%rbp)
-	cmpq	$0, -8(%rbp)
-	je	.L2
-	movq	-8(%rbp), %rdi
-	movl	$47, %esi
-	call	_strrchr
-	movq	%rax, __progname(%rip)
-	movq	__progname(%rip), %rax
-	testq	%rax, %rax
-	jne	.L4
-	movq	-8(%rbp), %rax
-	movq	%rax, __progname(%rip)
-	jmp	.L6
-.L4:
-	movq	__progname(%rip), %rax
-	addq	$1, %rax
-	movq	%rax, __progname(%rip)
-.L6:
-	movq	$__progname_storage, -16(%rbp)
-	jmp	.L7
-.L8:
-	movq	__progname(%rip), %rcx
-	movzbl	(%rcx), %edx
-	movq	-16(%rbp), %rax
-	movb	%dl, (%rax)
-	addq	$1, -16(%rbp)
-	leaq	1(%rcx), %rax
-	movq	%rax, __progname(%rip)
-.L7:
-	movq	__progname(%rip), %rax
-	movzbl	(%rax), %eax
-	testb	%al, %al
-	je	.L9
-	movl	$__progname_storage+255, %eax
-	cmpq	%rax, -16(%rbp)
-	jb	.L8
-.L9:
-	movq	-16(%rbp), %rax
-	movb	$0, (%rax)
-	movq	$__progname_storage, __progname(%rip)
-.L2:
-	movl	$_mcleanup, %edi
-	call	atexit
-	movl	$_etext, %eax
-	movq	%rax, %rsi
-	movl	$_eprol, %eax
-	movq	%rax, %rdi
-	call	monstartup
-	movl	$0, %eax
-	call	__init
-	movq	environ(%rip), %rdx
-	movq	-32(%rbp), %rsi
-	movl	-20(%rbp), %edi
-	movq    %rdi,operatingsystem_parameter_argc
-	movq    %rsi,operatingsystem_parameter_argv
-	movl	$0, %eax
-	call	main
-	# movl	%eax, %edi
-	# call	exit
-	jmp _haltproc
-        .p2align 2,0x90
-
-.globl _haltproc
-.type _haltproc,@function
-
-_haltproc:
-           movq $1,%rax
-           movzwq operatingsystem_result,%rbx
-           pushq   %rbx
-           call .Lactualsyscall
-           addq  $8,%rsp
-           jmp   _haltproc
-
-.Lactualsyscall:
-         int $0x80
-         jb .LErrorcode
-         xor %rbx,%rbx
-         ret
-.LErrorcode:
-         movq  %rax,%rbx
-         movq  $-1,%rax
-.LFE9:
-	.size	___start, .-___start
-	.type	_strrchr, @function
-_strrchr:
-.LFB10:
-	pushq	%rbp
-.LCFI3:
-	movq	%rsp, %rbp
-.LCFI4:
-	movq	%rdi, -24(%rbp)
-	movb	%sil, -25(%rbp)
-	movq	$0, -8(%rbp)
-.L13:
-	movq	-24(%rbp), %rdx
-	movzbl	(%rdx), %eax
-	cmpb	-25(%rbp), %al
-	jne	.L14
-	movq	-24(%rbp), %rax
-	movq	%rax, -8(%rbp)
-.L14:
-	movq	-24(%rbp), %rdx
-	movzbl	(%rdx), %eax
-	testb	%al, %al
-	jne	.L16
-	movq	-8(%rbp), %rax
-	movq	%rax, -16(%rbp)
-	jmp	.L12
-.L16:
-	addq	$1, -24(%rbp)
-	jmp	.L13
-.L12:
-	movq	-16(%rbp), %rax
-	leave
-	ret
-.LFE10:
-	.size	_strrchr, .-_strrchr
-#APP
-	  .text
-	_eprol:
-#NO_APP
-	.comm	environ,8,8
-	.comm	__progname_storage,256,32
-        .comm   operatingsystem_parameter_envp,8,8
-        .comm   operatingsystem_parameter_argc,8,8
-        .comm   operatingsystem_parameter_argv,8,8
-	.section	.eh_frame,"a",@progbits
-.Lframe1:
-	.long	.LECIE1-.LSCIE1
-.LSCIE1:
-	.long	0x0
-	.byte	0x1
-	.string	"zR"
-	.uleb128 0x1
-	.sleb128 -8
-	.byte	0x10
-	.uleb128 0x1
-	.byte	0x3
-	.byte	0xc
-	.uleb128 0x7
-	.uleb128 0x8
-	.byte	0x90
-	.uleb128 0x1
-	.align 8
-.LECIE1:
-.LSFDE1:
-	.long	.LEFDE1-.LASFDE1
-.LASFDE1:
-	.long	.LASFDE1-.Lframe1
-	.long	.LFB9
-	.long	.LFE9-.LFB9
-	.uleb128 0x0
-	.byte	0x4
-	.long	.LCFI0-.LFB9
-	.byte	0xe
-	.uleb128 0x10
-	.byte	0x86
-	.uleb128 0x2
-	.byte	0x4
-	.long	.LCFI1-.LCFI0
-	.byte	0xd
-	.uleb128 0x6
-	.align 8
-.LEFDE1:
-.LSFDE3:
-	.long	.LEFDE3-.LASFDE3
-.LASFDE3:
-	.long	.LASFDE3-.Lframe1
-	.long	.LFB10
-	.long	.LFE10-.LFB10
-	.uleb128 0x0
-	.byte	0x4
-	.long	.LCFI3-.LFB10
-	.byte	0xe
-	.uleb128 0x10
-	.byte	0x86
-	.uleb128 0x2
-	.byte	0x4
-	.long	.LCFI4-.LCFI3
-	.byte	0xd
-	.uleb128 0x6
-	.align 8
-.LEFDE3:
-	.ident	"GCC: (GNU) 4.2.1 20070719 "

+ 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

+ 3 - 17
rtl/openbsd/x86_64/si_c.inc

@@ -16,17 +16,10 @@
 
 
 {$asmmode gas}
 {$asmmode gas}
 
 
-{var
-  _etext: Byte; external name '_etext';
-  _eprol: Byte; external name '_eprol';}
-
-{procedure _mcleanup; cdecl; external name '_mcleanup';
-function atexit(proc: TCdeclProcedure): cint; cdecl; external name 'atexit';
-procedure monstartup(lowpc, highpc: u_long); cdecl; external name 'monstartup';}
 procedure __init; cdecl; external name '__init';
 procedure __init; cdecl; external name '__init';
 procedure c_exit(exit_code: cint); cdecl; noreturn; external name 'exit';
 procedure c_exit(exit_code: cint); cdecl; noreturn; external name 'exit';
 
 
-procedure _FPC_proc___start(argc: LongInt; argv: PPChar; envp: Pointer; para1, para2, para3: QWord); forward;
+procedure _FPC_proc___start(argc: LongInt; argv: PPChar; envp: Pointer; para1, para2, para3: QWord); cdecl; forward;
 
 
 procedure _FPC_proc_start; assembler; nostackframe; public name '_start'; public name '__start';
 procedure _FPC_proc_start; assembler; nostackframe; public name '_start'; public name '__start';
   asm
   asm
@@ -42,10 +35,9 @@ procedure _FPC_proc_start; assembler; nostackframe; public name '_start'; public
     jmp     _FPC_proc___start
     jmp     _FPC_proc___start
   end;
   end;
 
 
-procedure _FPC_proc_haltproc; noreturn; forward;
 function _strrchr(str: PChar; character: LongInt): PChar; forward;
 function _strrchr(str: PChar; character: LongInt): PChar; forward;
 
 
-procedure _FPC_proc___start(argc: LongInt; argv: PPChar; envp: Pointer; para1, para2, para3: QWord);
+procedure _FPC_proc___start(argc: LongInt; argv: PPChar; envp: Pointer; para1, para2, para3: QWord); cdecl;
   var
   var
     I: SizeUInt;
     I: SizeUInt;
   begin
   begin
@@ -69,14 +61,12 @@ procedure _FPC_proc___start(argc: LongInt; argv: PPChar; envp: Pointer; para1, p
         __progname_storage[I]:=#0;
         __progname_storage[I]:=#0;
         __progname:=@__progname_storage;
         __progname:=@__progname_storage;
       end;
       end;
-{    atexit(@_mcleanup);
-    monstartup(u_long(@_eprol),u_long(@_etext));}
     __init;
     __init;
     PascalMain;
     PascalMain;
     c_exit(operatingsystem_result);
     c_exit(operatingsystem_result);
   end;
   end;
 
 
-procedure _FPC_proc_haltproc; noreturn; public name '_haltproc';
+procedure _FPC_proc_haltproc; cdecl; noreturn; public name '_haltproc';
   begin
   begin
     c_exit(operatingsystem_result);
     c_exit(operatingsystem_result);
   end;
   end;
@@ -91,7 +81,3 @@ function _strrchr(str: PChar; character: LongInt): PChar; public name '_strrchr'
         Inc(str);
         Inc(str);
     until str^=#0;
     until str^=#0;
   end;
   end;
-
-{procedure MD_EPROL_LABEL; assembler; nostackframe; public name '_eprol';
-  asm
-  end;}

+ 8 - 17
rtl/openbsd/x86_64/si_dll.inc

@@ -17,9 +17,9 @@
 {$asmmode gas}
 {$asmmode gas}
 
 
 {$ifdef VER3_0}
 {$ifdef VER3_0}
-procedure _init; external name '_init';
+procedure _init; cdecl; external name '_init';
 {$else VER3_0}
 {$else VER3_0}
-procedure _init; weakexternal name '_init';
+procedure _init; cdecl; weakexternal name '_init';
 {$endif VER3_0}
 {$endif VER3_0}
 
 
 procedure _FPC_shared_lib_start; cdecl; public name 'FPC_LIB_START';
 procedure _FPC_shared_lib_start; cdecl; public name 'FPC_LIB_START';
@@ -34,21 +34,12 @@ procedure _FPC_shared_lib_start; cdecl; public name 'FPC_LIB_START';
     PascalMain;
     PascalMain;
   end;
   end;
 
 
-procedure _FPC_proc_haltproc; assembler; nostackframe; public name '_haltproc';
+{ this routine is only called when the halt() routine of the RTL embedded in
+  the shared library is called }
+procedure _FPC_shared_lib_haltproc; cdecl; 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
-    jmp     _FPC_proc_haltproc
-
-.Lactualsyscall:
-    int     $0x80
-    jb      .LErrorcode
-    xor     %rbx,%rbx
-    ret
-.LErrorcode:
-    movq    %rax,%rbx
-    movq    $-1,%rax
+    movl    operatingsystem_result(%rip),%edi
+    syscall
+    jmp     _FPC_shared_lib_haltproc
   end;
   end;

+ 3 - 4
rtl/openbsd/x86_64/si_g.inc

@@ -26,7 +26,7 @@ procedure _monstartup(lowpc, highpc: u_long); cdecl; external name '_monstartup'
 procedure __init; cdecl; external name '__init';
 procedure __init; cdecl; external name '__init';
 procedure c_exit(exit_code: cint); cdecl; noreturn; external name 'exit';
 procedure c_exit(exit_code: cint); cdecl; noreturn; external name 'exit';
 
 
-procedure _FPC_proc___start(argc: LongInt; argv: PPChar; envp: Pointer; para1, para2, para3: QWord); forward;
+procedure _FPC_proc___start(argc: LongInt; argv: PPChar; envp: Pointer; para1, para2, para3: QWord); cdecl; forward;
 
 
 procedure _FPC_proc_start; assembler; nostackframe; public name '_start'; public name '__start';
 procedure _FPC_proc_start; assembler; nostackframe; public name '_start'; public name '__start';
   asm
   asm
@@ -42,10 +42,9 @@ procedure _FPC_proc_start; assembler; nostackframe; public name '_start'; public
     jmp     _FPC_proc___start
     jmp     _FPC_proc___start
   end;
   end;
 
 
-procedure _FPC_proc_haltproc; noreturn; forward;
 function _strrchr(str: PChar; character: LongInt): PChar; forward;
 function _strrchr(str: PChar; character: LongInt): PChar; forward;
 
 
-procedure _FPC_proc___start(argc: LongInt; argv: PPChar; envp: Pointer; para1, para2, para3: QWord);
+procedure _FPC_proc___start(argc: LongInt; argv: PPChar; envp: Pointer; para1, para2, para3: QWord); cdecl;
   var
   var
     I: SizeUInt;
     I: SizeUInt;
   begin
   begin
@@ -76,7 +75,7 @@ procedure _FPC_proc___start(argc: LongInt; argv: PPChar; envp: Pointer; para1, p
     c_exit(operatingsystem_result);
     c_exit(operatingsystem_result);
   end;
   end;
 
 
-procedure _FPC_proc_haltproc; noreturn; public name '_haltproc';
+procedure _FPC_proc_haltproc; cdecl; noreturn; public name '_haltproc';
   begin
   begin
     c_exit(operatingsystem_result);
     c_exit(operatingsystem_result);
   end;
   end;

+ 4 - 15
rtl/openbsd/x86_64/si_prc.inc

@@ -32,7 +32,7 @@ procedure _FPC_proc_start; assembler; nostackframe; public name '_start'; public
     jmp     _FPC_proc___start
     jmp     _FPC_proc___start
   end;
   end;
 
 
-procedure _FPC_proc_haltproc; forward;
+procedure _FPC_proc_haltproc; cdecl; forward;
 function _strrchr(str: PChar; character: LongInt): PChar; forward;
 function _strrchr(str: PChar; character: LongInt): PChar; forward;
 
 
 procedure _FPC_proc___start(argc: LongInt; argv: PPChar; envp: Pointer; para1, para2, para3: QWord);
 procedure _FPC_proc___start(argc: LongInt; argv: PPChar; envp: Pointer; para1, para2, para3: QWord);
@@ -65,23 +65,12 @@ procedure _FPC_proc___start(argc: LongInt; argv: PPChar; envp: Pointer; para1, p
     end;
     end;
   end;
   end;
 
 
-procedure _FPC_proc_haltproc; assembler; nostackframe; public name '_haltproc';
+procedure _FPC_proc_haltproc; cdecl; 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';