From: Kevin Buettner Date: Thu, 5 Dec 2002 05:04:00 +0000 (+0000) Subject: Add n64 core file support for Linux/MIPS. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d0112f73538ba73e84082c207e597c857a97d7f2;p=binutils-gdb.git Add n64 core file support for Linux/MIPS. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 6c66b1fa7f4..85487191bca 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2002-12-04 Kevin Buettner + + * elf64-mips.c (elf64_mips_grok_prstatus, elf64_mips_grok_psinfo): + New functions. + (elf_backend_grok_prstatus, elf_backend_grok_psinfo): Define. + 2002-12-04 David Mosberger * cpu-ia64-opc.c: Add operand constant "ar.csd". diff --git a/bfd/elf64-mips.c b/bfd/elf64-mips.c index fda989fde98..50fcfbabf19 100644 --- a/bfd/elf64-mips.c +++ b/bfd/elf64-mips.c @@ -125,6 +125,10 @@ static bfd_boolean mips_elf64_object_p PARAMS ((bfd *)); static irix_compat_t elf64_mips_irix_compat PARAMS ((bfd *)); +static bfd_boolean elf64_mips_grok_prstatus + PARAMS ((bfd *, Elf_Internal_Note *)); +static bfd_boolean elf64_mips_grok_psinfo + PARAMS ((bfd *, Elf_Internal_Note *)); extern const bfd_target bfd_elf64_bigmips_vec; extern const bfd_target bfd_elf64_littlemips_vec; @@ -2529,6 +2533,71 @@ elf64_mips_irix_compat (abfd) return ict_none; } +/* Support for core dump NOTE sections. */ +static bfd_boolean +elf64_mips_grok_prstatus (abfd, note) + bfd *abfd; + Elf_Internal_Note *note; +{ + int offset; + unsigned int raw_size; + + switch (note->descsz) + { + default: + return FALSE; + + case 480: /* Linux/MIPS - N64 kernel */ + /* 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 + 32); + + /* pr_reg */ + offset = 112; + raw_size = 360; + + break; + } + + /* Make a ".reg/999" section. */ + return _bfd_elfcore_make_pseudosection (abfd, ".reg", + raw_size, note->descpos + offset); +} + +static bfd_boolean +elf64_mips_grok_psinfo (abfd, note) + bfd *abfd; + Elf_Internal_Note *note; +{ + switch (note->descsz) + { + default: + return FALSE; + + case 136: /* Linux/MIPS - N64 kernel elf_prpsinfo */ + elf_tdata (abfd)->core_program + = _bfd_elfcore_strndup (abfd, note->descdata + 40, 16); + elf_tdata (abfd)->core_command + = _bfd_elfcore_strndup (abfd, note->descdata + 56, 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); + + if (0 < n && command[n - 1] == ' ') + command[n - 1] = '\0'; + } + + return TRUE; +} + /* ECOFF swapping routines. These are used when dealing with the .mdebug section, which is in the ECOFF debugging format. */ static const struct ecoff_debug_swap mips_elf64_ecoff_debug_swap = @@ -2659,6 +2728,9 @@ const struct elf_size_info mips_elf64_size_info = #define elf_backend_ecoff_debug_swap &mips_elf64_ecoff_debug_swap #define elf_backend_size_info mips_elf64_size_info +#define elf_backend_grok_prstatus elf64_mips_grok_prstatus +#define elf_backend_grok_psinfo elf64_mips_grok_psinfo + #define elf_backend_got_header_size (4 * MIPS_RESERVED_GOTNO) #define elf_backend_plt_header_size 0