This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
SPU core file support
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: binutils at sourceware dot org
- Date: Sat, 25 Aug 2007 22:49:09 +0930
- Subject: SPU core file support
Teaches bfd and readelf about SPU core file notes.
include/elf/
* common.h (NT_SPU): Define.
bfd/
* elf.c (elfcore_grok_spu_note): New function.
(elf_parse_notes): Call it.
binutils/
* readelf.c (process_note): Recognize SPU core file notes.
Index: include/elf/common.h
===================================================================
RCS file: /cvs/src/src/include/elf/common.h,v
retrieving revision 1.88
diff -u -p -r1.88 common.h
--- include/elf/common.h 16 Aug 2007 18:49:42 -0000 1.88
+++ include/elf/common.h 25 Aug 2007 13:12:32 -0000
@@ -407,6 +407,10 @@
#define NT_NETBSDCORE_PROCINFO 1 /* Has a struct procinfo */
#define NT_NETBSDCORE_FIRSTMACH 32 /* start of machdep note types */
+/* Note segments for core files on SPU systems. Note name
+ must start with "SPU/". */
+
+#define NT_SPU 1
/* Values of note segment descriptor types for object files. */
Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.412
diff -u -p -r1.412 elf.c
--- bfd/elf.c 24 Aug 2007 21:29:19 -0000 1.412
+++ bfd/elf.c 25 Aug 2007 13:12:37 -0000
@@ -7980,6 +7980,32 @@ elfcore_grok_nto_note (bfd *abfd, Elf_In
}
}
+static bfd_boolean
+elfcore_grok_spu_note (bfd *abfd, Elf_Internal_Note *note)
+{
+ char *name;
+ asection *sect;
+ size_t len;
+
+ /* Use note name as section name. */
+ len = note->namesz;
+ name = bfd_alloc (abfd, len);
+ if (name == NULL)
+ return FALSE;
+ memcpy (name, note->namedata, len);
+ name[len - 1] = '\0';
+
+ sect = bfd_make_section_anyway_with_flags (abfd, name, SEC_HAS_CONTENTS);
+ if (sect == NULL)
+ return FALSE;
+
+ sect->size = note->descsz;
+ sect->filepos = note->descpos;
+ sect->alignment_power = 1;
+
+ return TRUE;
+}
+
/* Function: elfcore_write_note
Inputs:
@@ -8280,6 +8306,11 @@ elf_parse_notes (bfd *abfd, char *buf, s
if (! elfcore_grok_nto_note (abfd, &in))
return FALSE;
}
+ else if (CONST_STRNEQ (in.namedata, "SPU/"))
+ {
+ if (! elfcore_grok_spu_note (abfd, &in))
+ return FALSE;
+ }
else
{
if (! elfcore_grok_note (abfd, &in))
Index: binutils/readelf.c
===================================================================
RCS file: /cvs/src/src/binutils/readelf.c,v
retrieving revision 1.374
diff -u -p -r1.374 readelf.c
--- binutils/readelf.c 16 Aug 2007 18:49:42 -0000 1.374
+++ binutils/readelf.c 25 Aug 2007 13:12:41 -0000
@@ -9231,6 +9231,7 @@ get_netbsd_elfcore_note_type (unsigned e
static int
process_note (Elf_Internal_Note *pnote)
{
+ const char *name = pnote->namesz ? pnote->namedata : "(NONE)";
const char *nt;
if (pnote->namesz == 0)
@@ -9246,14 +9247,19 @@ process_note (Elf_Internal_Note *pnote)
/* NetBSD-specific core file notes. */
nt = get_netbsd_elfcore_note_type (pnote->type);
+ else if (strneq (pnote->namedata, "SPU/", 4))
+ {
+ /* SPU-specific core file notes. */
+ nt = pnote->namedata + 4;
+ name = "SPU";
+ }
+
else
/* Don't recognize this note name; just use the default set of
note type strings. */
nt = get_note_type (pnote->type);
- printf (" %s\t\t0x%08lx\t%s\n",
- pnote->namesz ? pnote->namedata : "(NONE)",
- pnote->descsz, nt);
+ printf (" %s\t\t0x%08lx\t%s\n", name, pnote->descsz, nt);
return 1;
}
--
Alan Modra
Australia Development Lab, IBM