Browse Source

--- Merging r21366 into '.':
U rtl/openbsd/Makefile.fpc
--- Merging r21367 into '.':
C rtl/openbsd/Makefile
--- Merging r21368 into '.':
G rtl/openbsd/Makefile.fpc
--- Merging r21370 into '.':
A rtl/netbsd/x86_64
A rtl/netbsd/x86_64/bsyscall.inc
A rtl/netbsd/x86_64/sighnd.inc
A rtl/netbsd/x86_64/prt0.as
A rtl/netbsd/x86_64/cprt0.as
A rtl/netbsd/x86_64/gprt0.as
--- Merging r21371 into '.':
U rtl/netbsd/Makefile.fpc
--- Merging r21372 into '.':
C rtl/netbsd/Makefile
Summary of conflicts:
Text conflicts: 2

# revisions: 21366,21367,21368,21370,21371,21372
r21366 | pierre | 2012-05-23 10:48:57 +0200 (Wed, 23 May 2012) | 1 line
Changed paths:
M /trunk/rtl/openbsd/Makefile.fpc

Add x86_64 specific units
r21367 | pierre | 2012-05-23 10:49:24 +0200 (Wed, 23 May 2012) | 1 line
Changed paths:
M /trunk/rtl/openbsd/Makefile

Regenerated after: Add x86_64 specific units
r21368 | pierre | 2012-05-23 10:54:26 +0200 (Wed, 23 May 2012) | 1 line
Changed paths:
M /trunk/rtl/openbsd/Makefile.fpc

Add missing x86_64 specific cpu unit dependency on sysutils
r21370 | pierre | 2012-05-23 11:09:46 +0200 (Wed, 23 May 2012) | 1 line
Changed paths:
A /trunk/rtl/netbsd/x86_64
A /trunk/rtl/netbsd/x86_64/bsyscall.inc
A /trunk/rtl/netbsd/x86_64/cprt0.as
A /trunk/rtl/netbsd/x86_64/gprt0.as
A /trunk/rtl/netbsd/x86_64/prt0.as
A /trunk/rtl/netbsd/x86_64/sighnd.inc

x86_64 subdirectory added
r21371 | pierre | 2012-05-23 11:13:06 +0200 (Wed, 23 May 2012) | 1 line
Changed paths:
M /trunk/rtl/netbsd/Makefile.fpc

Add x86_64 cpu specific units
r21372 | pierre | 2012-05-23 11:16:57 +0200 (Wed, 23 May 2012) | 1 line
Changed paths:
M /trunk/rtl/netbsd/Makefile

Regenerated after: Add x86_64 cpu specific units

git-svn-id: branches/fixes_2_6@21477 -

marco 13 years ago
parent
commit
8bfc206b77

+ 5 - 0
.gitattributes

@@ -7704,6 +7704,11 @@ rtl/netbsd/unxconst.inc svneol=native#text/plain
 rtl/netbsd/unxfunc.inc svneol=native#text/plain
 rtl/netbsd/unxsockh.inc svneol=native#text/plain
 rtl/netbsd/unxsysc.inc svneol=native#text/plain
+rtl/netbsd/x86_64/bsyscall.inc svneol=native#text/plain
+rtl/netbsd/x86_64/cprt0.as svneol=native#text/plain
+rtl/netbsd/x86_64/gprt0.as svneol=native#text/plain
+rtl/netbsd/x86_64/prt0.as svneol=native#text/plain
+rtl/netbsd/x86_64/sighnd.inc svneol=native#text/plain
 rtl/netware/Makefile svneol=native#text/plain
 rtl/netware/Makefile.fpc svneol=native#text/plain
 rtl/netware/README.txt svneol=native#text/plain

+ 46 - 5
rtl/netbsd/Makefile

@@ -1,8 +1,8 @@
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2012/03/20]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2012/06/03]
 #
 default: all
-MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian i386-nativent i386-iphonesim m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded powerpc-wii sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-solaris x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded mipsel-linux
+MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian i386-nativent i386-iphonesim m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded powerpc-wii sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-netbsd x86_64-solaris x86_64-openbsd x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded mipsel-linux
 BSDs = freebsd netbsd openbsd darwin
 UNIXs = linux $(BSDs) solaris qnx haiku
 LIMIT83fs = go32v2 os2 emx watcom
@@ -310,10 +310,11 @@ GRAPHDIR=$(INC)/graph
 ifndef USELIBGGI
 USELIBGGI=NO
 endif
-ifeq ($(CPU_TARGET),i386)
+ifeq ($(ARCH),x86_64)
+CPU_UNITS=x86 ports cpu
+endif
+ifeq ($(ARCH),i386)
 CPU_UNITS=x86 ports cpu mmx
-else
-CPU_UNITS=
 endif
 ifeq ($(FULL_TARGET),i386-linux)
 override TARGET_UNITS+=$(SYSTEMUNIT) unixtype ctypes objpas macpas iso7185 strings syscall sysctl  baseunix unixutil unix rtlconsts initc cmem matrix dl termio  printer sysutils varutils math variants typinfo types classes fgl fmtbcd dynlibs $(CPU_UNITS) charset ucomplex crt getopts heaptrc lnfodwrf lineinfo errors sockets ipc terminfo bsd video mouse keyboard serial dateutils sysconst cthreads strutils convutils stdconvs dos objects cwstring fpintres clocale
@@ -447,9 +448,15 @@ endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 override TARGET_UNITS+=$(SYSTEMUNIT) unixtype ctypes objpas macpas iso7185 strings syscall sysctl  baseunix unixutil unix rtlconsts initc cmem matrix dl termio  printer sysutils varutils math variants typinfo types classes fgl fmtbcd dynlibs $(CPU_UNITS) charset ucomplex crt getopts heaptrc lnfodwrf lineinfo errors sockets ipc terminfo bsd video mouse keyboard serial dateutils sysconst cthreads strutils convutils stdconvs dos objects cwstring fpintres clocale
 endif
+ifeq ($(FULL_TARGET),x86_64-netbsd)
+override TARGET_UNITS+=$(SYSTEMUNIT) unixtype ctypes objpas macpas iso7185 strings syscall sysctl  baseunix unixutil unix rtlconsts initc cmem matrix dl termio  printer sysutils varutils math variants typinfo types classes fgl fmtbcd dynlibs $(CPU_UNITS) charset ucomplex crt getopts heaptrc lnfodwrf lineinfo errors sockets ipc terminfo bsd video mouse keyboard serial dateutils sysconst cthreads strutils convutils stdconvs dos objects cwstring fpintres clocale
+endif
 ifeq ($(FULL_TARGET),x86_64-solaris)
 override TARGET_UNITS+=$(SYSTEMUNIT) unixtype ctypes objpas macpas iso7185 strings syscall sysctl  baseunix unixutil unix rtlconsts initc cmem matrix dl termio  printer sysutils varutils math variants typinfo types classes fgl fmtbcd dynlibs $(CPU_UNITS) charset ucomplex crt getopts heaptrc lnfodwrf lineinfo errors sockets ipc terminfo bsd video mouse keyboard serial dateutils sysconst cthreads strutils convutils stdconvs dos objects cwstring fpintres clocale
 endif
+ifeq ($(FULL_TARGET),x86_64-openbsd)
+override TARGET_UNITS+=$(SYSTEMUNIT) unixtype ctypes objpas macpas iso7185 strings syscall sysctl  baseunix unixutil unix rtlconsts initc cmem matrix dl termio  printer sysutils varutils math variants typinfo types classes fgl fmtbcd dynlibs $(CPU_UNITS) charset ucomplex crt getopts heaptrc lnfodwrf lineinfo errors sockets ipc terminfo bsd video mouse keyboard serial dateutils sysconst cthreads strutils convutils stdconvs dos objects cwstring fpintres clocale
+endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
 override TARGET_UNITS+=$(SYSTEMUNIT) unixtype ctypes objpas macpas iso7185 strings syscall sysctl  baseunix unixutil unix rtlconsts initc cmem matrix dl termio  printer sysutils varutils math variants typinfo types classes fgl fmtbcd dynlibs $(CPU_UNITS) charset ucomplex crt getopts heaptrc lnfodwrf lineinfo errors sockets ipc terminfo bsd video mouse keyboard serial dateutils sysconst cthreads strutils convutils stdconvs dos objects cwstring fpintres clocale
 endif
@@ -636,9 +643,15 @@ endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 override TARGET_IMPLICITUNITS+=exeinfo
 endif
+ifeq ($(FULL_TARGET),x86_64-netbsd)
+override TARGET_IMPLICITUNITS+=exeinfo
+endif
 ifeq ($(FULL_TARGET),x86_64-solaris)
 override TARGET_IMPLICITUNITS+=exeinfo
 endif
+ifeq ($(FULL_TARGET),x86_64-openbsd)
+override TARGET_IMPLICITUNITS+=exeinfo
+endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
 override TARGET_IMPLICITUNITS+=exeinfo
 endif
@@ -825,9 +838,15 @@ endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 override TARGET_LOADERS+=prt0 cprt0
 endif
+ifeq ($(FULL_TARGET),x86_64-netbsd)
+override TARGET_LOADERS+=prt0 cprt0
+endif
 ifeq ($(FULL_TARGET),x86_64-solaris)
 override TARGET_LOADERS+=prt0 cprt0
 endif
+ifeq ($(FULL_TARGET),x86_64-openbsd)
+override TARGET_LOADERS+=prt0 cprt0
+endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
 override TARGET_LOADERS+=prt0 cprt0
 endif
@@ -1014,9 +1033,15 @@ endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 override TARGET_RSTS+=math varutils typinfo classes variants dateutils sysconst
 endif
+ifeq ($(FULL_TARGET),x86_64-netbsd)
+override TARGET_RSTS+=math varutils typinfo classes variants dateutils sysconst
+endif
 ifeq ($(FULL_TARGET),x86_64-solaris)
 override TARGET_RSTS+=math varutils typinfo classes variants dateutils sysconst
 endif
+ifeq ($(FULL_TARGET),x86_64-openbsd)
+override TARGET_RSTS+=math varutils typinfo classes variants dateutils sysconst
+endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
 override TARGET_RSTS+=math varutils typinfo classes variants dateutils sysconst
 endif
@@ -1204,9 +1229,15 @@ endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 override COMPILER_INCLUDEDIR+=$(INC) $(PROCINC) $(UNIXINC) $(BSDINC) $(BSDPROCINC) $(TARGETPROCINC)
 endif
+ifeq ($(FULL_TARGET),x86_64-netbsd)
+override COMPILER_INCLUDEDIR+=$(INC) $(PROCINC) $(UNIXINC) $(BSDINC) $(BSDPROCINC) $(TARGETPROCINC)
+endif
 ifeq ($(FULL_TARGET),x86_64-solaris)
 override COMPILER_INCLUDEDIR+=$(INC) $(PROCINC) $(UNIXINC) $(BSDINC) $(BSDPROCINC) $(TARGETPROCINC)
 endif
+ifeq ($(FULL_TARGET),x86_64-openbsd)
+override COMPILER_INCLUDEDIR+=$(INC) $(PROCINC) $(UNIXINC) $(BSDINC) $(BSDPROCINC) $(TARGETPROCINC)
+endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
 override COMPILER_INCLUDEDIR+=$(INC) $(PROCINC) $(UNIXINC) $(BSDINC) $(BSDPROCINC) $(TARGETPROCINC)
 endif
@@ -1393,9 +1424,15 @@ endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 override COMPILER_SOURCEDIR+=$(INC) $(PROCINC) $(UNIXINC) $(BSDINC)
 endif
+ifeq ($(FULL_TARGET),x86_64-netbsd)
+override COMPILER_SOURCEDIR+=$(INC) $(PROCINC) $(UNIXINC) $(BSDINC)
+endif
 ifeq ($(FULL_TARGET),x86_64-solaris)
 override COMPILER_SOURCEDIR+=$(INC) $(PROCINC) $(UNIXINC) $(BSDINC)
 endif
+ifeq ($(FULL_TARGET),x86_64-openbsd)
+override COMPILER_SOURCEDIR+=$(INC) $(PROCINC) $(UNIXINC) $(BSDINC)
+endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
 override COMPILER_SOURCEDIR+=$(INC) $(PROCINC) $(UNIXINC) $(BSDINC)
 endif
@@ -2657,7 +2694,11 @@ character$(PPUEXT): $(OBJPASDIR)/character.pas objpas$(PPUEXT) sysutils$(PPUEXT)
 	$(COMPILER) $(OBJPASDIR)/character.pas
 macpas$(PPUEXT) : $(INC)/macpas.pp objpas$(PPUEXT) math$(PPUEXT)
 	$(COMPILER) $(INC)/macpas.pp $(REDIR)
+ifeq ($(ARCH),x86_64)
+cpu$(PPUEXT) : $(PROCINC)/cpu.pp $(SYSTEMUNIT)$(PPUEXT) sysutils$(PPUEXT)
+else
 cpu$(PPUEXT) : $(PROCINC)/cpu.pp $(SYSTEMUNIT)$(PPUEXT)
+endif
 mmx$(PPUEXT) : $(PROCINC)/mmx.pp cpu$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 getopts$(PPUEXT) : $(INC)/getopts.pp $(SYSTEMUNIT)$(PPUEXT)
 heaptrc$(PPUEXT) : $(INC)/heaptrc.pp $(SYSTEMUNIT)$(PPUEXT)

+ 8 - 3
rtl/netbsd/Makefile.fpc

@@ -85,10 +85,11 @@ ifndef USELIBGGI
 USELIBGGI=NO
 endif
 
-ifeq ($(CPU_TARGET),i386)
+ifeq ($(ARCH),x86_64)
+CPU_UNITS=x86 ports cpu
+endif
+ifeq ($(ARCH),i386)
 CPU_UNITS=x86 ports cpu mmx
-else
-CPU_UNITS=
 endif
 
 
@@ -239,7 +240,11 @@ macpas$(PPUEXT) : $(INC)/macpas.pp objpas$(PPUEXT) math$(PPUEXT)
 # Other system-independent RTL Units
 #
 
+ifeq ($(ARCH),x86_64)
+cpu$(PPUEXT) : $(PROCINC)/cpu.pp $(SYSTEMUNIT)$(PPUEXT) sysutils$(PPUEXT)
+else
 cpu$(PPUEXT) : $(PROCINC)/cpu.pp $(SYSTEMUNIT)$(PPUEXT)
+endif
 
 mmx$(PPUEXT) : $(PROCINC)/mmx.pp cpu$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 

+ 14 - 0
rtl/netbsd/x86_64/bsyscall.inc

@@ -0,0 +1,14 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2005 by Michael Van Canneyt,
+    member of the Free Pascal development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+

+ 249 - 0
rtl/netbsd/x86_64/cprt0.as

@@ -0,0 +1,249 @@
+	.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(%rip)
+	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(%rip)
+	movq    %rsi,operatingsystem_parameter_argv(%rip)
+	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(%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
+.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
+# This section is needed for NetBSD to recognize a NetBSD binary as such.
+# otherwise it will be startup in Linux emulation mode.
+
+.section ".note.netbsd.ident","a"
+.p2align 2
+
+.long 7
+.long 4
+# ELF NOTE TYPE NETBSD TAG
+.long 1
+.ascii "NetBSD\0\0"
+.long 199905
+
+	.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 "

+ 236 - 0
rtl/netbsd/x86_64/gprt0.as

@@ -0,0 +1,236 @@
+	.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(%rip)
+	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(%rip)
+	movq    %rsi,operatingsystem_parameter_argv(%rip)
+	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(%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
+.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 "

+ 249 - 0
rtl/netbsd/x86_64/prt0.as

@@ -0,0 +1,249 @@
+	.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(%rip)
+	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(%rip)
+	movq    %rsi,operatingsystem_parameter_argv(%rip)
+	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(%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
+.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
+# This section is needed for NetBSD to recognize a NetBSD binary as such.
+# otherwise it will be startup in Linux emulation mode.
+
+.section ".note.netbsd.ident","a"
+.p2align 2
+
+.long 7
+.long 4
+# ELF NOTE TYPE NETBSD TAG
+.long 1
+.ascii "NetBSD\0\0"
+.long 199905
+
+	.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 "

+ 111 - 0
rtl/netbsd/x86_64/sighnd.inc

@@ -0,0 +1,111 @@
+{
+   This file is part of the Free Pascal run time library.
+   (c) 2000-2003 by Marco van de Voort
+   member of the Free Pascal development team.
+
+   See the file COPYING.FPC, included in this distribution,
+   for details about the copyright.
+
+   Signalhandler for FreeBSD/i386
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY;without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+}
+
+CONST FPU_ALL=$7F;
+
+{$ifdef cpui386}
+function getfpustate(sininfo:psiginfo):longint; {inline;}
+begin
+  if ptruint(sininfo)> high(word) then
+    getfpustate:=sininfo^.si_code
+  else
+    getfpustate:=word(ptruint(sininfo));
+end;
+
+function getaltfpustate(sigcontext:psigcontextrec):longint; {inline;}
+begin
+  if assigned(sigcontext) then
+    getaltfpustate:=sigcontext^.sc_fpustate^.en_sw 
+  else
+    getaltfpustate:=0;
+end;
+{$endif}
+  procedure signal_trampoline; cdecl; 
+  begin
+    asm
+      mov    %r15,%rdi
+      mov    $0x134,%rax
+       syscall
+      mov    $0xffffffffffffffff,%rdi
+      mov    $0x1,%rax
+      syscall
+    end;
+  end;
+
+procedure SignalToRunerror(Sig: longint;sininfo:psiginfo; SigContext: PSigContextRec); public name '_FPC_DEFAULTSIGHANDLER'; cdecl;
+
+var
+  res,fpustate : word;
+begin
+  res:=0;
+{$ifdef BSD}
+{$ifdef cpui386}
+  fpustate:=0;
+  asm
+    fnstsw fpustate
+  end;
+{$endif cpui386}
+{$endif BSD}
+  case sig of
+    SIGFPE :
+          begin
+    { this is not allways necessary but I don't know yet
+      how to tell if it is or not PM }
+          res:=200;
+{$ifdef cpui386}
+          fpustate:=GetaltFPUState(sigcontext);
+{$else}
+          fpustate:=0;
+{$endif}
+          if (FpuState and FPU_All) <> 0 then
+            begin
+              { first check the more precise options }
+              if (FpuState and FPU_DivisionByZero)<>0 then
+                res:=200
+              else if (FpuState and FPU_Overflow)<>0 then
+                res:=205
+              else if (FpuState and FPU_Underflow)<>0 then
+                res:=206
+              else if (FpuState and FPU_Denormal)<>0 then
+                res:=216
+              else if (FpuState and (FPU_StackOverflow or FPU_StackUnderflow))<>0 then
+                res:=207
+              else if (FpuState and FPU_Invalid)<>0 then
+                res:=216
+              else
+                res:=207;  {'Coprocessor Error'}
+            end;
+          SysResetFPU;
+        end;
+    SIGILL,
+    SIGBUS,
+    SIGSEGV :
+        res:=216;
+    SIGINT:
+        res:=217;
+    SIGQUIT:
+        res:=233;
+  end;
+  reenable_signal(sig);
+{ give runtime error at the position where the signal was raised }
+  if res<>0 then
+   begin
+{$ifdef cpux86_64}
+      HandleErrorAddrFrame(res,pointer(SigContext^.sc_rip),pointer(SigContext^.sc_rbp));
+{$endif}
+   end;
+end;
+
+

+ 7 - 0
rtl/openbsd/Makefile

@@ -310,6 +310,9 @@ endif
 ifdef RELEASE
 override FPCOPT+=-Ur
 endif
+ifeq ($(ARCH),x86_64)
+CPU_UNITS=x86 ports cpu
+endif
 ifeq ($(ARCH),i386)
 CPU_UNITS=x86 ports cpu mmx
 endif
@@ -2699,7 +2702,11 @@ dynlibs$(PPUEXT) : $(INC)/dynlibs.pas $(UNIXINC)/dynlibs.inc dl$(PPUEXT) objpas$
 cwstring$(PPUEXT) : $(UNIXINC)/cwstring.pp $(SYSTEMUNIT)$(PPUEXT) sysutils$(PPUEXT) baseunix$(PPUEXT) unix$(PPUEXT) unixtype$(PPUEXT) ctypes$(PPUEXT)
 macpas$(PPUEXT) : $(INC)/macpas.pp objpas$(PPUEXT) math$(PPUEXT)
 	$(COMPILER) $(INC)/macpas.pp $(REDIR)
+ifeq ($(ARCH),x86_64)
+cpu$(PPUEXT) : $(PROCINC)/cpu.pp $(SYSTEMUNIT)$(PPUEXT) sysutils$(PPUEXT)
+else
 cpu$(PPUEXT) : $(PROCINC)/cpu.pp $(SYSTEMUNIT)$(PPUEXT)
+endif
 mmx$(PPUEXT) : $(PROCINC)/mmx.pp cpu$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 getopts$(PPUEXT) : $(INC)/getopts.pp $(SYSTEMUNIT)$(PPUEXT)
 heaptrc$(PPUEXT) : $(INC)/heaptrc.pp $(SYSTEMUNIT)$(PPUEXT)

+ 7 - 0
rtl/openbsd/Makefile.fpc

@@ -76,6 +76,9 @@ ifdef RELEASE
 override FPCOPT+=-Ur
 endif
 
+ifeq ($(ARCH),x86_64)
+CPU_UNITS=x86 ports cpu
+endif
 ifeq ($(ARCH),i386)
 CPU_UNITS=x86 ports cpu mmx
 endif
@@ -245,7 +248,11 @@ macpas$(PPUEXT) : $(INC)/macpas.pp objpas$(PPUEXT) math$(PPUEXT)
 # Other system-independent RTL Units
 #
 
+ifeq ($(ARCH),x86_64)
+cpu$(PPUEXT) : $(PROCINC)/cpu.pp $(SYSTEMUNIT)$(PPUEXT) sysutils$(PPUEXT)
+else
 cpu$(PPUEXT) : $(PROCINC)/cpu.pp $(SYSTEMUNIT)$(PPUEXT)
+endif
 
 mmx$(PPUEXT) : $(PROCINC)/mmx.pp cpu$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)