This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[elf64-hppa] Add grok_{prstatus,psinfo} methods
- From: Randolph Chung <randolph at tausq dot org>
- To: binutils at sourceware dot org
- Date: Thu, 22 Dec 2005 23:56:06 +0800
- Subject: [elf64-hppa] Add grok_{prstatus,psinfo} methods
This adds the grok_prstatus/psinfo methods for the elf64-hppa target for
Linux core dumps.
Tested on hppa64-gnu-linux. Please commit if okay.
randolph
2005-12-22 Randolph Chung <tausq@debian.org>
* elf64-hppa.c (elf64_hppa_grok_prstatus): New function.
(elf64_hppa_grok_psinfo): Likewise.
(elf_backend_grok_pstatus, elf_backend_grok_psinfo): Define.
Index: elf64-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-hppa.c,v
retrieving revision 1.67
diff -u -p -r1.67 elf64-hppa.c
--- elf64-hppa.c 4 Dec 2005 14:58:11 -0000 1.67
+++ elf64-hppa.c 22 Dec 2005 15:51:21 -0000
@@ -2542,6 +2542,67 @@ elf64_hppa_finish_dynamic_sections (outp
return TRUE;
}
+/* Support for core dump NOTE sections. */
+
+static bfd_boolean
+elf64_hppa_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
+{
+ int offset;
+ size_t size;
+
+ switch (note->descsz)
+ {
+ default:
+ return FALSE;
+
+ case 760: /* Linux/hppa */
+ /* 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;
+ size = 640;
+
+ break;
+ }
+
+ /* Make a ".reg/999" section. */
+ return _bfd_elfcore_make_pseudosection (abfd, ".reg",
+ size, note->descpos + offset);
+}
+
+static bfd_boolean
+elf64_hppa_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
+{
+ switch (note->descsz)
+ {
+ default:
+ return FALSE;
+
+ case 136: /* Linux/hppa 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;
+}
+
/* Return the number of additional phdrs we will need.
The generic ELF code only creates PT_PHDRs for executables. The HP
@@ -2775,6 +2836,8 @@ const struct elf_size_info hppa64_elf_si
elf64_hppa_finish_dynamic_symbol
#define elf_backend_finish_dynamic_sections \
elf64_hppa_finish_dynamic_sections
+#define elf_backend_grok_prstatus elf64_hppa_grok_prstatus
+#define elf_backend_grok_psinfo elf64_hppa_grok_psinfo
/* Stuff for the BFD linker: */
#define bfd_elf64_bfd_link_hash_table_create \