aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@gnu.org>2009-03-18 16:26:54 +0000
committerMark Kettenis <kettenis@gnu.org>2009-03-18 16:26:54 +0000
commit67cc50334e1706a942ef711c8aa21106cfe4d94d (patch)
tree7b7c241442afb2ea4c811664a925118d15b912bb
parent36dc683c524086a6ed9b74375d6501a33e875182 (diff)
downloadgdb-67cc50334e1706a942ef711c8aa21106cfe4d94d.zip
gdb-67cc50334e1706a942ef711c8aa21106cfe4d94d.tar.gz
gdb-67cc50334e1706a942ef711c8aa21106cfe4d94d.tar.bz2
* elf.c (elfcore_grok_openbsd_procinfo)
(elfcore_grok_openbsd_note): New functions. (elf_parse_notes): Handle notes from OpenBSD ELF core files.
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elf.c69
2 files changed, 75 insertions, 0 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 341eae1..750b2e2 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2009-03-18 Mark Kettenis <kettenis@gnu.org>
+
+ * elf.c (elfcore_grok_openbsd_procinfo)
+ (elfcore_grok_openbsd_note): New functions.
+ (elf_parse_notes): Handle notes from OpenBSD ELF core files.
+
2009-03-18 Alan Modra <amodra@bigpond.net.au>
* vms-hdr.c: Don't include alloca.h.
diff --git a/bfd/elf.c b/bfd/elf.c
index 8ca5ef9..6aa6d1c 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -8111,6 +8111,70 @@ elfcore_grok_netbsd_note (bfd *abfd, Elf_Internal_Note *note)
}
static bfd_boolean
+elfcore_grok_openbsd_procinfo (bfd *abfd, Elf_Internal_Note *note)
+{
+ /* Signal number at offset 0x08. */
+ elf_tdata (abfd)->core_signal
+ = bfd_h_get_32 (abfd, (bfd_byte *) note->descdata + 0x08);
+
+ /* Process ID at offset 0x20. */
+ elf_tdata (abfd)->core_pid
+ = bfd_h_get_32 (abfd, (bfd_byte *) note->descdata + 0x20);
+
+ /* Command name at 0x48 (max 32 bytes, including nul). */
+ elf_tdata (abfd)->core_command
+ = _bfd_elfcore_strndup (abfd, note->descdata + 0x48, 31);
+
+ return TRUE;
+}
+
+static bfd_boolean
+elfcore_grok_openbsd_note (bfd *abfd, Elf_Internal_Note *note)
+{
+ if (note->type == NT_OPENBSD_PROCINFO)
+ return elfcore_grok_openbsd_procinfo (abfd, note);
+
+ if (note->type == NT_OPENBSD_REGS)
+ return elfcore_make_note_pseudosection (abfd, ".reg", note);
+
+ if (note->type == NT_OPENBSD_FPREGS)
+ return elfcore_make_note_pseudosection (abfd, ".reg2", note);
+
+ if (note->type == NT_OPENBSD_XFPREGS)
+ return elfcore_make_note_pseudosection (abfd, ".reg-xfp", note);
+
+ if (note->type == NT_OPENBSD_AUXV)
+ {
+ asection *sect = bfd_make_section_anyway_with_flags (abfd, ".auxv",
+ SEC_HAS_CONTENTS);
+
+ if (sect == NULL)
+ return FALSE;
+ sect->size = note->descsz;
+ sect->filepos = note->descpos;
+ sect->alignment_power = 1 + bfd_get_arch_size (abfd) / 32;
+
+ return TRUE;
+ }
+
+ if (note->type == NT_OPENBSD_WCOOKIE)
+ {
+ asection *sect = bfd_make_section_anyway_with_flags (abfd, ".wcookie",
+ SEC_HAS_CONTENTS);
+
+ if (sect == NULL)
+ return FALSE;
+ sect->size = note->descsz;
+ sect->filepos = note->descpos;
+ sect->alignment_power = 1 + bfd_get_arch_size (abfd) / 32;
+
+ return TRUE;
+ }
+
+ return TRUE;
+}
+
+static bfd_boolean
elfcore_grok_nto_status (bfd *abfd, Elf_Internal_Note *note, long *tid)
{
void *ddata = note->descdata;
@@ -8597,6 +8661,11 @@ elf_parse_notes (bfd *abfd, char *buf, size_t size, file_ptr offset)
if (! elfcore_grok_netbsd_note (abfd, &in))
return FALSE;
}
+ else if (CONST_STRNEQ (in.namedata, "OpenBSD"))
+ {
+ if (! elfcore_grok_openbsd_note (abfd, &in))
+ return FALSE;
+ }
else if (CONST_STRNEQ (in.namedata, "QNX"))
{
if (! elfcore_grok_nto_note (abfd, &in))