aboutsummaryrefslogtreecommitdiff
path: root/ld
AgeCommit message (Collapse)AuthorFilesLines
2020-12-18ld: Build and install only unversioned libdepH.J. Lu3-11/+28
Build only unversioned libdep and remove the installed libdep.la since only a single libdep.so is needed. PR ld/27082 * Makefile.am (libdep_la_LDFLAGS): Add -module -avoid-version. (libdep_la_LINK): New. (install-data-local): Depend on $(install-bfdpluginLTLIBRARIES) and remove libdep.la.
2020-12-18elf: Copy elf_gnu_osabi_retain only for relocatable linkH.J. Lu4-0/+33
Copy elf_gnu_osabi_retain from input only for relocatable link since SHF_GNU_RETAIN has no impact on non-relocatable outputs. bfd/ PR ld/27091 * elflink.c (elf_link_input_bfd): Copy elf_gnu_osabi_retain from input only for relocatable link. ld/ PR ld/27091 * testsuite/ld-elf/retain7.s: New file. * testsuite/ld-elf/retain7a.d: Likewise. * testsuite/ld-elf/retain7b.d: Likewise.
2020-12-16ld: Skip libdep plugin if not all plugin hooks are availableH.J. Lu5-20/+32
Skip plugin if not all required plugin hooks are available. 2020-12-16 Howard Chu <hyc@symas.com> H.J. Lu <hongjiu.lu@intel.com> PR ld/27081 * libdep_plugin.c (onload): Skip if not all required plugin hooks are available. * testsuite/config/default.exp (dep_plug_opt): New. * testsuite/ld-elf/elf.exp: Pass $dep_plug_opt to nm. * testsuite/ld-elf/pr26391.fd: New file.
2020-12-16constify elfNN_bedAlan Modra6-23/+26
elfNN_bed was made writable as an expedient means of communicating ld -z max-page-size and ld -z common-page-size values to BFD linker code, and even for objcopy to communicate segment alignment between copy_private_bfd_data, rewrite_elf_program_header and assign_file_positions_for_load_sections. Some time later elfNN_bed elf_osabi was written by gas. It turns out none of these modifications to elfNN_bed was necessary, so make it const again. include/ * bfdlink.h (struct bfd_link_info): Add maxpagesize and commonpagesize. bfd/ * elfxx-target.h (elfNN_bed): Constify. * bfd.c (bfd_elf_set_pagesize): Delete. (bfd_emul_set_maxpagesize, bfd_emul_set_commonpagesize): Delete. * elf.c (get_program_header_size): Get commonpagesize from link info. (_bfd_elf_map_sections_to_segments): Get maxpagesize from link info. (assign_file_positions_for_load_sections): Likewise. (assign_file_positions_for_non_load_sections): Likewise. (rewrite_elf_program_header): Add maxpagesize param. Set map_p_align. (copy_private_bfd_data): Don't call bfd_elf_set_maxpagesize. Instead pass maxpagesize to rewrite_elf_program_header. * elf32-nds32.c (relax_range_measurement): Add link_info param. Get maxpagesize from link_info. Adjust caller. * bfd-in2.h: Regenerate. gas/ * config/obj-elf.c (obj_elf_section): Don't set elf_osabi here. (obj_elf_type): Likewise. ld/ * ld.h (ld_config_type): Delete maxpagesize and commonpagesize. * emultempl/elf.em: Use link_info rather than config for maxpagesize and commonpagesize. * emultempl/ppc32elf.em: Likewise. * ldexp.c (fold_binary, fold_name): Likewise. * ldemul.c (after_parse_default): Likewise. (set_output_arch_default): Don't call bfd_emul_set_maxpagesize or bfd_emul_set_commonpagesize.
2020-12-15Document -z unique/-z nounique in the ld man page and help outputVivek Das Mohapatra3-0/+16
* ld.texi (Options): Document -z unique and -z nounique. * lexsup.c (elf_shlib_list_options): Likewise.
2020-12-15Handle -z unique/-z nounique in ldVivek Das Mohapatra2-0/+9
Add (or suppress) a DT_GNU_FLAGS_1 dynamic section with a bit flag value of DF_GNU_1_UNIQUE. bfd/ * elflink.c (bfd_elf_size_dynamic_sections): Call _bfd_elf_add_dynamic_entry to add a DT_GNU_FLAGS_1 section. include/ * bfdlink.h (struct bfd_link_info): New field gnu_flags_1. ld/ * emultempl/elf.em (gld${EMULATION_NAME}_handle_option): Parse -z unique / -z nounique options.
2020-12-14Add a plugin for processing static library dependencies.Howard Chu7-1524/+2180
* libdep_plugin.c: New file: Processes archives that contain a special library dependencies element. * Makefile.am: Add build rules for libdep_plugin. * Makefile.in: Regenerate. * NEWS: Mention the new plugin. * ld.texi: Document the new plugin.
2020-12-14PR26836, memory leak in parse_argsAlan Modra2-0/+10
PR 26836 * lexsup.c (parse_args): Free really_longopts, longopts and shortopts.
2020-12-14Fix a use of an uninitialised variable in the bfd linker.Nick Clifton2-1/+7
PR 27050 * lexsup.c (parse_args): Ensure that the longind local variable is set.
2020-12-14Solaris 11.4 ld build failureAlan Modra2-4/+9
/usr/include/sys/mman.h:81:0: note: this is the location of the previous definition #define SHARED 0x10 PR 27064 * deffilep.y (SHARED_K): Rename from SHARED. Update uses.
2020-12-05VAX/BFD: Do not warn about GOT addend mismatches if no GOT entry is madeMaciej W. Rozycki15-2/+238
Match the condition used in `elf_vax_instantiate_got_entries' for the creation of GOT entries in the processing of R_VAX_GOT32 relocations in `elf_vax_check_relocs', removing incorrect warnings about a GOT addend mismatch like: ./ld-new: tmpdir/got-local-ref-off-r.o: warning: GOT addend of 1 to `bar_hidden' does not match previous GOT addend of 0 ./ld-new: tmpdir/got-local-ref-off-r.o: warning: GOT addend of 2 to `bar_hidden' does not match previous GOT addend of 0 and corresponding failures with the test cases newly added here: FAIL: GOT test (executable hidden reference with offset) FAIL: GOT test (executable visible reference with offset) for symbols that are considered local for reasons other than having been forced local with a version script, which is usually the ELF visibility. Correct code is produced regardless, but the warning breaks `-Werror' compilation and may upset people regardless. Interestingly this shows with executable links only, because in shared library links code from `elf_link_add_object_symbols' triggers: /* If the symbol already has a dynamic index, but visibility says it should not be visible, turn it into a local symbol. */ switch (ELF_ST_VISIBILITY (h->other)) { case STV_INTERNAL: case STV_HIDDEN: (*bed->elf_backend_hide_symbol) (info, h, TRUE); dynsym = FALSE; break; } that sets `h->forced_local' like with a version script. Add suitable test cases including disassembly to verify correct code has been produced where no warnings have been issued, and that warnings do get issued where necessary. Do not verify (broken) code produced in the latter case; we should probably make the warning an error, or preferably actually start supporting GOT references with different addends as they appear feasible with explicitly relocated GOT that we use. bfd/ * elf32-vax.c (elf_vax_check_relocs) <R_VAX_GOT32>: Use SYMBOL_REFERENCES_LOCAL rather than `h->forced_local' to check whether the symbol referred is local or not. ld/ * testsuite/ld-vax-elf/got-local-exe-off-hidden.dd: New test dump. * testsuite/ld-vax-elf/got-local-exe-off-visible.dd: New test dump. * testsuite/ld-vax-elf/got-local-lib-off-hidden.dd: New test dump. * testsuite/ld-vax-elf/got-local-lib-off-visible.ed: New test dump. * testsuite/ld-vax-elf/got-local-off-external.ed: New test dump. * testsuite/ld-vax-elf/got-local-exe-off.xd: New test dump. * testsuite/ld-vax-elf/got-local-lib-off.xd: New test dump. * testsuite/ld-vax-elf/got-local.ld: New test linker script. * testsuite/ld-vax-elf/got-local-aux-off.s: New test source. * testsuite/ld-vax-elf/got-local-def-off.s: New test source. * testsuite/ld-vax-elf/got-local-ref-off-external.s: New test source. * testsuite/ld-vax-elf/got-local-ref-off-hidden.s: New test source. * testsuite/ld-vax-elf/got-local-ref-off-visible.s: New test source. * testsuite/ld-vax-elf/vax-elf.exp: Run the new tests.
2020-12-04x86-64: Convert load to mov only for GOTPCRELX relocationsH.J. Lu6-0/+84
Since converting load to mov needs to rewrite the REX byte and we don't know if there is a REX byte with GOTPCREL relocation, do it only for GOTPCRELX relocations. bfd/ PR ld/27016 * elf64-x86-64.c (elf_x86_64_convert_load_reloc): Convert load to mov only for GOTPCRELX relocations. ld/ PR ld/27016 * testsuite/ld-x86-64/x86-64.exp: Run pr27016a and pr27016b. * testsuite/ld-x86-64/pr27016a.d: New file. * testsuite/ld-x86-64/pr27016a.s: Likewise. * testsuite/ld-x86-64/pr27016b.d: Likewise. * testsuite/ld-x86-64/pr27016b.s: Likewise.
2020-12-04PR26978, Inconsistency for strong foo@v1 and weak foo@@v1Alan Modra5-0/+37
Prior to this patch ld -shared --version-script=pr26979.ver pr26978a.o pr26978b.o results in ld: pr26978b.o: in function `foo_v1': (.text+0x0): multiple definition of `foo@v1' ld: pr26978b.o:(*IND*+0x0): multiple definition of `foo' while ld -shared --version-script=pr26979.ver pr26978b.o pr26978a.o results in no error, but some odd dynamic symbols. ... 0 NOTYPE GLOBAL DEFAULT 7 foo@v1 ... 0 NOTYPE WEAK DEFAULT 7 foo@@v1 When linking an undecorated reference to foo against such a shared library, ld complains about multiple definitions of foo@v1 while gold creates a dynamic reference to foo@v1. That results in foo@v1 being used at runtime. While we could error in both cases, it is reasonable to say foo@v1 and foo@@v1 are in fact the same symbol. (Same name, same version. The only real difference is that foo@@v1 satisfies a reference to plain foo, while foo@v1 does not.) Just as merging a weak undecorated sym with a strong sym results in the strong sym prevailing, so should the strong foo@v1 prevail. And since there is a definition that satisfies plain foo, the foo@@v1 variety of dynamic symbol should be emitted at the foo@v1 value. That makes the testcase that currently links continue to produce a shared library, and that shared library can now be used by both ld and gold with the same runtime behaviour as when using gold with the odd dynamic symbol library. bfd/ PR 26978 * elflink.c (_bfd_elf_add_default_symbol): Handle the case where a new weak sym@@ver should be overridden by an existing sym@ver. (elf_link_add_object_symbols): Don't _bfd_elf_add_default_symbol for a new weak sym@ver when sym@@ver already exists. * linker.c (link_action): Choose MIND for previous indirect, current def, rather than MDEF. (_bfd_generic_link_add_one_symbol <MIND>): Handle redefinition of weak indirect symbol. ld/ * testsuite/ld-elf/pr26978a.d, * testsuite/ld-elf/pr26978a.s, * testsuite/ld-elf/pr26978b.d, * testsuite/ld-elf/pr26978b.s: New tests.
2020-12-03IBM Z: Add support for HLASM extended mnemonicsAndreas Krebbel2-5/+10
Add extended mnemonics used in the HLASM assembler. All of them are just aliases for instructions we already support and help when assembling code which was written for the HLASM assembler. The HLASM mnemonics are documented here: https://www.ibm.com/support/knowledgecenter/SSENW6_1.6.0/com.ibm.hlasm.v1r6.asm/asmr1023.pdf See the 'Branching with extended mnemonic codes' chapter. objdump will still print the existing mnemonics with the exception of relative nop branches (i.e. conditional branches with an empty condition code mask). Now we have jnop and jgnop which will be used by objdump when possible. The same change have been applied to the LLVM assembler: https://reviews.llvm.org/D92185 opcodes/ * s390-opc.txt: Add extended mnemonics. gas/ * testsuite/gas/s390/esa-g5.s: Test new extended mnemonics. * testsuite/gas/s390/esa-g5.d: Likewise. * testsuite/gas/s390/esa-z900.s: Likewise. * testsuite/gas/s390/esa-z900.d: Likewise. * testsuite/gas/s390/zarch-z900.s: Likewise. * testsuite/gas/s390/zarch-z900.d: Likewise. ld/ * testsuite/ld-s390/tlsbin_64.dd: The newly added jgnop mnemonic replaces long relative branches with empty condition code mask.
2020-12-03VAX/LD/testsuite: Wrap excessively long linesMaciej W. Rozycki2-3/+11
A couple of lines in the vax-elf.exp test script exceed 80 characters; wrap them. ld/ * testsuite/ld-vax-elf/vax-elf.exp: Wrap excessively long lines throughout.
2020-12-02testsuite/ld-elf/pr26936.d: Pass -W.Hans-Peter Nilsson2-1/+5
Required for the expected "CU:" to be emitted for long source-paths. See binutils/dwarf.c: if (do_wide || strlen (directory) < 76) printf (_("CU: %s/%s:\n"), directory, file_table[0].name); else printf ("%s:\n", file_table[0].name);
2020-12-01arc: Enable -Ttext-segmentH.J. Lu2-0/+9
Define TEXT_START_ADDR and SHLIB_TEXT_START_ADDR with SEGMENT_START to enable -Ttext-segment. PR ld/26970 * scripttempl/elfarc.sc (TEXT_START_ADDR): New. Add SEGMENT_START. (SHLIB_TEXT_START_ADDR): Likewise.
2020-12-01tic6x elf testsuite fixAlan Modra3-3/+9
* testsuite/ld-elf/elf.exp: Set ASFLAGS for tic6x. * testsuite/ld-elf/reloc-discard.d: Remove tic6x xfail.
2020-12-01PR26979, Visibility of undefined foo@v1 should constrain foo@@v1Alan Modra7-0/+44
Also, undefined foo should constrain the visibility of foo@@v1 just as it does for a later plain foo definition. bfd/ PR 26979 * elf-bfd.h (elf_backend_merge_symbol_attribute): Update prototype. * elf32-m68hc1x.h (elf32_m68hc11_merge_symbol_attribute): Likewise. * elfxx-mips.h (_bfd_mips_elf_merge_symbol_attribute): Likewise. * elfxx-x86.h (_bfd_x86_elf_merge_symbol_attribute): Likewise. * elf32-m68hc1x.c (elf32_m68hc11_merge_symbol_attribute): Replace isym parameter with st_other. Adjust code. * elf64-alpha.c (elf64_alpha_merge_symbol_attribute): Likewise. * elf64-ppc.c (ppc64_elf_merge_symbol_attribute): Likewise. * elfnn-aarch64.c (elfNN_aarch64_merge_symbol_attribute): Likewise. * elfxx-mips.c (_bfd_mips_elf_merge_symbol_attribute): Likewise. * elfxx-x86.c (_bfd_x86_elf_merge_symbol_attribute): Likewise. * elflink.c (elf_merge_st_other): Likewise. (_bfd_elf_merge_symbol, elf_link_add_object_symbols): Adjust to suit. (_bfd_elf_copy_link_hash_symbol_type): Likewise. (_bfd_elf_add_default_symbol): Merge st_other from undecorated symbol and @VER symbol to @@VER symbol. ld/ * testsuite/ld-elf/pr26979a.s, * testsuite/ld-elf/pr26979b.s, * testsuite/ld-elf/pr26979c.s, * testsuite/ld-elf/pr26979.ver, * testsuite/ld-elf/pr26979a.d, * testsuite/ld-elf/pr26979b.d: New tests.
2020-11-30ld: Xfail PR ld/26936 test if not supportedH.J. Lu2-0/+13
Linkonce sections and comdat groups can be mixed only if comdat groups have only a single member with matching symbol table entries. Xfail ld/26936 test: 1. If comdat groups always have more than one member. 2. If symbol table entries in linkonce and comdat group don't match. 3. If the assembly source file is renamed. PR ld/26936 * testsuite/ld-elf/pr26936.d: Xfail targets which don't support mixing linkonce and comdat sections.
2020-11-28PR26907, segment contains empty SHT_NOBITS sectionAlan Modra4-0/+31
Section ordering is important for _bfd_elf_map_sections_to_segments and assign_file_positions_for_load_sections, which are only prepared to handle sections in increasing LMA order. When zero size sections are involved it is possible to have multiple sections at the same LMA. In that case the zero size sections must sort before any non-zero size sections regardless of their types. bfd/ PR 26907 * elf.c (elf_sort_sections): Don't sort zero size !load sections after load sections. ld/ * testsuite/ld-elf/pr26907.ld, * testsuite/ld-elf/pr26907.s, * testsuite/ld-elf/pr26907.d: New test.
2020-11-27ELF: Support .noinit and .persistent sectionsJozef Lawrynowicz15-18/+145
The ".persistent" section is for data that should be initialized during load, but not during application reset. The ".noinit" section is for data that should not be initialized during load or application reset. Targets utilizing the elf.sc linker script template can define HAVE_{NOINIT,PERSISTENT}=yes to include the .noinit or .persistent output sections in the generated linker script. Targets with existing support for .noinit did not handle unique .noinit.* and .gnu.linkonce.n.* sections the .noinit output section, this patch also fixes that. bfd/ChangeLog: * elf.c (special_sections_g): Add .gnu.linkonce.n and .gnu.linkonce.p. (special_sections_n): Add .noinit. (special_sections_p): Add .persistent. binutils/ChangeLog: * testsuite/lib/binutils-common.exp (supports_noinit_section): New. (supports_persistent_section): New. gas/ChangeLog: * testsuite/gas/elf/elf.exp: Run new tests. * testsuite/gas/elf/section25.d: New test. * testsuite/gas/elf/section25.s: New test. * testsuite/gas/elf/section26.d: New test. * testsuite/gas/elf/section26.s: New test. ld/ChangeLog: * emulparams/armelf.sh (OTHER_SECTIONS): Remove .noinit section definition. Define HAVE_{NOINIT,PERSISTENT}=yes. * scripttempl/avr.sc (.noinit): Add .noinit.* and .gnu.linkonce.n.* input section wildcard patterns. * scripttempl/elf.sc: Define .noinit and .persistent sections when HAVE_NOINIT or HAVE_PERSISTENT are defined to "yes". * scripttempl/elf32msp430.sc (.noinit): Add .noinit.* and .gnu.linkonce.n.*. input section wildcard patterns. (.persistent): Add .persistent.* and .gnu.linkonce.p.*. input section wildcard patterns. * scripttempl/elfarcv2.sc (.noinit): Add .noinit.* and .gnu.linkonce.n.*. input section wildcard patterns. * scripttempl/pru.sc: Likewise. * testsuite/ld-elf/noinit-sections-1.d: New test. * testsuite/ld-elf/noinit-sections-2.d: New test. * testsuite/ld-elf/noinit-sections-2.l: New test. * testsuite/ld-elf/noinit-sections.s: New test. * testsuite/ld-elf/persistent-sections-1.d: New test. * testsuite/ld-elf/persistent-sections-2.d: New test. * testsuite/ld-elf/persistent-sections-2.l: New test. * testsuite/ld-elf/persistent-sections.s: New test.
2020-11-26PR26936 testsuite fixesAlan Modra3-3/+23
Many targets fail this test due to -z noseparate-code not being supported, or _start not being the proper entry symbol, or "as -g" something other than "generate debug". PR 26936 * testsuite/ld-elf/pr26936.d: Pass --gen-debug to gas rather than -g. Only run when -shared -z options are supported. * testsuite/ld-elf/pr26936b.s: Define more entry symbols.
2020-11-25elf: Get the real kept sectionH.J. Lu5-0/+43
When mixing linkonce and comdat sections, we need to keep searching to get the real kept section. bfd/ PR ld/26936 * elflink.c (_bfd_elf_check_kept_section): Get the real kept section. ld/ PR ld/26936 * testsuite/ld-elf/pr26936.d: New file. * testsuite/ld-elf/pr26936a.s: Likewise. * testsuite/ld-elf/pr26936b.s: Likewise. * testsuite/ld-elf/pr26936c.s: Likewise.
2020-11-25Duplicate output sections in scriptsAlan Modra3-42/+45
Previously, ld merged duplicate output sections if such existed in scripts, except for those with a constraint of SPECIAL. This makes scripts with duplicate output section statements create duplicate output sections in the linker output file. * ldlang.c (lang_output_section_statement_lookup): Change "create" parameter to a tristate, if 2 then always create a new output section statement. Update all callers, with lang_enter_output_section_statement using "2". (map_input_to_output_sections): Don't ignore SPECIAL constraint here. * ldlang.h (lang_output_section_statement_type): Update prototype. (lang_output_section_find): Update.
2020-11-24ld/x86-64: Add PR gold/26939 testsH.J. Lu5-0/+40
GOTPCRELX relocations can be transformed only when addend == -4. Add tests for GOTPCRELX relocations with addend != -4. PR gold/26939 * testsuite/ld-x86-64/pr26939-x32.d: New file. * testsuite/ld-x86-64/pr26939.d: Likewise. * testsuite/ld-x86-64/pr26939.s: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run PR gold/26939 tests.
2020-11-23s390x: Set .got sh_entsize only if .got size > 0H.J. Lu4-0/+38
bfd/ PR ld/26918 * elf64-s390.c (elf_s390_finish_dynamic_sections): Set .got sh_entsize only if .got size > 0. ld: PR ld/26918 * testsuite/ld-s390/pr26918-1.d: New file. * testsuite/ld-s390/pr26918-1.s: Likewise. * testsuite/ld-s390/s390.exp: Run all *.d tests.
2020-11-23ld: Make ARC's tls_ie-01 test more flexibleShahab Vahedi2-7/+60
This is to address the regressions addressed by Nic [1]. The regular expression pattern for the tls_ie-01 test was too strict and raising false alarms. The new pattern only looks for matches that should be there AND ignores the boiler plates from the object dump. [1] New failures for ARC targets in linker testsuite https://sourceware.org/pipermail/binutils/2020-November/114177.html ld/ * testsuite/ld-arc/tls_ie-01.d: Use a more general pattern.
2020-11-21RISC-V: Relax PCREL to GPREL while doing other relaxations is dangerous.Nelson Chu5-1/+55
I get the feedback recently that enable linker relaxations may fail to build some program. Consider the following case, .text foo: addi a0, a0, %pcrel_lo(.L2) call foo .L1: auipc a1, %pcrel_hi(data_g) addi a1, a1, %pcrel_lo(.L1) lui a2, %hi(data_g) addi a2, a2, %lo(data_g) lui a3, %tprel_hi(data_t) add a3, a3, tp, %tprel_add(data_t) addi a3, a3, %tprel_lo(data_t) .L2: auipc a0, %pcrel_hi(data_g) .data .word 0x0 .global data_g data_g: .word 0x1 .section .tbss data_t: .word 0x0 The current ld reports `dangerous relocation error` when doing the pcgp relaxation, test.o: in function `foo': (.text+0x0): dangerous relocation: %pcrel_lo missing matching %pcrel_hi The .L2 auipc should not be removed since it is behind the corresponding addi, so we record the information in the pcgp_relocs table to avoid removing the auipc later. But current ld still remove it since we do not update the pcgp_relocs table while doing other relaxations. I have two solutions to fix the problem, 1. Update the pcgp_relocs table once we actually delete the code. 2. Add new relax pass to do the pcgp relaxations At first I tried to do the first solution, and we need to update at least three information - hi_sec_off of riscv_pcgp_lo_reloc, hi_sec_off and hi_addr (symbol value) of riscv_pcgp_hi_reloc. Update the hi_sec_off is simple, but it is more complicate to update the symbol value, since we almost have to do parts the same works of _bfd_riscv_relax_call again in the riscv_relax_delete_bytes to get the correct symbol value. Compared with the first solution, the second one is more intuitive and simple. We add a new relax pass to do the pcgp relaxations later, so we will get all the information correctly in the _bfd_riscv_relax_call, including the symbol value, without changing so much code. I do not see any penalty by adding a new relax pass for now, so it should be fine to delay the pcgp relaxations. Besides, I have pass all riscv-gnu-toolchain regressions for this patch. bfd/ * elfnn-riscv.c (_bfd_riscv_relax_section): Add a new relax pass to do the pcgp relaxation later, after the lui and call relaxations, but before the delete and alignment relaxations. ld/ * emultempl/riscvelf.em (riscv_elf_before_allocation): Change link_info.relax_pass from 3 to 4. * testsuite/ld-riscv-elf/pcgp-relax.d: New testcase. * testsuite/ld-riscv-elf/pcgp-relax.s: Likewise. * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated.
2020-11-20libctf, ld: properly deduplicate function typesNick Alcock2-1/+7
Some type kinds in CTF (functions, arrays, pointers, slices, and cvr-quals) are intrinsically nameless: the ctt_name field in the CTF is always zero, and the libctf API provides no way to set a name. But the compiler can and does sometimes set names for some of these kinds: in particular, the name it sets on CTF_K_FUNCTION types is the means it uses to force the name of the function into the string table so that it can point at it from the function info section. So null out the name at hashing time so that the deduplicator can correctly detect that e.g. function types identical but for name should be considered truly identical, since they will not have a name when the deduplicator re-emits them into the output. ld/ChangeLog 2020-11-20 Nick Alcock <nick.alcock@oracle.com> * testsuite/ld-ctf/data-func-conflicted.d: Shrink the expected size of the type section now that function types are being deduplicated properly. libctf/ChangeLog 2020-11-20 Nick Alcock <nick.alcock@oracle.com> * ctf-dedup.c (ctf_dedup_rhash_type): Null out the names of nameless type kinds, just in case the input has named them.
2020-11-20ld, ctf: new and adjusted CTF tests due to func info / object data sectionsNick Alcock26-45/+1191
The flags word is nonzero now (so all the tests have been adjusted to not depend on its content): some of them have data objects and functions in the data object and function info sections now, rather than in the variable section or recorded nowhere. There is a new test for parent/child relationships and index section emission. ld/ChangeLog 2020-11-20 Nick Alcock <nick.alcock@oracle.com> * testsuite/ld-ctf/array.d: Adjust for nonzero flags word and public symbols in the data section rather than variables: use sysv hash style to keep test results the same on non-GNU targets. * testsuite/ld-ctf/diag-cttname-null.d: Likewise. * testsuite/ld-ctf/diag-cuname.d: Likewise. * testsuite/ld-ctf/diag-parlabel.d: Likewise. * testsuite/ld-ctf/slice.d: Likewise. * testsuite/ld-ctf/function.d: Likewise, but in the function section. * testsuite/ld-ctf/conflicting-cycle-1.B-1.d: Adjust for nonzero flags word. * testsuite/ld-ctf/conflicting-cycle-1.B-2.d: Likewise. * testsuite/ld-ctf/conflicting-cycle-1.parent.d: Likewise. * testsuite/ld-ctf/conflicting-cycle-2.A-1.d: Likewise. * testsuite/ld-ctf/conflicting-cycle-2.A-2.d: Likewise. * testsuite/ld-ctf/conflicting-cycle-2.parent.d: Likewise. * testsuite/ld-ctf/conflicting-cycle-3.C-1.d: Likewise. * testsuite/ld-ctf/conflicting-cycle-3.C-2.d: Likewise. * testsuite/ld-ctf/conflicting-cycle-3.parent.d: Likewise. * testsuite/ld-ctf/cross-tu-noncyclic.d: Likewise. * testsuite/ld-ctf/cycle-1.d: Likewise. * testsuite/ld-ctf/cycle-2.A.d: Likewise. * testsuite/ld-ctf/cycle-2.B.d: Likewise. * testsuite/ld-ctf/cycle-2.C.d: Likewise. * testsuite/ld-ctf/diag-wrong-magic-number-mixed.d: Likewise. * testsuite/ld-ctf/super-sub-cycles.d: Likewise. * testsuite/ld-ctf/data-func-1.c: New test. * testsuite/ld-ctf/data-func-2.c: Likewise. * testsuite/ld-ctf/data-func-conflicted.d: Likewise.
2020-11-20bfd, include, ld, binutils, libctf: CTF should use the dynstr/symNick Alcock20-99/+187
This is embarrassing. The whole point of CTF is that it remains intact even after a binary is stripped, providing a compact mapping from symbols to types for everything in the externally-visible interface of an ELF object: it has connections to the symbol table for that purpose, and to the string table to avoid duplicating symbol names. So it's a shame that the hooks I implemented last year served to hook it up to the .symtab and .strtab, which obviously disappear on strip, leaving any accompanying the CTF dict containing references to strings (and, soon, symbols) which don't exist any more because their containing strtab has been vaporized. The original Solaris design used .dynsym and .dynstr (well, actually, .ldynsym, which has more symbols) which do not disappear. So should we. Thankfully the work we did before serves as guide rails, and adjusting things to use the .dynstr and .dynsym was fast and easy. The only annoyance is that the dynsym is assembled inside elflink.c in a fairly piecemeal fashion, so that the easiest way to get the symbols out was to hook in before every call to swap_symbol_out (we also leave in a hook in front of symbol additions to the .symtab because it seems plausible that we might want to hook them in future too: for now that hook is unused). We adjust things so that rather than being offered a whole hash table of symbols at once, libctf is now given symbols one at a time, with st_name indexes already resolved and pointing at their final .dynstr offsets: it's now up to libctf to resolve these to names as needed using the strtab info we pass it separately. Some bits might be contentious. The ctf_new_dynstr callback takes an elf_internal_sym, and this remains an elf_internal_sym right down through the generic emulation layers into ldelfgen. This is no worse than the elf_sym_strtab we used to pass down, but in the future when we gain non-ELF CTF symtab support we might want to lower the elf_internal_sym to some other representation (perhaps a ctf_link_symbol) in bfd or in ldlang_ctf_new_dynsym. We rename the 'apply_strsym' hooks to 'acquire_strings' instead, becuse they no longer have anything to do with symbols. There are some API changes to pieces of API which are technically public but actually totally unused by anything and/or unused by anything but ld so they can change freely: the ctf_link_symbol gains new fields to allow symbol names to be given as strtab offsets as well as strings, and a symidx so that the symbol index can be passed in. ctf_link_shuffle_syms loses its callback parameter: the idea now is that linkers call the new ctf_link_add_linker_symbol for every symbol in .dynsym, feed in all the strtab entries with ctf_link_add_strtab, and then a call to ctf_link_shuffle_syms will apply both and arrange to use them to reorder the CTF symtab at CTF serialization time (which is coming in the next commit). Inside libctf we have a new preamble flag CTF_F_DYNSTR which is always set in v3-format CTF dicts from this commit forwards: CTF dicts without this flag are associated with .strtab like they used to be, so that old dicts' external strings don't turn to garbage when loaded by new libctf. Dicts with this flag are associated with .dynstr and .dynsym instead. (The flag is not the next in sequence because this commit was written quite late: the missing flags will be filled in by the next commit.) Tests forthcoming in a later commit in this series. bfd/ChangeLog 2020-11-20 Nick Alcock <nick.alcock@oracle.com> * elflink.c (elf_finalize_dynstr): Call examine_strtab after dynstr finalization. (elf_link_swap_symbols_out): Don't call it here. Call ctf_new_symbol before swap_symbol_out. (elf_link_output_extsym): Call ctf_new_dynsym before swap_symbol_out. (bfd_elf_final_link): Likewise. * elf.c (swap_out_syms): Pass in bfd_link_info. Call ctf_new_symbol before swap_symbol_out. (_bfd_elf_compute_section_file_positions): Adjust. binutils/ChangeLog 2020-11-20 Nick Alcock <nick.alcock@oracle.com> * readelf.c (dump_section_as_ctf): Use .dynsym and .dynstr, not .symtab and .strtab. include/ChangeLog 2020-11-20 Nick Alcock <nick.alcock@oracle.com> * bfdlink.h (struct elf_sym_strtab): Replace with... (struct elf_internal_sym): ... this. (struct bfd_link_callbacks) <examine_strtab>: Take only a symstrtab argument. <ctf_new_symbol>: New. <ctf_new_dynsym>: Likewise. * ctf-api.h (struct ctf_link_sym) <st_symidx>: New. <st_nameidx>: Likewise. <st_nameidx_set>: Likewise. (ctf_link_iter_symbol_f): Removed. (ctf_link_shuffle_syms): Remove most parameters, just takes a ctf_dict_t now. (ctf_link_add_linker_symbol): New, split from ctf_link_shuffle_syms. * ctf.h (CTF_F_DYNSTR): New. (CTF_F_MAX): Adjust. ld/ChangeLog 2020-11-20 Nick Alcock <nick.alcock@oracle.com> * ldelfgen.c (struct ctf_strsym_iter_cb_arg): Rename to... (struct ctf_strtab_iter_cb_arg): ... this, changing fields: <syms>: Remove. <symcount>: Remove. <symstrtab>: Rename to... <strtab>: ... this. (ldelf_ctf_strtab_iter_cb): Adjust. (ldelf_ctf_symbols_iter_cb): Remove. (ldelf_new_dynsym_for_ctf): New, tell libctf about a single symbol. (ldelf_examine_strtab_for_ctf): Rename to... (ldelf_acquire_strings_for_ctf): ... this, only doing the strtab portion and not symbols. * ldelfgen.h: Adjust declarations accordingly. * ldemul.c (ldemul_examine_strtab_for_ctf): Rename to... (ldemul_acquire_strings_for_ctf): ... this. (ldemul_new_dynsym_for_ctf): New. * ldemul.h: Adjust declarations accordingly. * ldlang.c (ldlang_ctf_apply_strsym): Rename to... (ldlang_ctf_acquire_strings): ... this. (ldlang_ctf_new_dynsym): New. (lang_write_ctf): Call ldemul_new_dynsym_for_ctf with NULL to do the actual symbol shuffle. * ldlang.h (struct elf_strtab_hash): Adjust accordingly. * ldmain.c (bfd_link_callbacks): Wire up new/renamed callbacks. libctf/ChangeLog 2020-11-20 Nick Alcock <nick.alcock@oracle.com> * ctf-link.c (ctf_link_shuffle_syms): Adjust. (ctf_link_add_linker_symbol): New, unimplemented stub. * libctf.ver: Add it. * ctf-create.c (ctf_serialize): Set CTF_F_DYNSTR on newly-serialized dicts. * ctf-open-bfd.c (ctf_bfdopen_ctfsect): Check for the flag: open the symtab/strtab if not present, dynsym/dynstr otherwise. * ctf-archive.c (ctf_arc_bufpreamble): New, get the preamble from some arbitrary member of a CTF archive. * ctf-impl.h (ctf_arc_bufpreamble): Declare it.
2020-11-20libctf, include, binutils, gdb, ld: rename ctf_file_t to ctf_dict_tNick Alcock6-12/+25
The naming of the ctf_file_t type in libctf is a historical curiosity. Back in the Solaris days, CTF dictionaries were originally generated as a separate file and then (sometimes) merged into objects: hence the datatype was named ctf_file_t, and known as a "CTF file". Nowadays, raw CTF is essentially never written to a file on its own, and the datatype changed name to a "CTF dictionary" years ago. So the term "CTF file" refers to something that is never a file! This is at best confusing. The type has also historically been known as a 'CTF container", which is even more confusing now that we have CTF archives which are *also* a sort of container (they contain CTF dictionaries), but which are never referred to as containers in the source code. So fix this by completing the renaming, renaming ctf_file_t to ctf_dict_t throughout, and renaming those few functions that refer to CTF files by name (keeping compatibility aliases) to refer to dicts instead. Old users who still refer to ctf_file_t will see (harmless) pointer-compatibility warnings at compile time, but the ABI is unchanged (since C doesn't mangle names, and ctf_file_t was always an opaque type) and things will still compile fine as long as -Werror is not specified. All references to CTF containers and CTF files in the source code are fixed to refer to CTF dicts instead. Further (smaller) renamings of annoyingly-named functions to come, as part of the process of souping up queries across whole archives at once (needed for the function info and data object sections). binutils/ChangeLog 2020-11-20 Nick Alcock <nick.alcock@oracle.com> * objdump.c (dump_ctf_errs): Rename ctf_file_t to ctf_dict_t. (dump_ctf_archive_member): Likewise. (dump_ctf): Likewise. Use ctf_dict_close, not ctf_file_close. * readelf.c (dump_ctf_errs): Rename ctf_file_t to ctf_dict_t. (dump_ctf_archive_member): Likewise. (dump_section_as_ctf): Likewise. Use ctf_dict_close, not ctf_file_close. gdb/ChangeLog 2020-11-20 Nick Alcock <nick.alcock@oracle.com> * ctfread.c: Change uses of ctf_file_t to ctf_dict_t. (ctf_fp_info::~ctf_fp_info): Call ctf_dict_close, not ctf_file_close. include/ChangeLog 2020-11-20 Nick Alcock <nick.alcock@oracle.com> * ctf-api.h (ctf_file_t): Rename to... (ctf_dict_t): ... this. Keep ctf_file_t around for compatibility. (struct ctf_file): Likewise rename to... (struct ctf_dict): ... this. (ctf_file_close): Rename to... (ctf_dict_close): ... this, keeping compatibility function. (ctf_parent_file): Rename to... (ctf_parent_dict): ... this, keeping compatibility function. All callers adjusted. * ctf.h: Rename references to ctf_file_t to ctf_dict_t. (struct ctf_archive) <ctfa_nfiles>: Rename to... <ctfa_ndicts>: ... this. ld/ChangeLog 2020-11-20 Nick Alcock <nick.alcock@oracle.com> * ldlang.c (ctf_output): This is a ctf_dict_t now. (lang_ctf_errs_warnings): Rename ctf_file_t to ctf_dict_t. (ldlang_open_ctf): Adjust comment. (lang_merge_ctf): Use ctf_dict_close, not ctf_file_close. * ldelfgen.h (ldelf_examine_strtab_for_ctf): Rename ctf_file_t to ctf_dict_t. Change opaque declaration accordingly. * ldelfgen.c (ldelf_examine_strtab_for_ctf): Adjust. * ldemul.h (examine_strtab_for_ctf): Likewise. (ldemul_examine_strtab_for_ctf): Likewise. * ldeuml.c (ldemul_examine_strtab_for_ctf): Likewise. libctf/ChangeLog 2020-11-20 Nick Alcock <nick.alcock@oracle.com> * ctf-impl.h: Rename ctf_file_t to ctf_dict_t: all declarations adjusted. (ctf_fileops): Rename to... (ctf_dictops): ... this. (ctf_dedup_t) <cd_id_to_file_t>: Rename to... <cd_id_to_dict_t>: ... this. (ctf_file_t): Fix outdated comment. <ctf_fileops>: Rename to... <ctf_dictops>: ... this. (struct ctf_archive_internal) <ctfi_file>: Rename to... <ctfi_dict>: ... this. * ctf-archive.c: Rename ctf_file_t to ctf_dict_t. Rename ctf_archive.ctfa_nfiles to ctfa_ndicts. Rename ctf_file_close to ctf_dict_close. All users adjusted. * ctf-create.c: Likewise. Refer to CTF dicts, not CTF containers. (ctf_bundle_t) <ctb_file>: Rename to... <ctb_dict): ... this. * ctf-decl.c: Rename ctf_file_t to ctf_dict_t. * ctf-dedup.c: Likewise. Rename ctf_file_close to ctf_dict_close. Refer to CTF dicts, not CTF containers. * ctf-dump.c: Likewise. * ctf-error.c: Likewise. * ctf-hash.c: Likewise. * ctf-inlines.h: Likewise. * ctf-labels.c: Likewise. * ctf-link.c: Likewise. * ctf-lookup.c: Likewise. * ctf-open-bfd.c: Likewise. * ctf-string.c: Likewise. * ctf-subr.c: Likewise. * ctf-types.c: Likewise. * ctf-util.c: Likewise. * ctf-open.c: Likewise. (ctf_file_close): Rename to... (ctf_dict_close): ...this. (ctf_file_close): New trivial wrapper around ctf_dict_close, for compatibility. (ctf_parent_file): Rename to... (ctf_parent_dict): ... this. (ctf_parent_file): New trivial wrapper around ctf_parent_dict, for compatibility. * libctf.ver: Add ctf_dict_close and ctf_parent_dict.
2020-11-20Fix SHF_GNU_RETAIN testsuite falloutJozef Lawrynowicz5-9/+19
binutils/ChangeLog: * testsuite/binutils-all/readelf-maskos-1a.d: Fix test for unrecognized bit set in SHF_MASKOS range. * testsuite/binutils-all/readelf-maskos-1b.d: Likewise. * testsuite/binutils-all/readelf-maskos-unknown.s: New test. ld/ChangeLog: * testsuite/ld-elf/retain3.s: Move symbolic reference into writeable .data section from read-only .text section. * testsuite/ld-elf/retain5.d: Don't pass --print-gc-sections for test that doesn't require it. * testsuite/ld-elf/retain6a.d: Adjust test. * testsuite/ld-elf/retain6main.s: Move symbolic reference into writeable .data section from read-only .text section.
2020-11-18PowerPC paranioa testing of symbol merging involving comdat groupsAlan Modra10-0/+85
Ensures we don't mistreat st_other localentry bits. * testsuite/ld-powerpc/group1.d, * testsuite/ld-powerpc/group1.s, * testsuite/ld-powerpc/group1.sym, * testsuite/ld-powerpc/group2.d, * testsuite/ld-powerpc/group2.s, * testsuite/ld-powerpc/group2.sym, * testsuite/ld-powerpc/group3.s, * testsuite/ld-powerpc/group3.sym: New test files. * testsuite/ld-powerpc/powerpc.exp: Run new tests.
2020-11-18Support SHF_GNU_RETAIN ELF section flagJozef Lawrynowicz22-0/+363
The SHF_GNU_RETAIN section flag is an extension to the GNU ELF OSABI. It is defined as follows: ========================================================= Section Attribute Flags +-------------------------------------+ | Name | Value | +-------------------------------------+ | SHF_GNU_RETAIN | 0x200000 (1 << 21) | +-------------------------------------+ SHF_GNU_RETAIN The link editor should not garbage collect the section. ========================================================= The .section directive accepts the "R" flag, which indicates SHF_GNU_RETAIN should be applied to the section. There is not a direct mapping of SHF_GNU_RETAIN to the BFD section flag SEC_KEEP. Keeping these flags distinct allows SHF_GNU_RETAIN sections to be explicitly removed by placing them in /DISCARD/. bfd/ChangeLog: * elf-bfd.h (enum elf_gnu_osabi): Add elf_gnu_osabi_retain. (struct elf_obj_tdata): Increase has_gnu_osabi to 4 bits. * elf.c (_bfd_elf_make_section_from_shdr): Set elf_gnu_osabi_retain for SHF_GNU_RETAIN. (_bfd_elf_final_write_processing): Report if SHF_GNU_RETAIN is not supported by the OSABI. Adjust error messages. * elflink.c (elf_link_input_bfd): Copy enabled has_gnu_osabi bits from input BFD to output BFD. (bfd_elf_gc_sections): gc_mark the section if SHF_GNU_RETAIN is set. binutils/ChangeLog: * NEWS: Announce SHF_GNU_RETAIN support. * readelf.c (get_elf_section_flags): Handle SHF_GNU_RETAIN. Recognize SHF_GNU_RETAIN and SHF_GNU_MBIND only for supported OSABIs. * testsuite/binutils-all/readelf.exp: Run new tests. Don't run run_dump_test when there isn't an assembler available. * testsuite/lib/binutils-common.exp (supports_gnu_osabi): Adjust comment. * testsuite/binutils-all/readelf-maskos-1a.d: New test. * testsuite/binutils-all/readelf-maskos-1b.d: New test. * testsuite/binutils-all/readelf-maskos.s: New test. * testsuite/binutils-all/retain1.s: New test. * testsuite/binutils-all/retain1a.d: New test. * testsuite/binutils-all/retain1b.d: New test. gas/ChangeLog: * NEWS: Announce SHF_GNU_RETAIN support. * config/obj-elf.c (obj_elf_change_section): Merge SHF_GNU_RETAIN bit between section declarations. (obj_elf_parse_section_letters): Handle 'R' flag. Handle numeric flag values within the SHF_MASKOS range. (obj_elf_section): Validate SHF_GNU_RETAIN usage. * doc/as.texi: Document 'R' flag to .section directive. * testsuite/gas/elf/elf.exp: Run new tests. * testsuite/gas/elf/section10.d: Unset SHF_GNU_RETAIN bit. * testsuite/gas/elf/section10.s: Likewise. * testsuite/gas/elf/section22.d: New test. * testsuite/gas/elf/section22.s: New test. * testsuite/gas/elf/section23.s: New test. * testsuite/gas/elf/section23a.d: New test. * testsuite/gas/elf/section23b.d: New test. * testsuite/gas/elf/section23b.err: New test. * testsuite/gas/elf/section24.l: New test. * testsuite/gas/elf/section24.s: New test. * testsuite/gas/elf/section24a.d: New test. * testsuite/gas/elf/section24b.d: New test. include/ChangeLog: * elf/common.h (SHF_GNU_RETAIN): Define. ld/ChangeLog: * NEWS: Announce support for SHF_GNU_RETAIN. * ld.texi (garbage collection): Document SHF_GNU_RETAIN. (Output Section Discarding): Likewise. * testsuite/ld-elf/elf.exp: Run new tests. * testsuite/ld-elf/retain1.s: New test. * testsuite/ld-elf/retain1a.d: New test. * testsuite/ld-elf/retain1b.d: New test. * testsuite/ld-elf/retain2.d: New test. * testsuite/ld-elf/retain2.ld: New test. * testsuite/ld-elf/retain2.map: New test. * testsuite/ld-elf/retain3.d: New test. * testsuite/ld-elf/retain3.s: New test. * testsuite/ld-elf/retain4.d: New test. * testsuite/ld-elf/retain4.s: New test. * testsuite/ld-elf/retain5.d: New test. * testsuite/ld-elf/retain5.map: New test. * testsuite/ld-elf/retain5lib.s: New test. * testsuite/ld-elf/retain5main.s: New test. * testsuite/ld-elf/retain6a.d: New test. * testsuite/ld-elf/retain6b.d: New test. * testsuite/ld-elf/retain6lib.s: New test. * testsuite/ld-elf/retain6main.s: New test.
2020-11-17PR26882, --enable-textrel-check=warning test failures on powerpcAlan Modra8-9/+24
PR 26882 * testsuite/ld-powerpc/dotsym3.d: Add "-z notext" to ld options. * testsuite/ld-powerpc/dotsym4.d: Likewise. * testsuite/ld-powerpc/ppc476-shared.d: Likewise. * testsuite/ld-powerpc/ppc476-shared2.d: Likewise. * testsuite/ld-powerpc/powerpc.exp: Likewise for various tests. * testsuite/ld-undefined/weak-fundef.s: Add BLPLT variant. * testsuite/ld-undefined/weak-undef.exp: Define BLPLT for ppc32.
2020-11-16Update the Spanish translation for the ld/ subdirectory.Nick Clifton2-1781/+2031
* po/es.po: Updated Spanish translation.
2020-11-16ld: Fix the tls_ie-01 test for arcShahab Vahedi2-4/+11
The purpose of the test is to look for entries of "foo" and "bar" in the ".got". The old "objdump -s ..." has been replaced with "objdump -D ..." to inspect the final executable. A sample output looks like: ------------------------8<------------------------ $ arc-elf32-objdump -D -j .got tls_ie-01 tls_ie-01: file format elf32-littlearc Disassembly of section .got: 00002110 <_GLOBAL_OFFSET_TABLE_>: ... 211c: 08 00 00 00 .word 0x00000008 2120: 0c 00 00 00 .word 0x0000000c ------------------------>8------------------------ ld/ * testsuite/ld-arc/tls_ie-01.d: Update the dump command.
2020-11-14x86: Ignore CS/DS/ES/SS segment-override prefixes in 64-bit modeBorislav Petkov5-4/+10
"In 64-bit mode, the CS, DS, ES, and SS segment-override prefixes have no effect. These four prefixes are not treated as segment-override prefixes for the purposes of multiple-prefix rules. Instead, they are treated as null prefixes." (AMD APM v2). However, objdump disassembles instructions containing those ignored prefixes by still generating that segment override: 66 66 2e 0f 1f 84 00 data16 nopw %cs:0x0(%rax,%rax,1) 00 00 00 00 Print those segment override prefixes as excessive ones: 66 66 2e 0f 1f 84 00 data16 cs nopw 0x0(%rax,%rax,1) 00 00 00 00 which is what they actually are - they have no effect and the decoding hardware ignores them. gas/ 2020-11-14 Borislav Petkov <bp@suse.de> * testsuite/gas/i386/x86-64-segovr.d: Adjust regexes. * testsuite/gas/i386/x86-64-nops.d: Likewise. * testsuite/gas/i386/x86-64-nops-1.d: Likewise. * testsuite/gas/i386/x86-64-nops-1-g64.d: Likewise. * testsuite/gas/i386/x86-64-nops-1-core2.d: Likewise. * testsuite/gas/i386/x86-64-nops-1-k8.d: Likewise. * testsuite/gas/i386/x86-64-nops-2.d: Likewise. * testsuite/gas/i386/x86-64-nops-3.d: Likewise. * testsuite/gas/i386/x86-64-nops-4.d: Likewise. * testsuite/gas/i386/x86-64-nops-4-core2.d: Likewise. * testsuite/gas/i386/x86-64-nops-4-k8.d: Likewise. * testsuite/gas/i386/x86-64-nops-5.d: Likewise. * testsuite/gas/i386/x86-64-nops-5-k8.d: Likewise. * testsuite/gas/i386/x86-64-nops-7.d: Likewise. * testsuite/gas/i386/x86-64-nop-1.d: Likewise. * testsuite/gas/i386/x86-64-align-branch-1a.d: Likewise. * testsuite/gas/i386/x86-64-align-branch-1b.d: Likewise. * testsuite/gas/i386/x86-64-align-branch-1c.d: Likewise. * testsuite/gas/i386/x86-64-align-branch-1d.d: Likewise. * testsuite/gas/i386/x86-64-align-branch-1g.d: Likewise. * testsuite/gas/i386/x86-64-align-branch-2c.d: Likewise. * testsuite/gas/i386/x86-64-align-branch-6.d: Likewise. * testsuite/gas/i386/x86-64-align-branch-7.d: Likewise. * testsuite/gas/i386/x86-64-align-branch-8.d: Likewise. * testsuite/gas/i386/ilp32/x86-64-nops-1-core2.d: Likewise. * testsuite/gas/i386/ilp32/x86-64-nops-1-k8.d: Likewise. * testsuite/gas/i386/ilp32/x86-64-nops-1.d: Likewise. * testsuite/gas/i386/ilp32/x86-64-nops-2.d: Likewise. * testsuite/gas/i386/ilp32/x86-64-nops-3.d: Likewise. * testsuite/gas/i386/ilp32/x86-64-nops-4-core2.d: Likewise. * testsuite/gas/i386/ilp32/x86-64-nops-4-k8.d: Likewise. * testsuite/gas/i386/ilp32/x86-64-nops-4.d: Likewise. * testsuite/gas/i386/ilp32/x86-64-nops-5-k8.d: Likewise. * testsuite/gas/i386/ilp32/x86-64-nops-5.d: Likewise. * testsuite/gas/i386/ilp32/x86-64-nops.d:: Likewise. ld/ 2020-11-14 Borislav Petkov <bp@suse.de> * testsuite/ld-x86-64/pe-x86-64-4.od: Adjust regexes. * testsuite/ld-x86-64/tlsld3.dd: Likewise. * testsuite/ld-x86-64/tlsld4.dd: Likewise. opcodes/ 2020-11-14 Borislav Petkov <bp@suse.de> * i386-dis.c (ckprefix): Do not assign active_seg_prefix in 64-bit addressing mode. (NOTRACK_Fixup): Test prefixes for PREFIX_DS, instead of active_seg_prefix.
2020-11-13elf: Set rel_from_abs to 1 for __ehdr_startH.J. Lu5-0/+29
bfdlink.h has /* Symbol will be converted from absolute to section-relative. Set for symbols defined by a script from "dot" (also SEGMENT_START or ORIGIN) outside of an output section statement. */ unsigned int rel_from_abs : 1; linker.c has .{* Return TRUE if the symbol described by a linker hash entry H . is going to be absolute. Linker-script defined symbols can be . converted from absolute to section-relative ones late in the . link. Use this macro to correctly determine whether the symbol . will actually end up absolute in output. *} .#define bfd_is_abs_symbol(H) \ . (((H)->type == bfd_link_hash_defined \ . || (H)->type == bfd_link_hash_defweak) \ . && bfd_is_abs_section ((H)->u.def.section) \ . && !(H)->rel_from_abs) . Set rel_from_abs to 1 for __ehdr_start which will be converted from absolute to section-relative in assign_file_positions_for_load_sections. PR ld/26869 * ldelf.c (ldelf_before_allocation): Set rel_from_abs to 1 for __ehdr_start. * testsuite/ld-i386/i386.exp: Run pr26869. * testsuite/ld-i386/pr26869.d: New file. * testsuite/ld-i386/pr26869.s: Likewise.
2020-11-09Fix regexp for development.expAndreas Schwab3-2/+7
binutils/: * Makefile.am (development.exp): Fix regexp. * Makefile.in: Regenerate. gas/: * Makefile.am (development.exp): Fix regexp. * Makefile.in: Regenerate. ld/: * Makefile.am (development.exp): Fix regexp. * Makefile.in: Regenerate.
2020-11-06Extend ld's -Map=<dir> functionality by allowing '%' to be replaced with the ↵Nick Clifton4-20/+137
output file path. * lexsup.c (parse_args): Add more checks of the mapfile. If it is a directory use the basename of the output file as the file component. If the % character is present, replace it with the full output filepath. * testsuite/ld-scripts/map-address.exp: Add test of % functionality. * ld.texi: Document the new behaviour.
2020-11-06Updated Serbian translation for the ld subdirectoryNick Clifton2-1216/+4718
2020-11-03Fix compile time warningNick Clifton2-1/+6
2020-11-02PR26806, Suspected linker bug with LTOAlan Modra8-0/+74
This patch reverts most of git commit 1e3b96fd6cf, so IR symbols are again not marked def_regular or ref_regular. That should be enough to stop IR symbols from becoming dynamic. To mark as-needed shared libraries referenced by IR symbols, use the referencing BFD rather than the ref flags. bfd/ PR 15146 PR 26314 PR 26530 PR 26806 * elflink.c (elf_link_add_object_symbols): Don't set def/ref flags for plugin syms. Do allow plugin syms to mark as-needed libs. ld/ PR 26806 * testsuite/ld-plugin/lto-19.h, * testsuite/ld-plugin/lto-19a.c, * testsuite/ld-plugin/lto-19b.c, * testsuite/ld-plugin/lto-19c.c: New test. * testsuite/ld-plugin/pr26806.c, * testsuite/ld-plugin/pr26806.d: New test. * testsuite/ld-plugin/lto.exp: Run them.
2020-10-30x86: Support GNU_PROPERTY_X86_ISA_1_BASELINE markerH.J. Lu119-142/+304
GCC 11 supports -march=x86-64-v[234] to enable x86 micro-architecture ISA levels: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97250 X86 ISA markers are updated: https://gitlab.com/x86-psABIs/x86-64-ABI/-/merge_requests/13 GNU_PROPERTY_X86_ISA_1_BASELINE is added and GNU_PROPERTY_X86_ISA_1_V[234] are updated: #define GNU_PROPERTY_X86_ISA_1_BASELINE (1U << 0) #define GNU_PROPERTY_X86_ISA_1_V2 (1U << 1) #define GNU_PROPERTY_X86_ISA_1_V3 (1U << 2) #define GNU_PROPERTY_X86_ISA_1_V4 (1U << 3) Add -z x86-64-baseline linker command line option to mark x86-64-baseline ISA level as needed. bfd/ PR gas/26703 * elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Generate GNU_PROPERTY_X86_ISA_1_BASELINE for -z x86-64-baseline. binutils/ PR gas/26703 * readelf.c (decode_x86_isa): Handle * GNU_PROPERTY_X86_ISA_1_BASELINE. * testsuite/binutils-all/i386/empty.d: Updated. * testsuite/binutils-all/i386/ibt.d: Likewise. * testsuite/binutils-all/i386/pr21231a.d: Likewise. * testsuite/binutils-all/i386/pr21231b.d: Likewise. * testsuite/binutils-all/i386/shstk.d: Likewise. * testsuite/binutils-all/x86-64/empty-x32.d: Likewise. * testsuite/binutils-all/x86-64/empty.d: Likewise. * testsuite/binutils-all/x86-64/ibt-x32.d: Likewise. * testsuite/binutils-all/x86-64/ibt.d: Likewise. * testsuite/binutils-all/x86-64/pr21231a.d: Likewise. * testsuite/binutils-all/x86-64/pr21231b.d: Likewise. * testsuite/binutils-all/x86-64/pr23494a-x32.d: Likewise. * testsuite/binutils-all/x86-64/pr23494a.d: Likewise. * testsuite/binutils-all/x86-64/pr23494c-x32.d: Likewise. * testsuite/binutils-all/x86-64/pr23494c.d: Likewise. * testsuite/binutils-all/x86-64/pr23494d-x32.d: Likewise. * testsuite/binutils-all/x86-64/pr23494d.d: Likewise. * testsuite/binutils-all/x86-64/pr23494e-x32.d: Likewise. * testsuite/binutils-all/x86-64/pr23494e.d: Likewise. * testsuite/binutils-all/x86-64/shstk-x32.d: Likewise. * testsuite/binutils-all/x86-64/shstk.d: Likewise. gas/ PR gas/26703 * config/tc-i386.c (output_insn): Update for GNU_PROPERTY_X86_ISA_1_BASELINE. * testsuite/gas/i386/property-1.d: Updated. * testsuite/gas/i386/property-2.d: Likewise. * testsuite/gas/i386/property-3.d: Likewise. * testsuite/gas/i386/property-4.d: Likewise. * testsuite/gas/i386/property-5.d: Likewise. * testsuite/gas/i386/property-6.d: Likewise. * testsuite/gas/i386/property-11.d: Likewise. * testsuite/gas/i386/property-12.d: Likewise. * testsuite/gas/i386/x86-64-property-1.d: Likewise. * testsuite/gas/i386/x86-64-property-2.d: Likewise. * testsuite/gas/i386/x86-64-property-3.d: Likewise. * testsuite/gas/i386/x86-64-property-4.d: Likewise. * testsuite/gas/i386/x86-64-property-5.d: Likewise. * testsuite/gas/i386/x86-64-property-6.d: Likewise. * testsuite/gas/i386/x86-64-property-11.d: Likewise. * testsuite/gas/i386/x86-64-property-12.d: Likewise. include/ PR gas/26703 * elf/common.h (GNU_PROPERTY_X86_ISA_1_BASELINE): New. (GNU_PROPERTY_X86_ISA_1_V2): Uppdated. (GNU_PROPERTY_X86_ISA_1_V3): Likewise. (GNU_PROPERTY_X86_ISA_1_V4): Likewise. ld/ PR gas/26703 * NEWS: Mention -z x86-64-baseline. * ld.texi: Document -z x86-64-baseline. * emulparams/x86-64-level.sh: Handle -z x86-64-baseline. * testsuite/ld-elf/x86-feature-1a.rd: Update. * testsuite/ld-elf/x86-feature-1b.rd: Likewise. * testsuite/ld-elf/x86-feature-1c.rd: Likewise. * testsuite/ld-elf/x86-feature-1d.rd: Likewise. * testsuite/ld-elf/x86-feature-1e.rd: Likewise. * testsuite/ld-i386/pr23372c.d: Likewise. * testsuite/ld-i386/pr23486c.d: Likewise. * testsuite/ld-i386/pr23486d.d: Likewise. * testsuite/ld-i386/pr24322a.d: Likewise. * testsuite/ld-i386/pr24322b.d: Likewise. * testsuite/ld-i386/property-1a.r: Likewise. * testsuite/ld-i386/property-2a.r: Likewise. * testsuite/ld-i386/property-3.r: Likewise. * testsuite/ld-i386/property-3a.r: Likewise. * testsuite/ld-i386/property-4.r: Likewise. * testsuite/ld-i386/property-4a.r: Likewise. * testsuite/ld-i386/property-5.r: Likewise. * testsuite/ld-i386/property-5a.r: Likewise. * testsuite/ld-i386/property-7a.r: Likewise. * testsuite/ld-i386/property-x86-3.d: Likewise. * testsuite/ld-i386/property-x86-4a.d: Likewise. * testsuite/ld-i386/property-x86-5.d: Likewise. * testsuite/ld-i386/property-x86-cet1.d: Likewise. * testsuite/ld-i386/property-x86-cet2a.d: Likewise. * testsuite/ld-i386/property-x86-cet5a.d: Likewise. * testsuite/ld-i386/property-x86-cet5b.d: Likewise. * testsuite/ld-i386/property-x86-ibt1a.d: Likewise. * testsuite/ld-i386/property-x86-ibt1b.d: Likewise. * testsuite/ld-i386/property-x86-ibt2.d: Likewise. * testsuite/ld-i386/property-x86-ibt3a.d: Likewise. * testsuite/ld-i386/property-x86-ibt3b.d: Likewise. * testsuite/ld-i386/property-x86-ibt4.d: Likewise. * testsuite/ld-i386/property-x86-ibt5.d: Likewise. * testsuite/ld-i386/property-x86-isa1.d: Likewise. * testsuite/ld-i386/property-x86-isa2.d: Likewise. * testsuite/ld-i386/property-x86-isa3.d: Likewise. * testsuite/ld-i386/property-x86-shstk1a.d: Likewise. * testsuite/ld-i386/property-x86-shstk1b.d: Likewise. * testsuite/ld-i386/property-x86-shstk2.d: Likewise. * testsuite/ld-i386/property-x86-shstk3a.d: Likewise. * testsuite/ld-i386/property-x86-shstk3b.d: Likewise. * testsuite/ld-i386/property-x86-shstk4.d: Likewise. * testsuite/ld-i386/property-x86-shstk5.d: Likewise. * testsuite/ld-x86-64/pr23372c-x32.d: Likewise. * testsuite/ld-x86-64/pr23372c.d: Likewise. * testsuite/ld-x86-64/pr23486c-x32.d: Likewise. * testsuite/ld-x86-64/pr23486c.d: Likewise. * testsuite/ld-x86-64/pr23486d-x32.d: Likewise. * testsuite/ld-x86-64/pr23486d.d: Likewise. * testsuite/ld-x86-64/pr24322a-x32.d: Likewise. * testsuite/ld-x86-64/pr24322a.d: Likewise. * testsuite/ld-x86-64/pr24322b-x32.d: Likewise. * testsuite/ld-x86-64/pr24322b.d: Likewise. * testsuite/ld-x86-64/pr24458a-x32.d: Likewise. * testsuite/ld-x86-64/pr24458a.d: Likewise. * testsuite/ld-x86-64/pr24458b-x32.d: Likewise. * testsuite/ld-x86-64/pr24458b.d: Likewise. * testsuite/ld-x86-64/pr24458c-x32.d: Likewise. * testsuite/ld-x86-64/pr24458c.d: Likewise. * testsuite/ld-x86-64/property-1a.r: Likewise. * testsuite/ld-x86-64/property-2a.r: Likewise. * testsuite/ld-x86-64/property-3.r: Likewise. * testsuite/ld-x86-64/property-3a.r: Likewise. * testsuite/ld-x86-64/property-4.r: Likewise. * testsuite/ld-x86-64/property-4a.r: Likewise. * testsuite/ld-x86-64/property-5.r: Likewise. * testsuite/ld-x86-64/property-5a.r: Likewise. * testsuite/ld-x86-64/property-7a.r: Likewise. * testsuite/ld-x86-64/property-x86-3-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-3.d: Likewise. * testsuite/ld-x86-64/property-x86-4a-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-4a.d: Likewise. * testsuite/ld-x86-64/property-x86-5-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-5.d: Likewise. * testsuite/ld-x86-64/property-x86-cet1-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-cet1.d: Likewise. * testsuite/ld-x86-64/property-x86-cet2a-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-cet2a.d: Likewise. * testsuite/ld-x86-64/property-x86-cet5a-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-cet5a.d: Likewise. * testsuite/ld-x86-64/property-x86-cet5b-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-cet5b.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt1a-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt1a.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt1b-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt1b.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt2-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt2.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt3a-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt3a.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt3b-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt3b.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt4-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt4.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt5-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-isa1-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-isa1.d: Likewise. * testsuite/ld-x86-64/property-x86-isa2-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-isa2.d: Likewise. * testsuite/ld-x86-64/property-x86-isa3-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-isa3.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt5.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk1a-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk1a.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk1b-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk1b.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk2-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk2.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk3a-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk3a.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk3b-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk3b.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk4-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk4.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk5-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk5.d: Likewise. * testsuite/ld-i386/i386.exp: Run property-x86-isa4. * testsuite/ld-i386/property-x86-isa4.d: New file. * testsuite/ld-x86-64/property-x86-isa4-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-isa4.d: Likewise. * ld/testsuite/ld-x86-64/x86-64.exp: Run property-x86-isa4 and property-x86-isa4-x32.
2020-10-26ld: Pass -fno-lto in ld-elfweak/elfweak.expH.J. Lu2-5/+14
* testsuite/ld-elfweak/elfweak.exp: Pass $NOLTO_CFLAGS to CC.
2020-10-26Invoke the linker's error handling script with the keyword ↵Nick Clifton3-4/+11
"undefined-symbol" when using it to help with undefined symbol errors. PR 26626 * ldmain.c (undefined_symbol): Use the keyword undefined-symbol when invoking the error handling script for undefined symbols. * ld.texi: Update documentation.
2020-10-26CSKY: Change default linker script for elf toolchain.Cooper Qu5-14/+76
ld/ * emulparams/cskyelf.sh (TEXT_START_ADDR): Change to 0x60000000. (DATA_ADDR) : Define. (OTHER_SYMBOLS) : Define. (OTHER_BSS_SYMBOLS) : Set symbol __sbss__. (OTHER_BSS_END_SYMBOLS) : Set symbol __ebss__. * ld/emulparams/cskyelf_linux.sh : Don't include cskyelf.sh. * testsuite/ld-csky/data.d : Fix '/s*' to match spaces. * testsuite/ld-csky/hilo16.d : Likewise. Change-Id: Ia29b32eab4157ae5be0fc0b6125fb5b7d9dac939