diff options
author | Ryan Prichard <rprichard@google.com> | 2018-02-12 19:59:46 -0800 |
---|---|---|
committer | Ryan Prichard <rprichard@google.com> | 2018-02-12 21:43:12 -0800 |
commit | f857d59635cda31db2fdc0c58193f51eecf2cc73 (patch) | |
tree | 2cac454ac04d26b4b52518274d2914af11e0bb26 | |
parent | 919dd9dcb4ca547a67079b85494236cd5f680598 (diff) | |
download | android_bionic-f857d59635cda31db2fdc0c58193f51eecf2cc73.tar.gz android_bionic-f857d59635cda31db2fdc0c58193f51eecf2cc73.tar.bz2 android_bionic-f857d59635cda31db2fdc0c58193f51eecf2cc73.zip |
Switch x86 begin.c to asm; align ESP correctly
Every other architecture already uses an assembly file here.
The previous code aligned ESP incorrectly, but it doesn't really matter
because everything is built with Clang's -mstackrealign, which realigns
ESP in every function prologue.
Bug: http://b/73140672#comment4
Test: lunch aosp_x86-eng; m; emulator; device boots
Test: manual
Change-Id: I921fd7848cdc611b4f8f13d1176d1983ffea952d
-rw-r--r-- | linker/Android.bp | 4 | ||||
-rw-r--r-- | linker/arch/x86/begin.S (renamed from linker/arch/x86/begin.c) | 32 |
2 files changed, 12 insertions, 24 deletions
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 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 <stdint.h> -#include <sys/cdefs.h> +#include <private/bionic_asm.h> -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"); - - void (*start)(void); + .cfi_undefined %eip - 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) |