aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2017-10-16 03:49:54 -0700
committerH.J. Lu <hjl.tools@gmail.com>2017-10-16 03:50:13 -0700
commit5c3261b0e834647cf9eb555320e20871b7854f98 (patch)
tree16de4f57b1d4ff511e632f97bda5e365e7f84a3e /ld
parent5bfda25568c34410129c91042cdfdf10c143edac (diff)
downloadgdb-5c3261b0e834647cf9eb555320e20871b7854f98.zip
gdb-5c3261b0e834647cf9eb555320e20871b7854f98.tar.gz
gdb-5c3261b0e834647cf9eb555320e20871b7854f98.tar.bz2
ELF: Call check_relocs after opening all inputs
For all ELF targers, call check_relocs after opening all inputs and garbage collection. Since the symbol resolution is known, check_relocs can be simplified. Also garbage collection doesn't need to undo what check_relocs has done for symbols which have been garbage collected. Since ELF targets never see the removed sections, gc_sweep_hook can be removed from elf_backend_data and we can avoid GOT/PLT with garbage collection now. Set link_info.check_relocs_after_open_input to TRUE for all linker targets which use ELF linker and update garbage collection tests to remove unused GOT section. ldemul_after_check_relocs is added for powerpc to support --secure-plt, --bss-plt and --sdata-got. Tested natively without regressions on i686, x86-64 and x32. Tested cross binutils on x86-64 without regressions for aarch64-linux, alpha-linux, arm-linux, bfin-elf, cr16-elf, cris-elf, crx-elf, frv-linux, hppa64-linux, hppa-linux, ia64-linux, lm32-elf, m32r-elf, m68k-linux, mcore-elf, metag-elf, microblaze-linux, mips-linux, mmix, mn10300-elf, nds32le-linux, nios2-linux, or1k-elf, powerpc64-linux, powerpc-linux, riscv32-linux, riscv64-linux, s390-linux, s390x-linux, score-elf, sh3-linux, sparc64-linux, sparc-linux, tic6x-elf, tilegx-linux, tilepro-linux, vax-linux, x86_64-mingw32 and xtensa-linux. bfd/ * elf-bfd.h (elf_backend_data): Remove gc_sweep_hook. * elf32-arm.c (elf32_arm_gc_sweep_hook): Removed. (elf_backend_gc_sweep_hook): Likewise. * elf32-bfin.c (bfin_gc_sweep_hook): Likewise. (bfinfdpic_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-cr16.c (elf32_cr16_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-cris.c (cris_elf_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-lm32.c (lm32_elf_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-m68k.c (elf_m68k_got_entry): Remove elf_m68k_gc_sweep_hook from comments. (elf_m68k_remove_got_entry_type): Removed. (elf_m68k_find_got_entry_ptr): Likewise. (elf_m68k_remove_got_entry): Likewise. (elf_m68k_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-metag.c (elf_metag_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-microblaze.c (elf_backend_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-mips.c (elf_backend_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-nds32.c (nds32_elf_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-nios2.c (nios2_elf32_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-or1k.c (or1k_elf_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-s390.c (elf_s390_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-sparc.c (elf_backend_gc_sweep_hook): Likewise. * elf32-tic6x.c (elf32_tic6x_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-tilegx.c (elf_backend_gc_sweep_hook): Likewise. * elf32-tilepro.c (tilepro_elf_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-vax.c (elf_vax_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-xtensa.c (elf_xtensa_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf64-alpha.c (elf64_alpha_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf64-mips.c (elf_backend_gc_sweep_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf64-ppc.c (elf_backend_gc_sweep_hook): Likewise. (ppc64_elf_gc_sweep_hook): Likewise. * elf64-s390.c (elf_s390_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf64-sparc.c (elf_backend_gc_sweep_hook): Likewise. * elf64-tilegx.c (elf_backend_gc_sweep_hook): Likewise. * elflink.c (elf_link_add_object_symbols): Don't call _bfd_elf_link_check_relocs here. (gc_sweep_hook_fn): Removed. (elf_gc_sweep): Remove gc_sweep_hook. * elfnn-aarch64.c (elfNN_aarch64_gc_sweep_hook): Removed. (elf_backend_gc_sweep_hook): Likewise. * elfnn-riscv.c (riscv_elf_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elfxx-mips.c (_bfd_mips_elf_gc_sweep_hook): Likewise. * elfxx-mips.h (_bfd_mips_elf_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elfxx-sparc.c (_bfd_sparc_elf_gc_sweep_hook): Likewise. * elfxx-sparc.h (_bfd_sparc_elf_gc_sweep_hook): Likewise. * elfxx-target.h (elf_backend_gc_sweep_hook): Likewise. (elfNN_bed): Remove elf_backend_gc_sweep_hook. * elfxx-tilegx.c (tilegx_elf_gc_sweep_hook): Removed. * elfxx-tilegx.h (tilegx_elf_gc_sweep_hook): Likewise. ld/ * emulparams/elf32_x86_64.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Removed. * emulparams/elf_i386_be.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/elf_i386_chaos.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/elf_i386_ldso.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/elf_i386_vxworks.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/elf_iamcu.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/elf_k1om.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/elf_l1om.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/elf_x86_64.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/i386lynx.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/i386moss.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/i386nto.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/i386nw.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/shelf.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/shelf32.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/shelf_nto.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/shelf_vxworks.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/shlelf32_linux.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/shlelf_linux.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/shlelf_nto.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emultempl/aarch64elf.em (gld${EMULATION_NAME}_before_parse): Set link_info.check_relocs_after_open_input to TRUE. * emultempl/armelf.em (gld${EMULATION_NAME}_before_parse): Likewise. * emultempl/scoreelf.em (gld${EMULATION_NAME}_before_parse): Likewise. * emultempl/aix.em (ld_${EMULATION_NAME}_emulation): Add after_parse_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/gld960.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/gld960c.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/lnk960.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/m68kcoff.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/sunos.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/ticoff.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/vanilla.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/elf32.em (gld${EMULATION_NAME}_before_parse): Always set link_info.check_relocs_after_open_input to TRUE. (ld_${EMULATION_NAME}_emulation): Add $LDEMUL_AFTER_CHECK_RELOCS. * emultempl/linux.em (gld${EMULATION_NAME}_before_parse): Set link_info.check_relocs_after_open_input to TRUE. (ld_${EMULATION_NAME}_emulation): Add after_check_relocs_default. * emultempl/mmix-elfnmmo.em (mmix_before_parse): New function. (LDEMUL_BEFORE_PARSE): New. * emultempl/mmixelf.em (elfmmix_before_parse): Replace gld${EMULATION_NAME}_before_parse with mmix_before_parse. * emultempl/ppc32elf.em (ppc_after_open): Renamed to ... (ppc_after_check_relocs): This. Call after_check_relocs_default instead of gld${EMULATION_NAME}_after_open. (LDEMUL_AFTER_OPEN): Removed. (LDEMUL_AFTER_CHECK_RELOCS): New. * ldemul.c (ldemul_after_check_relocs): New. (after_check_relocs_default): Likewise. * ldemul.h (ldemul_after_check_relocs): Likewise. (after_check_relocs_default): Likewise. (ld_emulation_xfer_struct): Add after_check_relocs. * ldlang.c (lang_process): Call ldemul_after_check_relocs after lang_check_relocs. * testsuite/ld-aarch64/gc-got-relocs.d: Don't expect GOT section. * testsuite/ld-aarch64/gc-tls-relocs.d: Likewise. * testsuite/ld-cris/tls-gc-68.d: Likewise. * testsuite/ld-cris/tls-gc-69.d: Likewise. * testsuite/ld-cris/tls-gc-70.d: Likewise. * testsuite/ld-cris/tls-gc-75.d: Likewise. * testsuite/ld-cris/tls-gc-79.d: Likewise. * testsuite/ld-mmix/bpo-10.d: Don't expect .MMIX.reg_contents section.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog95
-rw-r--r--ld/emulparams/elf32_x86_64.sh1
-rw-r--r--ld/emulparams/elf_i386.sh1
-rw-r--r--ld/emulparams/elf_i386_be.sh1
-rw-r--r--ld/emulparams/elf_i386_chaos.sh1
-rw-r--r--ld/emulparams/elf_i386_ldso.sh1
-rw-r--r--ld/emulparams/elf_i386_vxworks.sh1
-rw-r--r--ld/emulparams/elf_iamcu.sh1
-rw-r--r--ld/emulparams/elf_k1om.sh1
-rw-r--r--ld/emulparams/elf_l1om.sh1
-rw-r--r--ld/emulparams/elf_x86_64.sh1
-rw-r--r--ld/emulparams/i386lynx.sh1
-rw-r--r--ld/emulparams/i386moss.sh1
-rw-r--r--ld/emulparams/i386nto.sh1
-rw-r--r--ld/emulparams/i386nw.sh1
-rw-r--r--ld/emulparams/shelf.sh4
-rw-r--r--ld/emulparams/shelf32.sh3
-rw-r--r--ld/emulparams/shelf_nto.sh3
-rw-r--r--ld/emulparams/shelf_vxworks.sh3
-rw-r--r--ld/emulparams/shlelf32_linux.sh3
-rw-r--r--ld/emulparams/shlelf_linux.sh3
-rw-r--r--ld/emulparams/shlelf_nto.sh3
-rw-r--r--ld/emultempl/aarch64elf.em1
-rw-r--r--ld/emultempl/aix.em1
-rw-r--r--ld/emultempl/armcoff.em1
-rw-r--r--ld/emultempl/armelf.em1
-rw-r--r--ld/emultempl/beos.em1
-rw-r--r--ld/emultempl/elf32.em3
-rw-r--r--ld/emultempl/generic.em1
-rw-r--r--ld/emultempl/gld960.em1
-rw-r--r--ld/emultempl/gld960c.em1
-rw-r--r--ld/emultempl/linux.em2
-rw-r--r--ld/emultempl/lnk960.em1
-rw-r--r--ld/emultempl/m68kcoff.em1
-rw-r--r--ld/emultempl/mmix-elfnmmo.em10
-rw-r--r--ld/emultempl/mmixelf.em2
-rw-r--r--ld/emultempl/msp430.em1
-rw-r--r--ld/emultempl/pe.em1
-rw-r--r--ld/emultempl/pep.em1
-rw-r--r--ld/emultempl/ppc32elf.em6
-rw-r--r--ld/emultempl/scoreelf.em1
-rw-r--r--ld/emultempl/sunos.em1
-rw-r--r--ld/emultempl/ticoff.em1
-rw-r--r--ld/emultempl/vanilla.em1
-rw-r--r--ld/ldemul.c11
-rw-r--r--ld/ldemul.h7
-rw-r--r--ld/ldlang.c2
-rw-r--r--ld/testsuite/ld-aarch64/gc-got-relocs.d10
-rw-r--r--ld/testsuite/ld-aarch64/gc-tls-relocs.d10
-rw-r--r--ld/testsuite/ld-cris/tls-gc-68.d22
-rw-r--r--ld/testsuite/ld-cris/tls-gc-69.d22
-rw-r--r--ld/testsuite/ld-cris/tls-gc-70.d23
-rw-r--r--ld/testsuite/ld-cris/tls-gc-75.d22
-rw-r--r--ld/testsuite/ld-cris/tls-gc-79.d23
-rw-r--r--ld/testsuite/ld-mmix/bpo-10.d1
55 files changed, 194 insertions, 130 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 6e7e58d..4fbf6ba 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,98 @@
+2017-10-16 H.J. Lu <hongjiu.lu@intel.com>
+
+ * emulparams/elf32_x86_64.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
+ Removed.
+ * emulparams/elf_i386_be.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
+ Likewise.
+ * emulparams/elf_i386_chaos.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
+ Likewise.
+ * emulparams/elf_i386_ldso.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
+ Likewise.
+ * emulparams/elf_i386_vxworks.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
+ Likewise.
+ * emulparams/elf_iamcu.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
+ Likewise.
+ * emulparams/elf_k1om.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
+ Likewise.
+ * emulparams/elf_l1om.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
+ Likewise.
+ * emulparams/elf_x86_64.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
+ Likewise.
+ * emulparams/i386lynx.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
+ Likewise.
+ * emulparams/i386moss.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
+ Likewise.
+ * emulparams/i386nto.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
+ Likewise.
+ * emulparams/i386nw.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
+ Likewise.
+ * emulparams/shelf.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
+ Likewise.
+ * emulparams/shelf32.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
+ Likewise.
+ * emulparams/shelf_nto.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
+ Likewise.
+ * emulparams/shelf_vxworks.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
+ Likewise.
+ * emulparams/shlelf32_linux.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
+ Likewise.
+ * emulparams/shlelf_linux.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
+ Likewise.
+ * emulparams/shlelf_nto.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
+ Likewise.
+ * emultempl/aarch64elf.em (gld${EMULATION_NAME}_before_parse):
+ Set link_info.check_relocs_after_open_input to TRUE.
+ * emultempl/armelf.em (gld${EMULATION_NAME}_before_parse):
+ Likewise.
+ * emultempl/scoreelf.em (gld${EMULATION_NAME}_before_parse):
+ Likewise.
+ * emultempl/aix.em (ld_${EMULATION_NAME}_emulation): Add
+ after_parse_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/gld960.em (ld_${EMULATION_NAME}_emulation): Likewise.
+ * emultempl/gld960c.em (ld_${EMULATION_NAME}_emulation): Likewise.
+ * emultempl/lnk960.em (ld_${EMULATION_NAME}_emulation): Likewise.
+ * emultempl/m68kcoff.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/sunos.em (ld_${EMULATION_NAME}_emulation): Likewise.
+ * emultempl/ticoff.em (ld_${EMULATION_NAME}_emulation): Likewise.
+ * emultempl/vanilla.em (ld_${EMULATION_NAME}_emulation): Likewise.
+ * emultempl/elf32.em (gld${EMULATION_NAME}_before_parse): Always
+ set link_info.check_relocs_after_open_input to TRUE.
+ (ld_${EMULATION_NAME}_emulation): Add $LDEMUL_AFTER_CHECK_RELOCS.
+ * emultempl/linux.em (gld${EMULATION_NAME}_before_parse):
+ Set link_info.check_relocs_after_open_input to TRUE.
+ (ld_${EMULATION_NAME}_emulation): Add after_check_relocs_default.
+ * emultempl/mmix-elfnmmo.em (mmix_before_parse): New function.
+ (LDEMUL_BEFORE_PARSE): New.
+ * emultempl/mmixelf.em (elfmmix_before_parse): Replace
+ gld${EMULATION_NAME}_before_parse with mmix_before_parse.
+ * emultempl/ppc32elf.em (ppc_after_open): Renamed to ...
+ (ppc_after_check_relocs): This. Call after_check_relocs_default
+ instead of gld${EMULATION_NAME}_after_open.
+ (LDEMUL_AFTER_OPEN): Removed.
+ (LDEMUL_AFTER_CHECK_RELOCS): New.
+ * ldemul.c (ldemul_after_check_relocs): New.
+ (after_check_relocs_default): Likewise.
+ * ldemul.h (ldemul_after_check_relocs): Likewise.
+ (after_check_relocs_default): Likewise.
+ (ld_emulation_xfer_struct): Add after_check_relocs.
+ * ldlang.c (lang_process): Call ldemul_after_check_relocs after
+ lang_check_relocs.
+ * testsuite/ld-aarch64/gc-got-relocs.d: Don't expect GOT section.
+ * testsuite/ld-aarch64/gc-tls-relocs.d: Likewise.
+ * testsuite/ld-cris/tls-gc-68.d: Likewise.
+ * testsuite/ld-cris/tls-gc-69.d: Likewise.
+ * testsuite/ld-cris/tls-gc-70.d: Likewise.
+ * testsuite/ld-cris/tls-gc-75.d: Likewise.
+ * testsuite/ld-cris/tls-gc-79.d: Likewise.
+ * testsuite/ld-mmix/bpo-10.d: Don't expect .MMIX.reg_contents
+ section.
+
2017-10-14 H.J. Lu <hongjiu.lu@intel.com>
PR ld/22269
diff --git a/ld/emulparams/elf32_x86_64.sh b/ld/emulparams/elf32_x86_64.sh
index a7f16b1..03f9d83 100644
--- a/ld/emulparams/elf32_x86_64.sh
+++ b/ld/emulparams/elf32_x86_64.sh
@@ -7,7 +7,6 @@
SCRIPT_NAME=elf
ELFSIZE=32
OUTPUT_FORMAT="elf32-x86-64"
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
NO_REL_RELOCS=yes
TEXT_START_ADDR=0x400000
MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
diff --git a/ld/emulparams/elf_i386.sh b/ld/emulparams/elf_i386.sh
index 6997d40..084497c 100644
--- a/ld/emulparams/elf_i386.sh
+++ b/ld/emulparams/elf_i386.sh
@@ -5,7 +5,6 @@
. ${srcdir}/emulparams/cet.sh
SCRIPT_NAME=elf
OUTPUT_FORMAT="elf32-i386"
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
NO_RELA_RELOCS=yes
TEXT_START_ADDR=0x08048000
MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
diff --git a/ld/emulparams/elf_i386_be.sh b/ld/emulparams/elf_i386_be.sh
index 4a24b02..70db443 100644
--- a/ld/emulparams/elf_i386_be.sh
+++ b/ld/emulparams/elf_i386_be.sh
@@ -3,7 +3,6 @@
. ${srcdir}/emulparams/call_nop.sh
SCRIPT_NAME=elf
OUTPUT_FORMAT="elf32-i386"
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
NO_RELA_RELOCS=yes
TEXT_START_ADDR=0x80000000
MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
diff --git a/ld/emulparams/elf_i386_chaos.sh b/ld/emulparams/elf_i386_chaos.sh
index 5349108..aa36cb5 100644
--- a/ld/emulparams/elf_i386_chaos.sh
+++ b/ld/emulparams/elf_i386_chaos.sh
@@ -4,7 +4,6 @@
. ${srcdir}/emulparams/call_nop.sh
SCRIPT_NAME=elf_chaos
OUTPUT_FORMAT="elf32-i386"
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
TEXT_START_ADDR=0x40000000
MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
ARCH=i386
diff --git a/ld/emulparams/elf_i386_ldso.sh b/ld/emulparams/elf_i386_ldso.sh
index dc4eef4..1328520 100644
--- a/ld/emulparams/elf_i386_ldso.sh
+++ b/ld/emulparams/elf_i386_ldso.sh
@@ -4,7 +4,6 @@
. ${srcdir}/emulparams/call_nop.sh
SCRIPT_NAME=elf
OUTPUT_FORMAT="elf32-i386"
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
NO_RELA_RELOCS=yes
TEXT_START_ADDR=0x08048000
MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
diff --git a/ld/emulparams/elf_i386_vxworks.sh b/ld/emulparams/elf_i386_vxworks.sh
index ac1bbeb..aaea8c4 100644
--- a/ld/emulparams/elf_i386_vxworks.sh
+++ b/ld/emulparams/elf_i386_vxworks.sh
@@ -1,6 +1,5 @@
SCRIPT_NAME=elf
OUTPUT_FORMAT="elf32-i386-vxworks"
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
NO_RELA_RELOCS=yes
TEXT_START_ADDR=0x08048000
MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
diff --git a/ld/emulparams/elf_iamcu.sh b/ld/emulparams/elf_iamcu.sh
index 45953e7..863027b 100644
--- a/ld/emulparams/elf_iamcu.sh
+++ b/ld/emulparams/elf_iamcu.sh
@@ -4,7 +4,6 @@
. ${srcdir}/emulparams/call_nop.sh
SCRIPT_NAME=elf
OUTPUT_FORMAT="elf32-iamcu"
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
NO_RELA_RELOCS=yes
TEXT_START_ADDR=0x08048000
MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
diff --git a/ld/emulparams/elf_k1om.sh b/ld/emulparams/elf_k1om.sh
index 828c10e..494efcc 100644
--- a/ld/emulparams/elf_k1om.sh
+++ b/ld/emulparams/elf_k1om.sh
@@ -5,7 +5,6 @@
SCRIPT_NAME=elf
ELFSIZE=64
OUTPUT_FORMAT="elf64-k1om"
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
NO_REL_RELOCS=yes
TEXT_START_ADDR=0x400000
MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
diff --git a/ld/emulparams/elf_l1om.sh b/ld/emulparams/elf_l1om.sh
index 9c59dc0..b115879 100644
--- a/ld/emulparams/elf_l1om.sh
+++ b/ld/emulparams/elf_l1om.sh
@@ -5,7 +5,6 @@
SCRIPT_NAME=elf
ELFSIZE=64
OUTPUT_FORMAT="elf64-l1om"
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
NO_REL_RELOCS=yes
TEXT_START_ADDR=0x400000
MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
diff --git a/ld/emulparams/elf_x86_64.sh b/ld/emulparams/elf_x86_64.sh
index c678479..09f3cda 100644
--- a/ld/emulparams/elf_x86_64.sh
+++ b/ld/emulparams/elf_x86_64.sh
@@ -7,7 +7,6 @@
SCRIPT_NAME=elf
ELFSIZE=64
OUTPUT_FORMAT="elf64-x86-64"
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
NO_REL_RELOCS=yes
TEXT_START_ADDR=0x400000
MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
diff --git a/ld/emulparams/i386lynx.sh b/ld/emulparams/i386lynx.sh
index 12bc7da..93afb3d 100644
--- a/ld/emulparams/i386lynx.sh
+++ b/ld/emulparams/i386lynx.sh
@@ -1,6 +1,5 @@
SCRIPT_NAME=elf
OUTPUT_FORMAT="elf32-i386"
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
NO_RELA_RELOCS=yes
ENTRY=_main
TEXT_BASE=0x0
diff --git a/ld/emulparams/i386moss.sh b/ld/emulparams/i386moss.sh
index bffef86..095d85a 100644
--- a/ld/emulparams/i386moss.sh
+++ b/ld/emulparams/i386moss.sh
@@ -1,6 +1,5 @@
SCRIPT_NAME=elf
OUTPUT_FORMAT="elf32-i386"
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
NO_RELA_RELOCS=yes
TEXT_START_ADDR=0x00002000
MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
diff --git a/ld/emulparams/i386nto.sh b/ld/emulparams/i386nto.sh
index 51284be..626f9c1 100644
--- a/ld/emulparams/i386nto.sh
+++ b/ld/emulparams/i386nto.sh
@@ -1,6 +1,5 @@
SCRIPT_NAME=elf
OUTPUT_FORMAT="elf32-i386"
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
NO_RELA_RELOCS=yes
TEXT_START_ADDR=0x08048000
TEXT_START_SYMBOLS='_btext = .;'
diff --git a/ld/emulparams/i386nw.sh b/ld/emulparams/i386nw.sh
index e6397f6..e1897be 100644
--- a/ld/emulparams/i386nw.sh
+++ b/ld/emulparams/i386nw.sh
@@ -1,6 +1,5 @@
SCRIPT_NAME=nw
OUTPUT_FORMAT="elf32-i386"
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
TEXT_START_ADDR=0x08000000
MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
ARCH=i386
diff --git a/ld/emulparams/shelf.sh b/ld/emulparams/shelf.sh
index 8d79b8d..5b34319 100644
--- a/ld/emulparams/shelf.sh
+++ b/ld/emulparams/shelf.sh
@@ -11,10 +11,6 @@ MACHINE=
TEMPLATE_NAME=elf32
GENERATE_SHLIB_SCRIPT=yes
EMBEDDED=yes
-# PR 17739. Delay checking relocs until after all files have
-# been opened and linker garbage collection has taken place.
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
-
# These are for compatibility with the COFF toolchain.
ENTRY=start
CTOR_START='___ctors = .;'
diff --git a/ld/emulparams/shelf32.sh b/ld/emulparams/shelf32.sh
index 7f46407..3fc9a3e 100644
--- a/ld/emulparams/shelf32.sh
+++ b/ld/emulparams/shelf32.sh
@@ -11,9 +11,6 @@ ALIGNMENT=8
TEMPLATE_NAME=elf32
GENERATE_SHLIB_SCRIPT=yes
EMBEDDED=yes
-# PR 17739. Delay checking relocs until after all files have
-# been opened and linker garbage collection has taken place.
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
DATA_START_SYMBOLS='PROVIDE (___data = .);'
diff --git a/ld/emulparams/shelf_nto.sh b/ld/emulparams/shelf_nto.sh
index 46efd87..c4d71aa 100644
--- a/ld/emulparams/shelf_nto.sh
+++ b/ld/emulparams/shelf_nto.sh
@@ -9,6 +9,3 @@ TEMPLATE_NAME=elf32
GENERATE_SHLIB_SCRIPT=yes
TEXT_START_SYMBOLS='_btext = .;'
ENTRY=_start
-# PR 17739. Delay checking relocs until after all files have
-# been opened and linker garbage collection has taken place.
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
diff --git a/ld/emulparams/shelf_vxworks.sh b/ld/emulparams/shelf_vxworks.sh
index 759ffac..c450990 100644
--- a/ld/emulparams/shelf_vxworks.sh
+++ b/ld/emulparams/shelf_vxworks.sh
@@ -14,9 +14,6 @@ TEMPLATE_NAME=elf32
GENERATE_SHLIB_SCRIPT=yes
ENTRY=__start
SYMPREFIX=_
-# PR 17739. Delay checking relocs until after all files have
-# been opened and linker garbage collection has taken place.
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
GOT=".got ${RELOCATING-0} : {
PROVIDE(__GLOBAL_OFFSET_TABLE_ = .);
diff --git a/ld/emulparams/shlelf32_linux.sh b/ld/emulparams/shlelf32_linux.sh
index 0327e57..03f6d9a 100644
--- a/ld/emulparams/shlelf32_linux.sh
+++ b/ld/emulparams/shlelf32_linux.sh
@@ -13,9 +13,6 @@ ALIGNMENT=8
TEMPLATE_NAME=elf32
GENERATE_SHLIB_SCRIPT=yes
GENERATE_PIE_SCRIPT=yes
-# PR 17739. Delay checking relocs until after all files have
-# been opened and linker garbage collection has taken place.
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
DATA_START_SYMBOLS='PROVIDE (___data = .);'
diff --git a/ld/emulparams/shlelf_linux.sh b/ld/emulparams/shlelf_linux.sh
index 4e2a581..c14aae2 100644
--- a/ld/emulparams/shlelf_linux.sh
+++ b/ld/emulparams/shlelf_linux.sh
@@ -12,9 +12,6 @@ MACHINE=
TEMPLATE_NAME=elf32
GENERATE_SHLIB_SCRIPT=yes
GENERATE_PIE_SCRIPT=yes
-# PR 17739. Delay checking relocs until after all files have
-# been opened and linker garbage collection has taken place.
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
DATA_START_SYMBOLS='PROVIDE (__data_start = .);';
diff --git a/ld/emulparams/shlelf_nto.sh b/ld/emulparams/shlelf_nto.sh
index f8ffc13..16f6508 100644
--- a/ld/emulparams/shlelf_nto.sh
+++ b/ld/emulparams/shlelf_nto.sh
@@ -9,6 +9,3 @@ TEMPLATE_NAME=elf32
GENERATE_SHLIB_SCRIPT=yes
TEXT_START_SYMBOLS='_btext = .;'
ENTRY=_start
-# PR 17739. Delay checking relocs until after all files have
-# been opened and linker garbage collection has taken place.
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
diff --git a/ld/emultempl/aarch64elf.em b/ld/emultempl/aarch64elf.em
index 3007e4d..f1a3a48 100644
--- a/ld/emultempl/aarch64elf.em
+++ b/ld/emultempl/aarch64elf.em
@@ -43,6 +43,7 @@ gld${EMULATION_NAME}_before_parse (void)
input_flags.dynamic = ${DYNAMIC_LINK-TRUE};
config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`;
config.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
+ link_info.check_relocs_after_open_input = TRUE;
link_info.relro = DEFAULT_LD_Z_RELRO;
}
diff --git a/ld/emultempl/aix.em b/ld/emultempl/aix.em
index 480bbbc..4965ad2 100644
--- a/ld/emultempl/aix.em
+++ b/ld/emultempl/aix.em
@@ -1539,6 +1539,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = {
hll_default,
after_parse_default,
gld${EMULATION_NAME}_after_open,
+ after_check_relocs_default,
after_allocation_default,
gld${EMULATION_NAME}_set_output_arch,
gld${EMULATION_NAME}_choose_target,
diff --git a/ld/emultempl/armcoff.em b/ld/emultempl/armcoff.em
index de2847b..bccf353 100644
--- a/ld/emultempl/armcoff.em
+++ b/ld/emultempl/armcoff.em
@@ -261,6 +261,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
hll_default,
after_parse_default,
gld${EMULATION_NAME}_after_open,
+ after_check_relocs_default,
after_allocation_default,
set_output_arch_default,
ldemul_default_target,
diff --git a/ld/emultempl/armelf.em b/ld/emultempl/armelf.em
index 34ff993..8fb92e4 100644
--- a/ld/emultempl/armelf.em
+++ b/ld/emultempl/armelf.em
@@ -58,6 +58,7 @@ gld${EMULATION_NAME}_before_parse (void)
input_flags.dynamic = ${DYNAMIC_LINK-TRUE};
config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`;
config.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
+ link_info.check_relocs_after_open_input = TRUE;
link_info.relro = DEFAULT_LD_Z_RELRO;
}
diff --git a/ld/emultempl/beos.em b/ld/emultempl/beos.em
index 3128e20..8b7d5a5 100644
--- a/ld/emultempl/beos.em
+++ b/ld/emultempl/beos.em
@@ -764,6 +764,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
hll_default,
after_parse_default,
gld_${EMULATION_NAME}_after_open,
+ after_check_relocs_default,
after_allocation_default,
set_output_arch_default,
ldemul_default_target,
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 8737376..ff4d565 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -104,7 +104,7 @@ gld${EMULATION_NAME}_before_parse (void)
config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`;
config.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
`if test -n "$CALL_NOP_BYTE" ; then echo link_info.call_nop_byte = $CALL_NOP_BYTE; fi`;
- link_info.check_relocs_after_open_input = `if test "x${CHECK_RELOCS_AFTER_OPEN_INPUT}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
+ link_info.check_relocs_after_open_input = TRUE;
link_info.relro = DEFAULT_LD_Z_RELRO;
}
@@ -2813,6 +2813,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
${LDEMUL_HLL-hll_default},
${LDEMUL_AFTER_PARSE-gld${EMULATION_NAME}_after_parse},
${LDEMUL_AFTER_OPEN-gld${EMULATION_NAME}_after_open},
+ ${LDEMUL_AFTER_CHECK_RELOCS-after_check_relocs_default},
${LDEMUL_AFTER_ALLOCATION-gld${EMULATION_NAME}_after_allocation},
${LDEMUL_SET_OUTPUT_ARCH-set_output_arch_default},
${LDEMUL_CHOOSE_TARGET-ldemul_default_target},
diff --git a/ld/emultempl/generic.em b/ld/emultempl/generic.em
index 55a19a8..9a54ba2 100644
--- a/ld/emultempl/generic.em
+++ b/ld/emultempl/generic.em
@@ -136,6 +136,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
${LDEMUL_HLL-hll_default},
${LDEMUL_AFTER_PARSE-after_parse_default},
${LDEMUL_AFTER_OPEN-after_open_default},
+ ${LDEMUL_AFTER_CHECK_RELOCS-after_check_relocs_default},
${LDEMUL_AFTER_ALLOCATION-after_allocation_default},
${LDEMUL_SET_OUTPUT_ARCH-set_output_arch_default},
${LDEMUL_CHOOSE_TARGET-ldemul_default_target},
diff --git a/ld/emultempl/gld960.em b/ld/emultempl/gld960.em
index 683bb81..9489462 100644
--- a/ld/emultempl/gld960.em
+++ b/ld/emultempl/gld960.em
@@ -129,6 +129,7 @@ struct ld_emulation_xfer_struct ld_gld960_emulation =
hll_default,
after_parse_default,
after_open_default,
+ after_check_relocs_default,
after_allocation_default,
gld960_set_output_arch,
gld960_choose_target,
diff --git a/ld/emultempl/gld960c.em b/ld/emultempl/gld960c.em
index 7bbb83a..1b4d09a 100644
--- a/ld/emultempl/gld960c.em
+++ b/ld/emultempl/gld960c.em
@@ -142,6 +142,7 @@ struct ld_emulation_xfer_struct ld_gld960coff_emulation =
hll_default,
after_parse_default,
after_open_default,
+ after_check_relocs_default,
after_allocation_default,
gld960_set_output_arch,
gld960_choose_target,
diff --git a/ld/emultempl/linux.em b/ld/emultempl/linux.em
index b79537d..0befb26 100644
--- a/ld/emultempl/linux.em
+++ b/ld/emultempl/linux.em
@@ -50,6 +50,7 @@ gld${EMULATION_NAME}_before_parse (void)
ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
input_flags.dynamic = TRUE;
config.has_shared = TRUE;
+ link_info.check_relocs_after_open_input = TRUE;
link_info.relro = DEFAULT_LD_Z_RELRO;
}
@@ -187,6 +188,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
hll_default,
after_parse_default,
after_open_default,
+ after_check_relocs_default,
after_allocation_default,
set_output_arch_default,
ldemul_default_target,
diff --git a/ld/emultempl/lnk960.em b/ld/emultempl/lnk960.em
index b30acb6..35fbae3 100644
--- a/ld/emultempl/lnk960.em
+++ b/ld/emultempl/lnk960.em
@@ -323,6 +323,7 @@ struct ld_emulation_xfer_struct ld_lnk960_emulation =
lnk960_hll,
lnk960_after_parse,
after_open_default,
+ after_check_relocs_default,
lnk960_after_allocation,
lnk960_set_output_arch,
lnk960_choose_target,
diff --git a/ld/emultempl/m68kcoff.em b/ld/emultempl/m68kcoff.em
index 359f0e0..424520e 100644
--- a/ld/emultempl/m68kcoff.em
+++ b/ld/emultempl/m68kcoff.em
@@ -220,6 +220,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
syslib_default,
hll_default,
after_parse_default,
+ after_check_relocs_default,
gld${EMULATION_NAME}_after_open,
gld${EMULATION_NAME}_after_allocation,
set_output_arch_default,
diff --git a/ld/emultempl/mmix-elfnmmo.em b/ld/emultempl/mmix-elfnmmo.em
index d703eac..39f532b 100644
--- a/ld/emultempl/mmix-elfnmmo.em
+++ b/ld/emultempl/mmix-elfnmmo.em
@@ -25,6 +25,15 @@
fragment <<EOF
#include "elf/mmix.h"
+static void gld${EMULATION_NAME}_before_parse (void);
+
+static void
+mmix_before_parse (void)
+{
+ link_info.check_relocs_after_open_input = TRUE;
+ gld${EMULATION_NAME}_before_parse ();
+}
+
/* Set up handling of linker-allocated global registers. */
static void
@@ -111,5 +120,6 @@ mmix_after_allocation (void)
}
EOF
+LDEMUL_BEFORE_PARSE=mmix_before_parse
LDEMUL_AFTER_ALLOCATION=mmix_after_allocation
LDEMUL_BEFORE_ALLOCATION=mmix_before_allocation
diff --git a/ld/emultempl/mmixelf.em b/ld/emultempl/mmixelf.em
index 8123d40..d9a2ba1 100644
--- a/ld/emultempl/mmixelf.em
+++ b/ld/emultempl/mmixelf.em
@@ -29,7 +29,7 @@ fragment <<EOF
static void
elfmmix_before_parse (void)
{
- gld${EMULATION_NAME}_before_parse ();
+ mmix_before_parse ();
/* Make sure we don't create a demand-paged executable. Unfortunately
this isn't changeable with a command-line option. It makes no
diff --git a/ld/emultempl/msp430.em b/ld/emultempl/msp430.em
index 0792e3c..65e6fb2 100644
--- a/ld/emultempl/msp430.em
+++ b/ld/emultempl/msp430.em
@@ -838,6 +838,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
${LDEMUL_HLL-hll_default},
${LDEMUL_AFTER_PARSE-after_parse_default},
msp430_elf_after_open,
+ after_check_relocs_default,
msp430_elf_after_allocation,
${LDEMUL_SET_OUTPUT_ARCH-set_output_arch_default},
${LDEMUL_CHOOSE_TARGET-ldemul_default_target},
diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em
index 0693483..039602a 100644
--- a/ld/emultempl/pe.em
+++ b/ld/emultempl/pe.em
@@ -2474,6 +2474,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
hll_default,
gld_${EMULATION_NAME}_after_parse,
gld_${EMULATION_NAME}_after_open,
+ after_check_relocs_default,
after_allocation_default,
set_output_arch_default,
ldemul_default_target,
diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em
index 1446e04..f76738c 100644
--- a/ld/emultempl/pep.em
+++ b/ld/emultempl/pep.em
@@ -2247,6 +2247,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
hll_default,
gld_${EMULATION_NAME}_after_parse,
gld_${EMULATION_NAME}_after_open,
+ after_check_relocs_default,
after_allocation_default,
set_output_arch_default,
ldemul_default_target,
diff --git a/ld/emultempl/ppc32elf.em b/ld/emultempl/ppc32elf.em
index 374459c..b1ea04d 100644
--- a/ld/emultempl/ppc32elf.em
+++ b/ld/emultempl/ppc32elf.em
@@ -57,7 +57,7 @@ EOF
if test -z "$VXWORKS_BASE_EM_FILE" ; then
fragment <<EOF
static void
-ppc_after_open (void)
+ppc_after_check_relocs (void)
{
if (is_ppc_elf (link_info.output_bfd))
{
@@ -108,7 +108,7 @@ ppc_after_open (void)
}
}
- gld${EMULATION_NAME}_after_open ();
+ after_check_relocs_default ();
}
EOF
@@ -355,7 +355,7 @@ PARSE_AND_LIST_ARGS_CASES=${PARSE_AND_LIST_ARGS_CASES}'
#
LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=ppc_after_open_output
if test -z "$VXWORKS_BASE_EM_FILE" ; then
- LDEMUL_AFTER_OPEN=ppc_after_open
+ LDEMUL_AFTER_CHECK_RELOCS=ppc_after_check_relocs
fi
LDEMUL_BEFORE_ALLOCATION=ppc_before_allocation
LDEMUL_FINISH=ppc_finish
diff --git a/ld/emultempl/scoreelf.em b/ld/emultempl/scoreelf.em
index 9560ff2..367f758 100644
--- a/ld/emultempl/scoreelf.em
+++ b/ld/emultempl/scoreelf.em
@@ -39,6 +39,7 @@ gld${EMULATION_NAME}_before_parse (void)
input_flags.dynamic = ${DYNAMIC_LINK-TRUE};
config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`;
config.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
+ link_info.check_relocs_after_open_input = TRUE;
link_info.relro = DEFAULT_LD_Z_RELRO;
}
diff --git a/ld/emultempl/sunos.em b/ld/emultempl/sunos.em
index 44e6e51..51e46dd 100644
--- a/ld/emultempl/sunos.em
+++ b/ld/emultempl/sunos.em
@@ -1016,6 +1016,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
hll_default,
after_parse_default,
gld${EMULATION_NAME}_after_open,
+ after_check_relocs_default,
after_allocation_default,
set_output_arch_default,
ldemul_default_target,
diff --git a/ld/emultempl/ticoff.em b/ld/emultempl/ticoff.em
index d394e12..b2552db 100644
--- a/ld/emultempl/ticoff.em
+++ b/ld/emultempl/ticoff.em
@@ -161,6 +161,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
hll_default,
after_parse_default,
after_open_default,
+ after_check_relocs_default,
after_allocation_default,
set_output_arch_default,
ldemul_default_target,
diff --git a/ld/emultempl/vanilla.em b/ld/emultempl/vanilla.em
index 3d8dc44..83837b9 100644
--- a/ld/emultempl/vanilla.em
+++ b/ld/emultempl/vanilla.em
@@ -62,6 +62,7 @@ struct ld_emulation_xfer_struct ld_vanilla_emulation =
hll_default,
after_parse_default,
after_open_default,
+ after_check_relocs_default,
after_allocation_default,
vanilla_set_output_arch,
ldemul_default_target,
diff --git a/ld/ldemul.c b/ld/ldemul.c
index cebf012..96c4b8b 100644
--- a/ld/ldemul.c
+++ b/ld/ldemul.c
@@ -65,6 +65,12 @@ ldemul_after_open (void)
}
void
+ldemul_after_check_relocs (void)
+{
+ ld_emulation->after_check_relocs ();
+}
+
+void
ldemul_after_allocation (void)
{
ld_emulation->after_allocation ();
@@ -227,6 +233,11 @@ after_open_default (void)
}
void
+after_check_relocs_default (void)
+{
+}
+
+void
after_allocation_default (void)
{
lang_relax_sections (FALSE);
diff --git a/ld/ldemul.h b/ld/ldemul.h
index 8e9bd2e..631a038 100644
--- a/ld/ldemul.h
+++ b/ld/ldemul.h
@@ -34,6 +34,8 @@ extern void ldemul_before_parse
(void);
extern void ldemul_after_open
(void);
+extern void ldemul_after_check_relocs
+ (void);
extern void ldemul_after_allocation
(void);
extern void ldemul_before_allocation
@@ -76,6 +78,8 @@ extern void after_parse_default
(void);
extern void after_open_default
(void);
+extern void after_check_relocs_default
+ (void);
extern void after_allocation_default
(void);
extern void before_allocation_default
@@ -114,6 +118,9 @@ typedef struct ld_emulation_xfer_struct {
/* Run after opening all input files, and loading the symbols. */
void (*after_open) (void);
+ /* Run after checking relocations. */
+ void (*after_check_relocs) (void);
+
/* Run after allocating output sections. */
void (*after_allocation) (void);
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 0018188..3ed7078 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -7259,6 +7259,8 @@ lang_process (void)
/* Check relocations. */
lang_check_relocs ();
+ ldemul_after_check_relocs ();
+
/* Update wild statements. */
update_wild_statements (statement_list.head);
diff --git a/ld/testsuite/ld-aarch64/gc-got-relocs.d b/ld/testsuite/ld-aarch64/gc-got-relocs.d
index bb98241..6525d10 100644
--- a/ld/testsuite/ld-aarch64/gc-got-relocs.d
+++ b/ld/testsuite/ld-aarch64/gc-got-relocs.d
@@ -6,24 +6,18 @@
#objdump: -s -t -d
# Executable with got related relocs against global sysmbol gced.
-# After gc-section removal we are cheking that symbol does not exit
-# got section is empty and text section contains only start function.
+# After gc-section removal we are cheking that symbol and got section
+# do not exist and text section contains only start function.
.*: file format elf64-(little|big)aarch64
SYMBOL TABLE:
0+8000 l d \.text 0+ \.text
-0+9000 l d \.got 0+ \.got
0+0000 l df \*ABS\* 0+ .*
-0+0000 l df \*ABS\* 0+
-0+9000 l O \.got 0+ _GLOBAL_OFFSET_TABLE_
0+8000 g \.text 0+ _start
Contents of section .text:
8000 1f2003d5 .*
-Contents of section .got:
- 9000 0+ 0+ 0+ 0+ .*
- 9010 0+ 0+ 0+ 0+ .*
Disassembly of section .text:
diff --git a/ld/testsuite/ld-aarch64/gc-tls-relocs.d b/ld/testsuite/ld-aarch64/gc-tls-relocs.d
index 480d869..38637dc 100644
--- a/ld/testsuite/ld-aarch64/gc-tls-relocs.d
+++ b/ld/testsuite/ld-aarch64/gc-tls-relocs.d
@@ -7,24 +7,18 @@
#objdump: -s -t -d
# Executable with tls related relocs against global and local symbol gced.
-# After gc-section removal we are cheking that symbols does not exit
-# got section is empty and text section contains only start function.
+# After gc-section removal we are cheking that symbols and got section do
+# not exist and text section contains only start function.
.*: file format elf64-(little|big)aarch64
SYMBOL TABLE:
0+8000 l d \.text 0+ \.text
-0+9000 l d \.got 0+ \.got
0+0000 l df \*ABS\* 0+ .*
-0+0000 l df \*ABS\* 0+
-0+9000 l O \.got 0+ _GLOBAL_OFFSET_TABLE_
0+8000 g \.text 0+ _start
Contents of section .text:
8000 1f2003d5 .*
-Contents of section .got:
- 9000 0+ 0+ 0+ 0+ .*
- 9010 0+ 0+ 0+ 0+ .*
Disassembly of section .text:
diff --git a/ld/testsuite/ld-cris/tls-gc-68.d b/ld/testsuite/ld-cris/tls-gc-68.d
index b7fc374..c1a7d25 100644
--- a/ld/testsuite/ld-cris/tls-gc-68.d
+++ b/ld/testsuite/ld-cris/tls-gc-68.d
@@ -7,27 +7,21 @@
# An executable with a R_CRIS_32_GOT_GD and a R_CRIS_16_GOT_GD against
# the same local symbol, gc:ed. Check that we have nothing left but
-# the start symbol and its code. Can't get rid of the GOT just yet.
+# the start symbol and its code.
.*: file format elf32-cris
Program Header:
LOAD off 0x0+ vaddr 0x0+80000 paddr 0x0+80000 align 2\*\*13
- filesz 0x0+78 memsz 0x0+78 flags r-x
- LOAD off 0x0+78 vaddr 0x0+82078 paddr 0x0+82078 align 2\*\*13
- filesz 0x0+c memsz 0x0+c flags rw-
+ filesz 0x0+58 memsz 0x0+58 flags r-x
private flags = 0:
SYMBOL TABLE:
-0+80074 l d \.text 0+ \.text
-0+82078 l d \.got 0+ \.got
-0+82078 l O \.got 0+ _GLOBAL_OFFSET_TABLE_
-0+80074 g \.text 0+ _start
-0+82084 g \.got 0+ __bss_start
-0+82084 g \.got 0+ _edata
-0+820a0 g \.got 0+ _end
+0+80054 l d \.text 0+ \.text
+0+80054 g \.text 0+ _start
+0+82058 g \.text 0+ __bss_start
+0+82058 g \.text 0+ _edata
+0+82060 g \.text 0+ _end
Contents of section \.text:
- 80074 41b20+ .*
-Contents of section \.got:
- 82078 0+ 0+ 0+ .*
+ 80054 41b20+ .*
diff --git a/ld/testsuite/ld-cris/tls-gc-69.d b/ld/testsuite/ld-cris/tls-gc-69.d
index c4c51b7..ef02437 100644
--- a/ld/testsuite/ld-cris/tls-gc-69.d
+++ b/ld/testsuite/ld-cris/tls-gc-69.d
@@ -8,27 +8,21 @@
# An executable with a R_CRIS_32_GOT_GD, a R_CRIS_16_GOT_GD, a
# R_CRIS_32_GOT_TPREL and a R_CRIS_16_GOT_TPREL against the same local
# symbol, gc:ed. Check that we have nothing left but the start symbol
-# and its code. Can't get rid of the GOT just yet.
+# and its code.
.*: file format elf32-cris
Program Header:
LOAD off 0x0+ vaddr 0x0+80000 paddr 0x0+80000 align 2\*\*13
- filesz 0x0+78 memsz 0x0+78 flags r-x
- LOAD off 0x0+78 vaddr 0x0+82078 paddr 0x0+82078 align 2\*\*13
- filesz 0x0+c memsz 0x0+c flags rw-
+ filesz 0x0+58 memsz 0x0+58 flags r-x
private flags = 0:
SYMBOL TABLE:
-0+80074 l d \.text 0+ \.text
-0+82078 l d \.got 0+ \.got
-0+82078 l O \.got 0+ _GLOBAL_OFFSET_TABLE_
-0+80074 g \.text 0+ _start
-0+82084 g \.got 0+ __bss_start
-0+82084 g \.got 0+ _edata
-0+820a0 g \.got 0+ _end
+0+80054 l d \.text 0+ \.text
+0+80054 g \.text 0+ _start
+0+82058 g \.text 0+ __bss_start
+0+82058 g \.text 0+ _edata
+0+82060 g \.text 0+ _end
Contents of section .text:
- 80074 41b20+ .*
-Contents of section .got:
- 82078 0+ 0+ 0+ .*
+ 80054 41b20+ .*
diff --git a/ld/testsuite/ld-cris/tls-gc-70.d b/ld/testsuite/ld-cris/tls-gc-70.d
index 6ab8f24..74d0d13 100644
--- a/ld/testsuite/ld-cris/tls-gc-70.d
+++ b/ld/testsuite/ld-cris/tls-gc-70.d
@@ -7,28 +7,21 @@
#objdump: -s -t -r -p
# An executable with a single R_CRIS_32_GD, with gc. Check that we
-# have nothing left but the start symbol and its code. Can't get rid
-# of the GOT just yet.
+# have nothing left but the start symbol and its code.
.*: file format elf32-cris
Program Header:
LOAD off 0x0+ vaddr 0x0+80000 paddr 0x0+80000 align 2\*\*13
- filesz 0x0+78 memsz 0x0+78 flags r-x
- LOAD off 0x0+78 vaddr 0x0+82078 paddr 0x0+82078 align 2\*\*13
- filesz 0x0+c memsz 0x0+c flags rw-
+ filesz 0x0+58 memsz 0x0+58 flags r-x
private flags = 0:
SYMBOL TABLE:
-0+80074 l d \.text 0+ \.text
-0+82078 l d \.got 0+ \.got
-0+82078 l O \.got 0+ _GLOBAL_OFFSET_TABLE_
-0+80074 g \.text 0+ _start
-0+82084 g \.got 0+ __bss_start
-0+82084 g \.got 0+ _edata
-0+820a0 g \.got 0+ _end
+0+80054 l d \.text 0+ \.text
+0+80054 g \.text 0+ _start
+0+82058 g \.text 0+ __bss_start
+0+82058 g \.text 0+ _edata
+0+82060 g \.text 0+ _end
Contents of section \.text:
- 80074 41b20+ .*
-Contents of section \.got:
- 82078 0+ 0+ 0+ .*
+ 80054 41b20+ .*
diff --git a/ld/testsuite/ld-cris/tls-gc-75.d b/ld/testsuite/ld-cris/tls-gc-75.d
index c2d5df4..f377dc2 100644
--- a/ld/testsuite/ld-cris/tls-gc-75.d
+++ b/ld/testsuite/ld-cris/tls-gc-75.d
@@ -10,27 +10,21 @@
# An executable with a R_CRIS_32_GOT_GD, a R_CRIS_16_GOT_GD, a
# R_CRIS_32_GOT_TPREL and a R_CRIS_16_GOT_TPREL against the same
-# symbol, gc:ed. Check that we have proper NPTL/TLS markings and GOT.
+# symbol, gc:ed. Check that we have proper NPTL/TLS markings.
.*: file format elf32-cris
Program Header:
LOAD off 0x0+ vaddr 0x0+80000 paddr 0x0+80000 align 2\*\*13
- filesz 0x0+78 memsz 0x0+78 flags r-x
- LOAD off 0x0+78 vaddr 0x0+82078 paddr 0x0+82078 align 2\*\*13
- filesz 0x0+c memsz 0x0+c flags rw-
+ filesz 0x0+58 memsz 0x0+58 flags r-x
private flags = 0:
SYMBOL TABLE:
-0+80074 l d \.text 0+ \.text
-0+82078 l d \.got 0+ \.got
-0+82078 l O \.got 0+ _GLOBAL_OFFSET_TABLE_
-0+80074 g \.text 0+ _start
-0+82084 g \.got 0+ __bss_start
-0+82084 g \.got 0+ _edata
-0+820a0 g \.got 0+ _end
+0+80054 l d \.text 0+ \.text
+0+80054 g \.text 0+ _start
+0+82058 g \.text 0+ __bss_start
+0+82058 g \.text 0+ _edata
+0+82060 g \.text 0+ _end
Contents of section \.text:
- 80074 41b20+ .*
-Contents of section \.got:
- 82078 0+ 0+ 0+ .*
+ 80054 41b20+ .*
diff --git a/ld/testsuite/ld-cris/tls-gc-79.d b/ld/testsuite/ld-cris/tls-gc-79.d
index f4916d3..a5bd7ff 100644
--- a/ld/testsuite/ld-cris/tls-gc-79.d
+++ b/ld/testsuite/ld-cris/tls-gc-79.d
@@ -7,28 +7,21 @@
#objdump: -s -t -r -p
# An executable with a single R_CRIS_32_IE, with gc. Check that we
-# have nothing left but the start symbol and its code. Can't get rid
-# of the GOT just yet.
+# have nothing left but the start symbol and its code.
.*: file format elf32-cris
Program Header:
LOAD off 0x0+ vaddr 0x0+80000 paddr 0x0+80000 align 2\*\*13
- filesz 0x0+78 memsz 0x0+78 flags r-x
- LOAD off 0x0+78 vaddr 0x0+82078 paddr 0x0+82078 align 2\*\*13
- filesz 0x0+c memsz 0x0+c flags rw-
+ filesz 0x0+58 memsz 0x0+58 flags r-x
private flags = 0:
SYMBOL TABLE:
-0+80074 l d \.text 0+ \.text
-0+82078 l d \.got 0+ \.got
-0+82078 l O \.got 0+ _GLOBAL_OFFSET_TABLE_
-0+80074 g \.text 0+ _start
-0+82084 g \.got 0+ __bss_start
-0+82084 g \.got 0+ _edata
-0+820a0 g \.got 0+ _end
+0+80054 l d \.text 0+ \.text
+0+80054 g \.text 0+ _start
+0+82058 g \.text 0+ __bss_start
+0+82058 g \.text 0+ _edata
+0+82060 g \.text 0+ _end
Contents of section \.text:
- 80074 41b20+ .*
-Contents of section \.got:
- 82078 0+ 0+ 0+ .*
+ 80054 41b20+ .*
diff --git a/ld/testsuite/ld-mmix/bpo-10.d b/ld/testsuite/ld-mmix/bpo-10.d
index 6f49287..06c2656 100644
--- a/ld/testsuite/ld-mmix/bpo-10.d
+++ b/ld/testsuite/ld-mmix/bpo-10.d
@@ -11,7 +11,6 @@
SYMBOL TABLE:
0+ l d \.init 0+ (|\.init)
-0+7f8 l +d \.MMIX.reg_contents 0+ (|\.MMIX\.reg_contents)
0+ l df \*ABS\* 0+ .*
0+ l \.init 0+ _start
2000000000000000 g \.init 0+ __bss_start