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]

[committed] Fix gcc.dg/cleanup-1[01].c on hppa-unknown-linux-gnu


The enclosed change fixes the failure gcc.dg/cleanup-10.c and
gcc.dg/cleanup-11.c on hppa-unknown-linux-gnu.  These tests use
alternate signal stacks allocated by malloc.  On this target,
this provides an 8-byte alignment.  The kernel doesn't take care
in allocating the stack area for the return trampoline to ensure
that it is placed on the normal 64-byte boundary mandated for
stack frames.  As a result, signal frames can be misaligned.

The MD_FALLBACK_FRAME_STATE_FOR implementation assumes a 64-byte
alignment for the signal trampoline in order to identify various
flavors of signal return trampolines.  The enclosed change relaxes
the alignment needed to detect post 2.6.5-rc2-pa3 trampolines to
8-bytes.  This is fragile and the kernel/glibc implementation
needs to be reworked.  Alternate signal trampolines will fail
with 2.6.5-rc2-pa3 and earlier unless the user takes care to align
the stack region used for the alternate signal stack.

Tested on hppa-unknown-linux-gnu.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

2005-02-10  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>

	* pa/linux-unwind.h (pa32_fallback_frame_state): Handle misaligned
	signal trampolines.

Index: config/pa/linux-unwind.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/pa/linux-unwind.h,v
retrieving revision 1.1
diff -u -3 -p -r1.1 linux-unwind.h
--- config/pa/linux-unwind.h	8 Sep 2004 00:17:17 -0000	1.1
+++ config/pa/linux-unwind.h	23 Jan 2005 15:24:37 -0000
@@ -78,7 +78,22 @@ pa32_fallback_frame_state (struct _Unwin
       off = 10 * 4;
     }
   else
-    return _URC_END_OF_STACK;
+    {
+      /* We may have to unwind through an alternate signal stack.
+	 We assume that the alignment of the alternate signal stack
+	 is BIGGEST_ALIGNMENT (i.e., that it has been allocated using
+	 malloc).  As a result, we can't distinguish trampolines
+	 used prior to 2.6.5-rc2-pa4.  However after 2.6.5-rc2-pa4,
+	 the return address of a signal trampoline will be on an odd
+	 word boundary and we can then determine the frame offset.  */
+      sp = (unsigned long)context->ra;
+      pc = (unsigned int *)sp;
+      if ((pc[0] == 0x34190000 || pc[0] == 0x34190002) && (sp & 4))
+	off = 5 * 4;
+      else
+	return _URC_END_OF_STACK;
+    }
+
   if (pc[1] != 0x3414015a
       || pc[2] != 0xe4008200
       || pc[3] != 0x08000240)


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