bfd/ELF: Skip the old note segment in illumos core file
Commit Message
On GDB I see problems with reading core files written on illumos (checked distros OmniosCE and Openindiana).
I could find out that the reason is the ancient structure of the illumos core files, which still contains an 2 decades old notes segment AND an new note segment. The proposed fix here is to skip the notes0 segment with the old proc content. The current core file content is described here:
https://www.illumos.org/man/5/core The proposed fix skips the notes0 segment. I tested this on GDB 16.3 source.
I do not know if the name "CORE" is still used by other OS's. So I still test for the name "CORE" and if there the content type NT_PRPSINFO exit the loop. Solaris 11.4 has removed the old segment already:
https://docs.oracle.com/cd/E88353_01/html/E37852/core-5.html says "Prior to Oracle Solaris 11.4, a core file contained two NOTE sections, the extra one containing structures defined in the obsolete <sys/old_procfs.h> header file for the old ioctl()-based /proc interface. Programs should recognize and skip this old NOTE segment. It can be recognized by the presence of entries with entry name "CORE" and with these note types:" More details was discussed first on
https://sourceware.org/bugzilla/show_bug.cgi?id=33258
do not evaluate the old core file note0 segment
@@ -11991,6 +11991,9 @@ elfcore_grok_solaris_note_impl (bfd *abfd, Elf_Internal_Note *note)
static bool
elfcore_grok_solaris_note (bfd *abfd, Elf_Internal_Note *note)
{
+ /* ignore the old note segment */
+ if (note->type == NT_PRPSINFO)
+ return true;
if (!elfcore_grok_solaris_note_impl (abfd, note))
return false;
@@ -13290,6 +13290,9 @@ elf_parse_notes (bfd *abfd, char *buf, size_t size, file_ptr offset,
{
if (! grokers[i].func (abfd, & in))
return false;
+ /* ignore the old note segment */
+ if ((grokers[i].func == elfcore_grok_solaris_note) && (in.type == NT_PRPSINFO))
+ p = buf + size;
break;
}
}