[binutils-gdb] PR 33474 SEGV in init_reloc_cookie

Alan Modra amodra@sourceware.org
Mon Nov 24 21:33:57 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=500806dc2a341c0f2e36baf5a379a0b578b2ee2f

commit 500806dc2a341c0f2e36baf5a379a0b578b2ee2f
Author: Alan Modra <amodra@gmail.com>
Date:   Mon Nov 24 19:14:16 2025 +1030

    PR 33474 SEGV in init_reloc_cookie
    
    This segfault is triggered by a tekhex input.
    
            PR 33474
            * elflink.c (bfd_elf_gc_sections): Don't try to parse .eh_frame
            in non-ELF input files.

Diff:
---
 bfd/elflink.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/bfd/elflink.c b/bfd/elflink.c
index 60a0a0efd88..ec34c8abcf7 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -14649,6 +14649,8 @@ bfd_elf_gc_sections (bfd *abfd, struct bfd_link_info *info)
       asection *sec;
       struct elf_reloc_cookie cookie;
 
+      if (bfd_get_flavour (sub) != bfd_target_elf_flavour)
+	continue;
       sec = sub->sections;
       if (sec == NULL || sec->sec_info_type == SEC_INFO_TYPE_JUST_SYMS)
 	continue;


More information about the Binutils-cvs mailing list