2013-03-22 05:48:18 +00:00
|
|
|
#include <asm/unistd.h>
|
2013-02-12 01:08:16 +00:00
|
|
|
#include <machine/asm.h>
|
2009-03-04 03:28:35 +00:00
|
|
|
|
2013-10-08 21:48:05 +00:00
|
|
|
// void _exit_with_stack_teardown(void* stackBase, int stackSize, int status)
|
2013-02-12 01:08:16 +00:00
|
|
|
ENTRY(_exit_with_stack_teardown)
|
2013-10-07 17:20:24 +00:00
|
|
|
// 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
|
2013-10-08 21:48:05 +00:00
|
|
|
// the status argument for exit while doing the munmap */
|
2013-10-07 17:20:24 +00:00
|
|
|
mov 4(%esp), %ebx // stackBase
|
|
|
|
mov 8(%esp), %ecx // stackSize
|
2009-03-04 03:28:35 +00:00
|
|
|
mov $__NR_munmap, %eax
|
|
|
|
int $0x80
|
2013-10-07 17:20:24 +00:00
|
|
|
|
|
|
|
// If munmap failed, we ignore the failure and exit anyway.
|
|
|
|
|
2013-10-08 21:48:05 +00:00
|
|
|
mov %edx, %ebx // status
|
2009-03-04 03:28:35 +00:00
|
|
|
movl $__NR_exit, %eax
|
|
|
|
int $0x80
|
2013-10-07 17:20:24 +00:00
|
|
|
|
|
|
|
// The exit syscall does not return.
|
2013-02-12 01:08:16 +00:00
|
|
|
END(_exit_with_stack_teardown)
|