summaryrefslogtreecommitdiff
path: root/bfd/elfcode.h
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
commit9a1ae1cc87f5e628a2ff2eee969e2540af655218 (patch)
tree9c6762f593584c4185343d58587bdc6f0a6d5b21 /bfd/elfcode.h
parent55651f3bc393b3204e86ebbf776fff0332c21c8a (diff)
downloadbinutils-redhat-9a1ae1cc87f5e628a2ff2eee969e2540af655218.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.
Diffstat (limited to 'bfd/elfcode.h')
-rw-r--r--bfd/elfcode.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/bfd/elfcode.h b/bfd/elfcode.h
index f7f85ba205..9bb66e11c0 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. */