svn commit: branches/uClibc_0_9_28/libc/sysdeps/linux/mips

andersen at uclibc.org andersen at uclibc.org
Fri Feb 2 02:15:09 UTC 2007


Author: andersen
Date: 2007-02-01 18:15:09 -0800 (Thu, 01 Feb 2007)
New Revision: 17718

Log:
backport fix from svn trunk.
Do not set SA_RESTORER when the application did not request it.


Modified:
   branches/uClibc_0_9_28/libc/sysdeps/linux/mips/sigaction.c


Changeset:
Modified: branches/uClibc_0_9_28/libc/sysdeps/linux/mips/sigaction.c
===================================================================
--- branches/uClibc_0_9_28/libc/sysdeps/linux/mips/sigaction.c	2007-02-02 01:57:24 UTC (rev 17717)
+++ branches/uClibc_0_9_28/libc/sysdeps/linux/mips/sigaction.c	2007-02-02 02:15:09 UTC (rev 17718)
@@ -27,9 +27,20 @@
 
 #define SA_RESTORER	0x04000000
 
+extern __typeof(sigaction) __libc_sigaction;
 
-#if defined __NR_rt_sigaction
+#ifdef __NR_rt_sigaction
 
+#if _MIPS_SIM != _ABIO32
+
+# ifdef __NR_rt_sigreturn
+static void restore_rt (void) asm ("__restore_rt");
+# endif
+# ifdef __NR_sigreturn
+static void restore (void) asm ("__restore");
+# endif
+#endif
+
 /* If ACT is not NULL, change the action for SIG to *ACT.
    If OACT is not NULL, put the old action for SIG in *OACT.  */
 int __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
@@ -48,10 +59,12 @@
 	kact.k_sa_handler = act->sa_handler;
 	memcpy (&kact.sa_mask, &act->sa_mask, sizeof (kact.sa_mask));
 	kact.sa_flags = act->sa_flags;
-
-	kact.sa_flags = act->sa_flags | SA_RESTORER;
 #ifdef HAVE_SA_RESTORER
+#  if _MIPS_SIM == _ABIO32
 	kact.sa_restorer = act->sa_restorer;
+#  else
+	kact.sa_restorer = &restore_rt;
+#  endif
 #endif
     }
 
@@ -73,8 +86,7 @@
 
 
 #else
-#warning "Yes there is a warning here.  Don't worry about it."
-static void restore (void) asm ("__restore");
+extern void restore (void) asm ("__restore") attribute_hidden;
 
 /* If ACT is not NULL, change the action for SIG to *ACT.
    If OACT is not NULL, put the old action for SIG in *OACT.  */
@@ -93,9 +105,12 @@
     if (act) {
 	kact.k_sa_handler = act->sa_handler;
 	kact.sa_mask = act->sa_mask.__val[0];
-	kact.sa_flags = act->sa_flags | SA_RESTORER;
 #ifdef HAVE_SA_RESTORER
+#  if _MIPS_SIM == _ABIO32
 	kact.sa_restorer = act->sa_restorer;
+#  else
+	kact.sa_restorer = &restore_rt;
+#  endif
 #endif
     }
 
@@ -121,3 +136,31 @@
 #endif
 weak_alias (__libc_sigaction, sigaction)
 
+
+/* NOTE: Please think twice before making any changes to the bits of
+   code below.  GDB needs some intimate knowledge about it to
+   recognize them as signal trampolines, and make backtraces through
+   signal handlers work right.  Important are both the names
+   (__restore_rt) and the exact instruction sequence.
+   If you ever feel the need to make any changes, please notify the
+   appropriate GDB maintainer.  */
+
+#define RESTORE(name, syscall) RESTORE2 (name, syscall)
+#define RESTORE2(name, syscall) \
+asm						\
+  (						\
+   ".align 4\n"					\
+   "__" #name ":\n"				\
+   "	li $2, " #syscall "\n"			\
+   "	syscall\n"				\
+   );
+
+/* The return code for realtime-signals.  */
+#if _MIPS_SIM != _ABIO32
+# ifdef __NR_rt_sigreturn
+RESTORE (restore_rt, __NR_rt_sigreturn)
+# endif
+# ifdef __NR_sigreturn
+RESTORE (restore, __NR_sigreturn)
+# endif
+#endif




More information about the uClibc-cvs mailing list