diff --git a/linker/Android.bp b/linker/Android.bp index 50587f27e..b6fcf4947 100644 --- a/linker/Android.bp +++ b/linker/Android.bp @@ -104,9 +104,7 @@ cc_binary { version_script: "linker.generic.map", }, x86: { - srcs: ["arch/x86/begin.c"], - - cflags: ["-D__work_around_b_24465209__"], + srcs: ["arch/x86/begin.S"], version_script: "linker.generic.map", }, x86_64: { diff --git a/linker/arch/x86/begin.c b/linker/arch/x86/begin.S similarity index 72% rename from linker/arch/x86/begin.c rename to linker/arch/x86/begin.S index 331b79e17..3812646e6 100644 --- a/linker/arch/x86/begin.c +++ b/linker/arch/x86/begin.S @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 The Android Open Source Project + * Copyright (C) 2018 The Android Open Source Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -26,28 +26,18 @@ * SUCH DAMAGE. */ -#include -#include +#include -extern unsigned __linker_init(void* raw_args); - -__LIBC_HIDDEN__ void _start() { +ENTRY(_start) // Force unwinds to end in this function. - asm volatile(".cfi_undefined \%eip"); + .cfi_undefined %eip - void (*start)(void); - - void* raw_args = (void*) ((uintptr_t) __builtin_frame_address(0) + sizeof(void*)); - start = (void(*)(void))__linker_init(raw_args); + movl %esp, %eax // %esp is aligned to 16 here. + subl $12, %esp + pushl %eax + call __linker_init // %esp is aligned to 16 before the call. + addl $16, %esp /* linker init returns (%eax) the _entry address in the main image */ - /* entry point expects sp to point to raw_args */ - - __asm__ ( - "mov %0, %%esp\n\t" - "jmp *%1\n\t" - : : "r"(raw_args), "r"(start) : - ); - - /* Unreachable */ -} + jmp *%eax +END(_start)