aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2025-09-09 18:32:09 +0930
committerAlan Modra <amodra@gmail.com>2025-09-09 18:55:26 +0930
commitf87a66db645caf8cc0e6fc87b0c28c78a38af59b (patch)
tree5923b223cfca35da3abc357b495d5a2a1120ff44
parent3ac272c1f115da7bfbb872bf7ad9aa72f42e0c01 (diff)
downloadbinutils-f87a66db645caf8cc0e6fc87b0c28c78a38af59b.zip
binutils-f87a66db645caf8cc0e6fc87b0c28c78a38af59b.tar.gz
binutils-f87a66db645caf8cc0e6fc87b0c28c78a38af59b.tar.bz2
PR 33406 SEGV in dump_dwarf_section
Trying to dump .sframe in a PE file results in a segfault accessing elf_section_data. * objdump (dump_sframe_section, dump_dwarf_section): Don't access elf_section_type without first checking the file is ELF.
-rw-r--r--binutils/objdump.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/binutils/objdump.c b/binutils/objdump.c
index 290f7e5..ee8823d 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -4485,7 +4485,8 @@ dump_dwarf_section (bfd *abfd, asection *section,
else
match = name;
- if (elf_section_type (section) == SHT_GNU_SFRAME)
+ if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
+ && elf_section_type (section) == SHT_GNU_SFRAME)
match = ".sframe";
for (i = 0; i < max; i++)
@@ -4993,9 +4994,10 @@ dump_sframe_section (bfd *abfd, const char *sect_name, bool is_mainfile)
SHT_GNU_SFRAME. For SFrame sections from Binutils 2.44 or earlier,
check explcitly for SFrame sections of type SHT_PROGBITS and name
".sframe" to allow them. */
- else if (elf_section_type (sec) != SHT_GNU_SFRAME
- && !(elf_section_type (sec) == SHT_PROGBITS
- && strcmp (sect_name, ".sframe") == 0))
+ else if (bfd_get_flavour (abfd) != bfd_target_elf_flavour
+ || (elf_section_type (sec) != SHT_GNU_SFRAME
+ && !(elf_section_type (sec) == SHT_PROGBITS
+ && strcmp (sect_name, ".sframe") == 0)))
{
printf (_("Section %s does not contain SFrame data\n\n"),
sanitize_string (sect_name));