diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2009-03-05 19:41:33 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2009-03-05 19:41:33 +0000 |
commit | 17de6a4d45010c925689e6af9fb64c026cfde07d (patch) | |
tree | 2288db5bee1fe6da5bd7badf63ea288b840ba2cd /gnu/usr.bin | |
parent | 68f3363dda760bc0bca756c00feacc333920748c (diff) |
Teach bfd and gdb about the upcoming ELF core dumps.
Diffstat (limited to 'gnu/usr.bin')
-rw-r--r-- | gnu/usr.bin/binutils/bfd/elf.c | 69 | ||||
-rw-r--r-- | gnu/usr.bin/binutils/gdb/amd64obsd-tdep.c | 16 | ||||
-rw-r--r-- | gnu/usr.bin/binutils/gdb/ppcobsd-tdep.c | 3 | ||||
-rw-r--r-- | gnu/usr.bin/binutils/include/elf/common.h | 11 |
4 files changed, 95 insertions, 4 deletions
diff --git a/gnu/usr.bin/binutils/bfd/elf.c b/gnu/usr.bin/binutils/bfd/elf.c index bb05fa800d3..af38fc96b0f 100644 --- a/gnu/usr.bin/binutils/bfd/elf.c +++ b/gnu/usr.bin/binutils/bfd/elf.c @@ -6963,6 +6963,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 (abfd, ".auxv"); + + if (sect == NULL) + return FALSE; + sect->_raw_size = note->descsz; + sect->filepos = note->descpos; + sect->flags = SEC_HAS_CONTENTS; + sect->alignment_power = 1 + bfd_get_arch_size (abfd) / 32; + + return TRUE; + } + + if (note->type == NT_OPENBSD_WCOOKIE) + { + asection *sect = bfd_make_section_anyway (abfd, ".wcookie"); + + if (sect == NULL) + return FALSE; + sect->_raw_size = note->descsz; + sect->filepos = note->descpos; + sect->flags = SEC_HAS_CONTENTS; + 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, pid_t *tid) { void *ddata = note->descdata; @@ -7297,6 +7361,11 @@ elfcore_read_notes (bfd *abfd, file_ptr offset, bfd_size_type size) if (! elfcore_grok_netbsd_note (abfd, &in)) goto error; } + if (strncmp (in.namedata, "OpenBSD", 7) == 0) + { + if (! elfcore_grok_openbsd_note (abfd, &in)) + goto error; + } else if (strncmp (in.namedata, "QNX", 3) == 0) { if (! elfcore_grok_nto_note (abfd, &in)) diff --git a/gnu/usr.bin/binutils/gdb/amd64obsd-tdep.c b/gnu/usr.bin/binutils/gdb/amd64obsd-tdep.c index b6a413ed0d1..59bb1b15890 100644 --- a/gnu/usr.bin/binutils/gdb/amd64obsd-tdep.c +++ b/gnu/usr.bin/binutils/gdb/amd64obsd-tdep.c @@ -453,9 +453,6 @@ amd64obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) tdep->gregset_num_regs = ARRAY_SIZE (amd64obsd_r_reg_offset); tdep->sizeof_gregset = 24 * 8; - set_gdbarch_regset_from_core_section (gdbarch, - amd64obsd_regset_from_core_section); - tdep->jb_pc_offset = 7 * 8; tdep->sigtramp_p = amd64obsd_sigtramp_p; @@ -474,6 +471,17 @@ amd64obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) /* Unwind kernel trap frames correctly. */ frame_unwind_prepend_unwinder (gdbarch, &amd64obsd_trapframe_unwind); } + +/* Traditional (a.out) NetBSD-style core dumps. */ + +static void +amd64obsd_core_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) +{ + amd64obsd_init_abi (info, gdbarch); + + set_gdbarch_regset_from_core_section + (gdbarch, amd64obsd_regset_from_core_section); +} /* Provide a prototype to silence -Wmissing-prototypes. */ @@ -490,5 +498,5 @@ _initialize_amd64obsd_tdep (void) /* OpenBSD uses traditional (a.out) NetBSD-style core dumps. */ gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64, - GDB_OSABI_NETBSD_AOUT, amd64obsd_init_abi); + GDB_OSABI_NETBSD_AOUT, amd64obsd_core_init_abi); } diff --git a/gnu/usr.bin/binutils/gdb/ppcobsd-tdep.c b/gnu/usr.bin/binutils/gdb/ppcobsd-tdep.c index 410852ddca2..2721a54266b 100644 --- a/gnu/usr.bin/binutils/gdb/ppcobsd-tdep.c +++ b/gnu/usr.bin/binutils/gdb/ppcobsd-tdep.c @@ -119,6 +119,9 @@ ppcobsd_regset_from_core_section (struct gdbarch *gdbarch, if (strcmp (sect_name, ".reg") == 0 && sect_size >= 412) return &ppcobsd_gregset; + if (strcmp (sect_name, ".reg2") == 0 && sect_size >= 260) + return &ppcobsd_fpregset; + return NULL; } diff --git a/gnu/usr.bin/binutils/include/elf/common.h b/gnu/usr.bin/binutils/include/elf/common.h index bf233f61dfd..84ef2b53723 100644 --- a/gnu/usr.bin/binutils/include/elf/common.h +++ b/gnu/usr.bin/binutils/include/elf/common.h @@ -386,6 +386,17 @@ #define NT_NETBSDCORE_FIRSTMACH 32 /* start of machdep note types */ +/* Note segments for core files on OpenBSD systems. Note name is + "OpenBSD". */ + +#define NT_OPENBSD_PROCINFO 10 +#define NT_OPENBSD_AUXV 11 +#define NT_OPENBSD_REGS 20 +#define NT_OPENBSD_FPREGS 21 +#define NT_OPENBSD_XFPREGS 22 +#define NT_OPENBSD_WCOOKIE 23 + + /* Values of note segment descriptor types for object files. */ #define NT_VERSION 1 /* Contains a version string. */ |