This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils 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/RFA] Create .wcookie sections for OpenBSD/sparc core dumps


Currently backtraces in core dumps generated by OpenBSD/sparc kernels
that use StackGhost are broken in GDB.  We need the StackGhost cookie
to fix that, and it is stored in the core files.  Unfortunately BFD
doesn't exectly present it to us in an easy way.  The attached patch
modifies netbsd-core.c such that for OpenBSD/sparc corefiles, BFD
creates a .wcookie section containing the cookie.  This seems the
natural approach, since it will make the transition to ELF core files
easier (where presumably the cookie would be stored in an ELF note).
The approach is inspired by the .auxv section created for NT_AUXV
notes.

OK, to check this in?

Mark


Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>
 
	* netbsd-core.c (CORE_WCOOKIE_OFFSET): New define.
	(netbsd_core_file_p): Create a .wcookie section for OpenBSD/sparc.

Index: netbsd-core.c
===================================================================
RCS file: /cvs/src/src/bfd/netbsd-core.c,v
retrieving revision 1.12
diff -u -p -r1.12 netbsd-core.c
--- netbsd-core.c 16 Mar 2004 12:22:18 -0000 1.12
+++ netbsd-core.c 16 Mar 2004 12:26:45 -0000
@@ -34,6 +34,10 @@
    NetBSD/sparc64 overlaps with M_MIPS1.  */
 #define M_SPARC64_OPENBSD	M_MIPS1
 
+/* Offset of StackGhost cookie within `struct md_coredump' on
+   OpenBSD/sparc.  */
+#define CORE_WCOOKIE_OFFSET	344
+
 struct netbsd_core_struct
 {
   struct core core;
@@ -139,6 +143,25 @@ netbsd_core_file_p (abfd)
       asect->vma = coreseg.c_addr;
       asect->filepos = offset;
       asect->alignment_power = 2;
+
+      if (CORE_GETMID (core) == M_SPARC_NETBSD
+	  && CORE_GETFLAG (coreseg) == CORE_CPU
+	  && coreseg.c_size > CORE_WCOOKIE_OFFSET)
+	{
+	  /* Truncate the .reg section.  */
+	  asect->_raw_size = CORE_WCOOKIE_OFFSET;
+
+	  /* And create the .wcookie section.  */
+	  asect = bfd_make_section_anyway (abfd, ".wcookie");
+	  if (asect == NULL)
+	    goto punt;
+
+	  asect->flags = SEC_ALLOC + SEC_HAS_CONTENTS;
+	  asect->_raw_size = 4;
+	  asect->vma = 0;
+	  asect->filepos = offset + CORE_WCOOKIE_OFFSET;
+	  asect->alignment_power = 2;
+	}
 
       offset += coreseg.c_size;
     }


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