Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Mark Kettenis <kettenis@chello.nl>
To: binutils@sources.redhat.com
Cc: gdb-patches@sources.redhat.com
Subject: [PATCH/RFA] Create .wcookie sections for OpenBSD/sparc core dumps
Date: Tue, 16 Mar 2004 12:35:00 -0000	[thread overview]
Message-ID: <200403161235.i2GCZksp000491@elgar.kettenis.dyndns.org> (raw)

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;
     }


WARNING: multiple messages have this Message-ID
From: Mark Kettenis <kettenis@chello.nl>
To: binutils@sources.redhat.com
Cc: gdb-patches@sources.redhat.com
Subject: [PATCH/RFA] Create .wcookie sections for OpenBSD/sparc core dumps
Date: Fri, 19 Mar 2004 00:09:00 -0000	[thread overview]
Message-ID: <200403161235.i2GCZksp000491@elgar.kettenis.dyndns.org> (raw)
Message-ID: <20040319000900.P2tHhaT93X17g4yaEGdBB8HbTNKxoev8vKxqkkH7Q0E@z> (raw)

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;
     }


             reply	other threads:[~2004-03-16 12:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-16 12:35 Mark Kettenis [this message]
2004-03-19  0:09 ` Mark Kettenis
2004-03-31  8:32 ` Nick Clifton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200403161235.i2GCZksp000491@elgar.kettenis.dyndns.org \
    --to=kettenis@chello.nl \
    --cc=binutils@sources.redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox