Blame SOURCES/gcc32-pr26208.patch

4ac4fd
2006-02-27  Jakub Jelinek  <jakub@redhat.com>
4ac4fd
4ac4fd
	PR other/26208
4ac4fd
	* unwind-dw2.c (struct _Unwind_Context): Add signal_frame field.
4ac4fd
	(_Unwind_FrameState): Add signal_frame field.
4ac4fd
	(extract_cie_info): Handle S flag in augmentation string.
4ac4fd
	(execute_cfa_program): If context->signal_frame, execute also
4ac4fd
	fs->pc == context->ra instructions.
4ac4fd
	(uw_frame_state_for): If context->signal_frame, don't subtract one
4ac4fd
	from context->ra to find FDE.
4ac4fd
	(uw_update_context_1): Set context->signal_frame to
4ac4fd
	fs->signal_frame.
4ac4fd
	(_Unwind_GetIPInfo): New function.
4ac4fd
	* unwind-c.c (PERSONALITY_FUNCTION): Use _Unwind_GetIPInfo instead
4ac4fd
	of _Unwind_GetIP.
4ac4fd
	* unwind-sjlj.c (_Unwind_GetIPInfo): New function.
4ac4fd
	* unwind.h (_Unwind_GetIPInfo): New prototype.
4ac4fd
	* libgcc-std.ver (_Unwind_GetIPInfo): Export @@GCC_4.2.0.
4ac4fd
	* config/ia64/unwind-ia64.c (_Unwind_GetIPInfo): New function.
4ac4fd
	* config/i386/linux.h (MD_FALLBACK_FRAME_STATE_FOR): Set
4ac4fd
	(FS)->signal_frame.
4ac4fd
	* config/i386/linux64.h (MD_FALLBACK_FRAME_STATE_FOR): Likewise.
4ac4fd
	* config/rs6000/linux.h (MD_FALLBACK_FRAME_STATE_FOR): Likewise.
4ac4fd
	* config/rs6000/linux64.h (MD_FALLBACK_FRAME_STATE_FOR): Likewise.
4ac4fd
	* config/s390/linux.h (MD_FALLBACK_FRAME_STATE_FOR): Likewise.
4ac4fd
4ac4fd
	* libsupc++/eh_personality.cc (PERSONALITY_FUNCTION): Use
4ac4fd
	_Unwind_GetIPInfo instead of _Unwind_GetIP.
4ac4fd
4ac4fd
	* exception.cc (PERSONALITY_FUNCTION): Use _Unwind_GetIPInfo instead
4ac4fd
	of _Unwind_GetIP.
4ac4fd
	* include/i386-signal.h (MAKE_THROW_FRAME): Change into empty macro.
4ac4fd
	(HANDLE_DIVIDE_OVERFLOW): Don't adjust _res->eip if falling through
4ac4fd
	to throw.
4ac4fd
	* include/x86_64-signal.h (MAKE_THROW_FRAME): Change into empty
4ac4fd
	macro.
4ac4fd
	* include/powerpc-signal.h (MAKE_THROW_FRAME): Change into empty
4ac4fd
	macro.
4ac4fd
4ac4fd
--- libjava/exception.cc.jj	2002-04-09 16:20:32.000000000 +0200
4ac4fd
+++ libjava/exception.cc	2006-04-25 15:33:37.000000000 +0200
4ac4fd
@@ -196,6 +196,7 @@ PERSONALITY_FUNCTION (int version,
4ac4fd
   int handler_switch_value;
4ac4fd
   bool saw_cleanup;
4ac4fd
   bool saw_handler;
4ac4fd
+  int ip_before_insn = 0;
4ac4fd
 
4ac4fd
 
4ac4fd
   // Interface version check.
4ac4fd
@@ -211,10 +212,10 @@ PERSONALITY_FUNCTION (int version,
4ac4fd
       goto install_context;
4ac4fd
     }
4ac4fd
 
4ac4fd
-  // FIXME: In Phase 1, record _Unwind_GetIP in xh->obj as a part of
4ac4fd
+  // FIXME: In Phase 1, record _Unwind_GetIPInfo in xh->obj as a part of
4ac4fd
   // the stack trace for this exception.  This will only collect Java
4ac4fd
   // frames, but perhaps that is acceptable.
4ac4fd
-  // FIXME2: _Unwind_GetIP is nonsensical for SJLJ, being a call-site
4ac4fd
+  // FIXME2: _Unwind_GetIPInfo is nonsensical for SJLJ, being a call-site
4ac4fd
   // index instead of a PC value.  We could perhaps arrange for
4ac4fd
   // _Unwind_GetRegionStart to return context->fc->jbuf[1], which
4ac4fd
   // is the address of the handler label for __builtin_longjmp, but
4ac4fd
@@ -229,7 +230,9 @@ PERSONALITY_FUNCTION (int version,
4ac4fd
 
4ac4fd
   // Parse the LSDA header.
4ac4fd
   p = parse_lsda_header (context, language_specific_data, &info;;
4ac4fd
-  ip = _Unwind_GetIP (context) - 1;
4ac4fd
+  ip = _Unwind_GetIPInfo (context, &ip_before_insn);
4ac4fd
+  if (! ip_before_insn)
4ac4fd
+    --ip;
4ac4fd
   landing_pad = 0;
4ac4fd
   action_record = 0;
4ac4fd
   handler_switch_value = 0;
4ac4fd
--- libjava/include/i386-signal.h.jj	2002-03-18 23:27:01.000000000 +0100
4ac4fd
+++ libjava/include/i386-signal.h	2006-04-25 15:33:37.000000000 +0200
4ac4fd
@@ -22,19 +22,7 @@ details.  */
4ac4fd
 #define SIGNAL_HANDLER(_name)	\
4ac4fd
 static void _name (int _dummy)
4ac4fd
 
4ac4fd
-#define MAKE_THROW_FRAME(_exception)					\
4ac4fd
-do									\
4ac4fd
-{									\
4ac4fd
-  void **_p = (void **)&_dummy;						\
4ac4fd
-  struct sigcontext_struct *_regs = (struct sigcontext_struct *)++_p;	\
4ac4fd
-									\
4ac4fd
-  /* Advance the program counter so that it is after the start of the	\
4ac4fd
-     instruction:  the x86 exception handler expects			\
4ac4fd
-     the PC to point to the instruction after a call. */		\
4ac4fd
-  _regs->eip += 2;							\
4ac4fd
-									\
4ac4fd
-}									\
4ac4fd
-while (0)
4ac4fd
+#define MAKE_THROW_FRAME(_exception)
4ac4fd
 
4ac4fd
 #define HANDLE_DIVIDE_OVERFLOW						\
4ac4fd
 do									\
4ac4fd
@@ -84,14 +72,6 @@ do									\
4ac4fd
 	  _regs->eip = (unsigned long)_eip;				\
4ac4fd
 	  return;							\
4ac4fd
 	}								\
4ac4fd
-      else								\
4ac4fd
-	{								\
4ac4fd
-	  /* Advance the program counter so that it is after the start	\
4ac4fd
-	     of the instruction: this is because the x86 exception	\
4ac4fd
-	     handler expects the PC to point to the instruction after a	\
4ac4fd
-	     call. */							\
4ac4fd
-	  _regs->eip += 2;						\
4ac4fd
-	}								\
4ac4fd
     }									\
4ac4fd
 }									\
4ac4fd
 while (0)
4ac4fd
--- libjava/include/x86_64-signal.h.jj	2003-01-24 23:41:38.000000000 +0100
4ac4fd
+++ libjava/include/x86_64-signal.h	2006-04-25 15:34:23.000000000 +0200
4ac4fd
@@ -34,17 +34,7 @@ extern "C" 
4ac4fd
   };
4ac4fd
 }
4ac4fd
 
4ac4fd
-#define MAKE_THROW_FRAME(_exception)					\
4ac4fd
-do									\
4ac4fd
-{									\
4ac4fd
-  /* Advance the program counter so that it is after the start of the	\
4ac4fd
-     instruction:  the x86_64 exception handler expects			\
4ac4fd
-     the PC to point to the instruction after a call. */		\
4ac4fd
-  struct ucontext *_uc = (struct ucontext *)_p;				\
4ac4fd
-  struct sigcontext *_sc = (struct sigcontext *) &_uc->uc_mcontext;	\
4ac4fd
-  _sc->rip += 2;							\
4ac4fd
-}									\
4ac4fd
-while (0)
4ac4fd
+#define MAKE_THROW_FRAME(_exception)
4ac4fd
 
4ac4fd
 #define RESTORE(name, syscall) RESTORE2 (name, syscall)
4ac4fd
 #define RESTORE2(name, syscall)			\
4ac4fd
--- libjava/include/powerpc-signal.h.jj	2004-02-28 12:27:44.000000000 +0100
4ac4fd
+++ libjava/include/powerpc-signal.h	2006-04-25 15:33:37.000000000 +0200
4ac4fd
@@ -22,18 +22,12 @@ details.  */
4ac4fd
 #define SIGNAL_HANDLER(_name)						\
4ac4fd
   static void _name (int /* _signal */, struct sigcontext *_sc)
4ac4fd
 
4ac4fd
-/* PPC either leaves PC pointing at a faulting instruction or the
4ac4fd
-   following instruction, depending on the signal.  SEGV always does
4ac4fd
-   the former, so we adjust the saved PC to point to the following
4ac4fd
-   instruction. This is what the handler in libgcc expects.  */
4ac4fd
+/* MD_FALBACK_FRAME_STATE_FOR takes care of special casing PC
4ac4fd
+   before the faulting instruction, so we don't need to do anything
4ac4fd
+   here.  */
4ac4fd
+
4ac4fd
+#define MAKE_THROW_FRAME(_exception)
4ac4fd
 
4ac4fd
-#define MAKE_THROW_FRAME(_exception)					\
4ac4fd
-do									\
4ac4fd
-  {									\
4ac4fd
-    _sc->regs->nip += 4;						\
4ac4fd
-  }									\
4ac4fd
-while (0)
4ac4fd
-  
4ac4fd
 /* For an explanation why we cannot simply use sigaction to
4ac4fd
    install the handlers, see i386-signal.h.  */
4ac4fd
 
4ac4fd
--- libstdc++-v3/libsupc++/eh_personality.cc.jj	2003-06-11 15:08:13.000000000 +0200
4ac4fd
+++ libstdc++-v3/libsupc++/eh_personality.cc	2006-04-25 15:33:37.000000000 +0200
4ac4fd
@@ -201,6 +201,7 @@ PERSONALITY_FUNCTION (int version,
4ac4fd
   _Unwind_Ptr landing_pad, ip;
4ac4fd
   int handler_switch_value;
4ac4fd
   void *thrown_ptr = xh + 1;
4ac4fd
+  int ip_before_insn = 0;
4ac4fd
 
4ac4fd
   // Interface version check.
4ac4fd
   if (version != 1)
4ac4fd
@@ -227,7 +228,9 @@ PERSONALITY_FUNCTION (int version,
4ac4fd
   // Parse the LSDA header.
4ac4fd
   p = parse_lsda_header (context, language_specific_data, &info;;
4ac4fd
   info.ttype_base = base_of_encoded_value (info.ttype_encoding, context);
4ac4fd
-  ip = _Unwind_GetIP (context) - 1;
4ac4fd
+  ip = _Unwind_GetIPInfo (context, &ip_before_insn);
4ac4fd
+  if (! ip_before_insn)
4ac4fd
+    --ip;
4ac4fd
   landing_pad = 0;
4ac4fd
   action_record = 0;
4ac4fd
   handler_switch_value = 0;
4ac4fd
--- gcc/libgcc-std.ver.jj	2004-02-28 12:16:53.000000000 +0100
4ac4fd
+++ gcc/libgcc-std.ver	2006-04-25 15:33:37.000000000 +0200
4ac4fd
@@ -210,3 +210,8 @@ GCC_3.4 {
4ac4fd
   __paritydi2
4ac4fd
   __parityti2
4ac4fd
 }
4ac4fd
+
4ac4fd
+%inherit GCC_4.2.0 GCC_3.4
4ac4fd
+GCC_4.2.0 {
4ac4fd
+  _Unwind_GetIPInfo
4ac4fd
+}
4ac4fd
--- gcc/unwind-c.c.jj	2003-06-11 15:08:12.000000000 +0200
4ac4fd
+++ gcc/unwind-c.c	2006-04-25 15:33:37.000000000 +0200
4ac4fd
@@ -93,6 +93,7 @@ PERSONALITY_FUNCTION (int version,
4ac4fd
   lsda_header_info info;
4ac4fd
   const unsigned char *language_specific_data, *p, *action_record;
4ac4fd
   _Unwind_Ptr landing_pad, ip;
4ac4fd
+  int ip_before_insn = 0;
4ac4fd
 
4ac4fd
   if (version != 1)
4ac4fd
     return _URC_FATAL_PHASE1_ERROR;
4ac4fd
@@ -110,7 +111,9 @@ PERSONALITY_FUNCTION (int version,
4ac4fd
 
4ac4fd
   /* Parse the LSDA header.  */
4ac4fd
   p = parse_lsda_header (context, language_specific_data, &info;;
4ac4fd
-  ip = _Unwind_GetIP (context) - 1;
4ac4fd
+  ip = _Unwind_GetIPInfo (context, &ip_before_insn);
4ac4fd
+  if (! ip_before_insn)
4ac4fd
+    --ip;
4ac4fd
   landing_pad = 0;
4ac4fd
 
4ac4fd
 #ifdef __USING_SJLJ_EXCEPTIONS__
4ac4fd
--- gcc/config/rs6000/linux.h.jj	2004-02-28 12:27:45.000000000 +0100
4ac4fd
+++ gcc/config/rs6000/linux.h	2006-04-25 15:36:47.000000000 +0200
4ac4fd
@@ -171,6 +171,7 @@ enum { SIGNAL_FRAMESIZE = 64 };
4ac4fd
     (FS)->regs.reg[CR0_REGNO].loc.offset 				\
4ac4fd
       = (long)&(sc_->regs->nip) - new_cfa_;				\
4ac4fd
     (FS)->retaddr_column = CR0_REGNO;					\
4ac4fd
+    (FS)->signal_frame = 1;						\
4ac4fd
     goto SUCCESS;							\
4ac4fd
   } while (0)
4ac4fd
 
4ac4fd
--- gcc/config/rs6000/linux64.h.jj	2004-10-29 09:35:44.000000000 +0200
4ac4fd
+++ gcc/config/rs6000/linux64.h	2006-04-25 15:37:14.000000000 +0200
4ac4fd
@@ -656,6 +656,7 @@ enum { SIGNAL_FRAMESIZE = 64 };
4ac4fd
     (FS)->regs.reg[ARG_POINTER_REGNUM].loc.offset 			\
4ac4fd
       = (long)&(sc_->regs->nip) - new_cfa_;				\
4ac4fd
     (FS)->retaddr_column = ARG_POINTER_REGNUM;				\
4ac4fd
+    (FS)->signal_frame = 1;						\
4ac4fd
     goto SUCCESS;							\
4ac4fd
   } while (0)
4ac4fd
 
4ac4fd
@@ -720,6 +721,7 @@ enum { SIGNAL_FRAMESIZE = 64 };
4ac4fd
     (FS)->regs.reg[CR0_REGNO].loc.offset 				\
4ac4fd
       = (long)&(sc_->regs->nip) - new_cfa_;				\
4ac4fd
     (FS)->retaddr_column = CR0_REGNO;					\
4ac4fd
+    (FS)->signal_frame = 1;						\
4ac4fd
     goto SUCCESS;							\
4ac4fd
   } while (0)
4ac4fd
 
4ac4fd
--- gcc/config/s390/linux.h.jj	2003-10-31 11:36:50.000000000 +0100
4ac4fd
+++ gcc/config/s390/linux.h	2006-04-25 15:33:41.000000000 +0200
4ac4fd
@@ -339,6 +339,7 @@ do {                                    
4ac4fd
       } __attribute__ ((__aligned__ (8))) sigregs_;			\
4ac4fd
 									\
4ac4fd
     sigregs_ *regs_;							\
4ac4fd
+    int *signo_ = NULL;							\
4ac4fd
 									\
4ac4fd
     /* svc $__NR_sigreturn or svc $__NR_rt_sigreturn  */		\
4ac4fd
     if (pc_[0] != 0x0a || (pc_[1] != 119 && pc_[1] != 173))		\
4ac4fd
@@ -359,6 +360,7 @@ do {                                    
4ac4fd
 	  } *uc_ = (CONTEXT)->cfa + 8 + 128;				\
4ac4fd
 									\
4ac4fd
 	regs_ = &uc_->uc_mcontext;					\
4ac4fd
+	signo_ = (CONTEXT)->cfa + sizeof(long);				\
4ac4fd
       }									\
4ac4fd
 									\
4ac4fd
     /* Old-style RT frame and all non-RT frames:			\
4ac4fd
@@ -367,6 +369,11 @@ do {                                    
4ac4fd
     else								\
4ac4fd
       {									\
4ac4fd
 	regs_ = *(sigregs_ **)((CONTEXT)->cfa + 8);			\
4ac4fd
+	/* Recent kernels store the signal number immediately after	\
4ac4fd
+	   the sigregs; old kernels have the return trampoline at	\
4ac4fd
+	   this location.  */						\
4ac4fd
+	if ((void *)(regs_ + 1) != (CONTEXT)->ra)			\
4ac4fd
+	  signo_ = (int *)(regs_ + 1);					\
4ac4fd
       }									\
4ac4fd
       									\
4ac4fd
     new_cfa_ = regs_->gprs[15] + 16*sizeof(long) + 32;			\
4ac4fd
@@ -393,6 +400,12 @@ do {                                    
4ac4fd
     (FS)->regs.reg[32].loc.offset = (long)&regs_->psw_addr - new_cfa_;	\
4ac4fd
     (FS)->retaddr_column = 32;						\
4ac4fd
 									\
4ac4fd
+    /* SIGILL, SIGFPE and SIGTRAP are delivered with psw_addr		\
4ac4fd
+       after the faulting instruction rather than before it.		\
4ac4fd
+       Don't set FS->signal_frame in that case.  */			\
4ac4fd
+    if (!signo_ || (*signo_ != 4 && *signo_ != 5 && *signo_ != 8))	\
4ac4fd
+      (FS)->signal_frame = 1;						\
4ac4fd
+									\
4ac4fd
     goto SUCCESS;							\
4ac4fd
   } while (0)
4ac4fd
 
4ac4fd
--- gcc/config/i386/linux.h.jj	2003-06-11 14:56:49.000000000 +0200
4ac4fd
+++ gcc/config/i386/linux.h	2006-04-25 15:33:41.000000000 +0200
4ac4fd
@@ -280,6 +280,7 @@ Boston, MA 02111-1307, USA.  */
4ac4fd
     (FS)->regs.reg[8].how = REG_SAVED_OFFSET;				\
4ac4fd
     (FS)->regs.reg[8].loc.offset = (long)&sc_->eip - new_cfa_;		\
4ac4fd
     (FS)->retaddr_column = 8;						\
4ac4fd
+    (FS)->signal_frame = 1;						\
4ac4fd
     goto SUCCESS;							\
4ac4fd
   } while (0)
4ac4fd
 #endif /* ifndef inhibit_libc  */
4ac4fd
--- gcc/config/i386/linux64.h.jj	2003-06-11 14:56:49.000000000 +0200
4ac4fd
+++ gcc/config/i386/linux64.h	2006-04-25 15:33:41.000000000 +0200
4ac4fd
@@ -135,6 +135,7 @@ Boston, MA 02111-1307, USA.  */
4ac4fd
     (FS)->regs.reg[16].how = REG_SAVED_OFFSET;				\
4ac4fd
     (FS)->regs.reg[16].loc.offset = (long)&sc_->rip - new_cfa_;		\
4ac4fd
     (FS)->retaddr_column = 16;						\
4ac4fd
+    (FS)->signal_frame = 1;						\
4ac4fd
     goto SUCCESS;							\
4ac4fd
   } while (0)
4ac4fd
 #else /* ifdef __x86_64__  */
4ac4fd
@@ -189,6 +190,7 @@ Boston, MA 02111-1307, USA.  */
4ac4fd
     (FS)->regs.reg[8].how = REG_SAVED_OFFSET;				\
4ac4fd
     (FS)->regs.reg[8].loc.offset = (long)&sc_->eip - new_cfa_;		\
4ac4fd
     (FS)->retaddr_column = 8;						\
4ac4fd
+    (FS)->signal_frame = 1;						\
4ac4fd
     goto SUCCESS;							\
4ac4fd
   } while (0)
4ac4fd
 #endif /* ifdef __x86_64__  */
4ac4fd
--- gcc/config/ia64/unwind-ia64.c.jj	2004-07-01 12:49:33.000000000 +0200
4ac4fd
+++ gcc/config/ia64/unwind-ia64.c	2006-04-25 15:33:41.000000000 +0200
4ac4fd
@@ -1700,6 +1700,13 @@ _Unwind_GetIP (struct _Unwind_Context *c
4ac4fd
   return context->rp;
4ac4fd
 }
4ac4fd
 
4ac4fd
+inline _Unwind_Ptr
4ac4fd
+_Unwind_GetIPInfo (struct _Unwind_Context *context, int *ip_before_insn)
4ac4fd
+{
4ac4fd
+  *ip_before_insn = 0;
4ac4fd
+  return context->rp;
4ac4fd
+}
4ac4fd
+
4ac4fd
 /* Overwrite the return address for CONTEXT with VAL.  */
4ac4fd
 
4ac4fd
 inline void
4ac4fd
--- gcc/unwind-sjlj.c.jj	2003-06-11 15:12:42.000000000 +0200
4ac4fd
+++ gcc/unwind-sjlj.c	2006-04-25 15:33:44.000000000 +0200
4ac4fd
@@ -197,6 +197,13 @@ _Unwind_GetIP (struct _Unwind_Context *c
4ac4fd
   return context->fc->call_site + 1;
4ac4fd
 }
4ac4fd
 
4ac4fd
+_Unwind_Ptr
4ac4fd
+_Unwind_GetIPInfo (struct _Unwind_Context *context, int *ip_before_insn)
4ac4fd
+{
4ac4fd
+  *ip_before_insn = 0;
4ac4fd
+  return context->fc->call_site + 1;
4ac4fd
+}
4ac4fd
+
4ac4fd
 /* Set the return landing pad index in CONTEXT.  */
4ac4fd
 
4ac4fd
 void
4ac4fd
--- gcc/unwind.h.jj	2003-09-04 11:16:10.000000000 +0200
4ac4fd
+++ gcc/unwind.h	2006-04-25 15:33:44.000000000 +0200
4ac4fd
@@ -136,6 +136,7 @@ extern _Unwind_Word _Unwind_GetGR (struc
4ac4fd
 extern void _Unwind_SetGR (struct _Unwind_Context *, int, _Unwind_Word);
4ac4fd
 
4ac4fd
 extern _Unwind_Ptr _Unwind_GetIP (struct _Unwind_Context *);
4ac4fd
+extern _Unwind_Ptr _Unwind_GetIPInfo (struct _Unwind_Context *, int *);
4ac4fd
 extern void _Unwind_SetIP (struct _Unwind_Context *, _Unwind_Ptr);
4ac4fd
 
4ac4fd
 /* @@@ Retrieve the CFA of the given context.  */
4ac4fd
--- gcc/unwind-dw2.c.jj	2003-07-16 13:38:32.000000000 +0200
4ac4fd
+++ gcc/unwind-dw2.c	2006-04-25 15:33:44.000000000 +0200
4ac4fd
@@ -62,6 +62,7 @@ struct _Unwind_Context
4ac4fd
   void *lsda;
4ac4fd
   struct dwarf_eh_bases bases;
4ac4fd
   _Unwind_Word args_size;
4ac4fd
+  char signal_frame;
4ac4fd
 };
4ac4fd
 
4ac4fd
 /* Byte size of every register managed by these routines.  */
4ac4fd
@@ -117,6 +118,7 @@ typedef struct
4ac4fd
   unsigned char fde_encoding;
4ac4fd
   unsigned char lsda_encoding;
4ac4fd
   unsigned char saw_z;
4ac4fd
+  unsigned char signal_frame;
4ac4fd
   void *eh_ptr;
4ac4fd
 } _Unwind_FrameState;
4ac4fd
 
4ac4fd
@@ -193,6 +195,16 @@ _Unwind_GetIP (struct _Unwind_Context *c
4ac4fd
   return (_Unwind_Ptr) context->ra;
4ac4fd
 }
4ac4fd
 
4ac4fd
+/* Retrieve the return address and flag whether that IP is before
4ac4fd
+   or after first not yet fully executed instruction.  */
4ac4fd
+
4ac4fd
+inline _Unwind_Ptr
4ac4fd
+_Unwind_GetIPInfo (struct _Unwind_Context *context, int *ip_before_insn)
4ac4fd
+{
4ac4fd
+  *ip_before_insn = context->signal_frame != 0;
4ac4fd
+  return (_Unwind_Ptr) context->ra;
4ac4fd
+}
4ac4fd
+
4ac4fd
 /* Overwrite the return address for CONTEXT with VAL.  */
4ac4fd
 
4ac4fd
 inline void
4ac4fd
@@ -304,6 +316,13 @@ extract_cie_info (struct dwarf_cie *cie,
4ac4fd
 	  aug += 1;
4ac4fd
 	}
4ac4fd
 
4ac4fd
+      /* "S" indicates a signal frame.  */
4ac4fd
+      else if (aug[0] == 'S')
4ac4fd
+	{
4ac4fd
+	  fs->signal_frame = 1;
4ac4fd
+	  aug += 1;
4ac4fd
+	}
4ac4fd
+
4ac4fd
       /* Otherwise we have an unknown augmentation string.
4ac4fd
 	 Bail unless we saw a 'z' prefix.  */
4ac4fd
       else
4ac4fd
@@ -736,8 +755,10 @@ execute_cfa_program (const unsigned char
4ac4fd
      a different stack configuration that we are not interested in.  We
4ac4fd
      assume that the call itself is unwind info-neutral; if not, or if
4ac4fd
      there are delay instructions that adjust the stack, these must be
4ac4fd
-     reflected at the point immediately before the call insn.  */
4ac4fd
-  while (insn_ptr < insn_end && fs->pc < context->ra)
4ac4fd
+     reflected at the point immediately before the call insn.
4ac4fd
+     In signal frames, return address is after last completed instruction,
4ac4fd
+     so we add 1 to return address to make the comparison <=.  */
4ac4fd
+  while (insn_ptr < insn_end && fs->pc < context->ra + context->signal_frame)
4ac4fd
     {
4ac4fd
       unsigned char insn = *insn_ptr++;
4ac4fd
       _Unwind_Word reg, utmp;
4ac4fd
@@ -927,7 +948,8 @@ uw_frame_state_for (struct _Unwind_Conte
4ac4fd
   context->args_size = 0;
4ac4fd
   context->lsda = 0;
4ac4fd
 
4ac4fd
-  fde = _Unwind_Find_FDE (context->ra - 1, &context->bases);
4ac4fd
+  fde = _Unwind_Find_FDE (context->ra + context->signal_frame - 1,
4ac4fd
+			  &context->bases);
4ac4fd
   if (fde == NULL)
4ac4fd
     {
4ac4fd
       /* Couldn't find frame unwind info for this function.  Try a
4ac4fd
@@ -1265,6 +1287,8 @@ uw_update_context_1 (struct _Unwind_Cont
4ac4fd
 	break;
4ac4fd
       }
4ac4fd
 
4ac4fd
+  context->signal_frame = fs->signal_frame;
4ac4fd
+
4ac4fd
   MD_FROB_UPDATE_CONTEXT (context, fs);
4ac4fd
 }
4ac4fd