summaryrefslogtreecommitdiffstats
path: root/libc/arch-arm/bionic
diff options
context:
space:
mode:
authorMatt Fischer <matt.fischer@garmin.com>2010-01-11 10:02:06 +0800
committerGarmin Android technology group <android@garmin.com>2010-05-12 14:18:36 -0500
commite4fa46e75cd0d433b5c6c064720ed7e195cba7c8 (patch)
tree88ab07e29e66cff45b3588718fa778c8218c4b6e /libc/arch-arm/bionic
parentc3581dc78a51180d3550d0d04596657cb2db852c (diff)
downloadbionic-e4fa46e75cd0d433b5c6c064720ed7e195cba7c8.zip
bionic-e4fa46e75cd0d433b5c6c064720ed7e195cba7c8.tar.gz
bionic-e4fa46e75cd0d433b5c6c064720ed7e195cba7c8.tar.bz2
Set SA_RESTORER in sigaction()
GDB looks for specific opcode sequences when trying to recognize a stack frame as a signal trampoline. The sequences it looks for happen to be those created when SA_RESTORER is set, since glibc always sets a restorer. This patch does the same here, so that the trampolines can be correctly identified. Change-Id: I0ac574a68818cb24d939c3527f3aaeb04b853d04
Diffstat (limited to 'libc/arch-arm/bionic')
-rw-r--r--libc/arch-arm/bionic/__sig_restorer.S7
-rw-r--r--libc/arch-arm/bionic/sigaction.c29
2 files changed, 36 insertions, 0 deletions
diff --git a/libc/arch-arm/bionic/__sig_restorer.S b/libc/arch-arm/bionic/__sig_restorer.S
new file mode 100644
index 0000000..3f6f284
--- /dev/null
+++ b/libc/arch-arm/bionic/__sig_restorer.S
@@ -0,0 +1,7 @@
+.global __sig_restorer
+
+/* This is the opcode sequence GDB looks for in order to recognize
+ this stack frame as a signal trampoline (see sigaction.c) */
+__sig_restorer:
+ mov r7, #119 /* __NR_sigreturn */
+ swi #0
diff --git a/libc/arch-arm/bionic/sigaction.c b/libc/arch-arm/bionic/sigaction.c
new file mode 100644
index 0000000..96ca7c6
--- /dev/null
+++ b/libc/arch-arm/bionic/sigaction.c
@@ -0,0 +1,29 @@
+#include <signal.h>
+
+extern int __sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
+extern void __sig_restorer();
+
+int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact)
+{
+ struct sigaction real_act;
+
+ /* If the caller has not set a custom restorer, then set up a default one.
+ * The code will function properly without this, however GDB will not be
+ * able to recognize the stack frame as a signal trampoline, because it
+ * is hardcoded to look for the instruction sequence that glibc uses in
+ * its custom restorer. By creating our own restorer with the same
+ * sequence, we ensure that GDB correctly identifies this as a signal
+ * trampoline frame.
+ *
+ * See http://sourceware.org/ml/gdb/2010-01/msg00143.html for more
+ * information on this.*/
+ if(act && !(act->sa_flags & SA_RESTORER)) {
+ real_act = *act;
+ real_act.sa_flags |= SA_RESTORER;
+ real_act.sa_restorer = __sig_restorer;
+
+ act = &real_act;
+ }
+
+ return __sigaction(signum, act, oldact);
+}