aboutsummaryrefslogtreecommitdiff
path: root/ld/emultempl
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2019-07-18 08:01:45 -0700
committerH.J. Lu <hjl.tools@gmail.com>2019-07-18 08:01:54 -0700
commit54d7dae59a2239720c848985a7d50a0a8b3319eb (patch)
treedf6fb11da6155641175b1840bf6b04df81779e50 /ld/emultempl
parent71c4e95abe66ec9fc2c064268e3f9640a5b951d8 (diff)
downloadfsf-binutils-gdb-54d7dae59a2239720c848985a7d50a0a8b3319eb.zip
fsf-binutils-gdb-54d7dae59a2239720c848985a7d50a0a8b3319eb.tar.gz
fsf-binutils-gdb-54d7dae59a2239720c848985a7d50a0a8b3319eb.tar.bz2
ld -r: Don't merge with member of output section group
When doing a relocatable link, members of input section group are placed in their own output sections. We need to make sure that no input sections are merged with member of output section group. PR ld/24819 * emultempl/elf32.em (elf_orphan_compatible): Return FALSE for member of output section group when doing a relocatable link. * testsuite/ld-elf/pr24819.d: New file. * testsuite/ld-elf/pr24819.s: Likewise.
Diffstat (limited to 'ld/emultempl')
-rw-r--r--ld/emultempl/elf32.em9
1 files changed, 6 insertions, 3 deletions
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 3e8ee46..f3c6e3a 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -2028,10 +2028,13 @@ elf_orphan_compatible (asection *in, asection *out)
if (elf_section_data (out)->this_hdr.sh_info
!= elf_section_data (in)->this_hdr.sh_info)
return FALSE;
- /* We can't merge two sections with differing SHF_EXCLUDE when doing
- a relocatable link. */
+ /* We can't merge with member of output section group nor merge two
+ sections with differing SHF_EXCLUDE when doing a relocatable link.
+ */
if (bfd_link_relocatable (&link_info)
- && ((elf_section_flags (out) ^ elf_section_flags (in)) & SHF_EXCLUDE) != 0)
+ && (elf_next_in_group (out) != NULL
+ || ((elf_section_flags (out) ^ elf_section_flags (in))
+ & SHF_EXCLUDE) != 0))
return FALSE;
return _bfd_elf_match_sections_by_type (link_info.output_bfd, out,
in->owner, in);