From 527d9364f989f088ba7a4dac68b1bdf317e3b026 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 29 Jul 2020 11:23:33 -0700 Subject: Don't let a single unrecognized ELF section break target matching. 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. --- bfd/ChangeLog | 6 ++++++ bfd/elfcode.h | 7 +++++-- 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 + + * 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 * 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)) -- cgit v1.2.1