+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.
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>
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>
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. */
}
}
+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;
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);
}