From dbb91b5ef0b5f55826814be5c7702bd0e0bb80fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A1roly=20Balogh?= Date: Mon, 5 Mar 2018 15:38:46 +0000 Subject: [PATCH] arm-netbsd: added platform define and dummy rtl files so the build passes for this platform. port not functional yet git-svn-id: trunk@38412 - --- .gitattributes | 5 +++ compiler/arm/agarmgas.pas | 2 +- compiler/arm/cpuelf.pas | 5 ++- compiler/systems.inc | 3 +- compiler/systems.pas | 7 +++- compiler/systems/i_bsd.pas | 66 ++++++++++++++++++++++++++++++ compiler/systems/t_bsd.pas | 4 ++ compiler/utils/ppuutils/ppudump.pp | 3 +- packages/fpmkunit/src/fpmkunit.pp | 4 +- rtl/netbsd/arm/bsyscall.inc | 14 +++++++ rtl/netbsd/arm/cprt0.as | 16 ++++++++ rtl/netbsd/arm/dllprt0.as | 16 ++++++++ rtl/netbsd/arm/prt0.as | 55 +++++++++++++++++++++++++ rtl/netbsd/arm/sighnd.inc | 49 ++++++++++++++++++++++ rtl/netbsd/signal.inc | 6 +++ utils/fpcm/fpcmmain.pp | 2 +- 16 files changed, 248 insertions(+), 9 deletions(-) create mode 100644 rtl/netbsd/arm/bsyscall.inc create mode 100644 rtl/netbsd/arm/cprt0.as create mode 100644 rtl/netbsd/arm/dllprt0.as create mode 100644 rtl/netbsd/arm/prt0.as create mode 100644 rtl/netbsd/arm/sighnd.inc diff --git a/.gitattributes b/.gitattributes index f30c75d3da..d0466699f6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9762,6 +9762,11 @@ rtl/nds/sysutils.pp svneol=native#text/plain rtl/nds/tthread.inc svneol=native#text/plain rtl/netbsd/Makefile svneol=native#text/plain rtl/netbsd/Makefile.fpc svneol=native#text/plain +rtl/netbsd/arm/bsyscall.inc svneol=native#text/plainn +rtl/netbsd/arm/cprt0.as svneol=native#text/plainn +rtl/netbsd/arm/dllprt0.as svneol=native#text/plainn +rtl/netbsd/arm/prt0.as svneol=native#text/plainn +rtl/netbsd/arm/sighnd.inc svneol=native#text/plainn rtl/netbsd/errno.inc svneol=native#text/plain rtl/netbsd/errnostr.inc svneol=native#text/plain rtl/netbsd/i386/bsyscall.inc svneol=native#text/plain diff --git a/compiler/arm/agarmgas.pas b/compiler/arm/agarmgas.pas index 65587b4c57..224ce306f8 100644 --- a/compiler/arm/agarmgas.pas +++ b/compiler/arm/agarmgas.pas @@ -402,7 +402,7 @@ unit agarmgas; idtxt : 'AS'; asmbin : 'as'; asmcmd : '-o $OBJ $EXTRAOPT $ASM'; - supported_targets : [system_arm_linux,system_arm_wince,system_arm_gba,system_arm_palmos,system_arm_nds, + supported_targets : [system_arm_linux,system_arm_netbsd,system_arm_wince,system_arm_gba,system_arm_palmos,system_arm_nds, system_arm_embedded,system_arm_symbian,system_arm_android,system_arm_aros]; flags : [af_needar,af_smartlink_sections]; labelprefix : '.L'; diff --git a/compiler/arm/cpuelf.pas b/compiler/arm/cpuelf.pas index 5d7a0c31f6..4930a113eb 100644 --- a/compiler/arm/cpuelf.pas +++ b/compiler/arm/cpuelf.pas @@ -955,8 +955,9 @@ implementation asmbin : ''; asmcmd : ''; supported_targets : [system_arm_embedded,system_arm_darwin, - system_arm_linux,system_arm_gba, - system_arm_nds,system_arm_aros]; + system_arm_linux,system_arm_netbsd, + system_arm_gba,system_arm_nds, + system_arm_aros]; flags : [af_outputbinary,af_smartlink_sections,af_supports_dwarf]; labelprefix : '.L'; comment : ''; diff --git a/compiler/systems.inc b/compiler/systems.inc index 9d524443bd..3d4d308a65 100644 --- a/compiler/systems.inc +++ b/compiler/systems.inc @@ -178,7 +178,8 @@ system_arm_aros, { 91 } system_wasm_wasm32, { 92 } system_sparc64_linux, { 93 } - system_sparc64_solaris { 94 } + system_sparc64_solaris, { 94 } + system_arm_netbsd { 95 } ); type diff --git a/compiler/systems.pas b/compiler/systems.pas index 8b9266ba57..b0201c7576 100644 --- a/compiler/systems.pas +++ b/compiler/systems.pas @@ -239,7 +239,8 @@ interface systems_netbsd = [system_i386_netbsd, system_m68k_netbsd, system_powerpc_netbsd, - system_x86_64_netbsd]; + system_x86_64_netbsd, + system_arm_netbsd]; systems_openbsd = [system_i386_openbsd, system_x86_64_openbsd]; @@ -974,6 +975,10 @@ begin {$define default_target_set} default_target(system_arm_linux); {$endif} + {$ifdef netbsd} + {$define default_target_set} + default_target(system_arm_netbsd); + {$endif} {$ifdef android} {$define default_target_set} default_target(system_arm_android); diff --git a/compiler/systems/i_bsd.pas b/compiler/systems/i_bsd.pas index 638cf3863d..e0f92dedd5 100644 --- a/compiler/systems/i_bsd.pas +++ b/compiler/systems/i_bsd.pas @@ -645,6 +645,69 @@ unit i_bsd; llvmdatalayout : 'e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128'; ); + system_arm_netbsd_info : tsysteminfo = + ( + system : system_arm_netbsd; + name : 'NetBSD for ARMHF'; + shortname : 'NetBSD'; + flags : [tf_under_development,tf_files_case_sensitive,tf_smartlink_sections,tf_has_winlike_resources]; + cpu : cpu_arm; + unit_env : ''; + extradefines : 'UNIX;BSD;HASUNIX'; + exeext : ''; + defext : '.def'; + scriptext : '.sh'; + smartext : '.sl'; + unitext : '.ppu'; + unitlibext : '.ppl'; + asmext : '.s'; + objext : '.o'; + resext : '.res'; + resobjext : '.or'; + sharedlibext : '.so'; + staticlibext : '.s'; + staticlibprefix : 'libp'; + sharedlibprefix : 'lib'; + sharedClibext : '.so'; + staticClibext : '.a'; + staticClibprefix : 'lib'; + sharedClibprefix : 'lib'; + importlibprefix : 'libimp'; + importlibext : '.a'; + Cprefix : ''; + newline : #10; + dirsep : '/'; + assem : as_gas; {as_arm_elf32;} + assemextern : as_gas; + link : ld_none; + linkextern : ld_bsd; + ar : ar_gnu_ar; + res : res_elf; + dbg : dbg_dwarf2; + script : script_unix; + endian : endian_big; + alignment : + ( + procalign : 4; + loopalign : 4; + jumpalign : 0; + constalignmin : 0; + constalignmax : 4; + varalignmin : 0; + varalignmax : 4; + localalignmin : 0; + localalignmax : 4; + recordalignmin : 0; + recordalignmax : 2; + maxCrecordalign : 4 // should be 8 probably + ); + first_parm_offset : 8; + stacksize : 32*1024*1024; + stackalign : 16; + abi : abi_default; + llvmdatalayout : 'todo'; + ); + system_powerpc_darwin_info : tsysteminfo = ( system : system_powerpc_darwin; @@ -1219,6 +1282,9 @@ initialization {$ifdef Darwin} set_source_info(system_arm_darwin_info); {$endif Darwin} + {$ifdef NetBSD} + set_source_info(system_arm_netbsd_info); + {$endif} {$endif cpuarm} {$ifdef cpuaarch64} {$ifdef Darwin} diff --git a/compiler/systems/t_bsd.pas b/compiler/systems/t_bsd.pas index cefc399e62..e6a5f22c81 100644 --- a/compiler/systems/t_bsd.pas +++ b/compiler/systems/t_bsd.pas @@ -1101,6 +1101,10 @@ initialization RegisterImport(system_arm_darwin,timportlibdarwin); RegisterExport(system_arm_darwin,texportlibdarwin); RegisterTarget(system_arm_darwin_info); + + RegisterImport(system_arm_netbsd,timportlibbsd); + RegisterExport(system_arm_netbsd,texportlibbsd); + RegisterTarget(system_arm_netbsd_info); {$endif arm} {$ifdef aarch64} RegisterImport(system_aarch64_darwin,timportlibdarwin); diff --git a/compiler/utils/ppuutils/ppudump.pp b/compiler/utils/ppuutils/ppudump.pp index 74b4a4599e..d9a62319aa 100644 --- a/compiler/utils/ppuutils/ppudump.pp +++ b/compiler/utils/ppuutils/ppudump.pp @@ -180,7 +180,8 @@ const { 91 } 'AROS-arm', { 92 } 'WebAssembly-wasm', { 93 } 'Linux-sparc64', - { 94 } 'Solaris-sparc64' + { 94 } 'Solaris-sparc64', + { 95 } 'NetBSD-arm' ); const diff --git a/packages/fpmkunit/src/fpmkunit.pp b/packages/fpmkunit/src/fpmkunit.pp index e22781e9f2..1ca9d9d68a 100644 --- a/packages/fpmkunit/src/fpmkunit.pp +++ b/packages/fpmkunit/src/fpmkunit.pp @@ -180,7 +180,7 @@ Const AllAmigaLikeOSes = [Amiga,MorphOS,AROS]; AllLimit83fsOses = [go32v2,os2,emx,watcom,msdos,win16,atari]; - AllSmartLinkLibraryOSes = [Linux,msdos,win16]; // OSes that use .a library files for smart-linking + AllSmartLinkLibraryOSes = [Linux,msdos,win16,palmos]; // OSes that use .a library files for smart-linking AllImportLibraryOSes = AllWindowsOSes + [os2,emx,netwlibc,netware,watcom,go32v2,macos,nativent,msdos,win16]; { This table is kept OS,Cpu because it is easier to maintain (PFV) } @@ -193,7 +193,7 @@ Const { os2 } ( false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false), { freebsd } ( false, true, true, false, false, true, false, false, false, false, false, false, false, false, false, false), { beos } ( false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false), - { netbsd } ( false, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false), + { netbsd } ( false, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false), { amiga } ( false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false), { atari } ( false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false), { solaris } ( false, true, false, false, true, true, false, false, false, false, false, false, false, false, false, false), diff --git a/rtl/netbsd/arm/bsyscall.inc b/rtl/netbsd/arm/bsyscall.inc new file mode 100644 index 0000000000..624654ec57 --- /dev/null +++ b/rtl/netbsd/arm/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. + + **********************************************************************} + diff --git a/rtl/netbsd/arm/cprt0.as b/rtl/netbsd/arm/cprt0.as new file mode 100644 index 0000000000..21f48d3daf --- /dev/null +++ b/rtl/netbsd/arm/cprt0.as @@ -0,0 +1,16 @@ +# +# This file is part of the Free Pascal run time library. +# Copyright (c) 2017 by Karoly Balogh +# 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. +# +#**********************************************************************} +# + +# FIX ME: dummy file, required for the build to pass, implement! (KB) diff --git a/rtl/netbsd/arm/dllprt0.as b/rtl/netbsd/arm/dllprt0.as new file mode 100644 index 0000000000..21f48d3daf --- /dev/null +++ b/rtl/netbsd/arm/dllprt0.as @@ -0,0 +1,16 @@ +# +# This file is part of the Free Pascal run time library. +# Copyright (c) 2017 by Karoly Balogh +# 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. +# +#**********************************************************************} +# + +# FIX ME: dummy file, required for the build to pass, implement! (KB) diff --git a/rtl/netbsd/arm/prt0.as b/rtl/netbsd/arm/prt0.as new file mode 100644 index 0000000000..1f06e8b69d --- /dev/null +++ b/rtl/netbsd/arm/prt0.as @@ -0,0 +1,55 @@ +# +# This file is part of the Free Pascal run time library. +# Copyright (c) 2017 by Karoly Balogh +# 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. +# +#**********************************************************************} +# +# NetBSD standard (shared) ELF/arm startup code for Free Pascal + +.section .text + .globl _start +_start: +# move.l %a2,-(%sp) | ps_strings +# move.l %a0,-(%sp) | obj +# move.l %a1,-(%sp) | cleanup + +# move.l 0(%a2),operatingsystem_parameter_argv +# move.l 4(%a2),operatingsystem_parameter_argc +# move.l 8(%a2),operatingsystem_parameter_envp +# move.l 8(%a2),environ + +# jsr PASCALMAIN +# jmp _haltproc + + .globl _haltproc +_haltproc: +# move.l operatingsystem_result,-(%sp) +# move.l #0,-(%sp) +# moveq.l #1,%d0 +# trap #0 +# rts + + +.section .data + .comm environ,4,4 + .comm operatingsystem_parameter_envp,4,4 + .comm operatingsystem_parameter_argc,4,4 + .comm operatingsystem_parameter_argv,4,4 + + +.section ".note.netbsd.ident", "a" + .long 2f-1f + .long 4f-3f + .long 1 +1: .asciz "NetBSD" +2: .p2align 2 +3: .long 400000000 +4: .p2align 2 diff --git a/rtl/netbsd/arm/sighnd.inc b/rtl/netbsd/arm/sighnd.inc new file mode 100644 index 0000000000..c2f61066e6 --- /dev/null +++ b/rtl/netbsd/arm/sighnd.inc @@ -0,0 +1,49 @@ +{ + This file is part of the Free Pascal run time library + (c) 2016 the Free Pascal development team + + See the file COPYING.FPC, included in this distribution, + for details about the copyright. + + Signalhandler for NetBSD/m68k + + 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; + +function getfpustate(const Sigcontext:sigcontextRec):longint; {inline;} +begin + getfpustate:=0; +end; + +procedure SignalToRunerror(Signo: longint;info : PSigInfo;SigContext: PSigContextRec); public name '_FPC_DEFAULTSIGHANDLER'; cdecl; +var + res : word; +begin + res:=0; + if signo = SIGFPE then + begin + res := 200; + end + else + if (signo = SIGILL) or (signo = SIGBUS) or (signo = SIGSEGV) then + begin + res := 216; + end + else if (signo = SIGINT) then + begin + res:=217; + end + else if (signo = SIGKILL) then + begin + res:=233 + end; + { give runtime error at the position where the signal was raised } + if res<>0 then + begin + HandleError(res); + end; +end; diff --git a/rtl/netbsd/signal.inc b/rtl/netbsd/signal.inc index 42616980a1..39d354e3d9 100644 --- a/rtl/netbsd/signal.inc +++ b/rtl/netbsd/signal.inc @@ -299,6 +299,12 @@ enum { _FRAME_GREG(GREG_OFFSETS) _NGREG = 26 }; {$WARNING FIXME! SigContextRec} end; {$endif powerpc} +{$ifdef CPUARM} + SigContextRec = record + sc_args : array[0..6] of clong; + {$WARNING FIXME! SigContextRec} + end; +{$endif m68k} SignalHandler = Procedure(Sig : Longint);cdecl; PSignalHandler = ^SignalHandler; diff --git a/utils/fpcm/fpcmmain.pp b/utils/fpcm/fpcmmain.pp index 8648a59812..6e54e522b1 100644 --- a/utils/fpcm/fpcmmain.pp +++ b/utils/fpcm/fpcmmain.pp @@ -121,7 +121,7 @@ interface { freebsd } ( true, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false), { beos } ( true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false), { haiku } ( true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false), - { netbsd } ( true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false), + { netbsd } ( true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false), { amiga } ( false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false), { atari } ( false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false), { solaris } ( true, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false),