diff options
author | laksen <laksen@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2018-07-29 13:08:15 +0000 |
---|---|---|
committer | laksen <laksen@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2018-07-29 13:08:15 +0000 |
commit | f644e76169c6e9fd07bfedfc92602b4fe998ef47 (patch) | |
tree | 2a5ea70538624a304eace7eaeb605362ab0a2a5c | |
parent | e0c39ce1b21f7c35799446b5be789cc7bef0b229 (diff) | |
download | fpc-f644e76169c6e9fd07bfedfc92602b4fe998ef47.tar.gz |
Added library search paths.
Removed GP and TP from allocatable registers for now. GP should not be overwritten.
Ported dllprt0.as
Fixed register usage in cprt0.as
git-svn-id: https://svn.freepascal.org/svn/fpc/branches/laksen@39522 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r-- | riscv_new/compiler/riscv64/cgcpu.pas | 1 | ||||
-rw-r--r-- | riscv_new/compiler/systems/t_linux.pas | 6 | ||||
-rw-r--r-- | riscv_new/rtl/linux/Makefile | 4 | ||||
-rw-r--r-- | riscv_new/rtl/linux/Makefile.fpc | 2 | ||||
-rw-r--r-- | riscv_new/rtl/linux/riscv64/cprt0.as | 63 | ||||
-rw-r--r-- | riscv_new/rtl/linux/riscv64/dllprt0.as | 62 |
6 files changed, 63 insertions, 75 deletions
diff --git a/riscv_new/compiler/riscv64/cgcpu.pas b/riscv_new/compiler/riscv64/cgcpu.pas index ac1a626c74..31c533f971 100644 --- a/riscv_new/compiler/riscv64/cgcpu.pas +++ b/riscv_new/compiler/riscv64/cgcpu.pas @@ -71,7 +71,6 @@ implementation [RS_X10,RS_X11,RS_X12,RS_X13,RS_X14,RS_X15,RS_X16,RS_X17, RS_X31,RS_X30,RS_X29,RS_X28, RS_X5,RS_X6,RS_X7, - RS_X3,RS_X4, RS_X9,RS_X27,RS_X26,RS_X25,RS_X24,RS_X23,RS_X22, RS_X21,RS_X20,RS_X19,RS_X18],first_int_imreg,[]); rg[R_FPUREGISTER]:=trgcpu.create(R_FPUREGISTER,R_SUBNONE, diff --git a/riscv_new/compiler/systems/t_linux.pas b/riscv_new/compiler/systems/t_linux.pas index f5ad6c98e1..908b19d267 100644 --- a/riscv_new/compiler/systems/t_linux.pas +++ b/riscv_new/compiler/systems/t_linux.pas @@ -181,6 +181,12 @@ begin {$ifdef sparc64} LibrarySearchPath.AddPath(sysrootpath,'/usr/lib/sparc64-linux-gnu',true); {$endif sparc64} +{$ifdef riscv32} + LibrarySearchPath.AddPath(sysrootpath,'/usr/lib/riscv32-linux-gnu',true); +{$endif riscv32} +{$ifdef riscv64} + LibrarySearchPath.AddPath(sysrootpath,'/usr/lib/riscv64-linux-gnu',true); +{$endif riscv64} end; end; diff --git a/riscv_new/rtl/linux/Makefile b/riscv_new/rtl/linux/Makefile index 9d266d41e2..fb0beb2fb9 100644 --- a/riscv_new/rtl/linux/Makefile +++ b/riscv_new/rtl/linux/Makefile @@ -1,5 +1,5 @@ # -# Don't edit, this file is generated by FPCMake Version 2.0.0 [2018/07/20] +# Don't edit, this file is generated by FPCMake Version 2.0.0 [2018-07-20 rev 39474] # default: all MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian i386-nativent i386-iphonesim i386-android i386-aros m68k-linux m68k-netbsd m68k-amiga m68k-atari m68k-palmos m68k-macos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded powerpc-wii powerpc-aix 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 x86_64-iphonesim x86_64-aros x86_64-dragonfly arm-linux arm-netbsd arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian arm-android arm-aros powerpc64-linux powerpc64-darwin powerpc64-embedded powerpc64-aix avr-embedded armeb-linux armeb-embedded mips-linux mipsel-linux mipsel-embedded mipsel-android jvm-java jvm-android i8086-embedded i8086-msdos i8086-win16 aarch64-linux aarch64-darwin wasm-wasm sparc64-linux riscv32-linux riscv32-embedded riscv64-linux riscv64-embedded @@ -361,7 +361,7 @@ override LOADERS= SYSINIT_UNITS=si_prc si_c si_g si_dll endif ifeq ($(ARCH),riscv64) -override LOADERS=prt0 cprt0 +override LOADERS=prt0 cprt0 dllprt0 endif ifeq ($(ARCH),mipsel) override FPCOPT+=-Ur diff --git a/riscv_new/rtl/linux/Makefile.fpc b/riscv_new/rtl/linux/Makefile.fpc index 8a9efd517a..835bd8018a 100644 --- a/riscv_new/rtl/linux/Makefile.fpc +++ b/riscv_new/rtl/linux/Makefile.fpc @@ -91,7 +91,7 @@ SYSINIT_UNITS=si_prc si_c si_g si_dll endif ifeq ($(ARCH),riscv64) -override LOADERS=prt0 cprt0 +override LOADERS=prt0 cprt0 dllprt0 endif # mipsel reuses mips files by including so some file names exist diff --git a/riscv_new/rtl/linux/riscv64/cprt0.as b/riscv_new/rtl/linux/riscv64/cprt0.as index fad4c51c50..01f4835dae 100644 --- a/riscv_new/rtl/linux/riscv64/cprt0.as +++ b/riscv_new/rtl/linux/riscv64/cprt0.as @@ -26,17 +26,17 @@ At this entry point, most registers' values are unspecified, except: - a1 Contains a function pointer to be registered with `atexit'. + a0 Contains a function pointer to be registered with `atexit'. This is how the dynamic linker arranges to have DT_FINI functions called for shared libraries that have been loaded before this code runs. sp The stack contains the arguments and environment: 0(sp) argc - 4(sp) argv[0] + 8(sp) argv[0] ... - (4*argc)(sp) NULL - (4*(argc+1))(sp) envp[0] + (8*argc)(sp) NULL + (8*(argc+1))(sp) envp[0] ... NULL */ @@ -51,21 +51,23 @@ _start: addi gp, gp, %pcrel_lo(1b) .option pop + /* Store rtld_fini in a5 */ + addi a5, a0, 0 + /* Clear the frame pointer since this is the outermost frame. */ addi x8, x0, 0 - ld a2, 0(sp) - addi sp, sp, 8 - /* Pop argc off the stack and save a pointer to argv */ -1:auipc x8,%pcrel_hi(operatingsystem_parameter_argc) - sd a2,%pcrel_lo(1b)(x8) -1:auipc x8,%pcrel_hi(operatingsystem_parameter_argv) - sd sp,%pcrel_lo(1b)(x8) - - addi a4, a2, 1 + /* Pop argc off the stack, and save argc, argv and envp */ + ld a1, 0(sp) + addi a2, sp, 8 + addi a4, a1, 1 slli a4, a4, 3 - add a4, sp, a4 + add a4, a2, a4 +1:auipc x8,%pcrel_hi(operatingsystem_parameter_argc) + sd a1,%pcrel_lo(1b)(x8) +1:auipc x8,%pcrel_hi(operatingsystem_parameter_argv) + sd a2,%pcrel_lo(1b)(x8) 1:auipc x8,%pcrel_hi(operatingsystem_parameter_envp) sd a4,%pcrel_lo(1b)(x8) @@ -75,30 +77,15 @@ _start: /* Fetch address of fini */ 1:auipc x8,%pcrel_hi(__libc_csu_fini) - addi a2,x8,%pcrel_lo(1b) - - /* argc already loaded to a2*/ + addi a4,x8,%pcrel_lo(1b) - /* load argv */ - addi a3, sp, 0 - - /* Push stack limit */ - sd a3, -8(sp) - addi sp, sp, -8 - - /* Push rtld_fini */ - sd a1, -8(sp) - addi sp, sp, -8 + addi a6, sp, 0 /* Set up the other arguments in registers */ 1:auipc x8,%pcrel_hi(PASCALMAIN) - addi a1, x8, %pcrel_lo(1b) + addi a0, x8, %pcrel_lo(1b) 1:auipc x8,%pcrel_hi(__libc_csu_init) - addi a4, x8, %pcrel_lo(1b) - - /* Push fini */ - sd a2, -8(sp) - addi sp, sp, -8 + addi a3, x8, %pcrel_lo(1b) /* __libc_start_main (main, argc, argv, init, fini, rtld_fini, stack_end) */ @@ -111,7 +98,7 @@ _start: jalr ra, x8, %pcrel_lo(1b) .globl _haltproc - .type _haltproc,function + .type _haltproc,function _haltproc: 1:auipc x8,%pcrel_hi(operatingsystem_result) lbu x1,%pcrel_lo(1b)(x8) @@ -128,11 +115,11 @@ __data_start: data_start = __data_start .bss - .comm __stkptr,4 + .comm __stkptr,8 - .comm operatingsystem_parameter_envp,4 - .comm operatingsystem_parameter_argc,4 - .comm operatingsystem_parameter_argv,4 + .comm operatingsystem_parameter_envp,8 + .comm operatingsystem_parameter_argc,8 + .comm operatingsystem_parameter_argv,8 .section ".comment" .byte 0 diff --git a/riscv_new/rtl/linux/riscv64/dllprt0.as b/riscv_new/rtl/linux/riscv64/dllprt0.as index a7b7ee585d..3e53d59947 100644 --- a/riscv_new/rtl/linux/riscv64/dllprt0.as +++ b/riscv_new/rtl/linux/riscv64/dllprt0.as @@ -21,60 +21,56 @@ _startlib: .globl FPC_SHARED_LIB_START .type FPC_SHARED_LIB_START,function FPC_SHARED_LIB_START: - sw x1, -4(x2) - sw x8, -8(x2) - addi x8, x2, 0 - addi x2, x2, -8 + addi sp, sp, -16 + sd ra, 8(sp) + sd x8, 0(sp) + addi x8, sp, 16 - /* a1 contains argc, a2 contains argv and a3 contains envp */ - lui x15, %hi(operatingsystem_parameter_argc) - addi x15,x15,%lo(operatingsystem_parameter_argc) - sw a1, (x15) - - lui x15, %hi(operatingsystem_parameter_argv) - addi x15,x15,%lo(operatingsystem_parameter_argv) - sw a2, (x15) - - lui x15, %hi(operatingsystem_parameter_envp) - addi x15,x15,%lo(operatingsystem_parameter_envp) - sw a3, (x15) + /* a0 contains argc, a1 contains argv and a2 contains envp */ +1:auipc x8,%pcrel_hi(operatingsystem_parameter_argc) + sd a0,%pcrel_lo(1b)(x8) +1:auipc x8,%pcrel_hi(operatingsystem_parameter_argv) + sd a1,%pcrel_lo(1b)(x8) +1:auipc x8,%pcrel_hi(operatingsystem_parameter_envp) + sd a2,%pcrel_lo(1b)(x8) /* save initial stackpointer */ - lui x15, %hi(__stklen) - addi x15,x15,%lo(__stklen) - sw x2, (x15) +1:auipc x8,%pcrel_hi(__stklen) + sd sp,%pcrel_lo(1b)(x8) /* call main and exit normally */ - jal x1, PASCALMAIN - lw x8, -8(x8) - lw x1, -4(x8) +1:auipc x8,%pcrel_hi(PASCALMAIN) + jalr ra, x8, %pcrel_lo(1b) + + ld x8, 0(x8) + ld ra, 8(x8) + addi sp, sp, 16 - jalr x0, x1 + jalr x0, ra .globl _haltproc .type _haltproc,function _haltproc: - /* reload exitcode */ - lui x10, %hi(operatingsystem_result) - addi x10,x10,%lo(operatingsystem_result) - addi x17, x0, 248 - scall +1:auipc x8,%pcrel_hi(operatingsystem_result) + lbu x1,%pcrel_lo(1b)(x8) + addi x17, x0, 94 + ecall jal x0, _haltproc .data .type operatingsystem_parameters,object - .size operatingsystem_parameters,12 + .size operatingsystem_parameters,24 operatingsystem_parameters: - .skip 3*4 + .skip 3*8 .global operatingsystem_parameter_envp .global operatingsystem_parameter_argc .global operatingsystem_parameter_argv .set operatingsystem_parameter_envp,operatingsystem_parameters+0 - .set operatingsystem_parameter_argc,operatingsystem_parameters+4 - .set operatingsystem_parameter_argv,operatingsystem_parameters+8 + .set operatingsystem_parameter_argc,operatingsystem_parameters+8 + .set operatingsystem_parameter_argv,operatingsystem_parameters+16 .bss - .comm __stkptr,4 + .comm __stkptr,8 |