From b15fa79e3ab3598d2a985fdc24d3fe68700b85a9 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Sat, 25 Aug 2007 13:20:41 +0000 Subject: [PATCH] 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. --- bfd/ChangeLog | 6 ++++++ bfd/elf.c | 31 +++++++++++++++++++++++++++++++ binutils/ChangeLog | 4 ++++ binutils/readelf.c | 12 +++++++++--- include/elf/ChangeLog | 4 ++++ include/elf/common.h | 4 ++++ 6 files changed, 58 insertions(+), 3 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 8a8327629de..5c6401a21c5 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2007-08-25 Ulrich Weigand + Alan Modra + + * elf.c (elfcore_grok_spu_note): New function. + (elf_parse_notes): Call it. + 2007-08-24 H.J. Lu * elf64-x86-64.c (elf64_x86_64_relocate_section): Adjust diff --git a/bfd/elf.c b/bfd/elf.c index 27c55afe929..16dd4a050f7 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -7980,6 +7980,32 @@ elfcore_grok_nto_note (bfd *abfd, Elf_Internal_Note *note) } } +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, size_t size, file_ptr offset) 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)) diff --git a/binutils/ChangeLog b/binutils/ChangeLog index d0fc8615255..04a31942d6a 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,7 @@ +2007-08-25 Ulrich Weigand + + * readelf.c (process_note): Recognize SPU core file notes. + 2007-08-24 Daniel Jacobowitz * configure.in: Install embedspu on powerpc*-*-eabi* also. diff --git a/binutils/readelf.c b/binutils/readelf.c index 7e3058496c1..9fc8e0cf051 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -9231,6 +9231,7 @@ get_netbsd_elfcore_note_type (unsigned e_type) 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; } diff --git a/include/elf/ChangeLog b/include/elf/ChangeLog index 0e07b03c743..c24893d169d 100644 --- a/include/elf/ChangeLog +++ b/include/elf/ChangeLog @@ -1,3 +1,7 @@ +2007-08-25 Ulrich Weigand + + * common.h (NT_SPU): Define. + 2007-08-16 H.J. Lu * common.h: Revert last change. diff --git a/include/elf/common.h b/include/elf/common.h index bc9a5cf2edb..5b71782fd62 100644 --- a/include/elf/common.h +++ b/include/elf/common.h @@ -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. */ -- 2.30.2