am 47033433: Merge "Remove the bogus exit status from _exit_with_stack_teardown."

* commit '470334333e2ad5119b72bb830c51c32852a77c6c':
  Remove the bogus exit status from _exit_with_stack_teardown.
This commit is contained in:
Elliott Hughes 2013-12-22 11:40:10 -08:00 committed by Android Git Automerger
commit 2f6f6c0b8e
6 changed files with 43 additions and 58 deletions

View File

@ -26,18 +26,16 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include <asm/unistd.h> #include <private/bionic_asm.h>
#include <machine/asm.h>
// void _exit_with_stack_teardown(void* stackBase, size_t stackSize, int status) // void _exit_with_stack_teardown(void* stackBase, size_t stackSize)
ENTRY(_exit_with_stack_teardown) ENTRY(_exit_with_stack_teardown)
mov w28, w2 mov w8, __NR_munmap
mov w8, __NR_munmap svc #0
svc #0
// If munmap failed, we ignore the failure and exit anyway. // If munmap failed, we ignore the failure and exit anyway.
sxtw x0, w28 mov x0, #0
mov w8, __NR_exit mov w8, __NR_exit
svc #0 svc #0
// The exit syscall does not return. // The exit syscall does not return.
END(_exit_with_stack_teardown) END(_exit_with_stack_teardown)

View File

@ -26,18 +26,16 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include <machine/asm.h> #include <private/bionic_asm.h>
#include <asm/unistd.h>
// void _exit_with_stack_teardown(void* stackBase, size_t stackSize, int status) // void _exit_with_stack_teardown(void* stackBase, size_t stackSize)
ENTRY(_exit_with_stack_teardown) ENTRY(_exit_with_stack_teardown)
mov lr, r2 ldr r7, =__NR_munmap
ldr r7, =__NR_munmap swi #0
swi #0 // If munmap failed, we ignore the failure and exit anyway.
// If munmap failed, we ignore the failure and exit anyway.
mov r0, lr mov r0, #0
ldr r7, =__NR_exit ldr r7, =__NR_exit
swi #0 swi #0
// The exit syscall does not return. // The exit syscall does not return.
END(_exit_with_stack_teardown) END(_exit_with_stack_teardown)

View File

@ -30,21 +30,19 @@
.text .text
// void _exit_with_stack_teardown(void* stackBase, size_t stackSize, int status) // void _exit_with_stack_teardown(void* stackBase, size_t stackSize)
.type _exit_with_stack_teardown, @function .type _exit_with_stack_teardown, @function
.global _exit_with_stack_teardown .global _exit_with_stack_teardown
.align 4 .align 4
.ent _exit_with_stack_teardown .ent _exit_with_stack_teardown
_exit_with_stack_teardown: _exit_with_stack_teardown:
move $s0,$a2 /* preserve status for exit() call */ li $v0, __NR_munmap
li $v0,__NR_munmap
syscall syscall
// If munmap failed, we ignore the failure and exit anyway. // If munmap failed, we ignore the failure and exit anyway.
move $a0,$s0 move $a0, 0
li $v0,__NR_exit li $v0, __NR_exit
syscall syscall
// The exit syscall does not return. // The exit syscall does not return.
.end _exit_with_stack_teardown .end _exit_with_stack_teardown

View File

@ -1,21 +1,16 @@
#include <asm/unistd.h> #include <private/bionic_asm.h>
#include <machine/asm.h>
// void _exit_with_stack_teardown(void* stackBase, size_t stackSize, int status) // void _exit_with_stack_teardown(void* stackBase, size_t stackSize)
ENTRY(_exit_with_stack_teardown) ENTRY(_exit_with_stack_teardown)
// We can trash registers because this function never returns. // We can trash registers because this function never returns.
// We can also take advantage of the fact that the linux syscall trap mov 4(%esp), %ebx // stackBase
// handler saves all the registers, so we don't need a stack to keep mov 8(%esp), %ecx // stackSize
// the status argument for exit while doing the munmap. mov $__NR_munmap, %eax
mov 4(%esp), %ebx // stackBase int $0x80
mov 8(%esp), %ecx // stackSize // If munmap failed, we ignore the failure and exit anyway.
mov 12(%esp), %edx // Also copy 'status' off the stack we're about to unmap.
mov $__NR_munmap, %eax
int $0x80
// If munmap failed, we ignore the failure and exit anyway.
mov %edx, %ebx // status mov $0, %ebx // status
movl $__NR_exit, %eax movl $__NR_exit, %eax
int $0x80 int $0x80
// The exit syscall does not return. // The exit syscall does not return.
END(_exit_with_stack_teardown) END(_exit_with_stack_teardown)

View File

@ -26,20 +26,16 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include <asm/unistd.h> #include <private/bionic_asm.h>
#include <machine/asm.h>
// void _exit_with_stack_teardown(void* stackBase, size_t stackSize, int status) // void _exit_with_stack_teardown(void* stackBase, size_t stackSize)
ENTRY(_exit_with_stack_teardown) ENTRY(_exit_with_stack_teardown)
// We take advantage of the fact that the linux syscall trap mov $__NR_munmap, %eax
// handler saves all the registers, so we don't need to save syscall
// the status argument for exit(2) while doing the munmap(2). // If munmap failed, we ignore the failure and exit anyway.
mov $__NR_munmap, %eax
syscall
// If munmap failed, we ignore the failure and exit anyway.
mov %rdx, %rdi // status mov $0, %rdi
mov $__NR_exit, %eax mov $__NR_exit, %eax
syscall syscall
// The exit syscall does not return. // The exit syscall does not return.
END(_exit_with_stack_teardown) END(_exit_with_stack_teardown)

View File

@ -34,7 +34,7 @@
#include "pthread_internal.h" #include "pthread_internal.h"
extern "C" void _exit_with_stack_teardown(void*, size_t, int); extern "C" void _exit_with_stack_teardown(void*, size_t);
extern "C" void __exit(int); extern "C" void __exit(int);
extern "C" int __set_tid_address(int*); extern "C" int __set_tid_address(int*);
@ -125,7 +125,7 @@ void pthread_exit(void* return_value) {
sigfillset(&mask); sigfillset(&mask);
sigprocmask(SIG_SETMASK, &mask, NULL); sigprocmask(SIG_SETMASK, &mask, NULL);
_exit_with_stack_teardown(stack_base, stack_size, 0); _exit_with_stack_teardown(stack_base, stack_size);
} }
// NOTREACHED, but we told the compiler this function is noreturn, and it doesn't believe us. // NOTREACHED, but we told the compiler this function is noreturn, and it doesn't believe us.