1 #include <sys/linux-syscalls.h>
3 .text
4 .type _exit_with_stack_teardown, @function
5 .globl _exit_with_stack_teardown
6 .align 4
8 /*
9 * void _exit_with_stack_teardown(void *stackBase, int stackSize, int *retCode)
10 */
12 _exit_with_stack_teardown:
13 /* we can trash %ebx here since this call should never return. */
14 /* We can also take advantage of the fact that the linux syscall trap
15 * handler saves all the registers, so we don't need a stack to keep
16 * the retCode argument for exit while doing the munmap */
18 /* TODO(dmtriyz): No one expects this code to return, so even if
19 * munmap fails, we have to exit. This should probably be fixed, but
20 * since ARM side does the same thing, leave it as is.
21 */
22 mov 4(%esp), %ebx /* stackBase */
23 mov 8(%esp), %ecx /* stackSize */
24 mov 12(%esp), %edx /* retCode, not used for munmap */
25 mov $__NR_munmap, %eax
26 int $0x80
27 mov %edx, %ebx /* retrieve the retCode */
28 movl $__NR_exit, %eax
29 int $0x80
30 /* exit does not return */
31 /* can't have a ret here since we no longer have a usable stack. Seems
32 * that presently, 'hlt' will cause the program to segfault.. but this
33 * should never happen :) */
34 hlt