summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland McGrath <mcgrathr@google.com>2020-07-29 11:23:33 -0700
committerRoland McGrath <mcgrathr@google.com>2020-07-29 11:23:33 -0700
commit527d9364f989f088ba7a4dac68b1bdf317e3b026 (patch)
tree3ca93571aecad4fcfbccf69707f4eb78de378aa0
parent9811697376b3f1950419ab13b19e2995703b839b (diff)
downloadbinutils-gdb-users/roland/tolerant-elf_object_p.tar.gz
Don't let a single unrecognized ELF section break target matching.users/roland/tolerant-elf_object_p
bfd/ * elfcode.h (elf_object_p): Ignore errors from individual bfd_section_from_shdr calls so a novel section type appearing in the input doesn't break target-matching.
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elfcode.h7
2 files changed, 11 insertions, 2 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 8e8dc99c1aa..789f6cf233f 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2020-07-29 Roland McGrath <mcgrathr@google.com>
+
+ * elfcode.h (elf_object_p): Ignore errors from individual
+ bfd_section_from_shdr calls so a novel section type appearing in
+ the input doesn't break target-matching.
+
2020-07-29 Alan Modra <amodra@gmail.com>
* elflink.c (bfd_elf_final_link): Don't segfault on local dynsyms
diff --git a/bfd/elfcode.h b/bfd/elfcode.h
index 2e2c5343f2c..f65160ca38a 100644
--- a/bfd/elfcode.h
+++ b/bfd/elfcode.h
@@ -816,8 +816,11 @@ elf_object_p (bfd *abfd)
a dummy placeholder entry, so we ignore it. */
num_sec = elf_numsections (abfd);
for (shindex = 1; shindex < num_sec; shindex++)
- if (!bfd_section_from_shdr (abfd, shindex))
- goto got_no_match;
+ /* Ignore the return value here since an unrecognized section type
+ doesn't make the entire file unusable. The unrecognized section
+ simply won't be examined, and bfd_section_from_shdr will have
+ emitted an error message. */
+ bfd_section_from_shdr (abfd, shindex);
/* Set up ELF sections for SHF_GROUP and SHF_LINK_ORDER. */
if (! _bfd_elf_setup_sections (abfd))