From: nickc Date: Fri, 2 Jan 2004 17:39:51 +0000 (+0000) Subject: Add support for FreeBSD cores X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=a8018e6bdc3e2f27292a1d14b78e1e3591ffd5f5;p=pf3gnuchains%2Fpf3gnuchains3x.git Add support for FreeBSD cores --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 994b9d3a0f..48a6c8d9c8 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2004-01-02 Mark Kettenis + + * elf32-i386.c (elf_i386_grok_prstatus): Add support for FreeBSD. + (elf_i386_grok_psinfo): Likewise. + 2004-01-02 Bernardo Innocenti * config.bfd: Add m68k-uClinux target. diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index 876efc6ab0..0a3d83fb5a 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -1,5 +1,5 @@ /* Intel 80386/80486-specific support for 32-bit ELF - Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 + Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -346,29 +346,50 @@ elf_i386_is_local_label_name (bfd *abfd, const char *name) } /* Support for core dump NOTE sections. */ + static bfd_boolean elf_i386_grok_prstatus (bfd *abfd, Elf_Internal_Note *note) { int offset; size_t raw_size; - switch (note->descsz) + if (note->namesz == 8 && strcmp (note->namedata, "FreeBSD") == 0) { - default: - return FALSE; + int pr_version = bfd_get_32 (abfd, note->descdata); + + if (pr_version != 1) + return FALSE; + + /* pr_cursig */ + elf_tdata (abfd)->core_signal = bfd_get_32 (abfd, note->descdata + 20); + + /* pr_pid */ + elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24); + + /* pr_reg */ + offset = 28; + raw_size = bfd_get_32 (abfd, note->descdata + 8); + } + else + { + switch (note->descsz) + { + default: + return FALSE; - case 144: /* Linux/i386 */ - /* pr_cursig */ - elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12); + case 144: /* Linux/i386 */ + /* pr_cursig */ + elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12); - /* pr_pid */ - elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24); + /* pr_pid */ + elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24); - /* pr_reg */ - offset = 72; - raw_size = 68; + /* pr_reg */ + offset = 72; + raw_size = 68; - break; + break; + } } /* Make a ".reg/999" section. */ @@ -379,22 +400,36 @@ elf_i386_grok_prstatus (bfd *abfd, Elf_Internal_Note *note) static bfd_boolean elf_i386_grok_psinfo (bfd *abfd, Elf_Internal_Note *note) { - switch (note->descsz) + if (note->namesz == 8 && strcmp (note->namedata, "FreeBSD") == 0) { - default: + int pr_version = bfd_get_32 (abfd, note->descdata); + + if (pr_version != 1) return FALSE; - case 124: /* Linux/i386 elf_prpsinfo */ - elf_tdata (abfd)->core_program - = _bfd_elfcore_strndup (abfd, note->descdata + 28, 16); - elf_tdata (abfd)->core_command - = _bfd_elfcore_strndup (abfd, note->descdata + 44, 80); + elf_tdata (abfd)->core_program + = _bfd_elfcore_strndup (abfd, note->descdata + 8, 17); + elf_tdata (abfd)->core_command + = _bfd_elfcore_strndup (abfd, note->descdata + 25, 81); + } + else + { + switch (note->descsz) + { + default: + return FALSE; + + case 124: /* Linux/i386 elf_prpsinfo. */ + elf_tdata (abfd)->core_program + = _bfd_elfcore_strndup (abfd, note->descdata + 28, 16); + elf_tdata (abfd)->core_command + = _bfd_elfcore_strndup (abfd, note->descdata + 44, 80); + } } /* Note that for some reason, a spurious space is tacked onto the end of the args in some (at least one anyway) implementations, so strip it off if it exists. */ - { char *command = elf_tdata (abfd)->core_command; int n = strlen (command);