From 89e987b22ecd3dd38d6d519485421374016f30b1 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Thu, 16 Oct 2014 20:23:22 +0200 Subject: [PATCH] base/x86_32: preserve EBX value in crt0 --- repos/base/src/platform/x86_32/crt0.s | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/repos/base/src/platform/x86_32/crt0.s b/repos/base/src/platform/x86_32/crt0.s index efedf4aca4..9b1dbd86cb 100644 --- a/repos/base/src/platform/x86_32/crt0.s +++ b/repos/base/src/platform/x86_32/crt0.s @@ -23,16 +23,17 @@ .global _start _start: - /* initialize GOT pointer in EBX */ + /* save initial register values using GOT-relative addressing */ 3: - movl $., %ebx - addl $_GLOBAL_OFFSET_TABLE_ + (. - 3b) , %ebx - movl %esp, __initial_sp@GOTOFF(%ebx) + movl $., %ecx + addl $_GLOBAL_OFFSET_TABLE_ + (. - 3b) , %ecx + movl %esp, __initial_sp@GOTOFF(%ecx) + movl %eax, __initial_ax@GOTOFF(%ecx) + movl %ebx, __initial_bx@GOTOFF(%ecx) + movl %edi, __initial_di@GOTOFF(%ecx) - /* make initial value of some registers available to higher-level code */ - mov %esp, __initial_sp - mov %eax, __initial_ax - mov %edi, __initial_di + /* initialize GOT pointer in EBX as expected by the tool chain */ + mov %ecx, %ebx /* * Install initial temporary environment that is replaced later by the @@ -74,6 +75,9 @@ .global __initial_ax __initial_ax: .space 4 + .global __initial_bx + __initial_bx: + .space 4 .global __initial_di __initial_di: .space 4