aboutsummaryrefslogtreecommitdiff
path: root/ld
AgeCommit message (Collapse)AuthorFilesLines
2020-06-16Really remove tic30-aout supportAlan Modra9-65/+15
bfd/ * aout-tic30.c: Delete file. * Makefile.am (BFD32_BACKENDS): Remove aout-tic30.lo. (BFD32_BACKENDS_CFILES): Remove aout-tic30.c. * config.bfd (c30-*-*aout*, tic30-*-*aout*): Remove entry. (xc16x-*-elf): Sort properly. * configure.ac: Remove tic30_aout_vec. * targets.c: Likewise. * Makefile.in: Regenerate. * configure: Regenerate. * po/SRC-POTFILES.in: Regenerate. gas/ * config/tc-tic30.h: Remove OBJ_AOUT support. * configure.tgt: Delete tic30-*-*aout* entry. ld/ * emulparams/tic30aout.sh: Delete file. * scripttempl/tic30aout.sc: Delete file. * Makefile.am: Remove etic30aout.c from ALL_EMULATION_SOURCES and delete dependency. * configure.tgt: Delete tic30-*-*aout* entry. * testsuite/ld-scripts/sane1.d: Delete tic30-*-aout mention. * testsuite/ld-scripts/segment-start.d: Likewise. * Makefile.in: Regenerate. * po/BLD-POTFILES.in: Regenerate.
2020-06-15xtensa: allow runtime ABI selectionMax Filippov3-5/+69
2020-06-15 Max Filippov <jcmvbkbc@gmail.com> bfd/ * elf32-xtensa.c (XSHAL_ABI, XTHAL_ABI_UNDEFINED) (XTHAL_ABI_WINDOWED, XTHAL_ABI_CALL0): New macros. (elf32xtensa_abi): New global variable. (xtensa_abi_choice): New function. (elf_xtensa_create_plt_entry): Use xtensa_abi_choice instead of XSHAL_ABI to select PLT code. gas/ * config/tc-xtensa.c (XTHAL_ABI_WINDOWED, XTHAL_ABI_CALL0): New macros. (elf32xtensa_abi): New declaration. (option_abi_windowed, option_abi_call0): New enum constants. (md_longopts): Add entries for --abi-windowed and --abi-call0. (md_parse_option): Add handlers for --abi-windowed and --abi-call0. (xtensa_add_config_info): Use xtensa_abi_choice instead of XSHAL_ABI to format ABI tag. * doc/as.texi (Target Xtensa options): Add --abi-windowed and --abi-call0 to the list of options. * doc/c-xtensa.texi: Add description for options --abi-windowed and --abi-call0. * testsuite/gas/xtensa/abi-call0.d: New test definition. * testsuite/gas/xtensa/abi-windowed.d: New test definition. * testsuite/gas/xtensa/abi.s: New test source. include/ * elf/xtensa.h (xtensa_abi_choice): New declaration. ld/ * emultempl/xtensaelf.em (XSHAL_ABI): Remove macro definition. (XTHAL_ABI_UNDEFINED, XTHAL_ABI_WINDOWED, XTHAL_ABI_CALL0): New macros. (elf32xtensa_abi): New declaration. (xt_config_info_unpack_and_check): Set elf32xtensa_abi if it is undefined. Use xtensa_abi_choice instead of XSHAL_ABI to test ABI tag consistency. (xtensa_add_config_info): Use xtensa_abi_choice instead of XSHAL_ABI to format ABI tag. (PARSE_AND_LIST_PROLOGUE): Define OPTION_ABI_WINDOWED, OPTION_ABI_CALL0 and declare elf32xtensa_abi. (PARSE_AND_LIST_LONGOPTS): Add entries for --abi-windowed and --abi-call0. (PARSE_AND_LIST_OPTIONS): Add help text for --abi-windowed and --abi-call0. (PARSE_AND_LIST_ARGS_CASES): Add handlers for --abi-windowed and --abi-call0. * ld.texi: Add description for options --abi-windowed and --abi-call0.
2020-06-15gold, ld: Implement -z start-stop-visibility=... option.Roland McGrath5-0/+41
gold/ Implement -z start-stop-visibility=... option. * options.h (class General_options): Handle -z start-stop-visibility=. (General_options::start_stop_visibility_enum): New public method. (General_options::set_start_stop_visibility_enum): New private method. (General_options::start_stop_visibility_enum_): New private member. * options.cc (General_options::General_options): Add initializer. (General_options::finalize): Set this->start_stop_visibility_enum_ from string value. * layout.cc (Layout::define_section_symbols): Use option setting. bfd/ * elflink.c (bfd_elf_define_start_stop): Use start_stop_visibility field of bfd_link_info. include/ * bfdlink.h (struct bfd_link_info): New field start_stop_visibility. ld/ * NEWS: Mention -z start-stop-visibility=... option for ELF. * ld.texi (Options): Document -z start-stop-visibility=... option. * ldmain.c (main): Initialize link_info.start_stop_visibility. * emultempl/elf.em (gld${EMULATION_NAME}_handle_option): Parse -z start-stop-visibility=... option.
2020-06-15Unnecessary load_lib in ld testsuiteAlan Modra7-18/+10
ld-lib.exp is loaded in config/defaults.exp * testsuite/ld-scripts/include.exp: Don't load ld-lib.exp. * testsuite/ld-scripts/phdrs3.exp: Likewise. * testsuite/ld-scripts/rgn-at.exp: Likewise. * testsuite/ld-scripts/rgn-over.exp: Likewise. * testsuite/ld-scripts/sort.exp: Likewise. * testsuite/ld-discard/discard.exp: Likewise. Use is_elf_format.
2020-06-15PR26103 testcaseAlan Modra7-9/+61
PR 26103 * testsuite/ld-linkonce/ref1.s, * testsuite/ld-linkonce/ref2.s, * testsuite/ld-linkonce/sym1.s, * testsuite/ld-linkonce/sym2.s, * testsuite/ld-linkonce/sym3.s: New test files. * testsuite/ld-linkonce/linkonce.exp: Run tests for PE too. Add pr26103 test. Remove unnecessary load_lib.
2020-06-15ld-linkonce testAlan Modra4-10/+18
* testsuite/ld-linkonce/zeroeh_x.s: Rename from x.s. * testsuite/ld-linkonce/zeroeh_y.s: Rename from y.s. * testsuite/ld-linkonce/zeroehl32.d: Adjust for renaming. Support big-endian output. Run for powerpc.
2020-06-11Run certain ld-plugun lto tests only for ELFAlan Modra2-25/+31
lto-6.c refers to _etext, pr12760b.c has a .gnu.warning section, the pr23818 test uses readelf, and pr23958.c has a .symver directive. * testsuite/ld-plugin/lto.exp (lto_link_tests): Move lto-6, pr12760, pr23818 and pr23958 tests to.. (lto_link_elf_tests): ..here.
2020-06-11Fix a compile time warning in the linker testsuite when compiling using clang.Nick Clifton2-3/+8
* testsuite/ld-elf/pr26094-1b.c (main): Change return type to int.
2020-06-10Fix x86 ld testsuite fails with glibc < 2.28Alan Modra6-20/+41
* testsuite/ld-elf/linux-x86.exp: Build tests when non-native. (check_pr25749b): Add optional args. Set expected pass file from args. Run -1b and -2a tests with passall.out. * testsuite/ld-elf/passall.out: New file. * testsuite/ld-elf/pr25749-1.c: Adjust to pass with older glibc. * testsuite/ld-elf/pr25749-2.c: Likewise. * testsuite/lib/ld-lib.exp (run_ld_link_exec_tests): Use regexp_diff to compare expected output from running binary.
2020-06-10ELF: Properly handle section symbolsH.J. Lu8-0/+69
When defining the section symbol, __start_FOO, for the section FOO: 1. Treat the common symbol, __start_FOO, in input object file as definition. 2. Clear verinfo.verdef. bfd/ PR ld/26094 * elflink.c (bfd_elf_define_start_stop): Handle common symbols. Clear verinfo.verdef. ld/ PR ld/26094 * testsuite/ld-elf/pr26094-1.ver: New fike. * testsuite/ld-elf/pr26094-1a.c: Likewise. * testsuite/ld-elf/pr26094-1a.rd: Likewise. * testsuite/ld-elf/pr26094-1b.c: Likewise. * testsuite/ld-elf/pr26094-1b.rd: Likewise. * testsuite/ld-elf/pr26094-1c.c: Likewise. * testsuite/ld-elf/shared.exp: Run ld/26094 tests.
2020-06-09IFUNC: Update IFUNC resolver check with DT_TEXTRELH.J. Lu17-4/+138
Add ifunc_resolvers to elf_link_hash_table and use it for both x86 and ppc64. Before glibc commit b5c45e837, DT_TEXTREL is incompatible with IFUNC resolvers. Set ifunc_resolvers if there are IFUNC resolvers and issue a warning for IFUNC resolvers with DT_TEXTREL. bfd/ PR ld/18801 * elf-bfd.h (elf_link_hash_table): Add ifunc_resolvers. (_bfd_elf_allocate_ifunc_dyn_relocs): Remove the bfd_boolean * argument. Set ifunc_resolvers if there are IFUNC resolvers. * elf-ifunc.c (_bfd_elf_allocate_ifunc_dyn_relocs): Updated. Set ifunc_resolvers if there are FUNC resolvers. * elf64-ppc.c (ppc_link_hash_table): Remove local_ifunc_resolver. (build_global_entry_stubs_and_plt): Replace local_ifunc_resolver with elf.ifunc_resolvers. (write_plt_relocs_for_local_syms): Likewise. (ppc64_elf_relocate_section): Likewise. (ppc64_elf_finish_dynamic_sections): Likewise. * elfnn-aarch64.c (elfNN_aarch64_allocate_ifunc_dynrelocs): Updated. * elfxx-x86.c (elf_x86_allocate_dynrelocs): Likewise. (_bfd_x86_elf_size_dynamic_sections): Check elf.ifunc_resolvers instead of readonly_dynrelocs_against_ifunc. * elfxx-x86.h (elf_x86_link_hash_table): Remove readonly_dynrelocs_against_ifunc. ld/ PR ld/18801 * testsuite/ld-i386/i386.exp: Run ifunc-textrel-1a, ifunc-textrel-1b, ifunc-textrel-2a and ifunc-textrel-2b. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/ifunc-textrel-1a.d: Likewise. * testsuite/ld-i386/ifunc-textrel-1b.d: Likewise. * testsuite/ld-i386/ifunc-textrel-2a.d: Likewise. * testsuite/ld-i386/ifunc-textrel-2b.d: Likewise. * testsuite/ld-x86-64/ifunc-textrel-1.s: Likewise. * testsuite/ld-x86-64/ifunc-textrel-1a.d: Likewise. * testsuite/ld-x86-64/ifunc-textrel-1b.d: Likewise. * testsuite/ld-x86-64/ifunc-textrel-2.s: Likewise. * testsuite/ld-x86-64/ifunc-textrel-2a.d: Likewise. * testsuite/ld-x86-64/ifunc-textrel-2b.d: Likewise. * testsuite/ld-i386/pr18801a.d: Expect warning for IFUNC resolvers. * testsuite/ld-i386/pr18801b.d: Likewise. * estsuite/ld-x86-64/pr18801a.d: Likewise. * estsuite/ld-x86-64/pr18801b.d: Likewise.
2020-06-09PR26065, ld/testsuite/ld-elf symbolic tests dl4e and dl4f failAlan Modra3-12/+13
PR 26065 * testsuite/ld-elf/shared.exp: Compile dl4main.c -fPIC. (dl4e, dl4f): Expect dl4a.out. * testsuite/ld-elf/dl4e.out: Delete.
2020-06-07ld: Pass $LFLAGS to PR ld/21703 shared testH.J. Lu2-1/+6
$LFLAGS is needed for -shared test. This fixes FAIL: PR ld/21703 shared for tic6x-*-elf. * testsuite/ld-elf/shared.exp: Pass $LFLAGS to PR ld/21703 shared test.
2020-06-07ld: Xfail pr20995 and pr20995-2 for tic6x-*-*H.J. Lu2-2/+7
Xfail pr20995 and pr20995-2 for tic6x-*-* since GNU_RELRO is not supported. * testsuite/ld-elf/shared.exp: Xfail pr20995/pr20995-2 for tic6x-*-*.
2020-06-07pr11304.d: Skip tic6x-*-elfH.J. Lu2-0/+6
Since address 0x800000 overlaps with .heap section on tic6x-*-elf, skip pr11304.d on tic6x-*-elf. * testsuite/ld-elf/pr11304.d: Skip tic6x-*-elf.
2020-06-06Re: PR13802, referred common symbol not UNDefinedAlan Modra2-3/+6
It looks like this one was previously just swept under the rug. Prior to git commit c4b126b87a6c, the arm backend emitted an absolute dynamic symbol "foo" with value zero for what was originally a common symbol. That was just wrong. The patch also removes an xfail for bfin-linux-uclibc. PR 13802 * testsuite/ld-elf/comm-data.exp: Don't xfail arm or bfin-linux.
2020-06-06ld -plugin options when plugins are disabledAlan Modra3-1/+13
This patch makes ld accept and ignore -plugin options when configured with --disable-plugins. The idea is to allow using a linker built without plugin support with a gcc built with plugin support. Quite obviously such a combination won't work if using LTO, but gcc has a habit of passing a bunch of -plugin and -plugin-opt arguments to ld even when not generating or linking LTO objects. Why do I want to do this? Well, it lets me and other binutils developers answer the question as to whether plugin support breaks binutils in some areas. Which it does for some targets. * lexsup.c (ld_options): Accept -plugin and -plugin-opt when !ENABLE_PLUGINS. * testsuite/lib/ld-lib.exp (check_plugin_api_available): Adjust.
2020-06-05RISC-V: The object without priv spec attributes can be linked with any object.Nelson Chu13-1/+85
bfd/ * elfnn-riscv.c (riscv_merge_attributes): Add new boolean priv_may_conflict, in_priv_zero and out_priv_zero to decide whether the object can be linked according to it's priv attributes. The object without any priv spec attributes can be linked with others. If the first input object doesn't contain any priv attributes, then we need to copy the setting from the next input one. Also report more detailed error messages to user. ld/ * testsuite/ld-riscv-elf/attr-merge-priv-spec.d: Rename to attr-merge-priv-spec-01.d. * testsuite/ld-riscv-elf/attr-merge-priv-spec-c.s: Set priv spec to 1.11. * testsuite/ld-riscv-elf/attr-merge-priv-spec-d.s: Empty priv spec setting. * testsuite/ld-riscv-elf/attr-merge-priv-spec-02.d: New testcase. * testsuite/ld-riscv-elf/attr-merge-priv-spec-03.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-01.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-02.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-03.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-04.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-05.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-06.d: Likewise. * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated.
2020-06-05RISC-V: Don't generate the ELF privilege attributes when no CSR are used.Nelson Chu11-27/+15
gas/ * config/tc-riscv.c (explicit_csr): New static boolean. Used to indicate CSR are explictly used. (riscv_ip): Set explicit_csr to TRUE if any CSR is used. (riscv_write_out_attrs): If we already have set elf priv attributes, then generate them. Otherwise, don't generate them when no CSR are used. * testsuite/gas/riscv/attribute-01.d: Remove the priv attributes. * testsuite/gas/riscv/attribute-02.d: Likewise. * testsuite/gas/riscv/attribute-03.d: Likewise. * testsuite/gas/riscv/attribute-04.d: Likewise. * testsuite/gas/riscv/attribute-05.d: Likewise. * testsuite/gas/riscv/attribute-06.d: Likewise. * testsuite/gas/riscv/attribute-07.d: Likewise. * testsuite/gas/riscv/attribute-08.d: Likewise. * testsuite/gas/riscv/attribute-09.d: Likewise. * testsuite/gas/riscv/attribute-10.d: Likewise. * testsuite/gas/riscv/attribute-unknown.d: Likewise. * testsuite/gas/riscv/attribute-11.s: New testcase. * testsuite/gas/riscv/attribute-11.d: New testcase. The CSR is used, so we should output the ELF priv attributes. * testsuite/gas/riscv/attribute-12.d: New testcase. The CSR is used, so output the priv attributes according to the -mpriv-spec. * testsuite/gas/riscv/attribute-13.d: New testcase. The CSR isn't used, so ignore the -mpriv-spec setting. ld/ * testsuite/ld-riscv-elf/attr-merge-arch-01.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-arch-02.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-arch-03.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-stack-align.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-strict-align-01.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-strict-align-02.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-strict-align-03.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-strict-align-04.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-strict-align-05.d: Likewise. * testsuite/ld-riscv-elf/call-relax.d: Add -mno-arch-attr.
2020-06-04ELF: Don't check relocations in non-loaded, non-alloced sectionsH.J. Lu5-27/+11
Don't do anything special with non-loaded, non-alloced sections. In particular, any relocs in such sections should not affect GOT and PLT reference counting (ie. we don't allow them to create GOT or PLT entries), there's no possibility or desire to optimize TLS relocs, and there's not much point in propagating relocs to shared libs that the dynamic linker won't relocate. Since check_relocs is no longer called on non-loaded, non-alloced sections, remove SEC_ALLOC check. Resolve relocation in debug section against symbol defined in shared library to 0. bfd/ PR ld/26080 * elf-m10300.c (mn10300_elf_relocate_section): Resolve relocation in debug section against symbol defined in shared library to 0. * elf32-i386.c (elf_i386_check_relocs): Remove SEC_ALLOC check. * elf32-lm32.c (lm32_elf_check_relocs): Likewise. * elf32-m32r.c (m32r_elf_check_relocs): Likewise. * elf32-nds32.c (nds32_elf_check_relocs): Likewise. * elf32-nios2.c (nios2_elf32_check_relocs): Likewise. * elf32-or1k.c (or1k_elf_check_relocs): Likewise. * elf32-ppc.c (ppc_elf_check_relocs): Likewise. * elf32-sh.c (sh_elf_check_relocs): Likewise. * elf32-xtensa.c (elf_xtensa_check_relocs): Likewise. * elf64-alpha.c (elf64_alpha_check_relocs): Likewise. * elf64-ppc.c (ppc64_elf_check_relocs): Likewise. * elf64-x86-64.c (elf_x86_64_check_relocs): Likewise. * elfxx-mips.c (_bfd_mips_elf_check_relocs): Likewise. * elf32-vax.c (elf_vax_check_relocs): Set non_got_ref for non-GOT reference. (elf_vax_adjust_dynamic_symbol): Generate a copy reloc only if there is non-GOT reference. * elflink.c (_bfd_elf_link_check_relocs): Skip non-loaded, non-alloced sections. ld/ PR ld/26080 * testsuite/ld-elf/comm-data.exp: Remove copy_reloc. * testsuite/ld-elf/comm-data2r.rd: Removed. * testsuite/ld-elf/comm-data2r.sd: Likewise. * testsuite/ld-elf/comm-data2r.xd: Likewise.
2020-06-04tcl global directive outside proc body does nothing (ld)Alan Modra38-111/+41
* testsuite/config/default.exp: Remove global directive outside proc body. * testsuite/ld-bootstrap/bootstrap.exp: Likewise. * testsuite/ld-elf/compress.exp: Likewise. * testsuite/ld-elf/elf.exp: Likewise. * testsuite/ld-elf/exclude.exp: Likewise. * testsuite/ld-elf/frame.exp: Likewise. * testsuite/ld-elf/indirect.exp: Likewise. * testsuite/ld-elf/linux-x86.exp: Likewise. * testsuite/ld-elf/shared.exp: Likewise. * testsuite/ld-elf/tls.exp: Likewise. * testsuite/ld-elf/tls_common.exp: Likewise. * testsuite/ld-elfcomm/elfcomm.exp: Likewise. * testsuite/ld-elfweak/elfweak.exp: Likewise. * testsuite/ld-frv/fdpic.exp: Likewise. * testsuite/ld-frv/tls.exp: Likewise. * testsuite/ld-gc/gc.exp: Likewise. * testsuite/ld-i386/i386.exp: Likewise. * testsuite/ld-i386/no-plt.exp: Likewise. * testsuite/ld-ifunc/ifunc.exp: Likewise. * testsuite/ld-mips-elf/mips-elf-flags.exp: Likewise. * testsuite/ld-nios2/nios2.exp: Likewise. * testsuite/ld-plugin/lto.exp: Likewise. * testsuite/ld-plugin/plugin.exp: Likewise. * testsuite/ld-powerpc/export-class.exp: Likewise. * testsuite/ld-scripts/align.exp: Likewise. * testsuite/ld-scripts/crossref.exp: Likewise. * testsuite/ld-scripts/defined.exp: Likewise. * testsuite/ld-scripts/overlay-size.exp: Likewise. * testsuite/ld-scripts/provide.exp: Likewise. * testsuite/ld-scripts/weak.exp: Likewise. * testsuite/ld-selective/selective.exp: Likewise. * testsuite/ld-sh/rd-sh.exp: Likewise. * testsuite/ld-size/size.exp: Likewise. * testsuite/ld-srec/srec.exp: Likewise. * testsuite/ld-x86-64/mpx.exp: Likewise. * testsuite/ld-x86-64/no-plt.exp: Likewise. * testsuite/ld-x86-64/x86-64.exp: Likewise.
2020-06-04ld-dynamic test fixesAlan Modra6-8/+31
* testsuite/ld-dynamic/export-dynamic-symbol-2.d: Match output for mips-sgi-irix6. * testsuite/ld-dynamic/export-dynamic-symbol-glob.d: Likewise. * testsuite/ld-dynamic/export-dynamic-symbol-list-2.d: Likewise. * testsuite/ld-dynamic/export-dynamic-symbol-list-glob.d: Likewise. * testsuite/ld-dynamic/export-dynamic-symbol.exp: Exclude targets with poor PIE support.
2020-06-04ld testsuite fails with default-PIE compilerAlan Modra3-3/+9
* testsuite/ld-plugin/lto.exp (pr12758.exe): Add NOPIE_LDFLAGS. * testsuite/ld-unique/unique.exp: Add NOPIE_LDFLAGS to unique executable and dynamic executable tests.
2020-06-03ld: Pass -fno-sanitize=all to tests with linkerH.J. Lu14-32/+121
When binutils is compiled with -fsanitize=undefined, many tests with linker, instead of $CC, fail with undefined symbol references to sanitize library. Define NOSANTIZE_CFLAGS to -fno-sanitize=all if target compiler supports it and compile such tests with $NOSANTIZE_CFLAGS. * testsuite/config/default.exp (NOSANTIZE_CFLAGS): New. * testsuite/ld-elf/linux-x86.exp: Add $NOSANTIZE_CFLAGS to tests with run_ld_link_exec_tests. * testsuite/ld-elf/shared.exp: Add $NOSANTIZE_CFLAGS to tests with run_ld_link_tests. * testsuite/ld-elf/tls.exp: Likewise. * testsuite/ld-elfweak/elfweak.exp: Add $NOSANTIZE_CFLAGS to tests with ld_link. * testsuite/ld-gc/gc.exp: Add $NOSANTIZE_CFLAGS to cflags. * testsuite/ld-plugin/lto.exp: Add $NOSANTIZE_CFLAGS to tests with run_ld_link_tests.a * testsuite/ld-plugin/plugin.exp: Append $NOSANTIZE_CFLAGS to CFLAGS. * testsuite/ld-selective/selective.exp: Add $NOSANTIZE_CFLAGS to cflags and cxxflags. * testsuite/ld-srec/srec.exp: Append $NOSANTIZE_CFLAGS to CC and CXX. * testsuite/ld-x86-64/plt-main-ibt-x32.dd: Updated for -fsanitize=undefined. * testsuite/ld-x86-64/plt-main-ibt.dd: Likewise. * testsuite/ld-x86-64/x86-64.exp: Add $NOSANTIZE_CFLAGS to tests with run_cc_link_tests and run_ld_link_tests.
2020-06-03ld: Add --export-dynamic-symbol and --export-dynamic-symbol-listFangrui Song22-9/+341
--export-dynamic-symbol-list is like a dynamic list, but without the symbolic property for unspecified symbols. When creating an executable, --export-dynamic-symbol-list is treated like --dynamic-list. When creating a shared library, it is treated like --dynamic-list if -Bsymbolic or --dynamic-list are used, otherwise, it is ignored, so that references to matched symbols will not be bound to the definitions within the shared library. PR ld/25910 * NEWS: Mention --export-dynamic-symbol[-list]. * ld.texi: Document --export-dynamic-symbol[-list]. * ldgram.y: Pass current_dynamic_list_p to lang_append_dynamic_list. * ldlang.c (current_dynamic_list_p): New. (ang_append_dynamic_list): Updated to take a pointer to struct bfd_elf_dynamic_list * argument instead of using link_info.dynamic_list. (lang_append_dynamic_list_cpp_typeinfo): Pass &link_info.dynamic_list to ang_append_dynamic_list. (lang_append_dynamic_list_cpp_new): Likewise. * ldlang.h (current_dynamic_list_p): New. (lang_append_dynamic_list): Add a pointer to struct bfd_elf_dynamic_list * argument. * ldlex.h (option_values): Add OPTION_EXPORT_DYNAMIC_SYMBOL and OPTION_EXPORT_DYNAMIC_SYMBOL_LIST. * lexsup.c (ld_options): Add entries for OPTION_EXPORT_DYNAMIC_SYMBOL and OPTION_EXPORT_DYNAMIC_SYMBOL_LIST. (parse_args): Handle --export-dynamic-symbol and --export-dynamic-symbol-list. * testsuite/ld-dynamic/export-dynamic-symbol-1.d: New. * testsuite/ld-dynamic/export-dynamic-symbol-2.d: New. * testsuite/ld-dynamic/export-dynamic-symbol-glob.d: New. * testsuite/ld-dynamic/export-dynamic-symbol-list-1.d: New. * testsuite/ld-dynamic/export-dynamic-symbol-list-2.d: New. * testsuite/ld-dynamic/export-dynamic-symbol-list-glob.d: New. * testsuite/ld-dynamic/export-dynamic-symbol.exp: New. * testsuite/ld-dynamic/export-dynamic-symbol.s: New. * testsuite/ld-dynamic/foo-bar.list: New. * testsuite/ld-dynamic/foo.list: New. * testsuite/ld-dynamic/foo.s: New. * testsuite/ld-dynamic/fstar.list: New. * testsuite/ld-elf/dlempty.list: New. * testsuite/ld-elf/shared.exp: Add tests for --export-dynamic-symbol and --export-dynamic-symbol-list.
2020-06-03ld: fix ld-elf/linux-x86.exp for r/o source treeJan Beulich2-0/+7
Since the copying ofthe individual files gets done more than once, make sure the destinations can be copied to on subsequent copying attempts.
2020-05-28Have the linker fail if any attempt to link in an executable is made.Nick Clifton2-2/+14
PR 26047 * ldelf.c (ldelf_after_open): Fail if attempting to link one executable into another. Ensure that the test is made for all forms of linking.
2020-05-28Stop the linker from accepting executable ELF files as inputs to other links.Nick Clifton2-0/+13
PR 26047 * ldelf.c (ldelf_after_open): Fail if attempting to link one executable into another.
2020-05-28ld: Mention --enable-textrel-check=yes is default for Linux/x86 targetsH.J. Lu2-3/+5
* NEWS: Mention --enable-textrel-check=yes is default for Linux/x86 targets.
2020-05-28ld: Enable --warn-textrel by default for Linux/x86 targetsH.J. Lu2-1/+9
* configure.tgt (ac_default_ld_textrel_check): Set to if unset for Linux/x86 targets.
2020-05-28ld: Add --enable-textrel-check=[no|yes|warning|error]H.J. Lu7-3/+98
Add a configure option, --enable-textrel-check=[no|yes|warning|error], to decide what ELF linker should do by default with DT_TEXTREL in an executable or shared library. PR ld/20824 * NEWS: Mention --enable-textrel-check=[no|yes|warning|error]. * configure.ac: Add --enable-textrel-check=[no|yes|warning|error]. (DEFAULT_LD_TEXTREL_CHECK): New AC_DEFINE_UNQUOTED. (DEFAULT_LD_TEXTREL_CHECK_WARNING): Likewise. * ldmain.c (main): Initialize link_info.textrel_check to DEFAULT_LD_TEXTREL_CHECK. * lexsup.c (ld_options): Check DEFAULT_LD_TEXTREL_CHECK_WARNING. * config.in: Regenerated. * configure: Likewise.
2020-05-28Linker: Remove support for -Map= with an empty argument.Nick Clifton4-18/+29
* lexsup.c (parse_args): Generate an error if a name is not provided to the -Map option. (ld_options): Mention that the -Map option supports a directory name as an argument. * NEWS: Remove mention of support for an empty string as an argument to -Map. * ld.texi: Likewise.
2020-05-27PR ld/22909 amendment; don't xfail ld-elf/pr19539.d for cris*-*-*.Hans-Peter Nilsson2-1/+6
Noticed by my autotester covering cris-axis-linux-gnu: ... Running <x>/src/ld/testsuite/ld-elf/elf.exp ... XPASS: ld-elf/pr19539 ... This was apparently as intended, so I'm just adjusting the xfail. PR ld/22909 * testsuite/ld-elf/pr19539.d: Don't xfail for cris*-*-*.
2020-05-27 [PATCH] allow empty string as argument to -MapNick Clifton5-2/+76
* lexsup.c (parse_args): If the map filename is defined but empty create a name based upon the output file name. If the name is defined but refers to a directory create a file inside the directory based on the output file name. * ld.texi: Document the new feature. * testsuite/ld-script/map-address.exp: Add test of new feature. * NEWS: Mention the new feature.
2020-05-27ld: Add --warn-textrel and obsolete --warn-shared-textrelH.J. Lu8-22/+60
--warn-shared-textrel and -z text apply to both shared object and PIE. Add --warn-textrel and obsolete --warn-shared-textrel. Consolidate --warn-textrel and -z text/notext/textoff implementation. bfd/ PR ld/22909 * elflink.c (bfd_elf_final_link): Use bfd_link_textrel_check. Check bfd_link_dll when issue a DT_TEXTREL warning. * elfxx-x86.c (maybe_set_textrel): Likewise. (_bfd_x86_elf_size_dynamic_sections): Likewise. include/ PR ld/22909 * bfdlink.h (textrel_check_method): New enum. (bfd_link_textrel_check): New. (bfd_link_info): Replace warn_shared_textrel and error_textrel with textrel_check. ld/ PR ld/22909 * NEWS: Mention --warn-textrel. * ld.texi: Update -z text/notext/textoff. Add --warn-textrel. Remove --warn-shared-textrel. * ldlex.h (option_values): Rename OPTION_WARN_SHARED_TEXTREL to OPTION_WARN_TEXTREL. * lexsup.c (ld_options): Add --warn-textrel. Obsolete --warn-shared-textrel. (parse_args): Updated. (elf_shlib_list_options): Check link_info.textrel_check. * emultempl/elf.em: Updated. * testsuite/ld-elf/pr19539.d: Replace -z notext with --warn-textrel. Expect a warning. * testsuite/ld-i386/warn1.d: Update expected warning.
2020-05-26ld: Skip some x86 ifunc tests for lynxos and ntoH.J. Lu4-0/+9
On lynxos and nto: regexp_diff match failure regexp "^Relocation section '.rel(a|).plt' at offset 0x[0-9a-f]+ contains 1 entry:$" line "Relocation section '.rel.dyn' at offset 0x74 contains 1 entry:" FAIL: ld-ifunc/ifunc-23a-x86 * testsuite/ld-ifunc/ifunc-23a-x86.d: Skip *-*-lynxos *-*-nto*. * testsuite/ld-ifunc/ifunc-24a-x86.d: Likewise. * testsuite/ld-ifunc/ifunc-25a-x86.d: Likewise.
2020-05-25ld-x86-64: Pass -z notext to linker for tests with DT_TEXTRELH.J. Lu2-2/+6
* testsuite/ld-x86-64/x86-64.exp: Pass -z notext to linker.
2020-05-25ld: Pass -z notext to linker for tests with DT_TEXTRELH.J. Lu35-49/+101
Some linker tests need DT_TEXTREL. Pass -z notext to linker for these tests so that they will pass with DT_TEXTREL check defaulting to warning or error. * testsuite/ld-elf/eh6.d: Pass -z notext to linker. * testsuite/ld-elf/ehdr_start-shared.d: Likewise. * testsuite/ld-elf/pr19539.d: Likewise. * testsuite/ld-elfvers/vers.exp: Likewise. * testsuite/ld-elfvsb/elfvsb.exp: Likewise. * testsuite/ld-i386/i386.exp: Likewise. * testsuite/ld-i386/nogot1.d: Likewise. * testsuite/ld-i386/pr19539.d: Likewise. * testsuite/ld-i386/pr19636-2a.d: Likewise. * testsuite/ld-i386/pr19636-2b.d: Likewise. * testsuite/ld-i386/pr19636-2c.d: Likewise. * testsuite/ld-i386/pr19636-2d.d: Likewise. * testsuite/ld-i386/pr19636-2e.d: Likewise. * testsuite/ld-i386/pr19636-3d.d: Likewise. * testsuite/ld-i386/pr19636-3e.d: Likewise. * testsuite/ld-i386/pr19939b.d: Likewise. * testsuite/ld-i386/undefweaka.d: Likewise. * testsuite/ld-i386/undefweakb.d: Likewise. * testsuite/ld-shared/shared.exp: Likewise. * testsuite/ld-size/size.exp: Likewise. * testsuite/ld-unique/unique.exp: Likewise. * testsuite/ld-x86-64/pie1.d: Likewise. * testsuite/ld-x86-64/pr19539a.d: Likewise. * testsuite/ld-x86-64/pr19539b.d: Likewise. * testsuite/ld-x86-64/pr19636-1d.d: Likewise. * testsuite/ld-x86-64/pr19636-1e.d: Likewise. * testsuite/ld-x86-64/pr19807-1a.d: Likewise. * testsuite/ld-x86-64/pr19807-1b.d: Likewise. * testsuite/ld-x86-64/pr19807-2b.d: Likewise. * testsuite/ld-x86-64/pr19807-2c.d: Likewise. * testsuite/ld-x86-64/pr19807-2d.d: Likewise. * testsuite/ld-x86-64/pr19807-2e.d: Likewise. * testsuite/ld-x86-64/pr19939b.d: Likewise. * testsuite/ld-x86-64/x86-64.exp: Likewise.
2020-05-24ld: Handle --dynamic-list* before -Bsymbolic -Bsymbolic-functionsFangrui Song4-25/+37
--dynamic-list* should work both before and after -Bsymbolic and -Bsymbolic-functions. PR ld/26018 * lexsup.c (parse_args): Simplify. * testsuite/ld-elf/dl4e.out: New. * testsuite/ld-elf/shared.exp: Updated for PR ld/26018 tests.
2020-05-23ld: Add -Bsymbolic-functions testsH.J. Lu6-0/+49
PR ld/26018 * testsuite/ld-i386/i386.exp: Add a -Bsymbolic-functions test. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/pr26018.d: New file. * testsuite/ld-x86-64/pr26018.d: Likewise. * testsuite/ld-x86-64/pr26018.s: Likewise.
2020-05-21Replace "if (x) free (x)" with "free (x)", ldAlan Modra14-84/+56
* deffilep.y: Replace "if (x) free (x)" with "free (x)" thoughout. * emultempl/elf.em: Likewise. * emultempl/msp430.em: Likewise. * emultempl/pe.em: Likewise. * emultempl/pep.em: Likewise. * emultempl/ppc64elf.em: Likewise. * emultempl/xtensaelf.em: Likewise. * ldelf.c: Likewise. * ldfile.c: Likewise. * ldmain.c: Likewise. * ldmisc.c: Likewise. * lexsup.c: Likewise. * pe-dll.c: Likewise.
2020-05-20[PATCH v2 0/9] RISC-V: Support version controling for ISA standard ↵Nelson Chu13-6/+49
extensions and CSR 1. Remove the -mriscv-isa-version and --with-riscv-isa-version options. We can still use -march to choose the version for each extensions, so there is no need to add these. 2. Change the arguments of options from [1p9|1p9p1|...] to [1.9|1.9.1|...]. Unlike the architecture string has specified by spec, ther is no need to do the same thing for options. 3. Spilt the patches to reduce the burdens of review. [PATCH 3/7] RISC-V: Support new GAS options and configure options to set ISA versions to [PATCH v2 3/9] RISC-V: Support GAS option -misa-spec to set ISA versions [PATCH v2 4/9] RISC-V: Support configure options to set ISA versions by default. [PATCH 4/7] RISC-V: Support version checking for CSR according to privilege version. to [PATCH v2 5/9] RISC-V: Support version checking for CSR according to privilege spec version. [PATCH v2 6/9] RISC-V: Support configure option to choose the privilege spec version. 4. Use enum class rather than string to compare the choosen ISA spec in opcodes/riscv-opc.c. The behavior is same as comparing the choosen privilege spec. include * opcode/riscv.h: Include "bfd.h" to support bfd_boolean. (enum riscv_isa_spec_class): New enum class. All supported ISA spec belong to one of the class (struct riscv_ext_version): New structure holds version information for the specific ISA. * opcode/riscv-opc.h (DECLARE_CSR): There are two version information, define_version and abort_version. The define_version means which privilege spec is started to define the CSR, and the abort_version means which privilege spec is started to abort the CSR. If the CSR is valid for the newest spec, then the abort_version should be PRIV_SPEC_CLASS_DRAFT. (DECLARE_CSR_ALIAS): Same as DECLARE_CSR, but only for the obselete CSR. * opcode/riscv.h (enum riscv_priv_spec_class): New enum class. Define the current supported privilege spec versions. (struct riscv_csr_extra): Add new fields to store more information about the CSR. We use these information to find the suitable CSR address when user choosing a specific privilege spec. binutils * dwarf.c: Updated since DECLARE_CSR is changed. opcodes * riscv-opc.c (riscv_ext_version_table): The table used to store all information about the supported spec and the corresponding ISA versions. Currently, only Zicsr is supported to verify the correctness of Z sub extension settings. Others will be supported in the future patches. (struct isa_spec_t, isa_specs): List for all supported ISA spec classes and the corresponding strings. (riscv_get_isa_spec_class): New function. Get the corresponding ISA spec class by giving a ISA spec string. * riscv-opc.c (struct priv_spec_t): New structure. (struct priv_spec_t priv_specs): List for all supported privilege spec classes and the corresponding strings. (riscv_get_priv_spec_class): New function. Get the corresponding privilege spec class by giving a spec string. (riscv_get_priv_spec_name): New function. Get the corresponding privilege spec string by giving a CSR version class. * riscv-dis.c: Updated since DECLARE_CSR is changed. * riscv-dis.c: Add new disassembler option -Mpriv-spec to dump the CSR according to the chosen version. Build a hash table riscv_csr_hash to store the valid CSR for the chosen pirv verison. Dump the direct CSR address rather than it's name if it is invalid. (parse_riscv_dis_option_without_args): New function. Parse the options without arguments. (parse_riscv_dis_option): Call parse_riscv_dis_option_without_args to parse the options without arguments first, and then handle the options with arguments. Add the new option -Mpriv-spec, which has argument. * riscv-dis.c (print_riscv_disassembler_options): Add description about the new OBJDUMP option. ld * testsuite/ld-riscv-elf/attr-merge-arch-01.d: Updated priv attributes according to the -mpriv-spec option. * testsuite/ld-riscv-elf/attr-merge-arch-02.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-arch-03.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-priv-spec-a.s: Likewise. * testsuite/ld-riscv-elf/attr-merge-priv-spec-b.s: Likewise. * testsuite/ld-riscv-elf/attr-merge-priv-spec.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-stack-align.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-strict-align-01.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-strict-align-02.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-strict-align-03.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-strict-align-04.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-strict-align-05.d: Likewise. bfd * elfxx-riscv.h (riscv_parse_subset_t): Add new callback function get_default_version. It is used to find the default version for the specific extension. * elfxx-riscv.c (riscv_parsing_subset_version): Remove the parameters default_major_version and default_minor_version. Add new bfd_boolean parameter *use_default_version. Set it to TRUE if we need to call the callback rps->get_default_version to find the default version. (riscv_parse_std_ext): Call rps->get_default_version if we fail to find the default version in riscv_parsing_subset_version, and then call riscv_add_subset to add the subset into subset list. (riscv_parse_prefixed_ext): Likewise. (riscv_std_z_ext_strtab): Support Zicsr extensions. * elfnn-riscv.c (riscv_merge_std_ext): Use strcasecmp to compare the strings rather than characters. riscv_merge_arch_attr_info): The callback function get_default_version is only needed for assembler, so set it to NULL int the linker. * elfxx-riscv.c (riscv_estimate_digit): Remove the static. * elfxx-riscv.h: Updated. gas * testsuite/gas/riscv/priv-reg-fail-read-only-01.s: Updated. * config/tc-riscv.c (default_arch_with_ext, default_isa_spec): Static variables which are used to set the ISA extensions. You can use -march (or ELF build attributes) and -misa-spec to set them, respectively. (ext_version_hash): The hash table used to handle the extensions with versions. (init_ext_version_hash): Initialize the ext_version_hash according to riscv_ext_version_table. (riscv_get_default_ext_version): The callback function of riscv_parse_subset_t. According to the choosed ISA spec, get the default version for the specific extension. (riscv_set_arch): Set the callback function. (enum options, struct option md_longopts): Add new option -misa-spec. (md_parse_option): Do not call riscv_set_arch for -march. We will call it later in riscv_after_parse_args. Call riscv_get_isa_spec_class to set default_isa_spec class. (riscv_after_parse_args): Call init_ext_version_hash to initialize the ext_version_hash, and then call riscv_set_arch to set the architecture with versions according to default_arch_with_ext. * testsuite/gas/riscv/attribute-02.d: Set 0p0 as default version for x extensions. * testsuite/gas/riscv/attribute-03.d: Likewise. * testsuite/gas/riscv/attribute-09.d: New testcase. For i-ext, we already set it's version to 2p1 by march, so no need to use the default 2p2 version. For m-ext, we do not set the version by -march and ELF arch attribute, so set the default 2p0 to it. For zicsr, it is not defined in ISA spec 2p2, so set 0p0 to it. * testsuite/gas/riscv/attribute-10.d: New testcase. The version of zicsr is 2p0 according to ISA spec 20191213. * config/tc-riscv.c (DEFAULT_RISCV_ARCH_WITH_EXT) (DEFAULT_RISCV_ISA_SPEC): Default configure option settings. You can set them by configure options --with-arch and --with-isa-spec, respectively. (riscv_set_default_isa_spec): New function used to set the default ISA spec. (md_parse_option): Call riscv_set_default_isa_spec rather than call riscv_get_isa_spec_class directly. (riscv_after_parse_args): If the -isa-spec is not set, then we set the default ISA spec according to DEFAULT_RISCV_ISA_SPEC by calling riscv_set_default_isa_spec. * testsuite/gas/riscv/attribute-01.d: Add -misa-spec=2.2, since the --with-isa-spec may be set to different ISA spec. * testsuite/gas/riscv/attribute-02.d: Likewise. * testsuite/gas/riscv/attribute-03.d: Likewise. * testsuite/gas/riscv/attribute-04.d: Likewise. * testsuite/gas/riscv/attribute-05.d: Likewise. * testsuite/gas/riscv/attribute-06.d: Likewise. * testsuite/gas/riscv/attribute-07.d: Likewise. * configure.ac: Add configure options, --with-arch and --with-isa-spec. * configure: Regenerated. * config.in: Regenerated. * config/tc-riscv.c (default_priv_spec): Static variable which is used to check if the CSR is valid for the chosen privilege spec. You can use -mpriv-spec to set it. (enum reg_class): We now get the CSR address from csr_extra_hash rather than reg_names_hash. Therefore, move RCLASS_CSR behind RCLASS_MAX. (riscv_init_csr_hashes): Only need to initialize one hash table csr_extra_hash. (riscv_csr_class_check): Change the return type to void. Don't check the ISA dependency if -mcsr-check isn't set. (riscv_csr_version_check): New function. Check and find the CSR address from csr_extra_hash, according to default_priv_spec. Report warning for the invalid CSR if -mcsr-check is set. (reg_csr_lookup_internal): Updated. (reg_lookup_internal): Likewise. (md_begin): Updated since DECLARE_CSR and DECLARE_CSR_ALIAS are changed. (enum options, struct option md_longopts): Add new GAS option -mpriv-spec. (md_parse_option): Call riscv_set_default_priv_version to set default_priv_spec. (riscv_after_parse_args): If -mpriv-spec isn't set, then set the default privilege spec to the newest one. (enum riscv_csr_class, struct riscv_csr_extra): Move them to include/opcode/riscv.h. * testsuite/gas/riscv/priv-reg-fail-fext.d: This test case just want to check the ISA dependency for CSR, so fix the spec version by adding -mpriv-spec=1.11. * testsuite/gas/riscv/priv-reg-fail-fext.l: Likewise. There are some version warnings for the test case. * gas/testsuite/gas/riscv/priv-reg-fail-read-only-01.d: Likewise. * gas/testsuite/gas/riscv/priv-reg-fail-read-only-01.l: Likewise. * gas/testsuite/gas/riscv/priv-reg-fail-read-only-02.d: Likewise. * gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.d: Likewise. * gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.l: Likewise. * gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.d: New test case. Check whether the CSR is valid when privilege version 1.9 is choosed. * gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.l: Likewise. * gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.d: New test case. Check whether the CSR is valid when privilege version 1.9.1 is choosed. * gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.l: Likewise. * gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.d: New test case. Check whether the CSR is valid when privilege version 1.10 is choosed. * gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.l: Likewise. * gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.d: New test case. Check whether the CSR is valid when privilege version 1.11 is choosed. * gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.l: Likewise. * config/tc-riscv.c (DEFAULT_RISCV_ISA_SPEC): Default configure option setting. You can set it by configure option --with-priv-spec. (riscv_set_default_priv_spec): New function used to set the default privilege spec. (md_parse_option): Call riscv_set_default_priv_spec rather than call riscv_get_priv_spec_class directly. (riscv_after_parse_args): If -mpriv-spec isn't set, then we set the default privilege spec according to DEFAULT_RISCV_PRIV_SPEC by calling riscv_set_default_priv_spec. * testsuite/gas/riscv/csr-dw-regnums.d: Add -mpriv-spec=1.11, since the --with-priv-spec may be set to different privilege spec. * testsuite/gas/riscv/priv-reg.d: Likewise. * configure.ac: Add configure option --with-priv-spec. * configure: Regenerated. * config.in: Regenerated. * config/tc-riscv.c (explicit_attr): Rename explicit_arch_attr to explicit_attr. Set it to TRUE if any ELF attribute is found. (riscv_set_default_priv_spec): Try to set the default_priv_spec if the priv attributes are set. (md_assemble): Set the default_priv_spec according to the priv attributes when we start to assemble instruction. (riscv_write_out_attrs): Rename riscv_write_out_arch_attr to riscv_write_out_attrs. Update the arch and priv attributes. If we don't set the corresponding ELF attributes, then try to output the default ones. (riscv_set_public_attributes): If any ELF attribute or -march-attr options is set (explicit_attr is TRUE), then call riscv_write_out_attrs to update the arch and priv attributes. (s_riscv_attribute): Make sure all arch and priv attributes are set before any instruction. * testsuite/gas/riscv/attribute-01.d: Update the priv attributes if any ELF attribute or -march-attr is set. If the priv attributes are not set, then try to update them by the default setting (-mpriv-spec or --with-priv-spec). * testsuite/gas/riscv/attribute-02.d: Likewise. * testsuite/gas/riscv/attribute-03.d: Likewise. * testsuite/gas/riscv/attribute-04.d: Likewise. * testsuite/gas/riscv/attribute-06.d: Likewise. * testsuite/gas/riscv/attribute-07.d: Likewise. * testsuite/gas/riscv/attribute-08.d: Likewise. * testsuite/gas/riscv/attribute-09.d: Likewise. * testsuite/gas/riscv/attribute-10.d: Likewise. * testsuite/gas/riscv/attribute-unknown.d: Likewise. * testsuite/gas/riscv/attribute-05.d: Likewise. Also, the priv spec set by priv attributes must be supported. * testsuite/gas/riscv/attribute-05.s: Likewise. * testsuite/gas/riscv/priv-reg-fail-version-1p9.d: Likewise. Updated priv attributes according to the -mpriv-spec option. * testsuite/gas/riscv/priv-reg-fail-version-1p9p1.d: Likewise. * testsuite/gas/riscv/priv-reg-fail-version-1p10.d: Likewise. * testsuite/gas/riscv/priv-reg-fail-version-1p11.d: Likewise. * testsuite/gas/riscv/priv-reg.d: Removed. * testsuite/gas/riscv/priv-reg-version-1p9.d: New test case. Dump the CSR according to the priv spec 1.9. * testsuite/gas/riscv/priv-reg-version-1p9p1.d: New test case. Dump the CSR according to the priv spec 1.9.1. * testsuite/gas/riscv/priv-reg-version-1p10.d: New test case. Dump the CSR according to the priv spec 1.10. * testsuite/gas/riscv/priv-reg-version-1p11.d: New test case. Dump the CSR according to the priv spec 1.11. * config/tc-riscv.c (md_show_usage): Add descriptions about the new GAS options. * doc/c-riscv.texi: Likewise.
2020-05-20PR25993, read of freed memoryAlan Modra3-52/+31
ldmain.c:add_archive_element copies file name pointers from the bfd to a lang_input_statement_type. input->filename = abfd->filename; input->local_sym_name = abfd->filename; This results in stale pointers when twiddling the bfd filename in places like the pe ld after_open. So don't free the bfd filename, and make copies using bfd_alloc memory that won't result in small memory leaks that annoy memory checkers. PR 25993 bfd/ * archive.c (_bfd_get_elt_at_filepos): Don't strdup filename, use bfd_set_filename. * elfcode.h (_bfd_elf_bfd_from_remote_memory): Likewise. * mach-o.c (bfd_mach_o_fat_member_init): Likewise. * opncls.c (bfd_fopen, bfd_openstreamr, bfd_openr_iovec, bfd_openw), (bfd_create): Likewise. (_bfd_delete_bfd): Don't free filename. (bfd_set_filename): Copy filename param to bfd_alloc'd memory, return pointer to the copy or NULL on alloc fail. * vms-lib.c (_bfd_vms_lib_get_module): Free newname and test result of bfd_set_filename. * bfd-in2.h: Regenerate. gdb/ * solib-darwin.c (darwin_bfd_open): Don't strdup pathname for bfd_set_filename. * solib-aix.c (solib_aix_bfd_open): Use std::string for name passed to bfd_set_filename. * symfile-mem.c (add_vsyscall_page): Likewise for string passed to symbol_file_add_from_memory. (symbol_file_add_from_memory): Make name param a const char* and don't strdup. ld/ * emultempl/pe.em (gld_${EMULATION_NAME}_after_open): Don't copy other_bfd_filename for bfd_set_filename, and test result of bfd_set_filename call. Don't create a new is->filename, simply copy from bfd filename. Free new_name after bfd_set_filename. * emultempl/pep.em (gld_${EMULATION_NAME}_after_open): Likewise.
2020-05-19[PATCH v3] aarch64: Emit jump slot for conditional branch to undefined symbolsSiddhesh Poyarekar4-0/+19
The linker silently writes out a conditional branch to 0 if the target symbol in R_AARCH64_CONDBR19 or R_AARCH64_TSTBR14 relocations is undefined. Emit a PLT instead so that behaviour is the same for these relocations as the llvm linker. The special behaviour for undefined weak symbols, where conditional branches to such symbols result in a branch unto themselves, has been retained. This is because the weak-undefined.s test explicitly checks for that, leading me to conclude that it's expected behaviour. bfd * elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Club BFD_RELOC_AARCH64_BRANCH19 and BFD_RELOC_AARCH64_TSTBR14 cases with BFD_RELOC_AARCH64_JUMP26. (elfNN_aarch64_check_relocs): Likewise. ld * testsuite/ld-aarch64/aarch64-elf.exp: New test emit-relocs-560. * testsuite/ld-aarch64/emit-relocs-560.d: New file. * testsuite/ld-aarch64/emit-relocs-560.s: New file.
2020-05-19Use bfd_get_filename throughout ldAlan Modra10-55/+80
* emultempl/beos.em (sort_by_file_name): Use bfd_get_filename rather than accessing bfd->filename directly. * emultempl/pe.em (gld_${EMULATION_NAME}_after_open): Likewise. * emultempl/pep.em (gld_${EMULATION_NAME}_after_open): Likewise. * emultempl/spuelf.em (embedded_spu_file): Likewise. * ldlang.c (input_statement_is_archive_path, wild_sort), (check_excluded_libs): Likewise. * ldmain.c (add_archive_element): Likewise. * ldmisc.c (vfinfo): Likewise. * pe-dll.c (auto_export, generate_edata, pe_create_import_fixup), (pe_dll_generate_implib, pe_process_import_defs): Likewise. * plugin.c (plugin_object_p): Likewise.
2020-05-18Show AIX gc'd symbol address adjustments in map fileDouglas B Rupp16-16/+100
* ldemul.h (ldemul_print_symbol): New. (ld_emulation_xfer_type) <print_symbol): Likewise. * ldemul.c (ldemul_print_symbol): New. * ldlang.c (SECTION_NAME_MAP_LANGTH): Move to ... (print_one_symbol): Make global and move declaration to ... (print_all_symbols): Rename print_one_symbol to ldemul_print_symbol (print_input_section): Likewise * ldlang.h: ... here. * emultempl/aix.em (gld${EMULATION_NAME}_print_symbol): New. (ld_emulation_xfer_struct): Use it. * emultempl/armcoff.em (ld_emulation_xfer_struct): Add print_symbol and default to NULL. * emultempl/beos.em (ld_emulation_xfer_struct): Likewise * emultempl/elf.em (ld_emulation_xfer_struct): Likewise * emultempl/generic.em (ld_emulation_xfer_struct): Likewise * emultempl/linux.em (ld_emulation_xfer_struct): Likewise * emultempl/msp430.em (ld_emulation_xfer_struct): Likewise * emultempl/pe.em (ld_emulation_xfer_struct): Likewise * emultempl/pep.em (ld_emulation_xfer_struct): Likewise * emultempl/ticoff.em (ld_emulation_xfer_struct): Likewise * emultempl/vanilla.em (ld_emulation_xfer_struct): Likewise
2020-05-18[PATCH] ld: fix s/claimi/claim/ typoSergei Trofimovich2-1/+6
* ldmain.c (add_archive_element): Fix s/claimi/claim/ typo in info message.
2020-05-18Updated translations for the gprof and ld sub-directoriesNick Clifton2-1157/+4979
2020-05-18Prevent a potential use-after-fee memory corruption bug in the linker (for ↵Nick Clifton3-12/+46
PE format files). PR 25993 * emultempl/pe.em (_after_open): Check for duplicate filename pointers before renaming the dll. * emultempl/pep.em (_after_open): Likewise.
2020-05-13Have the linker's help text include the default setting of the --hash-style ↵Nick Clifton2-1/+24
option, if relevent. PR 25979 * lexsup.c (elf_shlib_list_options): Include the default value for the hash style in the output text.