From: Andreas Schwab Date: Mon, 21 May 2012 08:17:15 +0000 (+0000) Subject: * elf32-m68k.c (elf_m68k_grok_prstatus): New function. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8bbeae90c581eef4bd6c060952c372dc8e7d7a75;p=binutils-gdb.git * elf32-m68k.c (elf_m68k_grok_prstatus): New function. (elf_m68k_grok_psinfo): New function. (elf_backend_grok_prstatus): Define. (elf_backend_grok_psinfo): Define. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index efa6cb7b4c4..a77a28c9ab0 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2012-05-21 Andreas Schwab + + * elf32-m68k.c (elf_m68k_grok_prstatus): New function. + (elf_m68k_grok_psinfo): New function. + (elf_backend_grok_prstatus): Define. + (elf_backend_grok_psinfo): Define. + 2012-05-19 Maciej W. Rozycki * elf64-mips.c (elf_backend_got_header_size): Correct definition. diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c index bba4c791b27..573003bfb3c 100644 --- a/bfd/elf32-m68k.c +++ b/bfd/elf32-m68k.c @@ -4821,6 +4821,69 @@ elf_m68k_plt_sym_val (bfd_vma i, const asection *plt, return plt->vma + (i + 1) * elf_m68k_get_plt_info (plt->owner)->size; } +/* Support for core dump NOTE sections. */ + +static bfd_boolean +elf_m68k_grok_prstatus (bfd *abfd, Elf_Internal_Note *note) +{ + int offset; + size_t size; + + switch (note->descsz) + { + default: + return FALSE; + + case 154: /* Linux/m68k */ + /* pr_cursig */ + elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12); + + /* pr_pid */ + elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 22); + + /* pr_reg */ + offset = 70; + size = 80; + + break; + } + + /* Make a ".reg/999" section. */ + return _bfd_elfcore_make_pseudosection (abfd, ".reg", + size, note->descpos + offset); +} + +static bfd_boolean +elf_m68k_grok_psinfo (bfd *abfd, Elf_Internal_Note *note) +{ + switch (note->descsz) + { + default: + return FALSE; + + case 124: /* Linux/m68k elf_prpsinfo. */ + elf_tdata (abfd)->core_pid + = bfd_get_32 (abfd, note->descdata + 12); + 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); + + if (n > 0 && command[n - 1] == ' ') + command[n - 1] = '\0'; + } + + return TRUE; +} + #define TARGET_BIG_SYM bfd_elf32_m68k_vec #define TARGET_BIG_NAME "elf32-m68k" #define ELF_MACHINE_CODE EM_68K @@ -4860,6 +4923,8 @@ elf_m68k_plt_sym_val (bfd_vma i, const asection *plt, #define elf_backend_reloc_type_class elf32_m68k_reloc_type_class #define elf_backend_plt_sym_val elf_m68k_plt_sym_val #define elf_backend_object_p elf32_m68k_object_p +#define elf_backend_grok_prstatus elf_m68k_grok_prstatus +#define elf_backend_grok_psinfo elf_m68k_grok_psinfo #define elf_backend_can_gc_sections 1 #define elf_backend_can_refcount 1