This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB 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] StackGhost support for signal handlers on OpenBSD/sparc


Committed,

Mark


Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>
 
	* sparc-tdep.h (sparc_fetch_wcookie): New prototype.
	* sparcnbsd-tdep.c (sparc32nbsd_sigcontext_saved_regs): Handle
	StackGhost.

Index: sparc-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/sparc-tdep.h,v
retrieving revision 1.7
diff -u -p -r1.7 sparc-tdep.h
--- sparc-tdep.h 25 Jan 2004 11:46:43 -0000 1.7
+++ sparc-tdep.h 7 Feb 2004 20:43:53 -0000
@@ -147,6 +147,9 @@ struct sparc_frame_cache
 /* Fetch the instruction at PC.  */
 extern unsigned long sparc_fetch_instruction (CORE_ADDR pc);
 
+/* Fetch StackGhost Per-Process XOR cookie.  */
+extern ULONGEST sparc_fetch_wcookie (void);
+
 extern CORE_ADDR sparc_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc,
 					 struct sparc_frame_cache *cache);
 
Index: sparcnbsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparcnbsd-tdep.c,v
retrieving revision 1.14
diff -u -p -r1.14 sparcnbsd-tdep.c
--- sparcnbsd-tdep.c 25 Jan 2004 12:03:36 -0000 1.14
+++ sparcnbsd-tdep.c 7 Feb 2004 20:43:53 -0000
@@ -141,6 +141,20 @@ sparc32nbsd_sigcontext_saved_regs (struc
        regnum <= SPARC_I7_REGNUM; regnum++, addr += 4)
     saved_regs[regnum].addr = addr;
 
+  /* Handle StackGhost.  */
+  {
+    ULONGEST wcookie = sparc_fetch_wcookie ();
+
+    if (wcookie != 0)
+      {
+	ULONGEST i7;
+
+	addr = saved_regs[SPARC_I7_REGNUM].addr;
+	i7 = get_frame_memory_unsigned (next_frame, addr, 4);
+	trad_frame_set_value (saved_regs, SPARC_I7_REGNUM, i7 ^ wcookie);
+      }
+  }
+
   /* The floating-point registers are only saved if the EF bit in %prs
      has been set.  */
 


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