From b6a28795ddfdf1d0f0882321f1ef5d70aa555966 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Fri, 28 Feb 2014 00:27:25 +0100 Subject: [PATCH] base & x86: setup GOT pointer in crt0.s This is normally needed in LDSO and was previously done by the LDSO specific crt0.s. I forgot to keep it during the unification of the different crt0s. fix #1077 --- base/src/platform/x86_32/crt0.s | 10 ++++++++-- base/src/platform/x86_64/crt0.s | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/base/src/platform/x86_32/crt0.s b/base/src/platform/x86_32/crt0.s index 776b4c54cb..eda33967cb 100644 --- a/base/src/platform/x86_32/crt0.s +++ b/base/src/platform/x86_32/crt0.s @@ -23,6 +23,12 @@ .global _start _start: + /* initialize GOT pointer in EBX */ + 3: + movl $., %ebx + addl $_GLOBAL_OFFSET_TABLE_ + (. - 3b) , %ebx + movl %esp, __initial_sp@GOTOFF(%ebx) + /* make initial value of some registers available to higher-level code */ mov %esp, __initial_sp mov %eax, __initial_ax @@ -32,7 +38,7 @@ * Install initial temporary environment that is replaced later by the * environment that init_main_thread creates. */ - leal _stack_high, %esp + leal _stack_high@GOTOFF(%ebx), %esp /* if this is the dynamic linker, init_rtld relocates the linker */ call init_rtld @@ -44,7 +50,7 @@ movl init_main_thread_result, %esp /* clear the base pointer in order that stack backtraces will work */ - xor %ebp,%ebp + xor %ebp, %ebp /* jump into init C code instead of calling it as it should never return */ jmp _main diff --git a/base/src/platform/x86_64/crt0.s b/base/src/platform/x86_64/crt0.s index d797f2a229..89b9f5ff17 100644 --- a/base/src/platform/x86_64/crt0.s +++ b/base/src/platform/x86_64/crt0.s @@ -23,6 +23,9 @@ .global _start _start: + /* initialize GLOBAL OFFSET TABLE */ + leaq _GLOBAL_OFFSET_TABLE_(%rip), %r15 + /* make initial value of some registers available to higher-level code */ movq __initial_ax@GOTPCREL(%rip), %rbx movq %rax, (%rbx)