summaryrefslogtreecommitdiffstats
path: root/libc/unistd
diff options
context:
space:
mode:
authorJean-Baptiste Queru <jbq@google.com>2009-11-15 12:05:31 -0800
committerJean-Baptiste Queru <jbq@google.com>2009-11-15 12:05:31 -0800
commit95604529ec25fe7923ba88312c590f38aa5e3d9e (patch)
treec6f1dd860fcdc273ab21b696778987261f6e4fa8 /libc/unistd
parent71c0aeb44f2301af85d6a370dbd7308602a1dfe0 (diff)
parent194d3fa048cf909ca592dd56fa538dc9cd3f5ddb (diff)
downloadbionic-95604529ec25fe7923ba88312c590f38aa5e3d9e.zip
bionic-95604529ec25fe7923ba88312c590f38aa5e3d9e.tar.gz
bionic-95604529ec25fe7923ba88312c590f38aa5e3d9e.tar.bz2
merge from eclair
Diffstat (limited to 'libc/unistd')
-rw-r--r--libc/unistd/abort.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/libc/unistd/abort.c b/libc/unistd/abort.c
index d4e40e1..3e3aab0 100644
--- a/libc/unistd/abort.c
+++ b/libc/unistd/abort.c
@@ -39,8 +39,13 @@
#define debug_log(format, ...) \
__libc_android_log_print(ANDROID_LOG_DEBUG, "libc-abort", (format), ##__VA_ARGS__ )
+#ifdef __arm__
+void
+__libc_android_abort(void)
+#else
void
abort(void)
+#endif
{
struct atexit *p = __atexit;
static int cleanup_called = 0;
@@ -73,10 +78,8 @@ abort(void)
}
/* temporary, for bug hunting */
- debug_log("abort() called in pid %d\n", getpid());
/* seg fault seems to produce better debuggerd results than SIGABRT */
*((char*)0xdeadbaad) = 39;
- debug_log("somehow we're not dead?\n");
/* -- */
(void)kill(getpid(), SIGABRT);
@@ -99,3 +102,29 @@ abort(void)
(void)kill(getpid(), SIGABRT);
_exit(1);
}
+
+#ifdef __arm__
+/*
+ * abort() does not return, which gcc interprets to mean that it doesn't
+ * need to preserve any of the callee-save registers. Unfortunately this
+ * includes the link register, so if LR is used there is no way to determine
+ * which function called abort().
+ *
+ * We work around this by inserting a trivial stub that doesn't alter
+ * any of the "interesting" registers and thus doesn't need to save them.
+ * We can't just call __libc_android_abort from C because gcc uses "bl"
+ * without first saving LR, so we use an asm statement. This also has
+ * the side-effect of replacing abort() with __libc_android_abort() in
+ * the stack trace.
+ *
+ * Ideally __libc_android_abort would be static, but I haven't figured out
+ * how to tell gcc to call a static function from an asm statement.
+ */
+void
+abort(void)
+{
+ asm ("b __libc_android_abort");
+ _exit(1); /* suppress gcc noreturn warnings */
+}
+#endif
+