From 7dc875e8c72f77219cf08845287ba5e11f0e2d47 Mon Sep 17 00:00:00 2001 From: Sebastian Sumpf Date: Thu, 4 Apr 2019 11:36:43 +0200 Subject: [PATCH] base: dynamic linking support of crt0.s on ARM 64-bit * added global offset table relative loading for global symbols * removed 'initial_sp' and 'initial_x0' because they are currently not used on this platform. If required they are easy to resurrect. issue #3260 --- repos/base/src/lib/startup/spec/arm_64/crt0.s | 31 ++++++------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/repos/base/src/lib/startup/spec/arm_64/crt0.s b/repos/base/src/lib/startup/spec/arm_64/crt0.s index d0f1a238fa..41db7888d9 100644 --- a/repos/base/src/lib/startup/spec/arm_64/crt0.s +++ b/repos/base/src/lib/startup/spec/arm_64/crt0.s @@ -24,19 +24,13 @@ .global _start_initial_stack _start_initial_stack: - /* make initial value of some registers available to higher-level code */ - ldr x4, =__initial_sp - mov x5, sp - str x5, [x4] - ldr x4, =__initial_x0 - str x0, [x4] - /* * Install initial temporary environment that is replaced later by the * environment that init_main_thread creates. */ - ldr x4, =_stack_high - mov sp, x4 + adrp x4, :got:__initial_stack_high + ldr x4, [x4, #:got_lo12:__initial_stack_high] + mov sp, x4 /* if this is the dynamic linker, init_rtld relocates the linker */ bl init_rtld @@ -45,8 +39,9 @@ bl init_main_thread /* apply environment that was created by init_main_thread */ - ldr x4, =init_main_thread_result - ldr x4, [x4] + adrp x4, :got:init_main_thread_result + ldr x4, [x4, #:got_lo12:init_main_thread_result] + ldr x4, [x4] mov sp, x4 /* jump into init C code instead of calling it as it should never return */ @@ -57,20 +52,12 @@ ** .bss (non-initialized data) ** *********************************/ -.section ".bss" +.bss /* stack of the temporary initial environment */ .p2align 8 .global __initial_stack_base __initial_stack_base: .space 12*1024 - _stack_high: - - /* initial value of the SP register */ - .global __initial_sp - __initial_sp: - .space 8 - /* initial value of the X0 register */ - .global __initial_x0 - __initial_x0: - .space 8 + .global __initial_stack_high + __initial_stack_high: