diff options
Diffstat (limited to 'ld')
55 files changed, 194 insertions, 130 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index 6e7e58dfc49..4fbf6ba5b8e 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 a7f16b1d325..03f9d830567 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 6997d40ba1c..084497c2309 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 4a24b020123..70db4432395 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 53491081744..aa36cb51c2d 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 dc4eef48896..1328520c57c 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 ac1bbeb4e34..aaea8c48743 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 45953e76d3a..863027b57b4 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 828c10efc99..494efcc6c90 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 9c59dc07a5f..b1158791f46 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 c678479d240..09f3cdac079 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 12bc7daa6a3..93afb3d7f37 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 bffef867a74..095d85ab921 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 51284be2bd4..626f9c13aa1 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 e6397f6879c..e1897bef957 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 8d79b8d86c5..5b343194902 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 7f4640730d3..3fc9a3e518e 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 46efd878960..c4d71aa9993 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 759ffac2886..c45099046e8 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 0327e57ad64..03f6d9a7e4a 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 4e2a5813f20..c14aae228d1 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 f8ffc13b36b..16f65087eb0 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 3007e4d581c..f1a3a480d8a 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 480bbbce100..4965ad2f2f4 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 de2847bdc52..bccf35306bf 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 34ff993cc7f..8fb92e46c20 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 3128e2037b5..8b7d5a53fa5 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 87373768043..ff4d565a21f 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 55a19a8168f..9a54ba2acbe 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 683bb819f8b..9489462ef12 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 7bbb83a8d5c..1b4d09abcc7 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 b79537df01c..0befb26025c 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 b30acb6de67..35fbae39712 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 359f0e0f6d1..424520ef9de 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 d703eac5666..39f532bfa70 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 8123d407859..d9a2ba18694 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 0792e3cc75d..65e6fb23241 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 06934831dd7..039602aa6c5 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 1446e046f77..f76738cf49c 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 374459c47d7..b1ea04dd918 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 9560ff23f0e..367f75868e4 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 44e6e512bc5..51e46ddf780 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 d394e12465c..b2552db2e62 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 3d8dc44f068..83837b9bac3 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 cebf012e78f..96c4b8bc33d 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 8e9bd2e952a..631a038767f 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 0018188205a..3ed707865ed 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 bb982414e4a..6525d10119c 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 480d869917e..38637dce07c 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 b7fc3743a57..c1a7d25c803 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 c4c51b7128f..ef02437a7d6 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 6ab8f24231c..74d0d1373f4 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 c2d5df47309..f377dc263e7 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 f4916d3f356..a5bd7ffe37d 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 6f49287e588..06c26562006 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 |