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]

[Patch] MIPS: Fix unwinding through signal frames.


Certain MIPS processors have an errata workaround that changes the stack
layout for signal handlers.  The current MD_FALLBACK_FRAME_STATE_FOR for
mips/Linux assumes that the signal context is at a constant offset from
the signal trampoline.  When the workaround is in effect, the signal
context is not in the expected location, so unwinding fails.

I discovered this problem while running the testsuite on an SGI O2
system.  All the other mips systems I test with don't have the
workaround so were not effected by the bug.

The patch changes the calculation of the signal context so that it uses
the CFA of the unwind context to find the signal context.  This has the
advantage of working on system either with or without the workaround.

Tested on mipsel-linux (without workaround) and spot checked on
mips64-linux n32 ABI (with workaround) with full mips64-linux test in
progress.

OK to commit?

2007-11-14  David Daney  <ddaney@avtrex.com>

    * config/mips/linux-unwind.h (mips_fallback_frame_state): Use CFA
    to find sigcontext.



Index: gcc/config/mips/linux-unwind.h
===================================================================
--- gcc/config/mips/linux-unwind.h	(revision 130173)
+++ gcc/config/mips/linux-unwind.h	(working copy)
@@ -66,9 +66,10 @@ mips_fallback_frame_state (struct _Unwin
   if (pc[0] == (0x24020000 | __NR_sigreturn))
     {
       struct sigframe {
+	u_int32_t ass[4];
 	u_int32_t trampoline[2];
 	struct sigcontext sigctx;
-      } *rt_ = context->ra;
+      } *rt_ = context->cfa;
       sc = &rt_->sigctx;
     }
   else
@@ -76,10 +77,11 @@ mips_fallback_frame_state (struct _Unwin
   if (pc[0] == (0x24020000 | __NR_rt_sigreturn))
     {
       struct rt_sigframe {
+	u_int32_t ass[4];
 	u_int32_t trampoline[2];
 	struct siginfo info;
 	_sig_ucontext_t uc;
-      } *rt_ = context->ra;
+      } *rt_ = context->cfa;
       sc = &rt_->uc.uc_mcontext;
     }
   else

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