summaryrefslogtreecommitdiff
path: root/ld/testsuite
AgeCommit message (Collapse)Author
2023-06-05ELF: Add "#pass" to ld-elf/pr30508.dH.J. Lu
Add "#pass" to ld-elf/pr30508.d to allow extra segments. PR binutils/30508 * testsuite/ld-elf/pr30508.d: Add "#pass".
2023-06-05ELF: Don't warn an empty PT_LOAD with the program headersH.J. Lu
When rewriting the program headers, don't warn an empty PT_LOAD with the program headers. bfd/ PR binutils/30508 * elf.c (rewrite_elf_program_header): Don't warn if an empty PT_LOAD contains the program headers. ld/ PR binutils/30508 * testsuite/ld-elf/pr30508.d: New file. * testsuite/ld-elf/pr30508.s: Likewise.
2023-06-05MIPS: fix some ld testcases with compilerYunQiang Su
1. config/default.exp: use -mabi=32 not for -gnuabi64 xfail_from_runlist: remove an element and mark it xfail. 2. ld-elf/indirect.exp: xfail indirect5a indirect5b indirect6a indirect6b indirect5c indirect5d indirect6c indirect6d 3. ld-elf/pr23658-2: mips output is not common 4. ld-elf/shared.exp: non-run on mips: Build libpr16496b.so 5. ld-elfvers/vers.exp: xfail vers4, vers4b no-run on mips: vers24a, vers24b, vers24c 6. ld-gc/gc.exp: add -KPIC into asflags for pr13683, pr14265, pr19161 7. ld-mips-elf/mips-elf.exp: use noarch for mips16-local-stubs-1, since it use -mips4 8. ld-plugin/lto.exp: no-run on mips/linux: PR ld/12982 add -KPIC into asflags for lto-3r, lto-5r, PR ld/19317 (2) xfail PR ld/15323 (4), PR ld/19317 (3) 9. ld-plugin/plugin.exp: xfail plugin claimfile lost symbol plugin claimfile replace symbol plugin claimfile replace symbol plugin claimfile lost symbol with source plugin claimfile replace symbol with source plugin claimfile resolve symbol with source plugin 2 with source lib load plugin 2 with source plugin 3 with source lib load plugin 3 with source 11. ld-selective/selective.exp: add -fno-PIC, which is needed for -mno-abicalls 12. ld-shared/shared.exp: xfail shared (non PIC), shared (PIC main, non PIC so)
2023-06-05MIPS: fix -gnuabi64 testsuiteYunQiang Su
Test on: mips64-linux-gnuabi64 mips64el-linux-gnuabi64 mipsisa64-linux-gnuabi64 mipsisa64el-linux-gnuabi64 mipsisa64r2-linux-gnuabi64 mipsisa64r2el-linux-gnuabi64 mipsisa64r6-linux-gnuabi64 mipsisa64r6el-linux-gnuabi64
2023-06-05MIPS: fix r6 testsuitesYunQiang Su
Introduce run_dump_test_o32l run_dump_test_n32l run_dump_test_n64l Which use `-march=from-abi` for pre-R6 testcases, like micromips/mips16e etc. For cases doesn't use run_dump_test_*, we use -mips32r2 for micromips32 -mips1 for mips16-32 -march=from-abi for testcases to o32/n32/n64 both/all. Replace `addi` with `addiu` for some cases for both r6 and pre-R6. Introduce some new testcases for r6 with FPXX/FP64. Introduce new testcase: comdat-reloc-r6. Skip `default` in mips_arch_list_matching if triple is mipsisa*, due to: 1)it will cannot match mipsr6@*.d: since mips32rN/mips64rN will always be used, it won't be a problem. 2)some test think -march=mips64rN will alway true for mipsisa64rN, which is not true now. This patch fix testsuite for all r6-default gnu triples: mipsisa32r6-linux-gnu mipsisa32r6el-linux-gnu mips-img-linux-gnu mipsel-img-linux-gnu mipsisa64r6-linux-gnu mipsisa64r6el-linux-gnu
2023-05-30LoongArch: ld: Add support for linker relaxation.mengqinggang
Add ld relax support and testsuits. ld/ChangeLog: * emultempl/loongarchelf.em: Regenerated. * testsuite/ld-elf/compressed1d.d: Xfail loongarch*-*. * testsuite/ld-elf/pr26936.d: Likewise. * testsuite/ld-loongarch-elf/disas-jirl.d: Regenerated. * testsuite/ld-loongarch-elf/disas-jirl-32.d: Regenerated. * testsuite/ld-loongarch-elf/jmp_op.d: Likewise. * testsuite/ld-loongarch-elf/macro_op.d: Likewise. * testsuite/ld-loongarch-elf/macro_op_32.d: Likewise. * testsuite/ld-loongarch-elf/relax-align.dd: New test. * testsuite/ld-loongarch-elf/relax-align.s: New test. * testsuite/ld-loongarch-elf/relax.exp: New test. * testsuite/ld-loongarch-elf/relax.s: New test. * testsuite/ld-loongarch-elf/uleb128.dd: New test. * testsuite/ld-loongarch-elf/uleb128.s: New test.
2023-05-26PR22263 ld testAlan Modra
A number of targets that I test regularly fail the "Build pr22263-1" test for various reasons. arm-linux-gnueabi: "undefined reference to `__aeabi_read_tp'" ia64-linux-gnu: "Explicit stops are ignored in auto mode" m68k-linux-gnu: "undefined reference to `__m68k_read_tp'" microblaze-linux-gnu: "undefined reference to `__tls_get_addr'" nios2-linux-gnu, s390-linux-gnu and sh4-linux-gnu have a tprel reloc in .got riscv64-linux-gnu has a dynamic relocation in text So only riscv really fails the pr. The rest fail due to test issues or lack of a linker optimisation. Lack of an optimisation isn't really a fail, but it's worth keeping the test to ensure those optimisations don't regress. The xfail targets may not be an exhaustive list. This just tidies test results for those for which I have cross compilers installed. PR 22263 * testsuite/ld-elf/tls.exp: Split pr22263 test into two parts, one to check for -z text errors, the other to check tprel linker optimisation. Supply needed symbols and assembler flags. xfail the linker optimisation on targets known to fail.
2023-05-24Remove accidentally added fileAndreas Schwab
2023-05-23PR30437 aarch64: make RELA relocs idempotentMichael Matz
normally RELA relocs in BFD should not consider the contents of the relocated place. The aarch64 psABI is even stricter, it specifies (section 5.7.16) that all RELA relocs _must_ be idempotent. Since the inception of the aarch64 BFD backend all the relocs have a non-zero src_mask, and hence break this invariant. It's normally not a very visible problem as one can see it only when the relocated place already contains a non-zero value, which usually only happens sometimes when using 'ld -r' (or as in the testcase when jumping through hoops to generate the relocations). Or with alternative toolchains that do encode stuff in the relocated places with the assumption that a relocation to that place ignores whatever is there (as they can according to the psABI). Golang is such a toolchain and https://github.com/golang/go/issues/39927 is ultimately caused by this problem: the testcase testGCData failing is caused by the garbage collection data-structure to describe a type containing pointers to be wrong. It's wrong because a field that's supposed to contain a file-relative offset (to some gcbits) has a relocation applied and that relocation has an addend which also is already part of the go-produced object file (so the addend is implicitely applied twice). bfd/ PR ld/30437 * elfnn-aarch64.c (elfNN_aarch64_howto_table): Clear src_mask if all relocation descriptors. ld/ * testsuite/ld-aarch64/rela-idempotent.s: New testcase. * testsuite/ld-aarch64/rela-idempotent.d: New. * testsuite/ld-aarch64/aarch64-elf.exp: Run it.
2023-05-19RISC-V: Support subtraction of .uleb128.Kuan-Lin Chen
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/commit/96d6e190e9fc04a8517f9ff7fb9aed3e9876cbd6 There are some known limitations for now, * Do not shrink the length of the uleb128 value, even if the value is reduced after relaxations. Also reports error if the length grows up. * The R_RISCV_SET_ULEB128 needs to be paired with and be placed before the R_RISCV_SUB_ULEB128. bfd/ * bfd-in2.h: Regenerated. * elfnn-riscv.c (perform_relocation): Perform R_RISCV_SUB_ULEB128 and R_RISCV_SET_ULEB128 relocations. Do not shrink the length of the uleb128 value, and report error if the length grows up. Called the generic functions, _bfd_read_unsigned_leb128 and _bfd_write_unsigned_leb128, to encode the uleb128 into the section contents. (riscv_elf_relocate_section): Make sure that the R_RISCV_SET_ULEB128 must be paired with and be placed before the R_RISCV_SUB_ULEB128. * elfxx-riscv.c (howto_table): Added R_RISCV_SUB_ULEB128 and R_RISCV_SET_ULEB128. (riscv_reloc_map): Likewise. (riscv_elf_ignore_reloc): New function. * libbfd.h: Regenerated. * reloc.c (BFD_RELOC_RISCV_SET_ULEB128, BFD_RELOC_RISCV_SUB_ULEB128): New relocations to support .uleb128 subtraction. gas/ * config/tc-riscv.c (md_apply_fix): Added BFD_RELOC_RISCV_SET_ULEB128 and BFD_RELOC_RISCV_SUB_ULEB128. (s_riscv_leb128): Updated to allow uleb128 subtraction. (riscv_insert_uleb128_fixes): New function, scan uleb128 subtraction expressions and insert fixups for them. (riscv_md_finish): Called riscv_insert_uleb128_fixes for all sections. include/ * elf/riscv.h ((R_RISCV_SET_ULEB128, (R_RISCV_SUB_ULEB128): Defined. ld/ * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated. * testsuite/ld-riscv-elf/uleb128*: New testcase for uleb128 subtraction. binutils/ * testsuite/binutils-all/nm.exp: Updated since RISCV supports .uleb128.
2023-05-15LoongArch: Fix PLT entry generate bugmengqinggang
If a function symbol only get its address by la.global, without directly called by bl instruction, the PLT entry is not required. bfd/ChangeLog: * elfnn-loongarch.c (loongarch_elf_adjust_dynamic_symbol): Fix PLT entry generate bug. ld/ChangeLog: * testsuite/ld-elf/shared.exp: Clear xfail for LoongArch.
2023-05-11Add LDPT_REGISTER_CLAIM_FILE_HOOK_V2 linker plugin hook [GCC PR109128]Joseph Myers
This is one part of the fix for GCC PR109128, along with a corresponding GCC change. Without this patch, what happens in the linker, when an unused object in a .a file has offload data, is that elf_link_is_defined_archive_symbol calls bfd_link_plugin_object_p, which ends up calling the plugin's claim_file_handler, which then records the object as one with offload data. That is, the linker never decides to use the object in the first place, but use of this _p interface (called as part of trying to decide whether to use the object) results in the plugin deciding to use its offload data (and a consequent mismatch in the offload data present at runtime). The new hook allows the linker plugin to distinguish calls to claim_file_handler that know the object is being used by the linker (from ldmain.c:add_archive_element), from calls that don't know it's being used by the linker (from elf_link_is_defined_archive_symbol); in the latter case, the plugin should avoid recording the object as one with offload data. bfd/ * plugin.c (struct plugin_list_entry): Add claim_file_v2. (register_claim_file_v2): New. (try_load_plugin): Use LDPT_REGISTER_CLAIM_FILE_HOOK_V2. (ld_plugin_object_p): Take second argument. (bfd_link_plugin_object_p): Update call to ld_plugin_object_p. (register_ld_plugin_object_p): Update argument prototype. (bfd_plugin_object_p): Update call to ld_plugin_object_p. * plugin.h (register_ld_plugin_object_p): Update argument prototype. include/ * plugin.api.h (ld_plugin_claim_file_handler_v2) (ld_plugin_register_claim_file_v2) (LDPT_REGISTER_CLAIM_FILE_HOOK_V2): New. (struct ld_plugin_tv): Add tv_register_claim_file_v2. ld/ * plugin.c (struct plugin): Add claim_file_handler_v2. (LDPT_REGISTER_CLAIM_FILE_HOOK_V2): New. (plugin_object_p): Add second argument. Update call to plugin_call_claim_file. (register_claim_file_v2): New. (set_tv_header): Handle LDPT_REGISTER_CLAIM_FILE_HOOK_V2. (plugin_call_claim_file): Add argument known_used. (plugin_maybe_claim): Update call to plugin_object_p. * testplug.c, testplug2.c, testplug3.c, testplug4.c: Handle LDPT_REGISTER_CLAIM_FILE_HOOK_V2. * testsuite/ld-plugin/plugin-1.d, testsuite/ld-plugin/plugin-10.d, testsuite/ld-plugin/plugin-11.d, testsuite/ld-plugin/plugin-13.d, testsuite/ld-plugin/plugin-14.d, testsuite/ld-plugin/plugin-15.d, testsuite/ld-plugin/plugin-16.d, testsuite/ld-plugin/plugin-17.d, testsuite/ld-plugin/plugin-18.d, testsuite/ld-plugin/plugin-19.d, testsuite/ld-plugin/plugin-2.d, testsuite/ld-plugin/plugin-26.d, testsuite/ld-plugin/plugin-3.d, testsuite/ld-plugin/plugin-30.d, testsuite/ld-plugin/plugin-4.d, testsuite/ld-plugin/plugin-5.d, testsuite/ld-plugin/plugin-6.d, testsuite/ld-plugin/plugin-7.d, testsuite/ld-plugin/plugin-8.d, testsuite/ld-plugin/plugin-9.d: Update test expectations.
2023-05-10Add linker option to include local symbols in the linker map.Nick Clifton
PR 16566 * ldlang.c (ld_is_local_symbol): New function. (print_input_section): Add code to display local symbols in the section. * ldlex.h (enum option_values): Add OPTION_PRINT_MAP_LOCALS and OPTION_PRINT_MAP_LOCALS. * lexsup.c (ld_options[]): Add entries for --print-map-locals and --no-print-map-locals. * NEWS: Mention the new feature. * ld.h (struct ld_config_type): Add print_map_locals field. * ld.texi: Document the new command line option. * testsuite/ld-scripts/sizeof.s: Add a local symbol. * testsuite/ld-scripts/map-locals.d: New test control file. * testsuite/ld-scripts/map-address.exp: Run the new test.
2023-04-28ld: Use run_cc_link_tests for PR ld/26391 testsH.J. Lu
Use run_cc_link_tests for PR ld/26391 tests to compile PR ld/26391 tests in C. PR ld/30002 * testsuite/ld-elf/elf.exp: Use run_cc_link_tests for PR ld/26391 tests.
2023-04-23LoongArch: Fix loongarch32 test failsmengqinggang
Regenerated macro_op_32.d and add skip loongarch64-*-*. gas/ChangeLog: * testsuite/gas/loongarch/macro_op_32.d: Regenerated. ld/ChangeLog: * testsuite/ld-loongarch-elf/macro_op_32.d: Regenerated.
2023-04-21RISC-V: Optimize relaxation of gp with max_alignment.Lifang Xia
This should be the first related issue, which posted in riscv-gnu-toolchain, https://github.com/riscv-collab/riscv-gnu-toolchain/issues/497 If the output sections are not between gp and the symbol, then their alignments shouldn't affect the gp relaxation. However, this patch improves this idea even more, it limits the range to the gp+-2k, which means only the output section which are in the [gp-2K, gp+2K) range need to be considered. Even if the output section candidates may be different for each relax passes, the symbol that can be relaxed ar this round will not be truncated at next round. That is because this round you can do relaxation which means that the section where the symbol is located is within the [gp-2K, gp+2K) range, so all the output section alignments between them should be considered. In other words, if the alignments between them may cause truncated, then we should already preserve the size and won't do the gp relaxation this time. This patch can resolve the github issue which mentioned above, and also passed all gcc/binutils regressions of riscv-gnu-toolchain, so should be worth and safe enough to commit. Originally, this patch also do the same optimization for the call relaxations, https://sourceware.org/pipermail/binutils/2022-October/123918.html But just in case there is something that has not been considered, we only deal with the gp relaxation at this time. bfd/ * elfnn-riscv.c (riscv_elf_link_hash_table): Added new bfd_vma, max_alignment_for_gp. It is used to record the maximum alignment of the output sections, which are in the [gp-2K, gp+2k) range. (riscv_elf_link_hash_table_create): Init max_alignment_for_gp to -1. (_bfd_riscv_get_max_alignment): Added new parameter, gp. If gp is zero, then all the output section alignments are possible candidates; Otherwise, only the output sections which are in the [gp-2K, gp+2K) range need to be considered. (_bfd_riscv_relax_lui): Called _bfd_riscv_get_max_alignment with the non-zero gp if the max_alignment_for_gp is -1. (_bfd_riscv_relax_pc): Likewise. (_bfd_riscv_relax_section): Record the first input section, so that we can reset the max_alignment_for_gp for each repeated relax passes. ld/ * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated. * testsuite/ld-riscv-elf/relax-max-align-gp.*: New testcase. It fails without this patch.
2023-04-18Symbols with GOT relocatios do not fix adjustbalemengqinggang
gas * config/tc-loongarch.c (loongarch_fix_adjustable): Symbols with GOT relocatios do not fix adjustbale. * testsuite/gas/loongarch/macro_op_large_abs.d: Regenerated. * testsuite/gas/loongarch/macro_op_large_pc.d: Regenerated. ld * testsuite/ld-loongarch-elf/macro_op.d: Regenerated. -
2023-04-13arc: Update ARC specific linker tests.Claudiu Zissulescu
All the tests are designed for a little-endian ARC system. Thus, update the arc predicate in arc.exp, improve the matching pattern for linker relaxation test, and add linker scripts to nps-1x tests. Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
2023-03-31lto: Don't add indirect symbols for versioned aliases in IRH.J. Lu
Linker adds indirect symbols for versioned symbol aliases, which are created by ".symver foo, foo@FOO", by checking symbol type, value and section so that references to foo will be replaced by references to foo@FOO if foo and foo@FOO have the same symbol type, value and section. But in IR, since all symbols of the same type have the same value and section, we can't tell if a symbol is an alias of another symbol by their types, values and sections. We shouldn't add indirect symbols for versioned symbol aliases in IR. bfd/ PR ld/30281 * elflink.c (elf_link_add_object_symbols): Don't add indirect symbols for ".symver foo, foo@FOO" aliases in IR. ld/ PR ld/30281 * testsuite/ld-plugin/lto.exp: Add PR ld/30281 test. * testsuite/ld-plugin/pr30281.t: New file. * testsuite/ld-plugin/pr30281.c: Likewise.
2023-03-30RISC-V: PR28789, Reject R_RISCV_PCREL relocations with ABS symbol in PIC/PIE.Palmer Dabbelt
The non-preemptible SHN_ABS symbol with a pc-relative relocation should be disallowed when generating shared object (pic and pie). Generally, the following cases, which refer to pr25749, will cause a symbol be non-preemptible, * -pie, or -shared with -symbolic * STV_HIDDEN, STV_INTERNAL, STV_PROTECTED * Have dynamic symbol table, but without the symbol * VER_NDX_LOCAL However, PCREL_HI20/LO12 relocs are always bind locally when generating shared object, so not only the non-preemptible absolute symbol need to be disallowed, all absolute symbol references need but except that they are defined in linker script. If we also disallow the absolute symbol in linker script, then the glibc-linux toolchain build failed, so regard them as pc-relative symbols, just like what x86 did. Maybe we should add this check for all pc-relative relocations, rather than just handle in R_RISCV_PCREL relocs. Ideally, since the value of SHN_ABS symbol is a constant, only S - A relocations should be allowed in the shared object, so only BFD_RELOC_8/16/32/64 are allowed, which means R_RISCV_32/R_RISCV_64. bfd/ PR 28789 * elfnn-riscv.c (riscv_elf_check_relocs): The absolute symbol cannot be referneced with pc-relative relocation when generating shared object. ld/ PR 28789 * ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated. * ld/testsuite/ld-riscv-elf/pcrel-reloc*: New testcases.
2023-03-30RISC-V: Clarify link behaviors of R_RISCV_32/64 relocations with ABS symbol.Nelson Chu
There are two improvements, which are all referenced to aarch64, * R_RISCV_32 with non ABS symbol cannot be used under RV64 when making shard objects. * Don't need dynamic relocation for R_RISCV_32/64 under RV32/RV64 when making shared objects, if the referenced symbol is local ABS symbol. However, considering this link, https://github.com/riscv-non-isa/riscv-elf-psabi-doc/issues/341 Seems like we should makes all R_RISCV_32/64 relocs with ABS symbol that don't need any dynamic relocations when making the shared objects. But anyway, I just sync the current behavior as aarch64 ld, in case there are any unexpected behaviors happen. Passed the gcc/binutils regressions in riscv-gnu-toolchain. bfd/ * elfnn-riscv.c (riscv_elf_check_relocs): Only allow R_RISCV_32 with ABS symbol under RV64. (riscv_elf_relocate_section): R_RISCV_32/64 with local ABS symbol under RV32/RV64 doesn't need any dynamic relocation when making shared objects. I just make the implementations similar to other targets, so that will be more easy to mainatain. ld/ * testsuite/ld-riscv-elf/data-reloc*: New testcases. * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Added new data-reloc* testcases, and need to make ifunc-seperate* testcases work for rv32. * testsuite/ld-riscv-elf/ifunc-seperate-caller-nonplt.s: Likewise. * testsuite/ld-riscv-elf/ifunc-seperate-caller-plt.s: Likewise.
2023-03-29ld testsuite CFLAGS_FOR_TARGETAlan Modra
run_host_cmd adds $gcc_B_opt and $ld_L_opt to the command line if it detects the program being run is a compiler. Since the program being run in lto.exp linking pr28138 is "sh", we need to add these by hand. This isn't exactly as run_host_cmd does, as it lacks reordering of any user -B option in $CC_FOR_TARGET, but it's better than ignoring gcc_B_opt. This fixes a mips64 testsuite fail. ld_compile adds CFLAGS_FOR_TARGET and other flags as well, so there is no need for the ld_compile command line to include CFLAGS_FOR_TARGET. Fixing this is just a tidy. * testsuite/ld-plugin/lto.exp: Add gcc_B_opt, CFLAGS_FOR_TARGET and $ld_L_opt to pr28138 link line. * testsuite/lib/ld-lib.exp (run_ld_link_tests): Don't pass unnecessary flags to ld_compile. (run_ld_link_exec_tests, run_cc_link_tests): Likewise.
2023-03-23bfd: aarch64: Optimize BTI stubs PR30076Szabolcs Nagy
Don't insert a second stub if the target is already compatible with an indirect branch.
2023-03-23bfd: aarch64: Fix stubs that may break BTI PR30076Szabolcs Nagy
Insert two stubs in a BTI enabled binary when fixing long calls: The first is near the call site and uses an indirect jump like before, but it targets the second stub that is near the call target site and uses a direct jump. This is needed when a single stub breaks BTI compatibility. The stub layout is kept fixed between sizing and building the stubs, so the location of the second stub is known at build time, this may introduce padding between stubs when those are relaxed. Stub layout with BTI disabled is unchanged.
2023-03-20Changed ld and gas BPF testsCupertino Miranda
Recent BPF patch removed and renamed the list of relocations based on the limitations of BPF instruction set. This patch is a correction to the tests.
2023-03-16Re: Add --enable-linker-version optionChristophe Lyon
The recently-added ld-version*.d tests expect .*GNU ld \(GNU Binutils\) 2.* in the .comment section. However, when buidling --with-pkgversion=XXX, we get GNU ld (XXX) 2.[...] instead, leading to a spurious FAIL. This small patch replaces "GNU Binutils" with ".*" instead. I inspected other testcases to see if we already had similar occurrences but I couldn't see any, so I hope this fix is OK for the purpose? Thanks, Christophe
2023-03-16ld/testsuite: disable ilp32 tests for aarch64-qnxClément Chigot
aarch64nto32 emulation isn't supported. The tests will then fall back on aarch64elf32. It does work but some extra warnings are being generated because the "-z relro" being added aarch64nto but ignored by aarch64elf32 emulation. Skip the tests to avoid any problems. ld/ChangeLog: * testsuite/ld-aarch64/emit-relocs-112-overflow.d: Skip for aarch64nto. * testsuite/ld-aarch64/emit-relocs-112.d: Likewise. * testsuite/ld-aarch64/emit-relocs-113.d: Likewise. * testsuite/ld-aarch64/emit-relocs-114-overflow.d: Likewise. * testsuite/ld-aarch64/emit-relocs-114.d: Likewise. * testsuite/ld-aarch64/emit-relocs-115.d: Likewise. * testsuite/ld-aarch64/emit-relocs-116-overflow.d: Likewise. * testsuite/ld-aarch64/emit-relocs-116.d: Likewise. * testsuite/ld-aarch64/emit-relocs-117.d: Likewise. * testsuite/ld-aarch64/emit-relocs-118-overflow.d: Likewise. * testsuite/ld-aarch64/emit-relocs-118.d: Likewise. * testsuite/ld-aarch64/emit-relocs-119.d: Likewise. * testsuite/ld-aarch64/emit-relocs-22.d: Likewise. * testsuite/ld-aarch64/emit-relocs-23.d: Likewise. * testsuite/ld-aarch64/emit-relocs-28.d: Likewise. * testsuite/ld-aarch64/emit-relocs-86-overflow.d: Likewise. * testsuite/ld-aarch64/emit-relocs-86.d: Likewise. * testsuite/ld-aarch64/emit-relocs-87.d: Likewise. * testsuite/ld-aarch64/emit-relocs-88-overflow.d: Likewise. * testsuite/ld-aarch64/emit-relocs-88.d: Likewise. * testsuite/ld-aarch64/emit-relocs-89.d: Likewise. * testsuite/ld-aarch64/emit-relocs-90-overflow.d: Likewise. * testsuite/ld-aarch64/emit-relocs-90.d: Likewise. * testsuite/ld-aarch64/emit-relocs-92.d: Likewise. * testsuite/ld-aarch64/tls-desc-ie-ilp32.d: Likewise. * testsuite/ld-aarch64/tls-relax-all-ilp32.d: Likewise. * testsuite/ld-aarch64/tls-relax-gd-ie-ilp32.d: Likewise. * testsuite/ld-aarch64/tls-relax-gd-le-ilp32.d: Likewise. * testsuite/ld-aarch64/tls-relax-gdesc-le-2-ilp32.d: Likewise. * testsuite/ld-aarch64/tls-relax-gdesc-le-ilp32.d: Likewise. * testsuite/ld-aarch64/tls-relax-ie-le-2-ilp32.d: Likewise. * testsuite/ld-aarch64/tls-relax-ie-le-3-ilp32.d: Likewise. * testsuite/ld-aarch64/tls-relax-ie-le-ilp32.d: Likewise. * testsuite/ld-aarch64/tls-relax-ld-le-small-ilp32.d: Likewise. * testsuite/ld-aarch64/tls-relax-ld-le-tiny-ilp32.d: Likewise. * testsuite/ld-aarch64/tls-tiny-desc-ie-ilp32.d: Likewise. * testsuite/ld-aarch64/tls-tiny-desc-le-ilp32.d: Likewise. * testsuite/ld-aarch64/tls-tiny-gd-ie-ilp32.d: Likewise. * testsuite/ld-aarch64/tls-tiny-gd-le-ilp32.d: Likewise.
2023-03-16ld/testsuite: add aarch64nto to ld-aarch64Clément Chigot
ld/ChangeLog: * testsuite/ld-aarch64/aarch64-elf.exp: Add support for aarch64nto.
2023-03-16ld: add support of QNX stack arguments for aarch64ntoClément Chigot
QNX is handling the stack argument using a .note section. Generate it according to ELF argument -zexecstack, -zstack-size and a new NTO argument --lazy-stack. Another NTO argument --stack mimicking -zstack-size is added in order to ensure compatibility with previously made NTO linkers. This requires a new emultempl nto.em which is applied above the default ${ARCH}elf.em. ld/ChangeLog: * emulparams/aarch64nto.sh: Move to nto.em. * emultempl/nto.em: New file. * testsuite/ld-aarch64/aarch64-nto.exp: New test. * testsuite/ld-aarch64/nto-stack-note-1.d: New test. * testsuite/ld-aarch64/nto-stack-note-2.d: New test. * testsuite/ld-aarch64/start.s: New test.
2023-03-16Re: Add --enable-linker-verssionAlan Modra
Output sections without any input sections to initialise their flags have their flags initialised by data statements to LOAD, ALLOC, HAS_CONTENTS by default. This is wrong for .comment. Fix that by making the script initialise the section type to INFO, one of the noalloc section types. That also allows the address of .comment to be set to zero, as is usual for non-alloc sections. Also, use source_sh for all of the sourced scripts to set up make dependencies. PR 30187 * scripttempl/misc-sections.sc: Set .comment address to zero and type to INFO. * scripttempl/ft32.sc: Fix breakages from last edit. * scripttempl/arclinux.sc: Use source_sh to source DWARF.sc and misc-sections.sc. * scripttempl/avr.sc: Likewise. * scripttempl/dlx.sc: Likewise. * scripttempl/elf.sc: Likewise. * scripttempl/elf32cr16.sc: Likewise. * scripttempl/elf32crx.sc: Likewise. * scripttempl/elf32msp430.sc: Likewise. * scripttempl/elf64bpf.sc: Likewise. * scripttempl/elf64hppa.sc: Likewise. * scripttempl/elf_chaos.sc: Likewise. * scripttempl/elfarc.sc: Likewise. * scripttempl/elfarcv2.sc: Likewise. * scripttempl/elfd10v.sc: Likewise. * scripttempl/elfd30v.sc: Likewise. * scripttempl/elfm68hc11.sc: Likewise. * scripttempl/elfm68hc12.sc: Likewise. * scripttempl/elfm9s12z.sc: Likewise. * scripttempl/elfmicroblaze.sc: Likewise. * scripttempl/elfxgate.sc: Likewise. * scripttempl/elfxtensa.sc: Likewise. * scripttempl/epiphany_4x4.sc: Likewise. * scripttempl/i386beos.sc: Likewise. * scripttempl/i386go32.sc: Likewise. * scripttempl/ia64vms.sc: Likewise. * scripttempl/ip2k.sc: Likewise. * scripttempl/iq2000.sc: Likewise. * scripttempl/mep.sc: Likewise. * scripttempl/mmo.sc: Likewise. * scripttempl/nds32elf.sc: Likewise. * scripttempl/pru.sc: Likewise. * scripttempl/v850.sc: Likewise. * scripttempl/v850_rh850.sc: Likewise. * scripttempl/visium.sc: Likewise. * scripttempl/xstormy16.sc: Likewise. * scripttempl/z80.sc: Likewise. * testsuite/ld-scripts/ld-version-2.d: Don't skip ft32 or pru.
2023-03-15Add --enable-linker-version option to bfd linker to add an entry in the ↵Nick Clifton
.comment section. PR 30187 * NEWS: Mention the new feature. * ld.texi: Document the new feature. * ldgram.y: Handle LINKER_VERSION token. * ldlang.c (lang_add_version): New function. (enable_linker_version): New global variable. * ldlang.h (land_add_version): Prototype. (enable_linker_version): Export. * ldlex.h (OPTION_ENABLE_LINKER_VERSION): Define. (OPTION_DISABLE_LINKER_VERSION): Define. * ldlex.l (LINKER_VERSION): Add token. * lexsup.c (ld_options): Add --enable-linker-version and --disable-linker-version. (parse_args): Handle the new options. * scripttempl/arclinux.sc: Remove stabs and comment sections and replace with inclusion of misc-sections.sc * scripttempl/avr.sc: Likewise. * scripttempl/dlx.sc: Likewise. * scripttempl/elf.sc: Likewise. * scripttempl/elf32cr16.sc: Likewise. * scripttempl/elf32crx.sc: Likewise. * scripttempl/elf32msp430.sc: Likewise. * scripttempl/elf64bpf.sc: Likewise. * scripttempl/elf64hppa.sc: Likewise. * scripttempl/elf_chaos.sc: Likewise. * scripttempl/elfarc.sc: Likewise. * scripttempl/elfarcv2.sc: Likewise. * scripttempl/elfd10v.sc: Likewise. * scripttempl/elfd30v.sc: Likewise. * scripttempl/elfm68hc11.sc: Likewise. * scripttempl/elfm68hc12.sc: Likewise. * scripttempl/elfm9s12z.sc: Likewise. * scripttempl/elfmicroblaze.sc: Likewise. * scripttempl/elfxgate.sc: Likewise. * scripttempl/elfxtensa.sc: Likewise. * scripttempl/epiphany_4x4.sc: Likewise. * scripttempl/ft32.sc: Likewise. * scripttempl/ip2k.sc: Likewise. * scripttempl/iq2000.sc: Likewise. * scripttempl/mep.sc: Likewise. * scripttempl/nds32elf.sc: Likewise. * scripttempl/pru.sc: Likewise. * scripttempl/v850.sc: Likewise. * scripttempl/v850_rh850.sc: Likewise. * scripttempl/visium.sc: Likewise. * scripttempl/xstormy16.sc: Likewise. * scripttempl/z80.sc: Likewise. * testsuite/ld-scripts/script.exp: Run new tests. * scripttempl/misc-sections.sc: New file. * testsuite/ld-scripts/ld-version-2.d: New file. * testsuite/ld-scripts/ld-version.d: New file. * testsuite/ld-scripts/ld-version.t: New file.
2023-03-10Revert ld ASCII supportAlan Modra
Revert "Prevent the ASCII linker script directive from generating huge amounts of padding if the size expression is not a constant." This reverts commit adbe951fc95943016325af08d677f18e8c177ac1. Revert "ld test asciz and ascii fails" This reverts the ascii.d part of commit 5f497256bee624f0fa470949aa41534093bc5b25. Revert "Add support for the ASCII directive inside linker scripts." This mostly reverts commit 9fe129a4105bb59398f73ce96938a94f19265b79 leaving the asciz.d and asciz.t changes in place.
2023-03-10Revert ld DIGEST supportAlan Modra
This is a hopefully temporary reversion of new ld features for embedded processors by Ulf Samuelsson, plus some followup patches. Squashed together from the following: Revert "lddigest 32-bit support and gcc-4 compile errors" This reverts commit d7ee19be87110a8f5342cec6e323d83d01c641d1. Revert "ld: Use correct types for crc64 calculations" This reverts commit 9a534b9f8e3d0f3cdb5a20f19ff165693fbb84d2. Revert "Re: DIGEST: testsuite" This reverts commit c8e85484d8a0fe9f7b88e00a6b9ae63bcb53ba32. Revert "Regen potfiles" This reverts commit 4d98c966f8bf305ab25badd34cb295631873cf7c. Revert "DIGEST: Makefile.*" This reverts commit 78ef6ab03f56ce83a606d974bb8a9f34b5d6e0b7. Revert "DIGEST: calculation" This reverts commit 5243990191e683d5066d3dd622c76deaba0bf15c. Revert "DIGEST: ldlang.*: add timestamp" This reverts commit bd9466d4aa277a469a9d8b12f0a6e6fa51678e36. Revert "DIGEST: ldmain.c" This reverts commit c8f8653fa7eeb3dc0769ac23039eadb5c5f09dff. Revert "DIGEST: ldgram.y" This reverts commit d73c01be2669e9c5267fab669a269f95a32048c9. Revert "DIGEST: ldlex.l" This reverts commit 48b5163a9dd5759cc87171331bbd6e902c547b5a. Revert "DIGEST: testsuite" This reverts commit a4135d1a4886400ea29af2da782dd8dd40ccad23. Revert "DIGEST: Documentation" This reverts commit 3ec28966c3e4c63704212778f96c517cbf2e0090. Revert "DIGEST: NEWS" This reverts commit 099bf2927d446424e8585a60cf4ce63209999aa2. Revert "DIGEST: LICENSING" This reverts commit 5c8a0c6654fb55926985edf3b360b62d4f20691d.
2023-03-09lddigest 32-bit support and gcc-4 compile errorsAlan Modra
* ld.texi: Revert 2023-03-08 commit 9a534b9f8e3d. * testsuite/ld-scripts/crc64-poly.d: Likewise. * testsuite/ld-scripts/crc64-poly.t: Likewise. * lddigest.c: Formatting. (get_uint64_t): New function. (lang_add_digest): Take etree_type* args. Replace "illegal" with "invalid" in error message. * lddigest.h (lang_add_digest): Update prototype. * lddigest_tab.c (algorithms): Work around gcc-4 errors. * ldgram.y (polynome): Adjust lang_add_digest call. * testsuite/ld-scripts/crc64-poly-size.d: Update expected error.
2023-03-08ld: Use correct types for crc64 calculationsNick Clifton
2023-03-08Re: DIGEST: testsuiteAlan Modra
Correct test target/skip lines to fix fails on alpha-dec-vms, alpha-linux-gnuecoff, i386-bsd, i386-msdos, ns32k-openbsd, ns32k-pc532-mach, pdp11-dec-aout, rs6000-aix*, tic4x-coff, and tic54x-coff.
2023-03-07DIGEST: testsuiteUlf Samuelsson
Signed-off-by: Ulf Samuelsson <ulf@emagii.com>
2023-02-28ld: Sort section contributions in PDB filesMark Harmstone
Microsoft's DIA library, and thus also MSVC and WinDbg, expects section contributions to be ordered by section number and offset, otherwise it's unable to resolve line numbers.
2023-02-24testsuite: prune DOS drive letter in test outputsClément Chigot
On DOS systems, absolute paths start with the drive letter. This can trigger failures in the regexp from dump tests, especially for those checking for warnings or errors. They are usually skipping everything before the first ":" as it has to be the file path. | [^:]*: warning: ... In order to avoid modifying many regexps to allow such drive letters, prune them from all the outputs if they are found at the beginning of a line. binutils/ChangeLog: * testsuite/lib/binutils-common.exp (prune_dump_output): New (run_dump_test): Use it. ld/ChangeLog: * testsuite/ld-elf/noinit-sections-2.l: Remove DOS drive letter handler.
2023-02-23RISC-V: Add --[no-]relax-gp to ldFangrui Song
--relax enables all relaxations. --no-relax-gp disables GP relaxation to allow measuring its effect. The option can test effectiveness of GP relaxation and support some ABI variants that use GP for other purposes. Link: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/issues/298 bfd/ * elfnn-riscv.c (struct riscv_elf_link_hash_table): Add params. (riscv_elfNN_set_options): New. (riscv_info_to_howto_rela): Check relax_gp. (_bfd_riscv_relax_section): Likewise. * elfxx-riscv.h (struct riscv_elf_params): New. (riscv_elf32_set_options): New. (riscv_elf64_set_options): New. ld/ * emultempl/riscvelf.em: Add option parsing. * testsuite/ld-riscv-elf/code-model-relax-medlow-01-norelaxgp.d: New. * testsuite/ld-riscv-elf/pcgp-relax-01-norelaxgp.d: New. * testsuite/ld-riscv-elf/pcgp-relax-02.d: Test --relax --relax-gp can be used together.
2023-02-23bfd: xtensa: fix __stop_SECTION literal dropAlexey Lapshin
2023-02-21ld/testsuite: don't output to /dev/nullClément Chigot
Mingw doesn't have /dev/null and thus "-o /dev/null" will fail. Currently, all the options are checked using this "-o /dev/null", resulting in them being disabled on mingw hosts. Fix that by outputting to a real file for all targets. ld/ChangeLog: * testsuite/config/default.exp: Replace "-o /dev/null" by a file.
2023-02-21Both FAIL and PASS "check sections 2"?Alan Modra
* testsuite/ld-checks/checks.exp (check sections 2): Don't continue on with rest of test past first fail.
2023-02-21ld-libs test on alpha-vmsAlan Modra
* testsuite/ld-libs/libs.exp: Don't run for alpha-vms.
2023-02-21alpha-*-vms missing librariesAlan Modra
For this: ./ld-new: cannot find -limagelib: No such file or directory ./ld-new: cannot find -lstarlet: No such file or directory ./ld-new: cannot find -lsys$public_vectors: No such file or directory the logs showed creating dummy tmpdir/libimagelib: creating dummy No creating dummy such etc. So rubbish instead of tmpdir/libimagelib.a and the other required libs. * testsuite/config/default.exp: Correct regex detecting missing libraries automatically searched by alpha-dec-vms-ld.
2023-02-20ld/testsuite: handle Windows drive letter in a noinit testClément Chigot
The regexp in "noinit sections (ld -r)" is skipping the file path before the first ":". However, on Windows, a path can start with "C:". Adjust the regexp to allow such cases. ld/ChangeLog: * testsuite/ld-elf/noinit-sections-2.l: Allow Windows paths (starting with C:).
2023-02-20ld/testsuite: adjust to Windows path separator.Clément Chigot
In some tests, the path reported on Windows will have a \ instead of a /. This occurs when a file is concatened with the search path in ldfile.c.: "ld -Ltmpdir -ltext" will result into "tmpdir\libtext.a". ld/ChangeLog: * testsuite/ld-elf/retain5.map: Allow \ path separator. * testsuite/ld-plugin/plugin-10.d: Likewise. * testsuite/ld-plugin/plugin-11.d: Likewise. * testsuite/ld-plugin/plugin-18.d: Likewise. * testsuite/ld-plugin/plugin-19.d: Likewise. * testsuite/ld-plugin/plugin-20.d: Likewise. * testsuite/ld-plugin/plugin-22.d: Likewise.
2023-02-17ld test asciz and ascii failsAlan Modra
Fix these fails: alpha-dec-vms +FAIL: ld-scripts/asciz alpha-dec-vms +FAIL: ld-scripts/ascii i386-go32 +FAIL: ld-scripts/asciz sh-coff +FAIL: ld-scripts/asciz It's better to positively select targets for .section support than to try to exclude all targets that don't. Make a new is_coff_format so we can easily select such. binutils/ * testsuite/lib/binutils-common.exp (is_coff_format): New. ld/ * testsuite/ld-scripts/ascii.d: Use is_elf_format and is_coff_format to select targets, exclude ti coff. * testsuite/ld-scripts/asciz.d: Likewise. Accept trailing zeros.
2023-02-16Add support for the ASCII directive inside linker scripts.Nick Clifton
* ldlex.l: Add ASCII token. * ldgram.y: Add parsing of the ASCII command. * ldlang.c (lang_add_string): Add maximum size parameter. Move escape character handling code into separate function. * ldlang.h (lang_add_string): Update prototype. * NEWS: Mention the new feature. * ld.texi (Output Section Data): Document the new directives. * testsuite/ld-scripts/asciz.t: Adjust to work on more architectures and to test more aspects of the ASCIZ directive. * testsuite/ld-scripts/asciz.d: Adjust to match the changes to the test linker script. * testsuite/ld-scripts/ascii.d: New test driver. * testsuite/ld-scripts/ascii.s: New test assembler source. * testsuite/ld-scripts/ascii.t: New test script. * testsuite/ld-scripts/script.exp: Run the new test.
2023-02-15Fix the linker's merge4 test for the HPPA architecture.Nick Clifton
PR 30078 * testsuite/ld-elf/merge4b.s: Use .asciz instead of .string in order to avoid the special behaviour of the .string directive on HPPA architectures.