* [PATCH/RFA] Create .wcookie sections for OpenBSD/sparc core dumps
@ 2004-03-16 12:35 Mark Kettenis
2004-03-19 0:09 ` Mark Kettenis
2004-03-31 8:32 ` Nick Clifton
0 siblings, 2 replies; 3+ messages in thread
From: Mark Kettenis @ 2004-03-16 12:35 UTC (permalink / raw)
To: binutils; +Cc: gdb-patches
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;
}
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH/RFA] Create .wcookie sections for OpenBSD/sparc core dumps
2004-03-16 12:35 [PATCH/RFA] Create .wcookie sections for OpenBSD/sparc core dumps Mark Kettenis
@ 2004-03-19 0:09 ` Mark Kettenis
2004-03-31 8:32 ` Nick Clifton
1 sibling, 0 replies; 3+ messages in thread
From: Mark Kettenis @ 2004-03-19 0:09 UTC (permalink / raw)
To: binutils; +Cc: gdb-patches
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;
}
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH/RFA] Create .wcookie sections for OpenBSD/sparc core dumps
2004-03-16 12:35 [PATCH/RFA] Create .wcookie sections for OpenBSD/sparc core dumps Mark Kettenis
2004-03-19 0:09 ` Mark Kettenis
@ 2004-03-31 8:32 ` Nick Clifton
1 sibling, 0 replies; 3+ messages in thread
From: Nick Clifton @ 2004-03-31 8:32 UTC (permalink / raw)
To: Mark Kettenis; +Cc: binutils, gdb-patches
Hi Mark,
> 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.
Approved - please apply.
Cheers
Nick
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-03-31 8:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-16 12:35 [PATCH/RFA] Create .wcookie sections for OpenBSD/sparc core dumps Mark Kettenis
2004-03-19 0:09 ` Mark Kettenis
2004-03-31 8:32 ` Nick Clifton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox