diff options
-rw-r--r-- | bfd/ChangeLog | 12 | ||||
-rw-r--r-- | bfd/elf.c | 120 |
2 files changed, 128 insertions, 4 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 5cf7440..779ce53 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,11 @@ +2001-12-18 Jason Thorpe <thorpej@wasabisystems.com> + + * elf.c (elfcore_netbsd_get_lwpid): New function. + (elfcore_grok_netbsd_procinfo): New function. + (elfcore_grok_netbsd_note): New function. + (elfcore_read_notes): Call elfcore_grok_netbsd_note to process + NetBSD ELF core file notes. + 2001-12-18 Alan Modra <amodra@bigpond.net.au> * elfcode.h (struct bfd_preserve): New. @@ -11,7 +19,7 @@ 2001-12-17 Tom Rix <trix@redhat.com> - * coffcode.h (sec_to_styp_flags): Add STYP_EXCEPT and STYP_TYPCHK for + * coffcode.h (sec_to_styp_flags): Add STYP_EXCEPT and STYP_TYPCHK for xcoff. 2001-12-17 Jakub Jelinek <jakub@redhat.com> @@ -722,7 +730,7 @@ 2001-11-14 Martin Schwidefsky <schwidefsky@de.ibm.com> * elf32-s390.c (elf_s390_relocate_section): Use the "unresolved_reloc" - scheme to get rid of an ugly complicated test. + scheme to get rid of an ugly complicated test. * elf64-s390.c (elf_s390_relocate_section): Likewise. 2001-11-14 Andreas Jaeger <aj@suse.de> @@ -71,6 +71,11 @@ static boolean elfcore_grok_prfpreg PARAMS ((bfd *, Elf_Internal_Note *)); static boolean elfcore_grok_prxfpreg PARAMS ((bfd *, Elf_Internal_Note *)); static boolean elfcore_grok_note PARAMS ((bfd *, Elf_Internal_Note *)); +static boolean elfcore_netbsd_get_lwpid PARAMS ((Elf_Internal_Note *, int *)); +static boolean elfcore_grok_netbsd_procinfo PARAMS ((bfd *, + Elf_Internal_Note *)); +static boolean elfcore_grok_netbsd_note PARAMS ((bfd *, Elf_Internal_Note *)); + /* Swap version information in and out. The version information is currently size independent. If that ever changes, this code will need to move into elfcode.h. */ @@ -6353,6 +6358,109 @@ elfcore_grok_note (abfd, note) } static boolean +elfcore_netbsd_get_lwpid (note, lwpidp) + Elf_Internal_Note *note; + int *lwpidp; +{ + char *cp; + + cp = strchr (note->namedata, '@'); + if (cp != NULL) + { + *lwpidp = atoi(cp); + return true; + } + return false; +} + +static boolean +elfcore_grok_netbsd_procinfo (abfd, note) + 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 0x50. */ + elf_tdata (abfd)->core_pid + = bfd_h_get_32 (abfd, (bfd_byte *) note->descdata + 0x50); + + /* Command name at 0x7c (max 32 bytes, including nul). */ + elf_tdata (abfd)->core_command + = _bfd_elfcore_strndup (abfd, note->descdata + 0x7c, 31); + + return true; +} + +static boolean +elfcore_grok_netbsd_note (abfd, note) + bfd *abfd; + Elf_Internal_Note *note; +{ + int lwp; + + if (elfcore_netbsd_get_lwpid (note, &lwp)) + elf_tdata (abfd)->core_lwpid = lwp; + + if (note->type == 1) + { + /* NetBSD-specific core "procinfo". Note that we expect to + find this note before any of the others, which is fine, + since the kernel writes this note out first when it + creates a core file. */ + + return elfcore_grok_netbsd_procinfo (abfd, note); + } + + /* There are not currently any other machine-independent notes defined + for NetBSD ELF core files. If the note type is less than the start + of the machine-dependent note types, we don't understand it. */ + + if (note->type < 32) + return true; + + + switch (bfd_get_arch (abfd)) + { + /* On the Alpha, SPARC (32-bit and 64-bit), PT_GETREGS == mach+0 and + PT_GETFPREGS == mach+2. */ + + case bfd_arch_alpha: + case bfd_arch_sparc: + switch (note->type) + { + case 32+0: + return elfcore_make_note_pseudosection (abfd, ".reg", note); + + case 32+2: + return elfcore_make_note_pseudosection (abfd, ".reg2", note); + + default: + return true; + } + + /* On all other arch's, PT_GETREGS == mach+1 and + PT_GETFPREGS == mach+3. */ + + default: + switch (note->type) + { + case 32+1: + return elfcore_make_note_pseudosection (abfd, ".reg", note); + + case 32+3: + return elfcore_make_note_pseudosection (abfd, ".reg2", note); + + default: + return true; + } + } + /* NOTREACHED */ +} + +static boolean elfcore_read_notes (abfd, offset, size) bfd *abfd; file_ptr offset; @@ -6394,8 +6502,16 @@ elfcore_read_notes (abfd, offset, size) in.descdata = in.namedata + BFD_ALIGN (in.namesz, 4); in.descpos = offset + (in.descdata - buf); - if (! elfcore_grok_note (abfd, &in)) - goto error; + if (strncmp (in.namedata, "NetBSD-CORE", 11) == 0) + { + if (! elfcore_grok_netbsd_note (abfd, &in)) + goto error; + } + else + { + if (! elfcore_grok_note (abfd, &in)) + goto error; + } p = in.descdata + BFD_ALIGN (in.descsz, 4); } |