diff options
author | Elliott Hughes <enh@google.com> | 2013-10-07 10:20:24 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2013-10-07 10:25:11 -0700 |
commit | a97cc5b458048ddaa034489e4a4e55e9064aca2f (patch) | |
tree | 699344735ec16ddeb4984c7cdd830e2d949ab55a /libc/arch-x86 | |
parent | a6e9ae80e51bffa40e600beb38e7796d2ef45242 (diff) | |
download | bionic-a97cc5b458048ddaa034489e4a4e55e9064aca2f.zip bionic-a97cc5b458048ddaa034489e4a4e55e9064aca2f.tar.gz bionic-a97cc5b458048ddaa034489e4a4e55e9064aca2f.tar.bz2 |
Clean up the x86 and x86_64 _exit_with_stack_teardown implementations.
Change-Id: I4bcbbc53893612bd94643ef07722becb00f91792
Diffstat (limited to 'libc/arch-x86')
-rw-r--r-- | libc/arch-x86/bionic/_exit_with_stack_teardown.S | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/libc/arch-x86/bionic/_exit_with_stack_teardown.S b/libc/arch-x86/bionic/_exit_with_stack_teardown.S index aad3f0b..a036e0d 100644 --- a/libc/arch-x86/bionic/_exit_with_stack_teardown.S +++ b/libc/arch-x86/bionic/_exit_with_stack_teardown.S @@ -1,28 +1,22 @@ #include <asm/unistd.h> #include <machine/asm.h> -// void _exit_with_stack_teardown(void *stackBase, int stackSize, int *retCode) +// void _exit_with_stack_teardown(void* stackBase, int stackSize, int retCode) ENTRY(_exit_with_stack_teardown) - /* we can trash %ebx here since this call should never return. */ - /* We can also take advantage of the fact that the linux syscall trap - * handler saves all the registers, so we don't need a stack to keep - * the retCode argument for exit while doing the munmap */ - - /* TODO(dmtriyz): No one expects this code to return, so even if - * munmap fails, we have to exit. This should probably be fixed, but - * since ARM side does the same thing, leave it as is. - */ - mov 4(%esp), %ebx /* stackBase */ - mov 8(%esp), %ecx /* stackSize */ - mov 12(%esp), %edx /* retCode, not used for munmap */ + // We can trash %ebx here since this call should never return. + // We can also take advantage of the fact that the linux syscall trap + // handler saves all the registers, so we don't need a stack to keep + // the retCode argument for exit while doing the munmap */ + mov 4(%esp), %ebx // stackBase + mov 8(%esp), %ecx // stackSize mov $__NR_munmap, %eax int $0x80 - mov %edx, %ebx /* retrieve the retCode */ + + // If munmap failed, we ignore the failure and exit anyway. + + mov %edx, %ebx // retCode movl $__NR_exit, %eax int $0x80 - /* exit does not return */ - /* can't have a ret here since we no longer have a usable stack. Seems - * that presently, 'hlt' will cause the program to segfault.. but this - * should never happen :) */ - hlt + + // The exit syscall does not return. END(_exit_with_stack_teardown) |