ELF: Discard a section if any of its linked-to sections has been discarded
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 7 Feb 2020 03:42:52 +0000 (19:42 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 7 Feb 2020 03:43:03 +0000 (19:43 -0800)
commit9b538ba71fc7dbab65371e3e4e5f7e093ff25023
treeda4c23f9a303106a0a01e1770034cfbeb112825d
parent5242a0a000ad7d3f2fa1cd0023f692d53261b302
ELF: Discard a section if any of its linked-to sections has been discarded

Add ldelf_before_place_orphans to call before lang_place_orphans to
discard a section if any of its linked-to sections has been discarded.

PR ld/25022
* emultempl/aix.em (ld_${EMULATION_NAME}_emulation): Add
before_place_orphans_default.
* emultempl/armcoff.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/beos.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/generic.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/linux.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/msp430.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/pe.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/pep.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/ticoff.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/vanilla.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/elf.em (ld_${EMULATION_NAME}_emulation): Use
ldelf_before_place_orphans.
* ldelf.c (ldelf_before_place_orphans): New.
* ldelf.h (ldelf_before_place_orphans): Likewise.
* ldemul.c (ldemul_before_place_orphans): Likewise.
(before_place_orphans_default): Likewise.
* ldemul.h (ldemul_before_place_orphans): Likewise.
(before_place_orphans_default): Likewise.
(ld_emulation_xfer_struct): Add before_place_orphans.
* ldlang.c (lang_process): Call ldemul_before_place_orphans
before lang_place_orphans.
* testsuite/ld-elf/pr25022.d: New file.
* testsuite/ld-elf/pr25022.s: Likewise.
* testsuite/ld-elf/pr25022.t: Likewise.
20 files changed:
ld/ChangeLog
ld/emultempl/aix.em
ld/emultempl/armcoff.em
ld/emultempl/beos.em
ld/emultempl/elf.em
ld/emultempl/generic.em
ld/emultempl/linux.em
ld/emultempl/msp430.em
ld/emultempl/pe.em
ld/emultempl/pep.em
ld/emultempl/ticoff.em
ld/emultempl/vanilla.em
ld/ldelf.c
ld/ldelf.h
ld/ldemul.c
ld/ldemul.h
ld/ldlang.c
ld/testsuite/ld-elf/pr25022.d [new file with mode: 0644]
ld/testsuite/ld-elf/pr25022.s [new file with mode: 0644]
ld/testsuite/ld-elf/pr25022.t [new file with mode: 0644]