summaryrefslogtreecommitdiff
path: root/ld
Commit message (Collapse)AuthorAgeFilesLines
* ld-x86-64: Pass -z notext to linker for tests with DT_TEXTRELH.J. Lu2020-05-252-2/+6
| | | | * testsuite/ld-x86-64/x86-64.exp: Pass -z notext to linker.
* ld: Pass -z notext to linker for tests with DT_TEXTRELH.J. Lu2020-05-2535-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.
* ld: Handle --dynamic-list* before -Bsymbolic -Bsymbolic-functionsFangrui Song2020-05-244-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.
* ld: Add -Bsymbolic-functions testsH.J. Lu2020-05-236-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.
* Replace "if (x) free (x)" with "free (x)", ldAlan Modra2020-05-2114-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.
* [PATCH v2 0/9] RISC-V: Support version controling for ISA standard ↵Nelson Chu2020-05-2013-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.
* PR25993, read of freed memoryAlan Modra2020-05-203-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.
* [PATCH v3] aarch64: Emit jump slot for conditional branch to undefined symbolsSiddhesh Poyarekar2020-05-194-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.
* Use bfd_get_filename throughout ldAlan Modra2020-05-1910-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.
* Show AIX gc'd symbol address adjustments in map fileDouglas B Rupp2020-05-1816-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
* [PATCH] ld: fix s/claimi/claim/ typoSergei Trofimovich2020-05-182-1/+6
| | | | | * ldmain.c (add_archive_element): Fix s/claimi/claim/ typo in info message.
* Updated translations for the gprof and ld sub-directoriesNick Clifton2020-05-182-1157/+4979
|
* Prevent a potential use-after-fee memory corruption bug in the linker (for ↵Nick Clifton2020-05-183-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.
* Have the linker's help text include the default setting of the --hash-style ↵Nick Clifton2020-05-132-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.
* Regen ld/Makefile.inAlan Modra2020-05-121-0/+1
| | | | Missed from c578f16ef18fd.
* Power10 VSX 32-byte storage accessAlan Modra2020-05-113-0/+33
| | | | | | | | | | | | | | | | | bfd/ * elf64-ppc.c (xlate_pcrel_opt): Handle lxvp and stxvp. opcodes/ * ppc-opc.c (insert_xtp, extract_xtp): New functions. (XTP, DQXP, DQXP_MASK): Define. (powerpc_opcodes): Add lxvp, stxvp, lxvpx, stxvpx. (prefix_opcodes): Add plxvp and pstxvp. gas/ * testsuite/gas/ppc/vsx_32byte.d, * testsuite/gas/ppc/vsx_32byte.s: New test. * testsuite/gas/ppc/ppc.exp: Run it. ld/ * testsuite/ld-powerpc/pcrelopt.s: Add lxvp and stxvp. * testsuite/ld-powerpc/pcrelopt.d: Update.
* PowerPC Rename powerxx to power10Alan Modra2020-05-117-14/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now that ISA3.1 is out we can finish with the powerxx silliness. bfd/ * elf64-ppc.c: Rename powerxx to power10 throughout. gas/ * config/tc-ppc.c (md_assemble): Update for PPC_OPCODE_POWER10 renaming. * testsuite/gas/ppc/prefix-align.d: Use -mpower10/-Mpower10 in place of -mfuture/-Mfuture. * testsuite/gas/ppc/prefix-pcrel.d: Likewise. * testsuite/gas/ppc/prefix-reloc.d: Likewise. gold/ * powerpc.cc: Rename powerxx to power10 throughout. include/ * elf/ppc64.h: Update comment. * opcode/ppc.h (PPC_OPCODE_POWER10): Rename from PPC_OPCODE_POWERXX. ld/ * testsuite/ld-powerpc/callstub-1.d: Use -mpower10/-Mpower10 in place of -mfuture/-Mfuture. * testsuite/ld-powerpc/notoc2.d: Likewise. * testsuite/ld-powerpc/powerpc.exp: Likewise. * testsuite/ld-powerpc/tlsgd.d: Likewise. * testsuite/ld-powerpc/tlsie.d: Likewise. * testsuite/ld-powerpc/tlsld.d: Likewise. opcodes/ * ppc-dis.c (ppc_opts): Add "power10" entry. (print_insn_powerpc): Update for PPC_OPCODE_POWER10 renaming. * ppc-opc.c (POWER10): Rename from POWERXX. Update all uses.
* Updated French translation for the ld sub-directory and an update Spanish ↵Nick Clifton2020-05-112-4052/+2376
| | | | translation for the opcodes subdirectory.
* [binutils-gdb][ld][AArch64] Fix group_sections algorithmWilco Dijkstra2020-05-044-0/+53
| | | | | | | | | PR ld/25665 * bfd/elfnn-aarch64.c (group_sections): Copy implementation from elf32-arm.c. * testsuite/ld-aarch64/aarch64-elf.exp: Add new test. * testsuite/ld-aarch64/farcall-group.s: New large group test. * testsuite/ld-aarch64/farcall-group.d: Likewise.
* PR25882, .gnu.attributes are not checked for shared librariesAlan Modra2020-05-012-4/+11
| | | | | | | | | | | | | | | | | This allows backend merge_private_bfd_data to examine shared library e_flags and/or .gnu.attributes. ARM and PowerPC have done so when using ld.gold for a long time. (The tic6x change below is dead code due to the earlier FIXME, but this is probably one of the changes needed there.) PR 25882 bfd/ * elf32-tic6x.c (elf32_tic6x_merge_attributes): Don't transfer Tag_ABI_PIC or Tag_ABI_PID from dynamic objects to the output. ld/ * ldlang.c (lang_check): Call bfd_merge_private_bfd_data for shared libraries.
* Regen ld BLD-POTFILES.inAlan Modra2020-05-012-0/+5
| | | | * po/BLD-POTFILES.in: Regenerate.
* AArch64: add GAS support for UDF instructionAlex Coplan2020-04-305-5/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | binutils * testsuite/binutils-all/aarch64/in-order-all.d: Update to use new disassembly. * testsuite/binutils-all/aarch64/out-of-order-all.d: Likewise. ld/ * testsuite/ld-aarch64/erratum843419_tls_ie.d: Use udf in disassembly. * testsuite/ld-aarch64/farcall-b-section.d: Likewise. * testsuite/ld-aarch64/farcall-back.d: Likewise. * testsuite/ld-aarch64/farcall-bl-section.d: Likewise. gas/ * config/tc-aarch64.c (fix_insn): Implement for AARCH64_OPND_UNDEFINED. (parse_operands): Implement for AARCH64_OPND_UNDEFINED. * testsuite/gas/aarch64/udf.s: New. * testsuite/gas/aarch64/udf.d: New. * testsuite/gas/aarch64/udf-invalid.s: New. * testsuite/gas/aarch64/udf-invalid.l: New. * testsuite/gas/aarch64/udf-invalid.d: New. include * opcode/aarch64.h (enum aarch64_opnd): Add AARCH64_OPND_UNDEFINED. opcodes * aarch64-opc.h (enum aarch64_field_kind): Add FLD_imm16_2. * aarch64-opc.c (fields): Add entry for FLD_imm16_2. (operand_general_constraint_met_p): validate AARCH64_OPND_UNDEFINED. * aarch64-tbl.h (aarch64_opcode_table): Add udf instruction, entry for FLD_imm16_2. * aarch64-asm-2.c: Regenerated. * aarch64-dis-2.c: Regenerated. * aarch64-opc-2.c: Regenerated.
* Add generic tests for linker support of the -shared or -pie options to tests ↵Nick Clifton2020-04-3078-77/+159
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | which use them. binutils* testsuite/lib/binutils-common.exp (check_pie_support): New proc. ld * testsuite/ld-elf/compress1c.d: XFAIL if thet target linker does not support the -shared command line option. * /ld-elf/compressed1c.d: Likewise. * /ld-elf/compressed1e.d: Likewise. * /ld-elf/dynamic1.d: Likewise. * /ld-elf/dynsym1.d: Likewise. * /ld-elf/ehdr_start-shared.d: Likewise. * /ld-elf/exclude3b.d: Likewise. * /ld-elf/global1.d: Likewise. * /ld-elf/hash.d: Likewise. * /ld-elf/local1.d: Likewise. * /ld-elf/mbind1b.d: Likewise. * /ld-elf/now-1.d: Likewise. * /ld-elf/now-2.d: Likewise. * /ld-elf/now-3.d: Likewise. * /ld-elf/now-4.d: Likewise. * /ld-elf/pr12975.d: Likewise. * /ld-elf/pr13177.d: Likewise. * /ld-elf/pr13195.d: Likewise. * /ld-elf/pr16322.d: Likewise. * /ld-elf/pr16498a.d: Likewise. * /ld-elf/pr16498b.d: Likewise. * /ld-elf/pr17615.d: Likewise. * /ld-elf/pr19162.d: Likewise. * /ld-elf/pr19698.d: Likewise. * /ld-elf/pr20513c.d: Likewise. * /ld-elf/pr20513d.d: Likewise. * /ld-elf/pr21389a.d: Likewise. * /ld-elf/pr21389b.d: Likewise. * /ld-elf/pr21389c.d: Likewise. * /ld-elf/pr21562a.d: Likewise. * /ld-elf/pr21562b.d: Likewise. * /ld-elf/pr21562c.d: Likewise. * /ld-elf/pr21562d.d: Likewise. * /ld-elf/pr21562e.d: Likewise. * /ld-elf/pr21562f.d: Likewise. * /ld-elf/pr21562g.d: Likewise. * /ld-elf/pr21562h.d: Likewise. * /ld-elf/pr21562i.d: Likewise. * /ld-elf/pr21562j.d: Likewise. * /ld-elf/pr21562k.d: Likewise. * /ld-elf/pr21562l.d: Likewise. * /ld-elf/pr21562m.d: Likewise. * /ld-elf/pr21562n.d: Likewise. * /ld-elf/pr21903a.d: Likewise. * /ld-elf/pr21903b.d: Likewise. * /ld-elf/pr22269b.d: Likewise. * /ld-elf/pr22393-1a.d: Likewise. * /ld-elf/pr22393-1b.d: Likewise. * /ld-elf/pr23658-1c.d: Likewise. * /ld-elf/pr25708.d: Likewise. * /ld-elf/rpath-1.d: Likewise. * /ld-elf/rpath-2.d: Likewise. * /ld-elf/runpath-1.d: Likewise. * /ld-elf/runpath-2.d: Likewise. * /ld-elf/sizeofb.d: Likewise. * /ld-elf/startofb.d: Likewise. * /ld-elf/strtab.d: Likewise. * /ld-elf/textaddr2.d: Likewise. * /ld-elf/textaddr5.d: Likewise. * /ld-elf/textaddr6.d: Likewise. * /ld-elf/unknown2.d: Likewise. * /ld-undefined/entry-3.d: Likewise. * /ld-undefined/entry-4.d: Likewise. * /ld-elf/mbind1c.d: XFAIL if the target linker does not support the -pie option. * /ld-elf/pie.d: Likewise. * /ld-elf/pr19539.d: Likewise. * /ld-elf/pr21903d.d: Likewise. * /ld-elf/pr22269a.d: Likewise. * /ld-elf/pr22393-1c.d: Likewise. * /ld-elf/pr22393-1d.d: Likewise. * /ld-elf/pr22423.d: Likewise. * /ld-elf/loadaddr1.d: Expect to fail on the rx-linux target. * /ld-elf/loadaddr2.d: Likewise. * /ld-elf/pr22393-1e.d: Likewise. * /ld-elf/pr22393-1f.d: Likewise. * /ld-elf/textaddr1.d: Likewise. * /ld-elf/textaddr4.d: Likewise.
* ld: Add rx-linux emulation. gas: Change ELF flags initial value in rx-linuxYoshinori Sato2020-04-306-0/+73
| | | | | | | | | | | ld * emulparams/elf32rx_linux.sh: New rx-linux emulation. * emultempl/rxlinux.em: New. * configure.tgt: Add rx-linux. * Makefile.am: Add eelf32rx_linux.c * Makefile.in: Regenerate. gas * config/tc-rx.c (elf_flags): Reset default value. (md_parse_option): For rx-elf Initialize elf_flags with RX_ABI.
* xtensa: fix XTENSA_NDIFF handling for PR ld/25861Max Filippov2020-04-296-0/+61
| | | | | | | | | | | | | | | | | | | | | | Fields marked with XTENSA_NDIFF relocations are not negated, they only have sign bits removed. Don't negate their values when relaxation is performed. Don't add sign bits when the value is zero. Report overflow when the result has negative sign but all significant bits are zero. 2020-04-29 Max Filippov <jcmvbkbc@gmail.com> bfd/ * elf32-xtensa.c (relax_section): Don't negate diff_value for XTENSA_NDIFF relocations. Don't add sign bits whe diff_value equals 0. Report overflow when the result has negative sign but all significant bits are zero. ld/ * testsuite/ld-xtensa/relax-diff1.d: New test definition. * testsuite/ld-xtensa/relax-diff1.s: New test source. * testsuite/ld-xtensa/relax-ndiff.d: New test definition. * testsuite/ld-xtensa/relax-ndiff.s: New test source. * testsuite/ld-xtensa/xtensa.exp: (relax-diff1) (relax-ndiff): New tests.
* Remove restriction on skipping some linker tests because their default image ↵Stephen Casner2020-04-291-0/+11
| | | | | | | | | | | | | base is too high. PR 25829 * testsuite/ld-scripts/default-script.exp: Add --image-base=0 to LDFLAGS for targets *-*-mingw64 x86_64-*-cygwin. * testsuite/ld-scripts/default-script1.d: No longer have to skip test for those targets. * testsuite/ld-scripts/default-script2.d: Likewise. * testsuite/ld-scripts/default-script3.d: Likewise. * testsuite/ld-scripts/default-script4.d: Likewise.
* x86: Add i386 PE big-object supportTamar Christina2020-04-272-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The 64-bit version of binutils got support for the PE COFF BIG OBJ format a couple of years ago. The BIG OBJ format is a slightly different COFF format which extends the size of the number of section field in the header from a uint16_t to a uint32_t and so greatly increases the number of sections allowed. However the 32-bit version of bfd never got support for this. The GHC Haskell compiler generates a great deal of symbols due to it's use of -ffunction-sections and -fdata-sections. This meant that we could not build the 32-bit version of the GHC Compiler for many releases now as binutils didn't have this support. This patch adds the support to the 32-bit port of binutils as well and also does come cleanup in the code. bfd/ChangeLog: * coff-i386.c (COFF_WITH_PE_BIGOBJ): New. * coff-x86_64.c (COFF_WITH_PE_BIGOBJ): New. * config.bfd (targ_selvecs): Rename x86_64_pe_be_vec to x86_64_pe_big_vec as it not a big-endian format. (vec i386_pe_big_vec): New. * configure.ac: Likewise. * targets.c: Likewise. * configure: Regenerate. * pe-i386.c (TARGET_SYM_BIG, TARGET_NAME_BIG, COFF_WITH_PE_BIGOBJ): New. * pe-x86_64.c (TARGET_SYM_BIG, TARGET_NAME_BIG): New. (x86_64_pe_be_vec): Moved. gas/ChangeLog: * NEWS: Add news entry for big-obj. * config/tc-i386.c (i386_target_format): Support new format. * doc/c-i386.texi: Add i386 support. * testsuite/gas/pe/big-obj.d: Rename test to not be x64 specific. * testsuite/gas/pe/pe.exp (big-obj): Make test run on i386 as well. ld/ChangeLog: * pe-dll.c (pe_detail_list): Add pe-bigobj-i386.
* xtensa: fix PR ld/25861Max Filippov2020-04-224-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce new relaxations XTENSA_PDIFF{8,16,32} for positive differences (subtracted symbol precedes diminished symbol) and XTENSA_NDIFF{8,16,32} for negative differences (subtracted symbol follows diminished symbol). Don't generate XTENSA_DIFF relocations in the assembler, generate XTENSA_PDIFF or XTENSA_NDIFF based on relative symbol position. Handle XTENSA_DIFF in BFD for compatibility with old object files. Handle XTENSA_PDIFF and XTENSA_NDIFF in BFD, treating difference value as unsigned. 2020-04-22 Max Filippov <jcmvbkbc@gmail.com> bfd/ * bfd-in2.h: Regenerated. * elf32-xtensa.c (elf_howto_table): New entries for R_XTENSA_PDIFF{8,16,32} and R_XTENSA_NDIFF{8,16,32}. (elf_xtensa_reloc_type_lookup, elf_xtensa_do_reloc) (relax_section): Add cases for R_XTENSA_PDIFF{8,16,32} and R_XTENSA_NDIFF{8,16,32}. * libbfd.h (bfd_reloc_code_real_names): Add names for BFD_RELOC_XTENSA_PDIFF{8,16,32} and BFD_RELOC_XTENSA_NDIFF{8,16,32}. * reloc.c: Add documentation for BFD_RELOC_XTENSA_PDIFF{8,16,32} and BFD_RELOC_XTENSA_NDIFF{8,16,32}. binutils/ * readelf.c (is_none_reloc): Recognize BFD_RELOC_XTENSA_PDIFF{8,16,32} and BFD_RELOC_XTENSA_NDIFF{8,16,32}. gas/ * config/tc-xtensa.c (md_apply_fix): Replace BFD_RELOC_XTENSA_DIFF{8,16,32} generation with BFD_RELOC_XTENSA_PDIFF{8,16,32} and BFD_RELOC_XTENSA_NDIFF{8,16,32} generation. * testsuite/gas/xtensa/loc.d: Replace BFD_RELOC_XTENSA_DIFF16 with BFD_RELOC_XTENSA_PDIFF16 in the expected output. include/ * elf/xtensa.h (elf_xtensa_reloc_type): New entries for R_XTENSA_PDIFF{8,16,32} and R_XTENSA_NDIFF{8,16,32}. ld/ * testsuite/ld-xtensa/relax-loc.d: New test definition. * testsuite/ld-xtensa/relax-loc.s: New test source. * testsuite/ld-xtensa/xtensa.exp (relax-loc): New test.
* For relative paths in INPUT() and GROUP(), search the directory of the ↵Fangrui Song2020-04-226-12/+77
| | | | | | | | | | | | current linker script before searching other paths. PR ld/25806 * ldlang.h (struct lang_input_statement_struct): Add extra_search_path. * ldlang.c (current_input_file): New. (ldirname): New. (new_afile): Add from_filename parameter. Set extra_search_path. (lang_add_input_file): Pass current_input_file to new_afile. (load_symbols): Set current_input_file.
* Correct mingw target selectAlan Modra2020-04-225-5/+12
| | | | | | | | | | | | x86_64-w64-mingw32 +FAIL: ld-scripts/default-script1 x86_64-w64-mingw32 +FAIL: ld-scripts/default-script2 x86_64-w64-mingw32 +FAIL: ld-scripts/default-script3 x86_64-w64-mingw32 +FAIL: ld-scripts/default-script4 * testsuite/ld-scripts/default-script1.d: Correct mingw skip. * testsuite/ld-scripts/default-script2.d: Likewise. * testsuite/ld-scripts/default-script3.d: Likewise. * testsuite/ld-scripts/default-script4.d: Likewise.
* Fix linker tests to work with 16-bit targets.Stephen Casner2020-04-2116-31/+60
| | | | | | | | | | | | | | | | | | | | | PR 25829 * testsuite/ld-scripts/script.exp (check_script) (extract_symbol_test): Make test addresses fit in 16 bits. * testsuite/ld-scripts/memory.t: Likewise. * testsuite/ld-scripts/memory_sym.t (TXT_LENGTH): Likewise. * testsuite/ld-scripts/default-script.t (_START): Likewise. * testsuite/ld-scripts/default-script1.d: Likewise. * testsuite/ld-scripts/default-script2.d: Likewise. * testsuite/ld-scripts/default-script3.d: Likewise. * testsuite/ld-scripts/default-script4.d: Likewise. * testsuite/ld-scripts/empty-address-1.t: Likewise. * testsuite/ld-scripts/empty-address-1.d: Likewise. * testsuite/ld-scripts/empty-address-2a.d: Likewise. * testsuite/ld-scripts/empty-address-2b.d: Likewise. * testsuite/ld-misc/start.s: .long -> .dc.a to allow relocation to fit target address size. * testsuite/ld-scripts/empty-address-1.s: Likewise. * testsuite/ld-scripts/empty-address-2.s: Likewise.
* elf: Strip zero-sized dynamic sectionsH.J. Lu2020-04-213-52/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ELF size_dynamic_sections is called by the ELF backend linker after all the linker input files have been seen but before the section sizes have been set. After the sections sizes have been set, target-specific, global optimizations may make some dynamic sections zero-sized if they are no longer needed. Add ELF strip_zero_sized_dynamic_sections so that ELF backend linker can strip zero-sized dynamic sections after the sections sizes have been set. bfd/ PR ld/25849 * elf-bfd.h (elf_backend_data): Add elf_backend_strip_zero_sized_dynamic_sections. (_bfd_elf_strip_zero_sized_dynamic_sections): New prototype. * elf64-alpha.c (elf_backend_strip_zero_sized_dynamic_sections): New macro. * elflink.c (_bfd_elf_strip_zero_sized_dynamic_sections): New function. * elfxx-target.h (elf_backend_strip_zero_sized_dynamic_sections): New macro. (elfNN_bed): Add elf_backend_strip_zero_sized_dynamic_sections. ld/ PR ld/25849 * ldelfgen.c (ldelf_map_segments): Call elf_backend_strip_zero_sized_dynamic_sections. * testsuite/ld-alpha/tlsbinr.rd: Updated.
* PowerPC64: remove empty .rela.dyn (.rela.branch_lt)Alan Modra2020-04-204-14/+20
| | | | | | | | | | | | | | Stripping .rela.branch_lt is easy enough but messes with the testsuite due to stub symbols (that use section id) changing. Tests that run on more than one target variant can be tricky to fix, this renaming happened to work. bfd/ * elf64-ppc.c (ppc64_elf_size_stubs): Strip relbrlt too. ld/ * testsuite/ld-powerpc/tlsopt5.s: Rename foo to aaaaa. * testsuite/ld-powerpc/tlsopt5.d: Adjust to suit. * testsuite/ld-powerpc/tlsopt6.d: Likewise.
* ld: Don't xfail ld-elf/warn[12] on 64-bit Solaris/SPARCRainer Orth2020-04-183-2/+5
| | | | | | | | | | | | | | | | | | | | Two ld tests currently XPASS on 64-bit Solaris/SPARC: XPASS: ld-elf/warn1 XPASS: ld-elf/warn2 They were xfail'ed on Solaris/SPARCv9 back in 2005 https://sourceware.org/pipermail/binutils/2005-February/039268.html but obviously this no longer appplies. Fixed by removing the xfail's. Tested on sparcv9-sun-solaris2.11 and sparc-sun-solaris2.11. * testsuite/ld-elf/warn1.d: Don't xfail on 64-bit Solaris/SPARC. * testsuite/ld-elf/warn2.d: Likewise.
* elf: Don't use .set for alpha targetH.J. Lu2020-04-183-0/+11
| | | | | | | | | Since the .set directive of ELF/alpha target is different, define NO_SET to 1 to use "=" for ELF/alpha target. * testsuite/ld-elf/elf.exp (ASFLAGS): Add "--defsym NO_SET=1" for alpha target. * testsuite/ld-elf/pr19789.s: Use "=" if NO_SET is defined.
* Fix the test for PR 18963 so that it will work on 16-bit targets.Stephen Casner2020-04-173-9/+20
| | | | | | | PR 18963 * testsuite/ld-scripts/pr18963.t: Reduce section sizes to fit in 16-bit address space. * testsuite/ld-scripts/pr18963.d: Likewise.
* Revert "Fix the test for PR 18963 so that it will work on 16-bit targets."Nick Clifton2020-04-175-33/+16
| | | | This reverts commit 7a1a12f4d1c6152017142d74c736dc1cc6b0e81c.
* [PATCH 1/2] coff-go32: update ldscriptJuan Manuel Guerrero2020-04-172-0/+18
| | | | | * scripttempl/i386go32.sc: Provide symbol _environ. Link in .ctors and .dtors. Discard LTO sections.
* Commit: Running the linker testsuite with clangNick Clifton2020-04-174-3/+71
| | | | | | | | | * testsuite/config/default.exp: If not already set then create the CCC_OVERRIDE_OPTIONS environment variable to help when running the testsuite with clang. * testsuite/ld-elf/pr22269-1.c: Add a missing return statement. * testsuite/ld-elfvers/vers.exp: Add checks to detect if files were built before attempting to copy them.
* Fix the test for PR 18963 so that it will work on 16-bit targets.Stephen Casner2020-04-165-16/+33
| | | | | | | | PR ld/18963 * testsuite/ld-scripts/pr18963.s: New, replaces empty data.s to allocate space in text, data, bss here rather than pr18963.t. * testsuite/ld-scripts/pr18963.t: Remove assignments to dot. * testsuite/ld-scripts/pr18963.d: Change addresses to fit 16 bits.
* Unify the behaviour of ld.bfd and ld.gold with respect to warning about ↵Fangrui Song2020-04-154-31/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | unresolved symbol references. (PR 24613) PR binutils/24613 include * bfdlink.h (enum report_method): Delete RM_GENERATE_WARNING and RM_GENERATE_ERROR. Add RM_DIAGNOSE. (struct bfd_link_info): Add warn_unresolved_syms. ld * lexsup.c (parse_args): Change RM_GENERATE_WARNING and RM_GENERATE_ERROR to RM_DIAGNOSE. * emultempl/aix.em (ld_${EMULATION_NAME}_emulation): Change RM_GENERATE_ERROR to RM_DIAGNOSE. * emultempl/elf.em (ld_${EMULATION_NAME}_emulation): Likewise. bfd * coff-rs6000.c (xcoff_ppc_relocate_section): Change RM_GENERATE_ERROR to RM_DIAGNOSE plus a check of warn_unresolved_syms. * coff64-rs6000.c (xcoff_ppc_relocate_section): Likewise. * elf-bfd.h (_bfd_elf_large_com_section): Likewise. * elf32-m32r.c (m32r_elf_relocate_section): Likewise. * elf32-score.c (s3_bfd_score_elf_relocate_section): Likewise. * elf32-score7.c (s7_bfd_score_elf_relocate_section): Likewise. * elf32-sh.c (sh_elf_relocate_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-hppa.c (elf64_hppa_relocate_section): Likewise. * elflink.c (elf_link_output_extsym): Likewise. * elfxx-mips.c (mips_elf_calculate_relocation): Likewise.
* Fixes for the magic number used in PDP11 AOUT binaries.Stephen Casner2020-04-1414-2/+380
| | | | | | | | | | | | | | | | | | | | | | | | | | | | PR ld/25677 include * aout/aout64.h (N_DATADDR): Add IMAGIC case. bfd * pdp11.c: Add implementation of --imagic option. (adjust_o_magic): Fix objcopy --extract-symbol test. * libaout.h (enum aout_magic): Add i_magic. ld * emulparams/pdp11.sh (SCRIPT_NAME): Change to pdp11. (EXTRA_EM_FILE): New, add emulation file pdp11. * scripttempl/pdp11.sc: New, derived from aout.sc without irrelevant input sections. * emultempl/pdp11.em (_add_options, _handle_option) (_list_options): New. Add options -z, --imagic for pdp11-aout. (_before_parse): Make --omagic be default instead of --nmagic. (_get_script): Modify special-case linker script for --imagic. * lexsup.c (parse_args): Explictly set config.text_read_only for -n. * ld.texi (Options): Add documentation of PDP11-specific options. (Options): Fix unrelated typo to --no-compact-branches. * gen-doc.texi: @set PDP11. * testsuite/ld-pdp11/pdp11.exp: New, start pdp11 testing. * testsuite/ld-pdp11/sections.s: New, source for options tests. * testsuite/ld-pdp11/imagic.d: New, test --imagic format. * testsuite/ld-pdp11/imagicz.d: New, test -z (imagic) format. * testsuite/ld-pdp11/nmagic.d: New, test --nmagic format. * testsuite/ld-pdp11/omagic.d: New, test --omagic format.
* readelf: Consolidate --syms --use-dynamic with --dyn-symsH.J. Lu2020-04-1415-148/+176
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When reconstructing dynamic symbol table from the PT_DYNAMIC segment, compute dynamic symbol table size from hash table. For DT_HASH, the number of dynamic symbol table entries equals the number of chains. For DT_GNU_HASH/DT_MIPS_XHASH, only defined symbols with non-STB_LOCAL indings are in hash table. Since DT_GNU_HASH/DT_MIPS_XHASH place all symbols with STB_LOCAL binding before symbols with other bindings and all undefined symbols defined ones in dynamic symbol table, the highest symbol index in DT_GNU_HASH/DT_MIPS_XHASH is the highest dynamic symbol table index. Rewrite print_dynamic_symbol to dump dynamic symbol table for --dyn-syms and --syms --use-dynamic. binutils/ PR binutils/25707 * readelf.c (nbuckets): New. (nchains): Likewise. (buckets): Likewise. (chains): Likewise. (ngnubuckets): Likewise. (gnubuckets): Likewise. (gnuchains): Likewise. (mipsxlat): Likewise. (ngnuchains): Likewise. (gnusymidx): Likewise. (VALID_SYMBOL_NAME): Likewise. (VALID_DYNAMIC_NAME): Use it. (get_dynamic_data): Moved before process_dynamic_section. (get_num_dynamic_syms): New function. (process_dynamic_section): Use DT_SYMTAB, DT_SYMENT, DT_HASH, DT_GNU_HASH and DT_MIPS_XHASH to reconstruct dynamic symbol table. Use DT_STRTAB and DT_STRSZ to reconstruct dynamic string table. (get_symbol_index_type): Don't print "bad section index" when there is no section header. (print_dynamic_symbol): Rewrite. (process_symbol_table): Call print_dynamic_symbol to dump dynamic symbol table. ld/ PR binutils/25707 * testsuite/ld-arm/armthumb-lib.sym: Updated. * testsuite/ld-arm/farcall-mixed-app.sym: Likewise. * testsuite/ld-arm/farcall-mixed-app2.sym: Likewise. * testsuite/ld-arm/fdpic-main-m.sym: Likewise. * testsuite/ld-arm/fdpic-main.sym: Likewise. * testsuite/ld-arm/fdpic-shared-m.sym: Likewise. * testsuite/ld-arm/fdpic-shared.sym: Likewise. * testsuite/ld-arm/mixed-app.sym: Likewise. * testsuite/ld-arm/mixed-lib.sym: Likewise. * testsuite/ld-arm/preempt-app.sym: Likewise. * testsuite/ld-elf/hash.d: Likewise. * testsuite/ld-elf/pr13195.d: Likewise. * testsuite/ld-elfvsb/hidden2.d: Likewise. * testsuite/ld-mips-elf/hash2.d: Likewise.
* ld: xfail several shared (non PIC) tests on SolarisRainer Orth2020-04-102-4/+11
| | | | | | | | | | | | | | | | | | | | | Three ld tests currently FAIL on Solaris/SPARC: FAIL: shared (non PIC) FAIL: shared (non PIC, load offset) FAIL: shared (PIC main, non PIC so) all of them in the same way: /var/gcc/binutils/sparcv7/obj/binutils/ld/tmpdir/ld/collect-ld: read-only segment has dynamic relocations Given that Solaris defaults to -z text, this is to be expected, thus this patch xfail's them. Tested on sparc-sun-solaris2.11 and sparcv9-sun-solaris2.11. * testsuite/ld-shared/shared.exp: Remove dangling comments. xfail shared non PIC tests on Solaris.
* ld: Fix pr22269-1 on 32-bit Solaris/SPARCRainer Orth2020-04-092-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | pr22269-1.s currently FAILs to assemble on 32-bit Solaris/SPARC: ERROR: -K PIC tmpdir/pr22269-1.s: assembly failed UNRESOLVED: pr22269-1 (static pie undefined weak) tmpdir/pr22269-1.s: Assembler messages: tmpdir/pr22269-1.s:27: Error: Architecture mismatch on "be,pn %icc,.LL4 ,pn %icc,.LL4". tmpdir/pr22269-1.s:27: (Requires v9|v9a|v9b|v9c|v9d|v9e|v9v|v9m|m8; requested architecture is sparclite.) tmpdir/pr22269-1.s:32: Error: Architecture mismatch on "return %i7+8". tmpdir/pr22269-1.s:32: (Requires v9|v9a|v9b|v9c|v9d|v9e|v9v|v9m|m8; requested architecture is sparclite.) tmpdir/pr22269-1.s:36: Error: Architecture mismatch on "return %i7+8". tmpdir/pr22269-1.s:36: (Requires v9|v9a|v9b|v9c|v9d|v9e|v9v|v9m|m8; requested architecture is sparclite.) I could trace this to the fact that gcc on sparc-sun-solaris2.* defaults to --with-cpu=v9. So the gcc -S step of compiling the testcase is run with -mcpu=v9, while the manual invocation of as-new lacks the corresponding -Av9, creating a mismatch. Solaris seems to be the only affected target, otherwise only 64-bit-default configurations default to --with-cpu=v9 or --with-cpu=ultrasparc: sparcv9-*-*, sparc64-*-*, sparc64-*-freebsd*, ultrasparc-*-freebsd*, and sparc64-*-openbsd*. This patch just adds -Av9 to AFLAGS_PIC in ld-elf/shared.exp. It has a precedent in ld-elfvers/vers.exp where -Av9a is added to as_options on sparc-*-*. It lets the test pass and causes no other changes in sparc-sun-solaris2.11 test results. * testsuite/ld-elf/shared.exp: Add -Av9 to AFLAGS_PIC on sparc*-*-*.
* NOCF_PROTECTION_CFLAGS: Replace nopie with availableH.J. Lu2020-04-022-3/+8
| | | | | * testsuite/config/default.exp (NOCF_PROTECTION_CFLAGS): Replace nopie with available.
* ld: Add NOCF_PROTECTION_CFLAGS to turn off -fcf-protectionH.J. Lu2020-04-024-8/+57
| | | | | | | | | | | | | | | | | | | | | GCC in Ubuntu 20.04 enables -fcf-protection by default, which leads to FAIL: S-records FAIL: S-records with constructors FAIL: Build plt-main with -z bndplt FAIL: Build plt-main with PIE and -z bndplt FAIL: Build plt-main with -z bndplt -z now FAIL: Build plt-main with PIE and -z bndplt -z now on x86-64. Add NOCF_PROTECTION_CFLAGS to pass -fcf-protection=none on these tests. * testsuite/config/default.exp (NOCF_PROTECTION_CFLAGS): New. Set to "-fcf-protection=none" if target compiler supports it. * testsuite/ld-srec/srec.exp: Add $NOCF_PROTECTION_CFLAGS to CC and CXX. * testsuite/ld-x86-64/x86-64.exp: Add $NOCF_PROTECTION_CFLAGS to PLT BND tests.
* linux-x86.exp: Compile with -I../bfdH.J. Lu2020-04-022-5/+11
| | | | | | | | Compile with -I../bfd to include <bfd_stdint.h> in PR ld/25749 tests. * testsuite/ld-elf/linux-x86.exp (check_pr25749a): Compile with -I../bfd. (check_pr25749b): Likewise.
* ld: Disable ifunc tests on SolarisRainer Orth2020-04-0243-42/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A couple of ld ifunc tests currently FAIL on 64-bit Solaris/x86: FAIL: ld-ifunc/ifunc-10-x86-64 FAIL: ld-ifunc/ifunc-11-x86-64 FAIL: ld-ifunc/ifunc-12-x86-64 FAIL: ld-ifunc/ifunc-13-x86-64 FAIL: ld-ifunc/ifunc-14a-x86-64 FAIL: ld-ifunc/ifunc-14b-x86-64 FAIL: ld-ifunc/ifunc-14c-x86-64 FAIL: ld-ifunc/ifunc-14d-x86-64 FAIL: ld-ifunc/ifunc-14e-x86-64 FAIL: ld-ifunc/ifunc-14f-x86-64 FAIL: ld-ifunc/ifunc-15-x86-64 FAIL: ld-ifunc/ifunc-17a-x86-64 FAIL: ld-ifunc/ifunc-17b-x86-64 FAIL: ld-ifunc/ifunc-2-local-x86-64-now FAIL: ld-ifunc/ifunc-2-local-x86-64 FAIL: ld-ifunc/ifunc-2-x86-64-now FAIL: ld-ifunc/ifunc-2-x86-64 FAIL: ld-ifunc/ifunc-20-x86-64 FAIL: ld-ifunc/pr17154-x86-64-now FAIL: ld-ifunc/pr17154-x86-64 For one, the actual error is weird: ./ld-new: target elf64-x86-64 not found failed with: <./ld-new: target elf64-x86-64 not found>, no expected output FAIL: ld-ifunc/ifunc-10-x86-64 although ld -V does report the elf_x86_64 emulation as supported: $ ./ld/ld-new -V GNU ld (GNU Binutils) 2.34.50.20200328 Supported emulations: elf_x86_64_sol2 elf_x86_64 [...] When using ld -m elf_x86_64_sol2 instead, one of the testcases links successfully. However, there's no point in pursuing this: Solaris does not support ifunc, as can be seen in <sys/elf.h>: /* * GNU/Linux specific symbol type not used by Solaris */ #define STT_GNU_IFUNC 10 and never will, given that it has symbol capabilities as solution to effectively the same problem: http://www.linker-aliens.org/blogs/rie/entry/symbol_capabilitie/ Therefore this patch disables ifunc testing on Solaris completely by removing Solaris from binutils/testsuite/lib/binutils-common.exp (supports_gnu_osabi). The ifunc part is justified above. SHF_GNU_MBIND is in the OS-specific range and conflicts with #define SHF_SUNW_REALLOC 0x01000000 /* internal: krtld realloc */ While the comment suggests this might be relocatable without too much problems, the description of mbind (no formal spec AFAICS, just the comment in the binutils patch submission) strongly suggests that this isn't relevant to Solaris at all. Indirectly, clearing supports_gnu_osabi on Solaris disables supports_gnu_unique. Again, Solaris <sys/elf.h> has /* * GNU/Linux specific binding not used by Solaris */ #define STB_GNU_UNIQUE 10 so this seems the right thing to do. Afterwards, one can remove the explicit mentions of *-*-solaris2* in quite a number of (but not all) the ld-ifunc dump file notarget lists. There's one fallout, though: two gas tests now XPASS because they are xfail'ed for !supports_gnu_osabi: XPASS: mbind sections 12 XPASS: mbind section contents 16 XPASS: mbind sections 16 XPASS: mbind section contents 16 To fix that, I've changed #xfail: ![supports_gnu_osabi] to notarget. Tested on x86_64-pc-solaris2.11, i386-pc-solaris2.11, x86_64-pc-linux-gnu, and i686-pc-linux-gnu. ld: * testsuite/ld-ifunc/ifunc-10-i386.d: Remove *-*-solaris2* from notarget. * ifunc-11-i386.d: Likewise. * ifunc-12-i386.d: Likewise. * ifunc-13-i386.d: Likewise. * ifunc-14a-i386.d: Likewise. * ifunc-14b-i386.d: Likewise. * ifunc-14c-i386.d: Likewise. * ifunc-14d-i386.d: Likewise. * ifunc-14e-i386.d: Likewise. * ifunc-14f-i386.d: Likewise. * ifunc-15-i386.d: Likewise. * ifunc-16-i386-now.d: Likewise. * ifunc-16-i386.d: Likewise. * ifunc-17a-i386.d: Likewise. * ifunc-17b-i386.d: Likewise. * ifunc-18a-i386.d: Likewise. * ifunc-18b-i386.d: Likewise. * ifunc-19a-i386.d: Likewise. * ifunc-19b-i386.d: Likewise. * ifunc-2-i386-now.d: Likewise. * ifunc-2-i386.d: Likewise. * ifunc-2-local-i386-now.d: Likewise. * ifunc-2-local-i386.d: Likewise. * ifunc-20-i386.d: Likewise. * ifunc-21-i386.d: Likewise. * ifunc-22-i386.d: Likewise. * ifunc-5a-i386.d: Likewise. * ifunc-5a-local-i386.d: Likewise. * ifunc-5b-i386.d: Likewise. * ifunc-5b-local-i386.d: Likewise. * ifunc-5r-local-i386.d: Likewise. * ifunc-6a-i386.d: Likewise. * ifunc-6b-i386.d: Likewise. * ifunc-7a-i386.d: Likewise. * ifunc-7b-i386.d: Likewise. * ifunc-8-i386.d: Likewise. * ifunc-9-i386.d: Likewise. * pr17154-i386-now.d: Likewise. * pr17154-i386.d: Likewise. * ifunc-23a-x86.d: Remove notarget. * ifunc-24a-x86.d: Likewise. * ifunc-25a-x86.d: Likewise. gas: * testsuite/gas/elf/section12a.d: Use notarget instead of xfail. * testsuite/gas/elf/section12b.d: Likewise. * testsuite/gas/elf/section16a.d: Likewise. * testsuite/gas/elf/section16b.d: Likewise. binutils: * testsuite/lib/binutils-common.exp (supports_gnu_osabi): Don't enable on *-*-solaris*.
* Replace "use use" in a warning message with "use".Nick Clifton2020-04-022-1/+6
| | | | | PR ld/25747 * ldfile.c (ldfile_open_file): Fix typo in warning message.