diff options
author | Christian Wailes <chriswailes@google.com> | 2021-05-12 22:52:59 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2021-05-12 22:52:59 +0000 |
commit | b1270fdd54bb9d5d744c754cd63a225924b73709 (patch) | |
tree | 2a2790f8aaa96eab5320bbac3d6f9660756fd75f | |
parent | 13d267e77e3f3897bd94064f6456320e584c7336 (diff) | |
parent | 559f27828cbc51851978c5781618fe5b3d34e4ba (diff) | |
download | bionic-b1270fdd54bb9d5d744c754cd63a225924b73709.tar.gz |
Merge "Clear the stack frame pointer in _start and __bionic_clone"
-rw-r--r-- | libc/arch-arm/bionic/__bionic_clone.S | 2 | ||||
-rw-r--r-- | libc/arch-common/bionic/crtbegin.c | 10 | ||||
-rw-r--r-- | libc/arch-x86/bionic/__bionic_clone.S | 1 |
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 |