summaryrefslogtreecommitdiffstats
path: root/libc/arch-sh/bionic/_exit_with_stack_teardown.S
diff options
context:
space:
mode:
Diffstat (limited to 'libc/arch-sh/bionic/_exit_with_stack_teardown.S')
-rw-r--r--libc/arch-sh/bionic/_exit_with_stack_teardown.S52
1 files changed, 52 insertions, 0 deletions
diff --git a/libc/arch-sh/bionic/_exit_with_stack_teardown.S b/libc/arch-sh/bionic/_exit_with_stack_teardown.S
new file mode 100644
index 0000000..6356eb6
--- /dev/null
+++ b/libc/arch-sh/bionic/_exit_with_stack_teardown.S
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#include <asm/unistd.h>
+
+.text
+.type _exit_with_stack_teardown, @function
+.globl _exit_with_stack_teardown
+.align 4
+
+# void _exit_with_stack_teardown(void * stackBase, int stackSize, int retCode)
+
+_exit_with_stack_teardown:
+ mov r6, r8 /* save retCode : breaks r8 value */
+ mov.l 0f, r3 /* system call number */
+ trapa #(2 + 0x10) /* invoke system call with num of args */
+
+ mov r8, r4 /* restore retCode */
+ mov.l 1f, r3 /* system call number */
+ trapa #(1 + 0x10) /* invoke system call with num of args */
+
+ /* exit() should never return, cause a crash if it does */
+ mov #0, r0
+ mov.l @r0, r0
+
+ .align 2
+0: .long __NR_munmap
+1: .long __NR_exit