PR 33474 SEGV in init_reloc_cookie

Alan Modra amodra@gmail.com
Mon Nov 24 11:27:02 GMT 2025


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 --git a/bfd/elflink.c b/bfd/elflink.c
index 81e4ee3da69..2a7e9a7ec21 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -14655,6 +14655,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;

-- 
Alan Modra


More information about the Binutils mailing list