aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2022-12-20 23:47:03 +1030
committerAlan Modra <amodra@gmail.com>2022-12-21 17:55:34 +1030
commit8f2c64de86bc3d7556121fe296dd679000283931 (patch)
treea327022ff9118436e4629396e2752513d2202f2c /bfd
parent8df77a27a3a329ba7c1611f4dbbc32f39d4734bb (diff)
downloadfsf-binutils-gdb-8f2c64de86bc3d7556121fe296dd679000283931.zip
fsf-binutils-gdb-8f2c64de86bc3d7556121fe296dd679000283931.tar.gz
fsf-binutils-gdb-8f2c64de86bc3d7556121fe296dd679000283931.tar.bz2
PR29922, SHT_NOBITS section avoids section size sanity check
PR 29922 * dwarf2.c (find_debug_info): Ignore sections without SEC_HAS_CONTENTS.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/dwarf2.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index 95f4570..0cd8152 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -4831,16 +4831,19 @@ find_debug_info (bfd *abfd, const struct dwarf_debug_section *debug_sections,
{
look = debug_sections[debug_info].uncompressed_name;
msec = bfd_get_section_by_name (abfd, look);
- if (msec != NULL)
+ /* Testing SEC_HAS_CONTENTS is an anti-fuzzer measure. Of
+ course debug sections always have contents. */
+ if (msec != NULL && (msec->flags & SEC_HAS_CONTENTS) != 0)
return msec;
look = debug_sections[debug_info].compressed_name;
msec = bfd_get_section_by_name (abfd, look);
- if (msec != NULL)
+ if (msec != NULL && (msec->flags & SEC_HAS_CONTENTS) != 0)
return msec;
for (msec = abfd->sections; msec != NULL; msec = msec->next)
- if (startswith (msec->name, GNU_LINKONCE_INFO))
+ if ((msec->flags & SEC_HAS_CONTENTS) != 0
+ && startswith (msec->name, GNU_LINKONCE_INFO))
return msec;
return NULL;
@@ -4848,6 +4851,9 @@ find_debug_info (bfd *abfd, const struct dwarf_debug_section *debug_sections,
for (msec = after_sec->next; msec != NULL; msec = msec->next)
{
+ if ((msec->flags & SEC_HAS_CONTENTS) == 0)
+ continue;
+
look = debug_sections[debug_info].uncompressed_name;
if (strcmp (msec->name, look) == 0)
return msec;