aboutsummaryrefslogtreecommitdiff
path: root/ld/ldelf.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2023-08-30 10:24:56 -0700
committerH.J. Lu <hjl.tools@gmail.com>2023-08-30 17:17:31 -0700
commit68a2d9bf874643da970fe945a9c60c397f6882ad (patch)
tree60eaddb169ea2d0e6e51cdcfc05b3e8200fefc8c /ld/ldelf.c
parentbac5753ca24bbbd601b6be93faa40e9458d8baa5 (diff)
downloadgdb-68a2d9bf874643da970fe945a9c60c397f6882ad.zip
gdb-68a2d9bf874643da970fe945a9c60c397f6882ad.tar.gz
gdb-68a2d9bf874643da970fe945a9c60c397f6882ad.tar.bz2
elf: Don't merge sections with different SHF_LINK_ORDER
For relocatable link, don't merge 2 SHF_LINK_ORDER sections if output sections of their linked to sections are different. * ldelf.c (elf_orphan_compatible): Don't merge sections with different SHF_LINK_ORDER. * testsuite/ld-elf/pr30791a.d: New file. * testsuite/ld-elf/pr30791a.s: Likewise. * testsuite/ld-elf/pr30791b.d: Likewise. * testsuite/ld-elf/pr30791b.s: Likewise. * testsuite/ld-elf/pr30791c.s: Likewise. * testsuite/ld-elf/pr30791d.s: Likewise.
Diffstat (limited to 'ld/ldelf.c')
-rw-r--r--ld/ldelf.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/ld/ldelf.c b/ld/ldelf.c
index 4212075..d74354a 100644
--- a/ld/ldelf.c
+++ b/ld/ldelf.c
@@ -2080,9 +2080,14 @@ elf_orphan_compatible (asection *in, asection *out)
return false;
/* We can't merge with a member of an output section group or merge
two sections with differing SHF_EXCLUDE or other processor and OS
- specific flags when doing a relocatable link. */
+ specific flags or with different SHF_LINK_ORDER when doing a
+ relocatable link. */
if (bfd_link_relocatable (&link_info)
&& (elf_next_in_group (out) != NULL
+ || ((elf_section_flags (in) & SHF_LINK_ORDER) != 0
+ && (elf_section_flags (out) & SHF_LINK_ORDER) != 0
+ && (elf_linked_to_section (in)->output_section
+ != elf_linked_to_section (out)->output_section))
|| ((elf_section_flags (out) ^ elf_section_flags (in))
& (SHF_MASKPROC | SHF_MASKOS)) != 0))
return false;