ld: Keep PREINIT_ARRAY/INIT_ARRAY/FINI_ARRAY sections for -r --gc-sections
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 11 Jan 2018 17:42:12 +0000 (09:42 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 11 Jan 2018 17:42:12 +0000 (09:42 -0800)
commit8b6f4cd34fdde524ea035c65f7d48aaa3fb449b5
treef2792cd8a1968d5db78c810fa7ae93874055f367
parent65f14869fd3fbee8ed4c4ca49de8aaa86dbc66cb
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.
bfd/ChangeLog
bfd/elflink.c
ld/ChangeLog
ld/scripttempl/elf.sc
ld/testsuite/ld-elf/pr22677.d [new file with mode: 0644]
ld/testsuite/ld-elf/pr22677.s [new file with mode: 0644]