aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Wailes <chriswailes@google.com>2021-05-13 00:10:02 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-05-13 00:10:02 +0000
commiteebb878a1d2a6dfd0f8e5a2af0fe4628215c6632 (patch)
tree2a2790f8aaa96eab5320bbac3d6f9660756fd75f
parentffa38f9a303a1a59124b63392563170ec3cacf6c (diff)
parent6b7cecc5ea2e6023fa4fbc04edc4a22ea7559415 (diff)
downloadbionic-eebb878a1d2a6dfd0f8e5a2af0fe4628215c6632.tar.gz
Merge "Clear the stack frame pointer in _start and __bionic_clone" am: b1270fdd54 am: 98a50fa503 am: e7bc7bde23 am: 6b7cecc5ea
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1695053 Change-Id: I4a4aee2e318bc49da5daffff1f09146aad7e7635
-rw-r--r--libc/arch-arm/bionic/__bionic_clone.S2
-rw-r--r--libc/arch-common/bionic/crtbegin.c10
-rw-r--r--libc/arch-x86/bionic/__bionic_clone.S1
3 files changed, 9 insertions, 4 deletions
diff --git a/libc/arch-arm/bionic/__bionic_clone.S b/libc/arch-arm/bionic/__bionic_clone.S
index 6669b93a2..3fe212b47 100644
--- a/libc/arch-arm/bionic/__bionic_clone.S
+++ b/libc/arch-arm/bionic/__bionic_clone.S
@@ -61,6 +61,8 @@ ENTRY_PRIVATE(__bionic_clone)
b __set_errno_internal
.L_bc_child:
+ # We're in the child now. Set the end of the frame record chain.
+ mov fp, #0
# Setting lr to 0 will make the unwinder stop at __start_thread.
mov lr, #0
# Call __start_thread with the 'fn' and 'arg' we stored on the child stack.
diff --git a/libc/arch-common/bionic/crtbegin.c b/libc/arch-common/bionic/crtbegin.c
index 628783789..5f681c53c 100644
--- a/libc/arch-common/bionic/crtbegin.c
+++ b/libc/arch-common/bionic/crtbegin.c
@@ -49,13 +49,15 @@ __used static void _start_main(void* raw_args) {
#define POST "; .size _start, .-_start"
#if defined(__aarch64__)
-__asm__(PRE "bti j; mov x0,sp; b _start_main" POST);
+__asm__(PRE "bti j; mov x29,#0; mov x30,#0; mov x0,sp; b _start_main" POST);
#elif defined(__arm__)
-__asm__(PRE "mov r0,sp; b _start_main" POST);
+__asm__(PRE "mov fp,#0; mov lr,#0; mov r0,sp; b _start_main" POST);
#elif defined(__i386__)
-__asm__(PRE "movl %esp,%eax; andl $~0xf,%esp; subl $12,%esp; pushl %eax; calll _start_main" POST);
+__asm__(PRE
+ "xorl %ebp,%ebp; movl %esp,%eax; andl $~0xf,%esp; subl $12,%esp; pushl %eax;"
+ "calll _start_main" POST);
#elif defined(__x86_64__)
-__asm__(PRE "movq %rsp,%rdi; andq $~0xf,%rsp; callq _start_main" POST);
+__asm__(PRE "xorl %ebp, %ebp; movq %rsp,%rdi; andq $~0xf,%rsp; callq _start_main" POST);
#else
#error unsupported architecture
#endif
diff --git a/libc/arch-x86/bionic/__bionic_clone.S b/libc/arch-x86/bionic/__bionic_clone.S
index b682b4863..f0c58a00d 100644
--- a/libc/arch-x86/bionic/__bionic_clone.S
+++ b/libc/arch-x86/bionic/__bionic_clone.S
@@ -45,6 +45,7 @@ ENTRY_PRIVATE(__bionic_clone)
.L_bc_child:
# We don't want anyone to unwind past this point.
.cfi_undefined %eip
+ .cfi_undefined %ebp
call __start_thread
hlt