summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2006-04-18 09:41:36 +0000
committerNick Clifton <nickc@redhat.com>2006-04-18 09:41:36 +0000
commit27fdced1327ababc1ec95d4145a81f4b5dd319cb (patch)
treef10e9aee5415fd44c93ef8abaf68fed803b0e4b9
parent9cce55acda9c3dba2aad3e962a921bb1632496f0 (diff)
downloadgdb-27fdced1327ababc1ec95d4145a81f4b5dd319cb.tar.gz
PR 2257
* elfcode.h (elf_object_p): Allow files with corrupt e_shstrndx fields to still be handled as ELF files. * readelf.c (SECTION_NAME): Cope with a missing string table. (process_file_header): Cope with a corrupt e_shstrndx field. (process_section_headers): Correctly handle an e_shstrndx value of SHF_UNDEF.
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elfcode.h13
2 files changed, 17 insertions, 2 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index d6069baafbc..2938fa0fe45 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2006-04-18 Nick Clifton <nickc@redhat.com>
+
+ PR 2257
+ * elfcode.h (elf_object_p): Allow files with corrupt e_shstrndx
+ fields to still be handled as ELF files.
+
2006-04-16 Daniel Jacobowitz <dan@codesourcery.com>
* po/SRC-POTFILES.in: Regenerated.
diff --git a/bfd/elfcode.h b/bfd/elfcode.h
index f7f85ba2056..9bb66e11c0c 100644
--- a/bfd/elfcode.h
+++ b/bfd/elfcode.h
@@ -742,9 +742,18 @@ elf_object_p (bfd *abfd)
if (i_ehdrp->e_shstrndx >= elf_numsections (abfd)
|| (i_ehdrp->e_shstrndx >= SHN_LORESERVE
&& i_ehdrp->e_shstrndx <= SHN_HIRESERVE))
- goto got_wrong_format_error;
+ {
+ /* PR 2257:
+ We used to just goto got_wrong_format_error here
+ but there are binaries in existance for which this test
+ will prevent the binutils from working with them at all.
+ So we are kind, and reset the string index value to 0
+ so that at least some processing can be done. */
+ i_ehdrp->e_shstrndx = SHN_UNDEF;
+ _bfd_error_handler (_("warning: %s has a corrupt string table index - ignoring"), abfd->filename);
+ }
}
- else if (i_ehdrp->e_shstrndx != 0)
+ else if (i_ehdrp->e_shstrndx != SHN_UNDEF)
goto got_wrong_format_error;
/* Read in the program headers. */