aboutsummaryrefslogtreecommitdiff
path: root/ld/scripttempl
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2018-01-11 09:42:12 -0800
committerH.J. Lu <hjl.tools@gmail.com>2018-01-11 09:42:12 -0800
commit8b6f4cd34fdde524ea035c65f7d48aaa3fb449b5 (patch)
treef2792cd8a1968d5db78c810fa7ae93874055f367 /ld/scripttempl
parent65f14869fd3fbee8ed4c4ca49de8aaa86dbc66cb (diff)
downloadfsf-binutils-gdb-8b6f4cd34fdde524ea035c65f7d48aaa3fb449b5.zip
fsf-binutils-gdb-8b6f4cd34fdde524ea035c65f7d48aaa3fb449b5.tar.gz
fsf-binutils-gdb-8b6f4cd34fdde524ea035c65f7d48aaa3fb449b5.tar.bz2
ld: Keep PREINIT_ARRAY/INIT_ARRAY/FINI_ARRAY sections for -r --gc-sections
We must keep all PREINIT_ARRAY, INIT_ARRAY as well as FINI_ARRAY sections for ld -r --gc-sections. bfd/ PR ld/22677 * elflink.c (bfd_elf_gc_sections): Keep all PREINIT_ARRAY, INIT_ARRAY as well as FINI_ARRAY sections for ld -r --gc-sections. ld/ PR ld/22677 * scripttempl/elf.sc (PREINIT_ARRAY): New. Don't add .preinit_array for ld -r. * testsuite/ld-elf/pr22677.d: New file. * testsuite/ld-elf/pr22677.s: Likewise.
Diffstat (limited to 'ld/scripttempl')
-rw-r--r--ld/scripttempl/elf.sc13
1 files changed, 7 insertions, 6 deletions
diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc
index 3de86b0..139773d 100644
--- a/ld/scripttempl/elf.sc
+++ b/ld/scripttempl/elf.sc
@@ -245,6 +245,12 @@ test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS="
*(.ldata${RELOCATING+ .ldata.* .gnu.linkonce.l.*})
${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);}
}"
+PREINIT_ARRAY=".preinit_array ${RELOCATING-0} :
+ {
+ ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);}}
+ KEEP (*(.preinit_array))
+ ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);}}
+ }"
if test "${ENABLE_INITFINI_ARRAY}" = "yes"; then
SORT_INIT_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))"
SORT_FINI_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))"
@@ -568,12 +574,7 @@ cat <<EOF
.tdata ${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) }
.tbss ${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} }
- .preinit_array ${RELOCATING-0} :
- {
- ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);}}
- KEEP (*(.preinit_array))
- ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);}}
- }
+ ${RELOCATING+${PREINIT_ARRAY}}
${RELOCATING+${INIT_ARRAY}}
${RELOCATING+${FINI_ARRAY}}
${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}}