This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[sh-elf-4_1] linux specific patch (2/2) (applied)


This is another patch for sh64-linux that I've checked in on
sh-elf-4_1 branch.  It provides an SHmedia version of
MD_FALLBACK_FRAME_STATE_FOR.  Tested on sh64-unknown-linux-gnu
and sh4-unknown-linux-gnu.

Regards,
	kaz
--
2005-05-08  Kaz Kojima  <kkojima@gcc.gnu.org>

	* config/sh/linux-unwind.h (SH_DWARF_FRAME_XD0): Remove for SH5.
	(SH_DWARF_FRAME_PR, SH_DWARF_FRAME_GBR, SH_DWARF_FRAME_MACL)
	(SH_DWARF_FRAME_MACH, SH_DWARF_FRAME_PC, SH_DWARF_FRAME_FPUL):
	Likewise.
	(SH_DWARF_FRAME_FP0, SH_DWARF_FRAME_FPSCR): Define to the correct
	dwarf register number for SHmedia.
	(shmedia_fallback_frame_state): New.
	(MD_FALLBACK_FRAME_STATE_FOR): Define to it for SH5.

diff -uprN ORIG/gcc-4.1-sh/gcc/config/sh/linux-unwind.h LOCAL/gcc-4.1-sh/gcc/config/sh/linux-unwind.h
--- ORIG/gcc-4.1-sh/gcc/config/sh/linux-unwind.h	2005-02-11 10:12:57.000000000 +0900
+++ LOCAL/gcc-4.1-sh/gcc/config/sh/linux-unwind.h	2005-05-06 07:22:04.981506305 +0900
@@ -35,18 +35,11 @@ Boston, MA 02111-1307, USA.  */
 
 # if defined (__SH5__)
 #define SH_DWARF_FRAME_GP0	0
-#define SH_DWARF_FRAME_FP0	(__SH5__ == 32 ? 245 : 77)
-#define SH_DWARF_FRAME_XD0	289
+#define SH_DWARF_FRAME_FP0	77
 #define SH_DWARF_FRAME_BT0	68
-#define SH_DWARF_FRAME_PR	241
 #define SH_DWARF_FRAME_PR_MEDIA	18
-#define SH_DWARF_FRAME_GBR	238
-#define SH_DWARF_FRAME_MACH	239
-#define SH_DWARF_FRAME_MACL	240
-#define SH_DWARF_FRAME_PC	64
 #define SH_DWARF_FRAME_SR	65
-#define SH_DWARF_FRAME_FPUL	244
-#define SH_DWARF_FRAME_FPSCR	243
+#define SH_DWARF_FRAME_FPSCR	76
 #else
 #define SH_DWARF_FRAME_GP0	0
 #define SH_DWARF_FRAME_FP0	25
@@ -62,7 +55,88 @@ Boston, MA 02111-1307, USA.  */
 #endif /* defined (__SH5__) */
 
 #if defined (__SH5__)
-/* MD_FALLBACK_FRAME_STATE_FOR is not yet defined for SHMEDIA.  */
+
+#define MD_FALLBACK_FRAME_STATE_FOR shmedia_fallback_frame_state
+
+static _Unwind_Reason_Code
+shmedia_fallback_frame_state (struct _Unwind_Context *context,
+			      _Unwind_FrameState *fs)
+{
+  unsigned char *pc = context->ra;
+  struct sigcontext *sc;
+  long new_cfa;
+  int i, r;
+
+  /* movi 0x10,r9; shori 0x77,r9; trapa	r9; nop (sigreturn)  */
+  /* movi 0x10,r9; shori 0xad,r9; trapa	r9; nop (rt_sigreturn)  */
+  if ((*(unsigned long *) (pc-1)  == 0xcc004090)
+      && (*(unsigned long *) (pc+3)  == 0xc801dc90)
+      && (*(unsigned long *) (pc+7)  == 0x6c91fff0)
+      && (*(unsigned long *) (pc+11)  == 0x6ff0fff0))
+    sc = context->cfa;
+  else if ((*(unsigned long *) (pc-1)  == 0xcc004090)
+	   && (*(unsigned long *) (pc+3)  == 0xc802b490)
+	   && (*(unsigned long *) (pc+7)  == 0x6c91fff0)
+	   && (*(unsigned long *) (pc+11)  == 0x6ff0fff0))
+    {
+      struct rt_sigframe {
+	struct siginfo *pinfo;
+	void *puc;
+	struct siginfo info;
+	struct ucontext uc;
+      } *rt_ = context->cfa;
+      sc = (struct sigcontext *) &rt_->uc.uc_mcontext;
+    }
+  else
+    return _URC_END_OF_STACK;
+
+  new_cfa = sc->sc_regs[15];
+  fs->cfa_how = CFA_REG_OFFSET;
+  fs->cfa_reg = 15;
+  fs->cfa_offset = new_cfa - (long) context->cfa;
+
+  for (i = 0; i < 63; i++)
+    {
+      if (i == 15)
+	continue;
+
+      fs->regs.reg[i].how = REG_SAVED_OFFSET;
+      fs->regs.reg[i].loc.offset
+	= (long)&(sc->sc_regs[i]) - new_cfa;
+    }
+
+  fs->regs.reg[SH_DWARF_FRAME_SR].how = REG_SAVED_OFFSET;
+  fs->regs.reg[SH_DWARF_FRAME_SR].loc.offset
+    = (long)&(sc->sc_sr) - new_cfa;
+
+  r = SH_DWARF_FRAME_BT0;
+  for (i = 0; i < 8; i++)
+    {
+      fs->regs.reg[r+i].how = REG_SAVED_OFFSET;
+      fs->regs.reg[r+i].loc.offset
+	= (long)&(sc->sc_tregs[i]) - new_cfa;
+    }
+
+  r = SH_DWARF_FRAME_FP0;
+  for (i = 0; i < 32; i++)
+    {
+      fs->regs.reg[r+i].how = REG_SAVED_OFFSET;
+      fs->regs.reg[r+i].loc.offset
+	= (long)&(sc->sc_fpregs[i]) - new_cfa;
+    }
+
+  fs->regs.reg[SH_DWARF_FRAME_FPSCR].how = REG_SAVED_OFFSET;
+  fs->regs.reg[SH_DWARF_FRAME_FPSCR].loc.offset
+    = (long)&(sc->sc_fpscr) - new_cfa;
+
+  /* We use the slot for the zero register to save return address.  */
+  fs->regs.reg[63].how = REG_SAVED_OFFSET;
+  fs->regs.reg[63].loc.offset
+    = (long)&(sc->sc_pc) - new_cfa;
+  fs->retaddr_column = 63;
+  return _URC_NO_REASON;
+}
+
 #else /* defined (__SH5__) */
 
 #define MD_FALLBACK_FRAME_STATE_FOR sh_fallback_frame_state


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]