multi-threaded core files
Alan Modra
amodra@bigpond.net.au
Wed Oct 29 11:16:00 GMT 2003
This patch fixes an annoying bug with cross-binutils. I often want to
look at a raw powerpc64-linux core file on my x86 box, and
multi-threaded cores like the following:
Notes at offset 0x000006d0 with length 0x00001460:
Owner Data size Description
CORE 0x000001f8 NT_PRSTATUS (prstatus structure)
CORE 0x00000088 NT_PRPSINFO (prpsinfo structure)
CORE 0x00000710 NT_TASKSTRUCT (task structure)
CORE 0x00000108 NT_FPREGSET (floating point registers)
CORE 0x000001f8 NT_PRSTATUS (prstatus structure)
CORE 0x00000108 NT_FPREGSET (floating point registers)
CORE 0x000001f8 NT_PRSTATUS (prstatus structure)
CORE 0x00000108 NT_FPREGSET (floating point registers)
CORE 0x000001f8 NT_PRSTATUS (prstatus structure)
CORE 0x00000108 NT_FPREGSET (floating point registers)
result in
$ objdump -s core.30390
objdump: core.30390: File format not recognized
The root of the problem is that in processing NT_FPREGSET we want to
create sections with names based on the thread id. However, the thread
id is found when processing NT_PRSTATUS, and the generic binutils code
only understands prstatus structs for the host. (I should really write
elf_backend_grok_prstatus for ppc64.) Thus when trying to grok a
non-native core file, binutils fails to set the thread id. If there's
more than one thread, we end up trying to create sections with the same
name and fail. The easy work-around is to allow multiple sections with
the same name.
Amusingly, binutils-2.13 had a bug in bfd_make_section that caused it
to behave like bfd_make_section_anyway, so objdump from 2.13 happened
to work on these core files.
* elf.c (_bfd_elfcore_make_pseudosection): Allow multiple
sections with the same name.
(elfcore_grok_lwpstatus): Likewise.
(elfcore_grok_win32pstatus): Likewise.
(elfcore_grok_note): Likewise.
(elfcore_grok_nto_status): Likewise.
(elfcore_grok_nto_gregs): Likewise.
Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.203
diff -u -p -r1.203 elf.c
--- bfd/elf.c 20 Oct 2003 14:38:39 -0000 1.203
+++ bfd/elf.c 29 Oct 2003 11:03:39 -0000
@@ -6315,7 +6315,7 @@ _bfd_elfcore_make_pseudosection (bfd *ab
return FALSE;
memcpy (threaded_name, buf, len);
- sect = bfd_make_section (abfd, threaded_name);
+ sect = bfd_make_section_anyway (abfd, threaded_name);
if (sect == NULL)
return FALSE;
sect->_raw_size = size;
@@ -6599,7 +6599,7 @@ elfcore_grok_lwpstatus (bfd *abfd, Elf_I
return FALSE;
memcpy (name, buf, len);
- sect = bfd_make_section (abfd, name);
+ sect = bfd_make_section_anyway (abfd, name);
if (sect == NULL)
return FALSE;
@@ -6629,7 +6629,7 @@ elfcore_grok_lwpstatus (bfd *abfd, Elf_I
return FALSE;
memcpy (name, buf, len);
- sect = bfd_make_section (abfd, name);
+ sect = bfd_make_section_anyway (abfd, name);
if (sect == NULL)
return FALSE;
@@ -6685,7 +6685,7 @@ elfcore_grok_win32pstatus (bfd *abfd, El
memcpy (name, buf, len);
- sect = bfd_make_section (abfd, name);
+ sect = bfd_make_section_anyway (abfd, name);
if (sect == NULL)
return FALSE;
@@ -6712,7 +6712,7 @@ elfcore_grok_win32pstatus (bfd *abfd, El
memcpy (name, buf, len);
- sect = bfd_make_section (abfd, name);
+ sect = bfd_make_section_anyway (abfd, name);
if (sect == NULL)
return FALSE;
@@ -6789,7 +6789,7 @@ elfcore_grok_note (bfd *abfd, Elf_Intern
case NT_AUXV:
{
- asection *sect = bfd_make_section (abfd, ".auxv");
+ asection *sect = bfd_make_section_anyway (abfd, ".auxv");
if (sect == NULL)
return FALSE;
@@ -6941,7 +6941,7 @@ elfcore_grok_nto_status (bfd *abfd, Elf_
return FALSE;
strcpy (name, buf);
- sect = bfd_make_section (abfd, name);
+ sect = bfd_make_section_anyway (abfd, name);
if (sect == NULL)
return FALSE;
@@ -6968,7 +6968,7 @@ elfcore_grok_nto_gregs (bfd *abfd, Elf_I
return FALSE;
strcpy (name, buf);
- sect = bfd_make_section (abfd, name);
+ sect = bfd_make_section_anyway (abfd, name);
if (sect == NULL)
return FALSE;
--
Alan Modra
IBM OzLabs - Linux Technology Centre
More information about the Binutils
mailing list