PR 34450 SEGV in elf_orphan_compatible
Alan Modra
amodra@gmail.com
Tue Sep 22 12:03:02 GMT 2026
Don't trust that SHF_LINK_ORDER set means linked_to is non-NULL.
* ldelf.c (elf_orphan_compatible): Sanity check linked_to before
dereferencing.
diff --git a/ld/ldelf.c b/ld/ldelf.c
index c1f29608c6d..0fe69784e08 100644
--- a/ld/ldelf.c
+++ b/ld/ldelf.c
@@ -2129,6 +2129,7 @@ elf_orphan_compatible (asection *in, asection *out)
|| ((elf_section_flags (in) & SHF_LINK_ORDER) != 0
&& (elf_section_flags (out) & SHF_LINK_ORDER) != 0
&& elf_linked_to_section (in) != NULL
+ && elf_linked_to_section (out) != NULL
&& (elf_linked_to_section (in)->output_section
!= elf_linked_to_section (out)->output_section))
|| ((elf_section_flags (out) ^ elf_section_flags (in))
--
Alan Modra
More information about the Binutils
mailing list