aboutsummaryrefslogtreecommitdiff
path: root/ld
AgeCommit message (Collapse)AuthorFilesLines
2020-09-24PR26655, Power10 libstdc++.so R_PPC64_NONE dynamic relocsAlan Modra2-3/+22
Some of the powerpc64 code editing functions are better run after dynamic symbols have stabilised in order to make proper decisions based on SYMBOL_REFERENCES_LOCAL. The dynamic symbols are processed early in bfd_elf_size_dynamic_sections, before the backend always_size_sections function is called. One function, ppc64_elf_tls_setup must run before bfd_elf_size_dynamic_sections because it changes dynamic symbols. ppc64_elf_edit_opd and ppc64_elf_inline_plt can run early or late, I think. ppc64_elf_tls_optimize and ppc64_elf_edit_toc are better run later. So this patch arranges to call some edit functions later via always_size_sections. PR 26655 bfd/ * elf64-ppc.c (ppc64_elf_func_desc_adjust): Rename to.. (ppc64_elf_edit): Call params->edit. (ppc64_elf_tls_setup): Don't call _bfd_elf_tls_setup. Return a bfd_boolean. * elf64-ppc.h (struct ppc64_elf_params): Add "edit". (ppc64_elf_tls_setup): Update declaration. ld/ * emultempl/ppc64elf.em (params): Add ppc_edit. (ppc_before_allocation): Split off some edit functions to.. (ppc_edit): ..this, new function.
2020-09-22Linker: If the type is pie the results should be an executable which entry ↵Frediano Ziglio3-2/+8
point should be an executable entry point, not a DLL one. * emultempl/pe.em (set_entry_point): Only use the DLL entry point for DLLs. * emultempl/pep.em (set_entry_point): Likewise.
2020-09-16Add -Av9 to AFLAGS_PIC and AFLAGS_PIE in the ld test suite on SPARC.Mikael Pettersson3-1/+9
* testsuite/ld-elf/shared.exp: Add -Av9 to AFLAGS_PIE on sparc. * testsuite/ld-elf/tls.exp: Add -Av9 to AFLAGS_PIC on sparc.
2020-09-16elf/x86-64: Adjust relocation for PE/x86-64 inputsH.J. Lu21-10/+294
PE linker calls _bfd_relocate_contents to resolve relocation, instead of bfd_perform_relocation. But ELF linker calls bfd_perform_relocation, not _bfd_relocate_contents. When linking PE/x86-64 inputs to generate ELF output, we need to adjust PE/x86-64 relocations in bfd_perform_relocation. Enable PE/x86-64 in bfd together with PEI/x86-64. Update run_ld_link_tests to handle bzip2 binary inputs. bfd/ PR ld/26583 * config.bfd (targ64_selvecs, targ_selvecs): Add x86_64_pe_vec to x86_64_pei_vec. * reloc.c: Include "coff/internal.h". (bfd_perform_relocation): Adjust relocation for PE/x86-64 inputs. ld/ PR ld/26583 * testsuite/ld-x86-64/pe-x86-64-1.od: New file. * testsuite/ld-x86-64/pe-x86-64-1a.obj.bz2: Likewise. * testsuite/ld-x86-64/pe-x86-64-1b.obj.bz2: Likewise. * testsuite/ld-x86-64/pe-x86-64-1c.obj.bz2: Likewise. * testsuite/ld-x86-64/pe-x86-64-2.od: Likewise. * testsuite/ld-x86-64/pe-x86-64-2a.obj.bz2: Likewise. * testsuite/ld-x86-64/pe-x86-64-2b.obj.bz2: Likewise. * testsuite/ld-x86-64/pe-x86-64-2c.obj.bz2: Likewise. * testsuite/ld-x86-64/pe-x86-64-3.od: Likewise. * testsuite/ld-x86-64/pe-x86-64-3a.obj.bz2: Likewise. * testsuite/ld-x86-64/pe-x86-64-3b.obj.bz2: Likewise. * testsuite/ld-x86-64/pe-x86-64-3c.obj.bz2: Likewise. * testsuite/ld-x86-64/pe-x86-64-3d.obj.bz2: Likewise. * testsuite/ld-x86-64/pe-x86-64-4.od: Likewise. * testsuite/ld-x86-64/pe-x86-64-4a.obj.bz2: Likewise. * testsuite/ld-x86-64/pe-x86-64-4b.obj.bz2: Likewise. * testsuite/ld-x86-64/pe-x86-64-4c.obj.bz2: Likewise. * testsuite/ld-x86-64/pe-x86-64-4d.obj.bz2: Likewise. * testsuite/ld-x86-64/pe-x86-64.exp: Likewise. * testsuite/lib/ld-lib.exp (run_ld_link_tests): Handle bz2 binary inputs.
2020-09-16Tidy elf_symbol_fromAlan Modra2-1/+6
bfd/ * elf-bfd.h (elf_symbol_from): Remove unused ABFD parameter. * elf.c (ignore_section_sym, _bfd_elf_copy_private_symbol_data), (swap_out_syms): Adjust elf_symbol_from invocation. binutils/ * nm.c (print_symbol): Adjust elf_symbol_from invocation. * objcopy.c (is_hidden_symbol): Likewise. gas/ * config/obj-elf.c (obj_elf_visibility, elf_frob_symbol): Adjust elf_symbol_from invocation. * config/tc-aarch64.c (s_variant_pcs): Likewise. * config/tc-m68hc11.c (s_m68hc11_mark_symbol): Likewise. * config/tc-ppc.c (ppc_elf_localentry, ppc_force_relocation), (ppc_fix_adjustable): Likewise. * config/tc-xgate.c (xgate_frob_symbol): Likewise. ld/ * plugin.c (asymbol_from_plugin_symbol): Adjust elf_symbol_from invocation. opcodes/ * ppc-dis.c (ppc_symbol_is_valid): Adjust elf_symbol_from invocation.
2020-09-15elf: Check bfd_target_elf_flavour on input firstH.J. Lu2-1/+6
Check bfd_target_elf_flavour on input first in ldelf_after_open before checking elf_tdata. * ldelf.c (ldelf_after_open): Check bfd_target_elf_flavour first.
2020-09-15CRIS: fix PR ld/26589, a missing NULL check in fix for PR ld/22269Hans-Peter Nilsson3-0/+35
Not sure why there wasn't a NULL check in the ld/22269 patch (e01c16a8) at the time, as there was one for the corresponding patch to elf32-m68k.c (5056ba1d). Incidentally, I had missed that in 2017, as a prerequisite for the ld/22269 series, the check_relocs function finally were made "safe"! (I.e. the number of references and symbol types are final, garbage collection done, so port-specific accounting can be made sanely.) Committed. bfd: PR ld/26589 * elf32-cris.c (cris_elf_check_relocs): Add missing NULL check on argument before calling UNDEFWEAK_NO_DYNAMIC_RELOC. ld: PR ld/26589 * testsuite/ld-elf/pr26589.d, testsuite/ld-elf/locref3.s: New test.
2020-09-13Re: elf: Add -z unique-symbolAlan Modra2-3/+9
PR 26391 * testsuite/ld-elf/pr26391.nd: Adjust to match powerpc64 function descriptors.
2020-09-12elf: Add -z unique-symbol to avoid duplicated local symbol namesH.J. Lu12-0/+221
The symbol string table in the .symtab section is optional and cosmetic. The contents of the .symtab section have no impact on run-time execution. The symbol names in the symbol string table help distinguish addresses at different locations. Add a linker option, -z unique-symbol, to avoid duplicated local symbol names in the symbol string table. This feature was well received by the livepatch maintainers. It not only solves the duplicated local symbol name problem, but also would allow livepatch to more precisely locate duplicate symbols in general for patching. bfd/ PR ld/26391 * elflink.c (elf_final_link_info): Add local_hash_table. (local_hash_entry): New. (local_hash_newfunc): Likewise. (elf_link_output_symstrtab): Append ".COUNT" to duplicated local symbols. (bfd_elf_final_link): Initialize and free local_hash_table for "-z unique-symbol". include/ PR ld/26391 * bfdlink.h (bfd_link_info): Add unique_symbol. ld/ PR ld/26391 * NEWS: Mention "-z unique-symbol". * emultempl/elf.em (gld${EMULATION_NAME}_handle_option): Handle "-z unique-symbol" and "-z nounique-symbol". * ld.texi: Document "-z unique-symbol" and "-z nounique-symbol". * lexsup.c (elf_static_list_options): Add "-z unique-symbol" and "-z nounique-symbol". * testsuite/ld-elf/elf.exp: Add PR ld/26391 tests. * testsuite/ld-elf/pr26391.nd: New file. * testsuite/ld-elf/pr26391.out: Likewise. * testsuite/ld-elf/pr26391a.c: Likewise. * testsuite/ld-elf/pr26391b.c: Likewise. * testsuite/ld-elf/pr26391c.c: Likewise. * testsuite/ld-elf/pr26391d.c: Likewise.
2020-09-11Fix a segfault when creating an import library with 0 exports.Jeremy Drake3-2/+11
PR 26588 * emultempl/pe.em (_finish): Only generate a import library if not exporting relocs. * emultempl/pep.em: Likewise.
2020-09-10aarch64: Return an error on conditional branch to an undefined symbolSiddhesh Poyarekar2-6/+6
The fix in 7e05773767820b441b23a16628b55c98cb1aef46 introduced a PLT for conditional jumps when the target symbol is undefined. This is incorrect because conditional branch relocations are not allowed to clobber IP0/IP1 and hence, should not result in a dynamic relocation. Revert that change and in its place, issue an error when the target symbol is undefined. bfd/ 2020-09-10 Siddhesh Poyarekar <siddesh.poyarekar@arm.com> * elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Revert changes in 7e05773767820b441b23a16628b55c98cb1aef46. Set error for undefined symbol in BFD_RELOC_AARCH64_BRANCH19 and BFD_RELOC_AARCH64_TSTBR14 relocations. ld/ 2020-09-10 Siddhesh Poyarekar <siddesh.poyarekar@arm.com> * testsuite/ld-aarch64/emit-relocs-560.d: Expect error instead of valid output.
2020-09-10ld: Add more tests for --as-neededH.J. Lu7-0/+99
Prior to commit 1e3b96fd6cf0c7d018083994ad951ccf92aba582 Author: Alan Modra <amodra@gmail.com> Date: Fri Sep 4 13:54:21 2020 +0930 Allow plugin syms to mark as-needed shared libs needed when removing unused IR symbol references, ld didn't add unnecessary DT_NEEDED libraries which may lead to undefined symbol reference in a --as-needed library when the symbol is defined in a prior --as-needed library and there is no reference in relocatable inputs. This behavior is desirable since it ensures that both lazy and non-lazy bindings work the same way. The problem is with --as-needed libraries, which happens with and without LTO. Now, the linker may add many unnecessary DT_NEEDED libraries for IR inputs. PR ld/26590 * testsuite/ld-elf/pr26590.err: New file. * testsuite/ld-elf/pr26590a.c: Likewise. * testsuite/ld-elf/pr26590b.c: Likewise. * testsuite/ld-elf/pr26590c.c: Likewise. * testsuite/ld-elf/pr26590d.c: Likewise. * testsuite/ld-elf/shared.exp: Run ld/26590 tests.
2020-09-10Re: PR26580, Size and alignment of commons vs as-needed shared libAlan Modra2-1/+5
Some MIPS targets, for reasons I didn't analyse, use the larger common symbol in a shared lib rather than a smaller common in an executable. That doesn't seem unreasonable, so allow that to pass for pr26580-2. bfin-elf complains about not supporting copy relocs, but it's quite silly to want a copy reloc for common symbols, so leave the fail there. mn10300-elf and score-elf both fail the test with "PHDR segment not covered by LOAD segment". Other tests fail similarly so one more doesn't hurt. The failure is a consequence of supporting dynamic objects but setting EMBEDDED in ld scripts. PR 26580 * testsuite/ld-elf/pr26580-2.sd: Accept undefined symbol.
2020-09-10Re: lto-18 testAlan Modra4-4/+21
Extend the test a little to archives, not that we expect this to fail. Nor has the lto-18 test ever failed without -flto. * testsuite/ld-plugin/lto-18b.c (select): Remove. * testsuite/ld-plugin/lto-18c.c (select): Remove. * testsuite/ld-plugin/lto.exp: Build archives for lto-18 too, and run static versions of the test.
2020-09-09lto-18 testAlan Modra7-4/+74
Demonstrates a reason to use IR symbols when deciding an --as-needed library should be loaded. * testsuite/ld-plugin/lto-18a.c, * testsuite/ld-plugin/lto-18b.c, * testsuite/ld-plugin/lto-18c.c, * testsuite/ld-plugin/lto-18d.c, * testsuite/ld-plugin/lto-18.out: New test. * testsuite/ld-plugin/lto.exp: Run it.
2020-09-08MSP430: Support relocations for subtract expressions in .uleb128 directivesJozef Lawrynowicz5-0/+64
Link-time relaxations of branches are common for MSP430, given that GCC can generate pessimal branch instructions, and the -mcode-region=either/-mdata-region=either options to shuffle sections can further change the type of branch instruction required. These relaxations can result in invalid code when .uleb128 directives, used in the .gcc_except_table section, are used to calculate the distance between two labels. A value for the .uleb128 directive is calculated at assembly-time, and can't be updated at link-time, even if relaxation causes the distance between the labels to change. This patch adds relocations for subtract expressions in .uleb128 directives, to allow the linker to re-calculate the value of these expressions after relaxation has been performed. bfd/ChangeLog: * bfd-in2.h (bfd_reloc_code_real): Add BFD_RELOC_MSP430_{SET,SUB}_ULEB128. * elf32-msp430.c (msp430_elf_ignore_reloc): New. (elf_msp430_howto_table): Add R_MSP430{,X}_GNU_{SET,SUB}_ULEB128. (msp430_reloc_map): Add R_MSP430_GNU_{SET,SUB}_ULEB128. (msp430x_reloc_map): Add R_MSP430X_GNU_{SET,SUB}_ULEB128. (write_uleb128): New. (msp430_final_link_relocate): Handle R_MSP430{,X}_GNU_{SET,SUB}_ULEB128. * libbfd.c (_bfd_write_unsigned_leb128): New. * libbfd.h (_bfd_write_unsigned_leb128): New prototype. Add BFD_RELOC_MSP430_{SET,SUB}_ULEB128. * reloc.c: Document BFD_RELOC_MSP430_{SET,SUB}_ULEB128. binutils/ChangeLog: * readelf.c (target_specific_reloc_handling): Handle R_MSP430{,X}_GNU_{SET,SUB}_ULEB128. gas/ChangeLog: * config/tc-msp430.c (msp430_insert_uleb128_fixes): New. (msp430_md_end): Call msp430_insert_uleb128_fixes. include/ChangeLog: * elf/msp430.h (elf_msp430_reloc_type): Add R_MSP430_GNU_{SET,SUB}_ULEB128. (elf_msp430x_reloc_type): Add R_MSP430X_GNU_{SET,SUB}_ULEB128. ld/ChangeLog: * testsuite/ld-msp430-elf/msp430-elf.exp: Run new tests. * testsuite/ld-msp430-elf/uleb128.s: New test. * testsuite/ld-msp430-elf/uleb128_430.d: New test. * testsuite/ld-msp430-elf/uleb128_430x.d: New test.
2020-09-08PR26580, Size and alignment of commons vs as-needed shared libAlan Modra11-10/+113
Two pieces to this puzzle: 1) Revert HJ's fix for PR13250 so that size and alignment isn't sticky, instead attack the real underlying problem that _bfd_generic_link_add_one_symbol does the wrong thing in making a common section in a shared library bfd. 2) Save and restore common u.c.p fields, which hold the section and alignment. A better fix for (2) would be to throw away all of that horrible code saving and restoring the hash table when loading as-needed library symbols, and instead do a scan over as-needed library symbols before adding anything. bfd/ PR 13250 PR 26580 * elflink.c (_bfd_elf_merge_symbol): Make "override" a bfd**. Return oldbfd in override when old common should override new common. (_bfd_elf_add_default_symbol): Adjust to suit. (elf_link_add_object_symbols): Likewise. Pass "override" to _bfd_generic_link_add_one_symbol. Save and restore common u.c.p field for --as-needed shared libraries. Revert pr13250 changes. ld/ * testsuite/ld-elf/pr26580-a.s, * testsuite/ld-elf/pr26580-b.s, * testsuite/ld-elf/pr26580-1.sd, * testsuite/ld-elf/pr26580-2.sd: New tests * testsuite/ld-elf/comm-data.exp: Run new tests. * testsuite/ld-elf/pr26580-a.c, * testsuite/ld-elf/pr26580-b.c, * testsuite/ld-elf/pr26580-3.out, * testsuite/ld-elf/pr26580-4.out: New tests. * testsuite/ld-elf/shared.exp: Run new tests.
2020-09-04Allow plugin syms to mark as-needed shared libs neededAlan Modra7-47/+9
We must tell LTO about symbols in all shared libraries loaded. That means we can't load extra shared libraries after LTO recompilation, at least, not those that affect the set of symbols that LTO cares about, the IR symbols. This change will likely result in complaints about --as-needed libraries being loaded unnecessarily, but being correct is more important than being optimal. One of the PR15146 tests regresses, and while that could be hidden by disabling the missing dso message by making it conditional on h->root.non_ir_ref_regular, that would just be sweeping a problem under the rug. bfd/ PR 15146 PR 26314 PR 26530 * elflink.c (elf_link_add_object_symbols): Do set def_regular and ref_regular for IR symbols. Don't clear dynsym, allowing IR symbols to load --as-needed shared libraries, but prevent IR symbols from becoming dynamic. ld/ * testsuite/ld-plugin/lto.exp: Don't run pr15146 tests. * testsuite/ld-plugin/pr15146.d: Delete. * testsuite/ld-plugin/pr15146a.c: Delete. * testsuite/ld-plugin/pr15146b.c: Delete. * testsuite/ld-plugin/pr15146c.c: Delete. * testsuite/ld-plugin/pr15146d.c: Delete.
2020-09-03ld: Change NOSANTIZE_CFLAGS to NOSANITIZE_CFLAGSH.J. Lu20-97/+120
* testsuite/config/default.exp: Change NOSANTIZE_CFLAGS to NOSANITIZE_CFLAGS. * testsuite/ld-elf/dwarf.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-elfcomm/elfcomm.exp: Likewise. * testsuite/ld-elfvers/vers.exp: Likewise. * testsuite/ld-elfvsb/elfvsb.exp: Likewise. * testsuite/ld-elfweak/elfweak.exp: Likewise. * testsuite/ld-gc/gc.exp: Likewise. * testsuite/ld-plugin/lto.exp: Likewise. * testsuite/ld-plugin/plugin.exp: Likewise. * testsuite/ld-scripts/crossref.exp: Likewise. * testsuite/ld-selective/selective.exp: Likewise. * testsuite/ld-shared/shared.exp: Likewise. * testsuite/ld-size/size.exp: Likewise. * testsuite/ld-srec/srec.exp: Likewise. * testsuite/ld-x86-64/x86-64.exp: Likewise.
2020-09-03RISC-V: Minor cleanup and typos when merging elf attributes.Nelson Chu7-12/+22
bfd/ * elfnn-riscv.c (riscv_i_or_e_p): Minor cleanup for warnings/errors. (riscv_merge_std_ext): Likewise. (riscv_merge_arch_attr_info): Likewise. (riscv_merge_attributes): Likewise and fix comment typos. ld/ * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-01.d: Remove the useless `warnings` keywords. * 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.
2020-09-03RISC-V: Report warnings rather than errors for the mis-matched ISA versions.Nelson Chu8-1/+50
Same as the privileged spec attributes check - different ISA versions should be compatible, unless there are some known conflicts. Therefore, we should allow to link objects with different ISA versions, and update the output ISA versions once the corresponding input ones are newer. But it's better to also warn people that the conflicts may happen when the ISA versions are mis-matched. bfd/ * elfnn-riscv.c (riscv_version_mismatch): Change the return type from void to bfd_boolean. Report warnings rather than errors when the ISA versions are mis-matched. Afterwards, remember to update the output ISA versions to the newest ones. (riscv_merge_std_ext): Allow to link objects with different standard ISA versions. Try to add output ISA versions to merged_subsets first. (riscv_merge_multi_letter_ext): Likewise. But for standard additional ISA and non-standard ISA versions. ld/ * testsuite/ld-riscv-elf/attr-merge-arch-failed-01.d: Update the message from error to warning. * testsuite/ld-riscv-elf/attr-merge-arch-failed-02.d: New testcases. * testsuite/ld-riscv-elf/attr-merge-arch-failed-02a.s: Likewise. * testsuite/ld-riscv-elf/attr-merge-arch-failed-02b.s: Likewise. * testsuite/ld-riscv-elf/attr-merge-arch-failed-02c.s: Likewise. * testsuite/ld-riscv-elf/attr-merge-arch-failed-02d.s: Likewise. * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated.
2020-09-03RISC-V: Improve the error message for the mis-matched ISA versions.Kito Cheng4-3/+9
Consider the updated attr-merge-arch-failed-01.d testcase. Extension A's version are mis-matched between attr-merge-arch-failed-01a.s and attr-merge-arch-failed-01b.s. But the old binutils reports that the mis-matched extension is M rather than A. This commit is used to fix the wrong mis-matched error message. Besides, when parsing the arch string in the riscv_parse_subset, it shouldn't be NULL or empty. However, it might be empty when we failed to merge the arch string in the riscv_merge_attributes. Since we should already issue the correct error message in another side, and the message - ISA string must begin with rv32 or rv64 - is meaninglesss when the arch string is empty, so do not issue it. bfd/ * elfnn-riscv.c (riscv_merge_std_ext): Fix to report the correct error message when the versions of extension are mis-matched. * elfxx-riscv.c (riscv_parse_subset): Don't issue the error when the string is empty. ld/ * testsuite/ld-riscv-elf/attr-merge-arch-failed-01.d: Updated. * testsuite/ld-riscv-elf/attr-merge-arch-failed-01a.s: Likewise. * testsuite/ld-riscv-elf/attr-merge-arch-failed-01b.s: Likewise.
2020-09-03heap use after free in xcoff_archive_info_eqAlan Modra2-1/+6
Using an input file objalloc memory for anything that isn't created when opening the bfd is not a good idea. The problem is that this memory can disappear if bfd_free_cached_info is called or when bfd closes files in order to keep the number of open files reasonable. bfd/ * xcofflink.c (xcoff_get_archive_info): Allocate xcoff_archive_info on the output bfd objalloc memory. ld/ * testsuite/ld-scripts/sysroot-prefix.exp (single_sysroot_prefix_test): Log $scriptname.
2020-08-30ld: Add $NOSANTIZE_CFLAGS to more linker testsH.J. Lu6-9/+33
* testsuite/ld-elf/dwarf.exp: Append $NOSANTIZE_CFLAGS to CFLAGS. * testsuite/ld-elf/shared.exp: Likewise. * testsuite/ld-elfvsb/elfvsb.exp: Likewise. * testsuite/ld-shared/shared.exp: Likewise. * testsuite/ld-size/size.exp: Likewise.
2020-08-28MSP430: Fix alignment of __*_array_start symbols in default linker scriptJozef Lawrynowicz13-1/+320
__{preinit,init,fini}_array_start symbols must be word aligned in linker scripts. If the section preceding the __*_array_start symbol has an odd size, then a NULL byte will be present between the start symbol and the .*_array section itself, when the section gets automatically word-aligned. This results in a branch to an invalid address when the CRT startup code tries to run through the functions listed in the array sections. Some MSP430 linker scripts do not align the __*_array start symbols, so this added warning will catch that problem and help the user avoid the potential incorrect execution of the program. ld/ChangeLog: * emultempl/msp430.em (input_section_exists): New. (check_array_section_alignment): New. (gld${EMULATION_NAME}_finish): New. * scripttempl/elf32msp430.sc: Add ALIGN directives before the definition of __*_array_start symbols. * testsuite/ld-msp430-elf/finiarray-warn.ld: New test. * testsuite/ld-msp430-elf/finiarray-warn.r: New test. * testsuite/ld-msp430-elf/initarray-nowarn.ld: New test. * testsuite/ld-msp430-elf/initarray-warn.ld: New test. * testsuite/ld-msp430-elf/initarray-warn.r: New test. * testsuite/ld-msp430-elf/initarray.s: New test. * testsuite/ld-msp430-elf/msp430-elf.exp: Run new tests. * testsuite/ld-msp430-elf/preinitarray-warn.ld: New test. * testsuite/ld-msp430-elf/preinitarray-warn.r: New test.
2020-08-28LD: Add new %pU vfinfo format for printing linker script nameJozef Lawrynowicz2-3/+10
The %pT vfinfo format prints the linker script name with a line number, however sometimes it may be necessary to print the linker script name without any associated line number. ld/ChangeLog: * ldmisc.c (vfinfo): Support new "%pU" format specifier.
2020-08-28CSKY: Support attribute section.Cooper Qu5-0/+14
bfd * elf32-csky.c (csky_archs): Fix arch names. (csky_find_arch_with_name): New. (elf32_csky_merge_attributes): New. (csky_elf_merge_private_bfd_data): Add process of merge attribute section. (elf32_csky_obj_attrs_arg_type): New. (elf32_csky_obj_attrs_handle_unknown): New. (elf_backend_obj_attrs_vendor): Define. (elf_backend_obj_attrs_section): Define. (elf_backend_obj_attrs_arg_type): Define. (elf_backend_obj_attrs_section_type): Define. binutils/ * readelf.c (get_csky_section_type_name): New. (get_section_type_name): Add handler for CSKY. (display_csky_attribute): New. (process_arch_specific): Add handler for CSKY. * testsuite/binutils-all/strip-3.d: Remove .csky.attributes section. elfcpp/ * elfcpp.h (enum SHT): New enum SHT_CSKY_ATTRIBUTES. gas/ * gas/config/tc-csky.c (md_begin): Set attributes. (isa_flag): Change type to unsigned 64 bits. (struct csky_cpu_info): Likewise. (struct csky_macro_info): Likewise. (set_csky_attribute): New. * testsuite/gas/csky/802j.d: Ignore .csky.attributes section. * testsuite/gas/csky/all.d: Likewise. * testsuite/gas/csky/bsr1.d: Likewise. * testsuite/gas/csky/csky_vdsp.d: Likewise. * testsuite/gas/csky/cskyv2_all.d: Likewise. * testsuite/gas/csky/cskyv2_ck803r2.d: Likewise. * testsuite/gas/csky/cskyv2_ck860.d: Likewise. * testsuite/gas/csky/cskyv2_dsp.d: Likewise. * testsuite/gas/csky/cskyv2_elrw.d: Likewise. * testsuite/gas/csky/cskyv2_float.d: Likewise. * testsuite/gas/csky/enhance_dsp.d: Likewise. * testsuite/gas/csky/java.d: Likewise. * testsuite/gas/csky/v1_float.d: Likewise. * testsuite/gas/csky/v2_float_part1.d: Likewise. * testsuite/gas/csky/v2_float_part2.d: Likewise. * testsuite/gas/csky/v2_tls_gd.d: Likewise. * testsuite/gas/csky/v2_tls_ie.d: Likewise. * testsuite/gas/csky/v2_tls_ld.d: Likewise. * testsuite/gas/csky/v2_tls_le.d: Likewise. * testsuite/gas/elf/elf.exp: Add handler for CSKY. * testsuite/gas/elf/section2.e-csky: New. include/ * elf/csky.h (SHT_CSKY_ATTRIBUTES): Define. (Tag_CSKY_ARCH_NAME): New enum constant. (Tag_CSKY_CPU_NAME): Likewise. (Tag_CSKY_ISA_FLAGS): Likewise. (Tag_CSKY_DSP_VERSION): Likewise. (Tag_CSKY_VDSP_VERSION): Likewise. (Tag_CSKY_FPU_VERSION): Likewise. (Tag_CSKY_FPU_ABI): Likewise. (Tag_CSKY_FPU_ROUNDING): Likewise. (Tag_CSKY_FPU_DENORMAL): Likewise. (Tag_CSKY_FPU_Exception): Likewise. (Tag_CSKY_FPU_NUMBER_MODULE): Likewise. (Tag_CSKY_FPU_HARDFP): Likewise. (Tag_CSKY_MAX): Likewise. (VAL_CSKY_DSP_VERSION_EXTENSION): Likewise. (VAL_CSKY_DSP_VERSION_2): Likewise. (VAL_CSKY_VDSP_VERSION_1): Likewise. (VAL_CSKY_VDSP_VERSION_2): Likewise. (VAL_CSKY_FPU_ABI_SOFT): Likewise. (VAL_CSKY_FPU_ABI_SOFTFP): Likewise. (VAL_CSKY_FPU_ABI_HARD): Likewise. (VAL_CSKY_FPU_HARDFP_HALF): Likewise. (VAL_CSKY_FPU_HARDFP_SINGLE): Likewise. (VAL_CSKY_FPU_HARDFP_DOUBLE): Likewise. * opcode/csky.h (CSKY_ISA_VDSP_V2): Define. CSKYV1_ISA_E1: Change to long constant type. CSKYV2_ISA_E1: Likewise. CSKYV2_ISA_1E2: Likewise. CSKYV2_ISA_2E3: Likewise. CSKYV2_ISA_3E7: Likewise. CSKYV2_ISA_7E10: Likewise. CSKYV2_ISA_3E3R1: Likewise. CSKYV2_ISA_3E3R2: Likewise. CSKYV2_ISA_10E60: Likewise. CSKY_ISA_TRUST: Likewise. CSKY_ISA_CACHE: Likewise. CSKY_ISA_NVIC: Likewise. CSKY_ISA_CP: Likewise. CSKY_ISA_MP: Likewise. CSKY_ISA_MP_1E2: Likewise. CSKY_ISA_JAVA: Likewise. CSKY_ISA_MAC: Likewise. CSKY_ISA_MAC_DSP: Likewise. CSKY_ISA_DSP: Likewise. CSKY_ISA_DSP_1E2: Likewise. CSKY_ISA_DSP_ENHANCE: Likewise. CSKY_ISA_FLOAT_E1: Likewise. CSKY_ISA_FLOAT_1E2: Likewise. CSKY_ISA_FLOAT_1E3: Likewise. CSKY_ISA_FLOAT_3E4: Likewise. CSKY_ISA_VDSP: Likewise. ld/ * emulparams/cskyelf.sh: Support attribute section. * testsuite/ld-csky/tls-le-v1.d: Match .csky.attributes section. * ld/testsuite/ld-csky/tls-le.d: Likewise. * testsuite/ld-elf/non-contiguous.ld: Ignore .csky.attributes section. opcodes/ * csky-dis.c (CSKY_DEFAULT_ISA): Define. (csky_dis_info): Add member isa. (csky_find_inst_info): Skip instructions that do not belong to current CPU. (csky_get_disassembler): Get infomation from attribute section. (print_insn_csky): Set defualt ISA flag. * csky.h (CSKY_ISA_VDSP_2): Rename from CSKY_ISA_VDSP_V2. * csky-opc.h (struct csky_opcode): Change isa_flag16 and isa_flag32'type to unsigned 64 bits.
2020-08-28Fixes for testsuite failures introduced by the changes made for PR 19011.Nick Clifton2-1/+7
PR19011 bfd * cofflink.c (_bfd_coff_generic_relocate_section): Provide a value for undefined symbols which will not generate extra warning messages about truncated relocs. ld * testsuite/lib/ld-lib.exp (ld_link_defsyms): For PE based targets define the __main and ___main symbols in terms of the main symbol.
2020-08-28mingw plugin test regressions due to commit 514b4e191d5fAlan Modra2-4/+17
Fixes new failures due to image base change. PR 19011 * testsuite/ld-plugin/plugin.exp: Use modified CFLAGS throughout file. Add --image-base for pecoff.
2020-08-28RISC-V: Treat R_RISCV_CALL and R_RISCV_CALL_PLT as the same in check_relocs.Nelson Chu4-3/+10
In fact, we can treate these two relocation as the same one in the riscv_elf_check_relocs. I have heard that RISC-V lld had made this improvement, and so had GNU AARCH64, they only need R_AARCH64_CALL26 for calls rather than two seperate relocations. Beside, the following PLT issue for RISC-V 32-bit glibc seems to be fixed by applying at least this patch. <https://sourceware.org/pipermail/libc-alpha/2020-August/117214.html> I have ran the toolchain regression, and everything seems fine for now. bfd/ * elfnn-riscv.c (riscv_elf_check_relocs): Treat R_RISCV_CALL and R_RISCV_CALL_PLT as the same in the riscv_elf_check_relocs. (riscv_elf_relocate_section): Remove the R_RISCV_CALL for the unresolved reloc checks. ld/ testsuite/ld-riscv-elf/lib-nopic-01a.s: Use R_RISCV_JAL rather than R_RISCV_CALL. testsuite/ld-riscv-elf/lib-nopic-01b.d: Likewise. testsuite/ld-riscv-elf/lib-nopic-01b.s: Likewise.
2020-08-27ld/emultempl/msp430.em: Remove unused variableJozef Lawrynowicz2-3/+5
ld/ChangeLog: * emultempl/msp430.em: Remove unused variable "buf".
2020-08-27Remove commit 9fb2400ce6Nick Clifton4-81/+64
2020-08-27Fix linker testcase for alpha-linux affected by fix for PR 26416Nick Clifton4-64/+81
PR 26416 * testsuite/ld-alpha/tlsbinr.rd: Update expected output. * testsuite/ld-alpha/tlsbinr.dd: Likewise. * testsuite/ld-alpha/tlsbinr.sd: Likewise.
2020-08-27binutils, ld: dequote libctf error messagesNick Alcock9-11/+25
These are not identifiers and should not be quoted. (Also, quoting them just looks odd.) Adjust diagnostics tests accordingly. binutils/ChangeLog 2020-08-27 Nick Alcock <nick.alcock@oracle.com> * objdump.c (dump_ctf_errs): Unquote CTF error messages. * readelf.c (dump_ctf_errs): Likewise. ld/ChangeLog 2020-08-27 Nick Alcock <nick.alcock@oracle.com> * ldlang.c (dump_ctf_errs): Unquote CTF error messages. (ldlang_open_ctf): Likewise. (lang_merge_ctf): Likewise. (lang_write_ctf): Likewise. * testsuite/ld-ctf/diag-ctf-version-f.d: Adjust. * testsuite/ld-ctf/diag-cttname-invalid.d: Adjust. * testsuite/ld-ctf/diag-decompression-failure.d: Adjust. * testsuite/ld-ctf/diag-parname.d: Adjust. * testsuite/ld-ctf/diag-unsupported-flag.d: Adjust. * testsuite/ld-ctf/diag-wrong-magic-number-mixed.d: Adjust. * testsuite/ld-ctf/diag-wrong-magic-number.d: Adjust.
2020-08-27libctf, binutils, include, ld: gettextize and improve error handlingNick Alcock3-27/+56
This commit follows on from the earlier commit "libctf, ld, binutils: add textual error/warning reporting for libctf" and converts every error in libctf that was reported using ctf_dprintf to use ctf_err_warn instead, gettextizing them in the process, using N_() where necessary to avoid doing gettext calls unless an error message is actually generated, and rephrasing some error messages for ease of translation. This requires a slight change in the ctf_errwarning_next API: this API is public but has not been in a release yet, so can still change freely. The problem is that many errors are emitted at open time (whether opening of a CTF dict, or opening of a CTF archive): the former of these throws away its incompletely-initialized ctf_file_t rather than return it, and the latter has no ctf_file_t at all. So errors and warnings emitted at open time cannot be stored in the ctf_file_t, and have to go elsewhere. We put them in a static local in ctf-subr.c (which is not very thread-safe: a later commit will improve things here): ctf_err_warn with a NULL fp adds to this list, and the public interface ctf_errwarning_next with a NULL fp retrieves from it. We need a slight exception from the usual iterator rules in this case: with a NULL fp, there is nowhere to store the ECTF_NEXT_END "error" which signifies the end of iteration, so we add a new err parameter to ctf_errwarning_next which is used to report such iteration-related errors. (If an fp is provided -- i.e., if not reporting open errors -- this is optional, but even if it's optional it's still an API change. This is actually useful from a usability POV as well, since ctf_errwarning_next is usually called when there's been an error, so overwriting the error code with ECTF_NEXT_END is not very helpful! So, unusually, ctf_errwarning_next now uses the passed fp for its error code *only* if no errp pointer is passed in, and leaves it untouched otherwise.) ld, objdump and readelf are adapted to call ctf_errwarning_next with a NULL fp to report open errors where appropriate. The ctf_err_warn API also has to change, gaining a new error-number parameter which is used to add the error message corresponding to that error number into the debug stream when LIBCTF_DEBUG is enabled: changing this API is easy at this point since we are already touching all existing calls to gettextize them. We need this because the debug stream should contain the errno's message, but the error reported in the error/warning stream should *not*, because the caller will probably report it themselves at failure time regardless, and reporting it in every error message that leads up to it leads to a ridiculous chattering on failure, which is likely to end up as ridiculous chattering on stderr (trimmed a bit): CTF error: `ld/testsuite/ld-ctf/A.c (0): lookup failure for type 3: flags 1: The parent CTF dictionary is unavailable' CTF error: `ld/testsuite/ld-ctf/A.c (0): struct/union member type hashing error during type hashing for type 80000001, kind 6: The parent CTF dictionary is unavailable' CTF error: `deduplicating link variable emission failed for ld/testsuite/ld-ctf/A.c: The parent CTF dictionary is unavailable' ld/.libs/lt-ld-new: warning: CTF linking failed; output will have no CTF section: `The parent CTF dictionary is unavailable' We only need to be told that the parent CTF dictionary is unavailable *once*, not over and over again! errmsgs are still emitted on warning generation, because warnings do not usually lead to a failure propagated up to the caller and reported there. Debug-stream messages are not translated. If translation is turned on, there will be a mixture of English and translated messages in the debug stream, but rather that than burden the translators with debug-only output. binutils/ChangeLog 2020-08-27 Nick Alcock <nick.alcock@oracle.com> * objdump.c (dump_ctf_archive_member): Move error- reporting... (dump_ctf_errs): ... into this separate function. (dump_ctf): Call it on open errors. * readelf.c (dump_ctf_archive_member): Move error- reporting... (dump_ctf_errs): ... into this separate function. Support calls with NULL fp. Adjust for new err parameter to ctf_errwarning_next. (dump_section_as_ctf): Call it on open errors. include/ChangeLog 2020-08-27 Nick Alcock <nick.alcock@oracle.com> * ctf-api.h (ctf_errwarning_next): New err parameter. ld/ChangeLog 2020-08-27 Nick Alcock <nick.alcock@oracle.com> * ldlang.c (lang_ctf_errs_warnings): Support calls with NULL fp. Adjust for new err parameter to ctf_errwarning_next. Only check for assertion failures when fp is non-NULL. (ldlang_open_ctf): Call it on open errors. * testsuite/ld-ctf/ctf.exp: Always use the C locale to avoid breaking the diags tests. libctf/ChangeLog 2020-08-27 Nick Alcock <nick.alcock@oracle.com> * ctf-subr.c (open_errors): New list. (ctf_err_warn): Calls with NULL fp append to open_errors. Add err parameter, and use it to decorate the debug stream with errmsgs. (ctf_err_warn_to_open): Splice errors from a CTF dict into the open_errors. (ctf_errwarning_next): Calls with NULL fp report from open_errors. New err param to report iteration errors (including end-of-iteration) when fp is NULL. (ctf_assert_fail_internal): Adjust ctf_err_warn call for new err parameter: gettextize. * ctf-impl.h (ctfo_get_vbytes): Add ctf_file_t parameter. (LCTF_VBYTES): Adjust. (ctf_err_warn_to_open): New. (ctf_err_warn): Adjust. (ctf_bundle): Used in only one place: move... * ctf-create.c: ... here. (enumcmp): Use ctf_err_warn, not ctf_dprintf, passing the err number down as needed. Don't emit the errmsg. Gettextize. (membcmp): Likewise. (ctf_add_type_internal): Likewise. (ctf_write_mem): Likewise. (ctf_compress_write): Likewise. Report errors writing the header or body. (ctf_write): Likewise. * ctf-archive.c (ctf_arc_write_fd): Use ctf_err_warn, not ctf_dprintf, and gettextize, as above. (ctf_arc_write): Likewise. (ctf_arc_bufopen): Likewise. (ctf_arc_open_internal): Likewise. * ctf-labels.c (ctf_label_iter): Likewise. * ctf-open-bfd.c (ctf_bfdclose): Likewise. (ctf_bfdopen): Likewise. (ctf_bfdopen_ctfsect): Likewise. (ctf_fdopen): Likewise. * ctf-string.c (ctf_str_write_strtab): Likewise. * ctf-types.c (ctf_type_resolve): Likewise. * ctf-open.c (get_vbytes_common): Likewise. Pass down the ctf dict. (get_vbytes_v1): Pass down the ctf dict. (get_vbytes_v2): Likewise. (flip_ctf): Likewise. (flip_types): Likewise. Use ctf_err_warn, not ctf_dprintf, and gettextize, as above. (upgrade_types_v1): Adjust calls. (init_types): Use ctf_err_warn, not ctf_dprintf, as above. (ctf_bufopen_internal): Likewise. Adjust calls. Transplant errors emitted into individual dicts into the open errors if this turns out to be a failed open in the end. * ctf-dump.c (ctf_dump_format_type): Adjust ctf_err_warn for new err argument. Gettextize. Don't emit the errmsg. (ctf_dump_funcs): Likewise. Collapse err label into its only case. (ctf_dump_type): Likewise. * ctf-link.c (ctf_create_per_cu): Adjust ctf_err_warn for new err argument. Gettextize. Don't emit the errmsg. (ctf_link_one_type): Likewise. (ctf_link_lazy_open): Likewise. (ctf_link_one_input_archive): Likewise. (ctf_link_deduplicating_count_inputs): Likewise. (ctf_link_deduplicating_open_inputs): Likewise. (ctf_link_deduplicating_close_inputs): Likewise. (ctf_link_deduplicating): Likewise. (ctf_link): Likewise. (ctf_link_deduplicating_per_cu): Likewise. Add some missed ctf_set_errnos to obscure error cases. * ctf-dedup.c (ctf_dedup_rhash_type): Adjust ctf_err_warn for new err argument. Gettextize. Don't emit the errmsg. (ctf_dedup_populate_mappings): Likewise. (ctf_dedup_detect_name_ambiguity): Likewise. (ctf_dedup_init): Likewise. (ctf_dedup_multiple_input_dicts): Likewise. (ctf_dedup_conflictify_unshared): Likewise. (ctf_dedup): Likewise. (ctf_dedup_rwalk_one_output_mapping): Likewise. (ctf_dedup_id_to_target): Likewise. (ctf_dedup_emit_type): Likewise. (ctf_dedup_emit_struct_members): Likewise. (ctf_dedup_populate_type_mapping): Likewise. (ctf_dedup_populate_type_mappings): Likewise. (ctf_dedup_emit): Likewise. (ctf_dedup_hash_type): Likewise. Fix a bit of messed-up error status setting. (ctf_dedup_rwalk_one_output_mapping): Likewise. Don't hide unknown-type-kind messages (which signify file corruption).
2020-08-27Change the default characteristics of DLLs built by the linker to more ↵Jeremy Drake8-43/+201
secure settings. PR 19011 * emultempl/pe.em (DEFAULT_DLL_CHARACTERISTICS): Define. (pe_dll_characteristics): Initialise to DEFAULT_DLL_CHARACTERISTICS. (add_options): Add options to disable DLL characteristics. (list_options): List the new options. (handle_options): Handle the new options. * emultempl/pep.em: Similar changes to above. (NT_EXE_IMAGE_BASE): Default to an address above 4G. (NT_DLL_IMAGE_BASE, NT_DLL_AUTO_IMAGE_BASE, (NT_DLL_AUTO_IMAGE_MASK): Likewise. * ld.texi: Document the new options. * pe-dll.c (pe_dll_enable_reloc_section): Change to default to true. (generate_reloc): Do nothing if there is no reloc section. (pe_exe_fill_sections): Only assign the reloc section contents if the section exists. * testsuite/ld-pe/pe.exp: Add the --disable-reloc-section flag to the .secrel32 tests. * testsuite/ld-scripts/provide-8.d: Expect for fail on PE targets. * NEWS: Mention the change in DLL generation.
2020-08-26ld: Add $NOSANTIZE_CFLAGS to more linker testsH.J. Lu10-57/+141
-fsanitize= can be used to build binutils with $ CC="gcc -fsanitize=address,undefined" CXX="g++ -fsanitize=address,undefined" .../configure --disable-werror Since not all linker tests are compatible with -fsanitize=, pass $NOSANTIZE_CFLAGS to disable -fsanitize= for such tests. * testsuite/ld-elf/indirect.exp: Append $NOSANTIZE_CFLAGS to CC. * testsuite/ld-elf/shared.exp: Likewise. * testsuite/ld-elfcomm/elfcomm.exp: Likewise. * testsuite/ld-elfvers/vers.exp: Likewise. * testsuite/ld-elfvsb/elfvsb.exp: Likewise. * testsuite/ld-elfweak/elfweak.exp: Likewise. * testsuite/ld-plugin/lto.exp: Likewise. * testsuite/ld-plugin/plugin.exp: Likewise. * testsuite/ld-scripts/crossref.exp: Likewise.
2020-08-26PR26499 UBSAN: eelf32_spu.c:537 member access null pointerAlan Modra2-1/+6
Another &p->field. PR 26499 * emultempl/spuelf.em (spu_elf_relink): Check for NULL tmp_file_list.
2020-08-26PR26431 UBSAN: pe-dll.c:568 null pointer bsearchAlan Modra2-2/+8
PR 26431 * pe-dll.c (auto_export): Don't call bsearch with zero count.
2020-08-25tic54x ld testsuiteAlan Modra9-2/+27
* testsuite/ld-libs/libs.exp: Don't run on sh-pe, tic30 or tic54x. * testsuite/ld-scripts/data.d: xfail tic4x and tic54x. * testsuite/ld-scripts/empty-address-2a.d: xfail tic54x. * testsuite/ld-scripts/empty-address-2b.d: Likewise. * testsuite/ld-scripts/include-1.d: xfail tic4x and tic54x. * testsuite/ld-scripts/provide-1.d: xfail tic54x. * testsuite/ld-scripts/provide-2.d: Likewise. * testsuite/ld-scripts/provide-4.d: Likewise.
2020-08-24sparc testsuite falloutAlan Modra3-2/+7
2020-08-24PowerPC TPREL_HA/LO optimisationAlan Modra12-58/+133
ppc64 ld optimises sequences like the following addis 3,13,wot@tprel@ha lwz 3,wot@tprel@l(3) to nop lwz 3,wot@tprel(13) when "wot" is located near enough to the thread pointer. However, the ABI doesn't require that R_PPC64_TPREL16_HA always be on an addis rt,13,imm instruction, and while ld checked for that on the high-part instruction it didn't disable the optimisation on the low-part instruction. This patch fixes that problem, disabling the tprel optimisation globally if high-part instructions don't pass sanity checks. The optimisation is also enabled for ppc32, where before ld.bfd had the code in the wrong place and ld.gold had it in a block only enabled for ppc64. bfd/ * elf32-ppc.c (ppc_elf_check_relocs): Set has_tls_reloc for high part tprel16 relocs. (ppc_elf_tls_optimize): Sanity check high part tprel16 relocs. Clear do_tls_opt on odd instructions. (ppc_elf_relocate_section): Move TPREL16_HA/LO optimisation later. Don't sanity check them here. * elf64-ppc.c (ppc64_elf_check_relocs): Set has_tls_reloc for high part tprel16 relocs. (ppc64_elf_tls_optimize): Sanity check high part tprel16 relocs. Clear do_tls_opt on odd instructions. (ppc64_elf_relocate_section): Don't sanity check TPREL16_HA. ld/ * testsuite/ld-powerpc/tls32.d: Update for TPREL_HA/LO optimisation. * testsuite/ld-powerpc/tlsexe32.d: Likewise. * testsuite/ld-powerpc/tlsldopt32.d: Likewise. * testsuite/ld-powerpc/tlsmark32.d: Likewise. * testsuite/ld-powerpc/tlsopt4_32.d: Likewise. * testsuite/ld-powerpc/tprel.s, * testsuite/ld-powerpc/tprel.d, * testsuite/ld-powerpc/tprel32.d: New tests. * testsuite/ld-powerpc/tprelbad.s, * testsuite/ld-powerpc/tprelbad.d: New test. * testsuite/ld-powerpc/powerpc.exp: Run them. gold/ * powerpc.cc (Target_powerpc): Add tprel_opt_ and accessors. (Target_powerpc::Scan::local): Sanity check tprel high relocs. (Target_powerpc::Scan::global): Likewise. (Target_powerpc::Relocate::relocate): Control tprel optimisation with tprel_opt_ and enable for 32-bit.
2020-08-22elf: Keep only one '@' for undefined versioned symbolsH.J. Lu4-2/+22
The symbol string table in the .symtab section is optional and cosmetic. Keep only one '@' for undefined versioned symbols, which are defined in shared objects, in the symbol string table. Update "nm -D" to display only one '@' for undefined versioned symbols. bfd/ PR ld/26382 * elflink.c (elf_link_output_symstrtab): Keep only one '@' for versioned symbols, which are defined in shared objects, in symbol string table. binutils/ PR ld/26382 * nm.c (print_symname): Display only one '@' for undefined versioned symbols. * doc/binutils.texi: Update nm version information. ld/ PR ld/26382 * testsuite/ld-elf/pr26302.nd: Updated. * testsuite/ld-elf/pr26302.rd: New file. * testsuite/ld-elf/shared.exp: Add a test for readelf -sW.
2020-08-20Ensure that compressed sections that have an ELF compression header ↵Nick Clifton3-2/+8
structure at the start are correctly aligned. PR 26428 bfd * bfd.c (bfd_update_compression_header): Also set the sh_addralign field in the ELF header of the compressed sections. ld * testsuite/ld-elf/zlibbegin.rS: Update expected output. * testsuite/ld-elf/zlibnormal.rS: Likewise.
2020-08-16PowerPC64 inline PLT call testsAlan Modra11-0/+173
* testsuite/ld-powerpc/inline.s, * testsuite/ld-powerpc/inline-1.d, * testsuite/ld-powerpc/inline-2.d, * testsuite/ld-powerpc/inline-3.d, * testsuite/ld-powerpc/inline-4.d, * testsuite/ld-powerpc/inlinepcrel.s, * testsuite/ld-powerpc/inlinepcrel-1.d, * testsuite/ld-powerpc/inlinepcrel-2.d, * testsuite/ld-powerpc/inlinepcrel-3.d: New tests. * testsuite/ld-powerpc/powerpc.exp: Run them.
2020-08-16ld: Add a PR binutils/26389 testH.J. Lu4-0/+15
PR binutils/26389 * testsuite/ld-plugin/lto.exp: Run PR binutils/26389 test. * testsuite/ld-plugin/pr26389.c: New file. * testsuite/ld-plugin/pr26389.d: Likewise.
2020-08-14AArch64: Relax thumb-plt testcases regexpr.Tamar Christina3-4/+9
The regexpr in these two files are a bit strict in that they don't account for the slight changes in tags in certain arm targets which cause our address offsets to change. This changes the tests to allow slight movement in locations while still strictly checking the rest. ld/ChangeLog: 2020-08-03 Tamar Christina <tamar.christina@arm.com> * testsuite/ld-arm/thumb-plt-got.d: Relax regexpr. * testsuite/ld-arm/thumb-plt.d: Likewise.
2020-08-13PowerPC64 --no-pcrel-optimizeAlan Modra2-1/+18
This new option effectively ignores R_PPC64_PCREL_OPT, disabling the optimization of instructions marked by that relocation. The patch also disables GOT indirect to GOT/TOC pointer relative code editing when --no-toc-optimize. bfd/ * elf64-ppc.h (struct ppc64_elf_params): Add no_pcrel_opt. * elf64-ppc.c (ppc64_elf_relocate_section): Disable GOT reloc optimizations when --no-toc-optimize. Disable R_PPC64_PCREL_OPT optimization when --no-pcrel-optimize. ld/ * emultempl/ppc64elf.em (params): Init new field. (enum ppc64_opt): Add OPTION_NO_PCREL_OPT. (PARSE_AND_LIST_LONGOPTS, PARSE_AND_LIST_OPTIONS), (PARSE_AND_LIST_ARGS_CASES): Support --no-pcrel-optimize.
2020-08-10Improve the documentation of the linker's --relax option.Nick Clifton2-8/+12
PR ld/21351 * ld.texi: Clarify the behaviour of the --relax and --no-relax options on systems that do not support them.
2020-08-10nm: Remove --with-symbol-versionsH.J. Lu6-0/+46
Since commit 7e6e972f74aeac0ebdbd95a7f905d871cd2581de Author: H.J. Lu <hjl.tools@gmail.com> Date: Tue Mar 24 04:23:11 2020 -0700 bfd: Display symbol version for nm -D always displays symbol version for nm, remove --with-symbol-versions and silently accept it for backward compatibility. binutils/ PR binutils/26302 * nm.c (with_symbol_versions): Removed. (long_option_values): Add OPTION_WITH_SYMBOL_VERSIONS. (long_options): Update --with-symbol-versions entry. (print_symbol): Remove the with_symbol_versions check. (main): Add OPTION_WITH_SYMBOL_VERSIONS for backward compatibility. * doc/binutils.texi: Remove --with-symbol-versions. ld/ PR binutils/26302 * testsuite/ld-elf/pr26302.nd: New file. * testsuite/ld-elf/pr26302.ver: Likewise. * testsuite/ld-elf/pr26302a.c: Likewise. * testsuite/ld-elf/pr26302b.c: Likewise. * testsuite/ld-elf/shared.exp: Run binutils/26302 tests.