[PATCH] PPC32: Correct signal handling

Franz Sirl Franz.Sirl-kernel@lauterbach.com
Thu Jun 19 20:51:00 GMT 2003


On Thursday 19 June 2003 21:55, Jakub Jelinek wrote:
> On Tue, Jun 17, 2003 at 02:04:49PM +0200, Franz Sirl wrote:
> > Hi,
> >
> > as promised, here is the powerpc part to correct libjava signal handling.
> >
> > Bootstrapped and regtested on powerpc-linux.
> >
> > OK to commit to mainline and 3.3 branch?
> >
> > Franz.
> >
> > gcc/
> > 	* config/rs6000/linux.h (MD_FALLBACK_FRAME_STATE_FOR): Partly revert
> > 	2003-01-23 patch. Corrected to handle kernels with changed ucontext.
>
> Please adjust config/rs6000/linux64.h (!defined __powerpc64__) as well.

Like attached? Could you please test it somewhere?

Note that the PPC64 case is wrong as well, the messing around with gpr[47] 
needs to be removed and replaced with a proper MAKE_THROW_FRAME macro in 
libjava/include/powerpc64-signal.h.

Franz.


	* config/rs6000/linux64.h (MD_FALLBACK_FRAME_STATE_FOR): Mirror
	2003-06-17 change to linux.h.
-------------- next part --------------
Index: config/rs6000/linux64.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/linux64.h,v
retrieving revision 1.45
diff -u -p -r1.45 linux64.h
--- config/rs6000/linux64.h	17 Jun 2003 08:06:57 -0000	1.45
+++ config/rs6000/linux64.h	19 Jun 2003 20:42:47 -0000
@@ -520,11 +520,25 @@ while (0)
 
 #ifdef IN_LIBGCC2
 #include <signal.h>
-#include <sys/ucontext.h>
 
 #ifdef __powerpc64__
+#include <sys/ucontext.h>
+
 enum { SIGNAL_FRAMESIZE = 128 };
 #else
+/* During the 2.5 kernel series the kernel ucontext was changed, but
+   the new layout is compatible with the old one, so we just define
+   and use the old one here for simplicity and compatibility.  */
+
+struct kernel_old_ucontext 
+{  
+  unsigned long     uc_flags;
+  struct ucontext  *uc_link;
+  stack_t           uc_stack;
+  struct sigcontext_struct uc_mcontext;
+  sigset_t          uc_sigmask;
+};
+
 enum { SIGNAL_FRAMESIZE = 64 };
 #endif
 #endif
@@ -626,7 +640,7 @@ enum { SIGNAL_FRAMESIZE = 64 };
 	  struct siginfo *pinfo;					\
 	  void *puc;							\
 	  struct siginfo info;						\
-	  struct ucontext uc;						\
+	  struct kernel_old_ucontext uc;				\
 	} *rt_ = (CONTEXT)->cfa;					\
 	sc_ = &rt_->uc.uc_mcontext;					\
       }									\
@@ -650,15 +664,9 @@ enum { SIGNAL_FRAMESIZE = 64 };
     (FS)->regs.reg[LINK_REGISTER_REGNUM].loc.offset 			\
       = (long)&(sc_->regs->link) - new_cfa_;				\
 									\
-    /* The unwinder expects the IP to point to the following insn,	\
-       whereas the kernel returns the address of the actual		\
-       faulting insn. We store NIP+4 in an unused register slot to	\
-       get the same result for multiple evaluation of the same signal	\
-       frame.  */							\
-    sc_->regs->gpr[47] = sc_->regs->nip + 4;  				\
     (FS)->regs.reg[CR0_REGNO].how = REG_SAVED_OFFSET;			\
     (FS)->regs.reg[CR0_REGNO].loc.offset 				\
-      = (long)&(sc_->regs->gpr[47]) - new_cfa_;				\
+      = (long)&(sc_->regs->nip) - new_cfa_;				\
     (FS)->retaddr_column = CR0_REGNO;					\
     goto SUCCESS;							\
   } while (0)


More information about the Java-patches mailing list