aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite
AgeCommit message (Collapse)AuthorFilesLines
7 daystestsuite: fix typo in bti-plt-1-b.d testYury Khrustalev1-1/+1
This test is not supposed to use -z force-bti
7 daysaarch64: ld: add tests for combination of bti and memory-sealYury Khrustalev2-0/+59
Both BTI and memory sealing require use of GNU properties and we should check that there is no interference.
9 daysRe: ld: Skip the LTO archive member only for the earlier DSOAlan Modra1-10/+10
Add -fPIC when compiling the test, to fix complaints on some targets about certains relocation not being valid for shared libraries.
13 daysld: Skip the LTO archive member only for the earlier DSOH.J. Lu6-0/+64
commit 2707d55e539ef323dd14a1293e762bf3d9739ee7 Author: Michael Matz <matz@suse.de> Date: Mon Mar 31 15:57:08 2025 +0200 skipped the LTO archive member even when the earlier item is also an archive. Instead, skip the LTO archive member only if the earlier item is a shared library. bfd/ PR ld/32846 PR ld/32854 * elflink.c (elf_link_add_archive_symbols): Skip the LTO archive member only if the earlier item is a shared library. ld/ PR ld/32846 PR ld/32854 * testsuite/ld-plugin/lto.exp: Run ld/32846 test. * testsuite/ld-plugin/pr32846a.c: New file. * testsuite/ld-plugin/pr32846b.c: Likewise. * testsuite/ld-plugin/pr32846c.c: Likewise. * testsuite/ld-plugin/pr32846d.c: Likewise. * testsuite/ld-plugin/pr32846e.c: Likewise. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-04-07[lto] Fix symlookup in archives vs sharedMichael Matz4-0/+24
when a shared library defines 'foo@@FOO' (default version), a static archive defines 'foo', the shared lib comes in front of the archive and under effect of --as-needed, and the requesting object file uses LTO, then the link editor was wrongly including the definition from the static archive. It must use the one from the shared lib, like in the non-LTO or the --no-as-needed case. See the added testcase that would wrongly print "FAIL" before this patch. The problem stems from several connected problems: (1) only the decorated symbol was entered into first_hash (the hash table designed to handle definition order in the pre-LTO-plugin phase of the symbol table walks) (2) in the archive symbol walk only the undecorated name would be looked up in first_hash (and hence not found due to (1)) (3) in the archive symbol walk first_hash would only be consulted when the linker hash table had a defined symbol. In pre-LTO phase shared lib symbols aren't entered into the linker symbol table. So: add also the undecorated name into first_hash when it stems from a default version and consult first_hash in the archive walker also for currently undefined symbols. If it has an entry which doesn't point to the archive, then it comes from an earlier library (shared or static), and so _this_ archive won't provide the definition.
2025-04-03ld/testsuite/ld-pe: Escape dots in regular expressionsLIU Hao1-4/+4
Signed-off-by: LIU Hao <lh_mouse@126.com> ld/ChangeLog: * testsuite/ld-pe/secidx.d: Escape dots in regular expressions.
2025-04-02Add optional filename argument to the linker's --stats option, allowing ↵Nick Clifton3-13/+60
extra resource use information to be reported.
2025-03-28x86: Pass $NOPIE_LDFLAGS to undefined weak testsJens Remus1-2/+2
Some distributions configure GCC with --enable-default-pie, so that it defaults to compile with -fPIE and link with -pie, which is unexpected by some of the tests. Therefore link the PDE test programs with $NOPIE_LDFLAGS to disable PIE. This complements commit a7eaf017f959 ("Use NOPIE_CFLAGS and NOPIE_LDFLAGS to disable PIE"). ld/testsuite/ PR ld/21090 * ld-x86-64/x86-64.exp (undefined_weak): Use NOPIE_LDFLAGS to disable PIE for the non-PIE versions of the test. Bug: https://sourceware.org/PR21090 Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2025-03-28ld: Pass $NOPIE_CFLAGS and $NOPIE_LDFLAGS to more ELF visibility testsJens Remus1-7/+9
Some distributions configure GCC with --enable-default-pie, so that it defaults to compile with -fPIE and link with -pie, which is unexpected by the test. Therefore compile the non-PIC sources with $NOPIE_CFLAGS and link the test programs with $NOPIE_LDFLAGS. Commit 922109c71828 ("Pass $NOPIE_CFLAGS to ELF visibility tests") added $NOPIE_CFLAGS when compiling sh1np.o and sh2np.o. It missed to add it to mainnp.o. ld/testsuite/ PR ld/21090 * ld-vsb/vsb.exp (visibility_test): Add support for optional ldflags argument and use it when linking the test program. (mainnp.o): Compile with $NOPIE_CFLAGS. (vnp, vp, vmpnp, vmpp): Link with $NOPIE_LDFLAGS. Fixes: 922109c71828 ("Pass $NOPIE_CFLAGS to ELF visibility tests") Bug: https://sourceware.org/PR21090 Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2025-03-28ld: Pass $NOPIE_CFLAGS and $NOPIE_LDFLAGS to even more ELF shared testsJens Remus1-16/+18
Some distributions configure GCC with --enable-default-pie, so that it defaults to compile with -fPIE and link with -pie, which is unexpected by the test. Therefore compile the non-PIC sources with $NOPIE_CFLAGS and link the test programs with $NOPIE_LDFLAGS. Commit 9d1c54ed7f3a ("Pass $NOPIE_CFLAGS and $NOPIE_LDFLAGS to more ELF tests") added $NOPIE_CFLAGS when compiling sh1np.o. It missed to add it to sh2np.o and mainnp.o. ld/testsuite/ PR ld/21090 * ld-shared/shared.exp (shared_test): Add support for optional ldflags argument and use it when linking the test program. (sh2np.o, mainnp.o): Compile with $NOPIE_CFLAGS. (shnp, shp, shmpnp, shmpp): Link with $NOPIE_LDFLAGS. Fixes: 9d1c54ed7f3a ("Pass $NOPIE_CFLAGS and $NOPIE_LDFLAGS to more ELF tests") Bug: https://sourceware.org/PR21090 Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2025-03-28ld: Pass $NOPIE_CFLAGS and $NOPIE_LDFLAGS to test pr21964-4Jens Remus1-2/+2
Linker test "pr21964-4" fails on s390x on Ubuntu 24.10 but not on Fedora 41. The reason is that GCC on Ubuntu is configured with --enable-default-pie, so that it defaults to compile with -fPIE and link with -pie, which causes the test to erroneously fail. ld/testsuite/ PR ld/21090 * ld-elf/shared.exp: Compile pr21964-4 with $NOPIE_CFLAGS and link with $NOPIE_LDFLAGS. Bug: https://sourceware.org/PR21090 Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2025-03-28ld: Pass $NOPIE_CFLAGS and $NOPIE_LDFLAGS to test pr19719Jens Remus1-1/+1
Linker test "pr19719 fun defined" (non PIE) fails on s390x on Fedora 41 but not on Ubuntu 24.10. The reason is that GCC on Ubuntu is configured with --enable-default-pie, so that it defaults to compile with -fPIE and link with -pie, which hides the test fail. ld/testsuite/ PR ld/21090 * ld-elf/shared.exp: Compile pr19719 (non-PIE) with $NOPIE_CFLAGS and link with $NOPIE_LDFLAGS. Bug: https://sourceware.org/PR21090 Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2025-03-26ld: Correct test pr19719 naming mix-upJens Remus1-4/+4
The suffix "defined/undefined" in the ld test pr19719 name specifies whether weak fun() is defined or undefined is mixed up. The test builds an executable and a shared library. The latter in two flavors, one with weak fun() defined (libpr19719a.so, "defined") and one without weak fun() defined (libpr19719b.so, "undefined"). The first "Run $exe fun [...]" invocation uses libpr19719b.so as libpr19719.so, which is build from dummy.c, which does not define fun. Thus fun is undefined during this test run. The second "Run $exe fun [...]" invocation uses libpr19719a.so as libpr19719.so, which is build from pr19719d.c, which does define fun. Thus fun is defined during this test run. Correct the test naming mix-up accordingly. ld/testsuite/ * ld-elf/shared.exp (mix_pic_and_non_pic): Correct test naming mix-up of when weak fun is un-/defined. Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2025-03-20x86-64: Remove the unused pr19636-3d.dH.J. Lu1-10/+0
Remove the unused pr19636-3d.d since static Position Dependent Executable doesn't have a dynamic symbol table. PR ld/32807 * testsuite/ld-x86-64/pr19636-3d.d: Removed. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-03-17ld/testsuite: add gnu property section in nto-stack-note*Clément Chigot2-0/+10
A GNU property section is now always generated when `-z stack-size` is passed. This was probably introduced by GNU Property refactoring within elfxx-aarch64.c.
2025-03-14elf: Clear the SEC_ALLOC bit for NOLOAD note sectionsH.J. Lu2-0/+21
When generating an ELF output file, if a note section is marked as NOLOAD, clear the SEC_ALLOC bit so that it won't be treated as an SHF_ALLOC section, like a .bss style section. PR ld/32787 * ld.texi: Update NOLOAD for ELF output files. * ldlang.c (lang_add_section): Clear the SEC_ALLOC bit for NOLOAD note sections for ELF output files. * testsuite/ld-elf/pr32787.d: New file. * testsuite/ld-elf/pr32787.t: Likewise. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-03-07Re: ld: Add a test for PR ld/25237Alan Modra2-28/+0
Delete the test. It doesn't make sense to check a linker hack for a meaningless p_offset.
2025-03-06ld: Update PR ld/25237 testH.J. Lu2-4/+7
1. Skip targets which don't support the .bss section alignment, 1 << 16. 2. Replace .bss with ".section .bss". 3. Use ".zero 0xb60000" for targets which pad the section to its alignment. PR ld/25237 * testsuite/ld-elf/pr25237.d: Skip avr-*-* and h8300-*-*. Update expected segment size to 0xb60000. * testsuite/ld-elf/pr25237.s: Use ".section .bss" and ".zero 0xb60000". Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-03-05ld: Add a test for PR ld/25237H.J. Lu2-0/+25
PR ld/25237 * testsuite/ld-elf/pr25237.d: New file. * testsuite/ld-elf/pr25237.s: Likewise. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-03-05ld: Pass -Wl,-z,lazy to compiler for i386 lazy binding testsH.J. Lu2-8/+8
Pass -Wl,-z,lazy to compiler for i386 tests which require lazy binding to support compilers which default to non-lazy binding. PR ld/32762 * testsuite/ld-i386/i386.exp: Pass -Wl,-z,lazy for "Build ifunc-1a with PIE -z ibtplt" test. * testsuite/ld-i386/no-plt.exp: Pass -Wl,-z,lazy for "Build libno-plt-1b.so", "No PLT (dynamic 1a)", "No PLT (dynamic 1b)", "No PLT (dynamic 1c)", "No PLT (PIE 1e)", "No PLT (PIE 1f)", "No PLT (PIE 1g)" tests. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-02-27x86-64: Pass -z separate-code to ld for -z mark-plt testsH.J. Lu8-8/+8
Pass -z separate-code to ld for -z mark-plt tests to fix: FAIL: ld-x86-64/mark-plt-1a FAIL: ld-x86-64/mark-plt-1b FAIL: ld-x86-64/mark-plt-1c FAIL: ld-x86-64/mark-plt-1d FAIL: ld-x86-64/mark-plt-1a-x32 FAIL: ld-x86-64/mark-plt-1b-x32 FAIL: ld-x86-64/mark-plt-1c-x32 FAIL: ld-x86-64/mark-plt-1d-x32 when binutils is configured with --disable-separate-code. * ld-x86-64/mark-plt-1a-x32.d: Pass -z separate-code to ld. * ld-x86-64/mark-plt-1a.d: Likewise. * ld-x86-64/mark-plt-1b-x32.d: Likewise. * ld-x86-64/mark-plt-1b.d: Likewise. * ld-x86-64/mark-plt-1c-x32.d: Likewise. * ld-x86-64/mark-plt-1c.d: Likewise. * ld-x86-64/mark-plt-1d-x32.d: Likewise. * ld-x86-64/mark-plt-1d.d: Likewise. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-02-26ld/testsuite: add -z separate-code to sframe x86_64 testsClément Chigot5-5/+5
Those tests were generated by a linker having "-z separate-code" on by default. However, being controlled by a configure option, it can be off by default. Forcing the option as part of the tests ensures clean results in both cases.
2025-02-21ix86: restrict use of GOT32X relocsJan Beulich3-0/+10
The ELF linker rejects use of this reloc type without a base register for PIC code. Suppress its use by gas in such cases. To keep things building for non-ELF, include the entire containing if() in an #ifdef: All consumers of ->fx_tcbit* live in such conditionals as well, hence there's no reason to keep the producer active.
2025-02-21x86-64: further tighten convert-load-reloc checkingJan Beulich2-3/+12
REX2.M affects what insn we're actually dealing with, so we better check this to avoid transforming (future) insns we must not touch.
2025-02-21x86: widen @got{,pcrel} support to PUSH and APX IMULJan Beulich12-0/+119
With us doing the transformation to an immediate operand for MOV and various ALU insns, there's little reason to then not support the same conversion for the other two insns which have respective immediate operand forms. Unfortunately for IMUL (due to the 0F opcode prefix) there's no suitable relocation, so the pre-APX forms cannot be marked for relaxation in the assembler.
2025-02-21x86/APX: use CS: in place of ES: in @gotpcrel and @gottpoff relaxationJan Beulich3-20/+20
H.J. requested this adjustment; I'm unaware of any specific technical background.
2025-02-21ix86: tighten convert-load-reloc checkingJan Beulich3-0/+36
Just like was done recently for x86-64 (commit 4998f9ea9d35): Even if the assembler avoids using the relaxable relocation for inapplicable insns, the relocation type can still appear for other reasons. Be more thorough in the opcode checking we do, to avoid bogusly altering other insns. Furthermore correct an opcode mask (even if with the added condition that's now fully benign).
2025-02-19PR32715, ld-elf/pr29072 fail with --disable-default-execstackAlan Modra1-4/+6
--disable-default-stack is an alias for --enable-default-execstack=no. The existing check only looked for the latter config option. PR 32715 * testsuite/ld-elf/elf.exp (target_defaults_to_execstack): Look in config.h for result of --enable-default-execstack.
2025-02-18ld: Add tests for PR ld/32690H.J. Lu4-0/+3456
Without commit 230a788eb28a64d628e623068c44add2a24aa5d3 Author: Alan Modra <amodra@gmail.com> Date: Tue Feb 18 08:54:06 2025 +1030 PR32690, assertion failure in lang_size_relro_segment this test triggers the linker error: .../ld: internal error .../ld/ldlang.c 6618 collect2: error: ld returned 1 exit status with GCC 10 or above on x86-64. PR ld/32690 * testsuite/ld-elf/elf.exp: Run PR ld/32690 tests. * testsuite/ld-elf/pr32690.h: New file. * testsuite/ld-elf/pr32690a.c: Likewise. * testsuite/ld-elf/pr32690b.c: Likewise. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-02-10x86: Return error for invalid relocation offsetH.J. Lu3-0/+8
Return error if relocation offset + relocation size > section size. bfd/ PR ld/32665 * elf32-i386.c (elf_i386_scan_relocs): Return error for invalid relocation offset. * elf64-x86-64.c (elf_x86_64_scan_relocs): Likewise. ld/ PR ld/32665 * testsuite/ld-x86-64/pr32665.err: New file. * testsuite/ld-x86-64/pr32665.o.bz2: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run PR ld/32665 test. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-02-08sparc: define _GLOBAL_OFFSET_TABLE_ when referencedAlexandre Oliva2-0/+23
GCC testsuite gcc.dg/20050321-2.c hit link errors on undefined _GLOBAL_OFFSET_TABLE_. The compiler output referenced only _GLOBAL_OFFSET_TABLE_-offsets to set it up, and to compute the GOT-relative address of local symbols, none of which triggered the machinery that enabled the creation of the dynamic section, so _GLOBAL_OFFSET_TABLE_ ended up undefined. Enable the dynamic section if we find a relocation involving _GLOBAL_OFFSET_TABLE_. While at that, optimize checks for references to it. for bfd/ChangeLog * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Check for _GLOBAL_OFFSET_TABLE_ references early, then compare hashed symbols instead of strings. (_bfd_sparc_elf_relocate_section): Compare hashed symbols. for ld/ChangeLog * testsuite/ld-sparc/got-def.s: New test. * testsuite/ld-sparc/sparc.exp: Add it.
2025-02-07x86-64: Estimate output section layout before sizing dynamic sectionsH.J. Lu31-8/+424
When sizing dynamic sections, elf_x86_64_scan_relocs converts GOTPCREL relocations to R_X86_64_PC32, R_X86_64_32S or R_X86_64_32 for local symbols. But at that time, since the output section layout is unknown, the local symbol values can't be determined. Later linker issues an error if the converted relocation overflows when resolving relocations against these local symbols. Update the x86-64 ELF linker to estimate output section layout before sizing dynamic sections and use the preliminary output section layout info to skip the GOTPCREL relocation conversion if the converted relocation overflows. bfd/ PR ld/32591 * elf64-x86-64.c (elf_x86_64_convert_load_reloc): Add an input section argument. Use the lowest-addressed section to estimate the __ehdr_start symbol value. Don't convert relocation if the converted relocation will overflow. ld/ PR ld/32591 * emultempl/elf-x86.em (elf_x86_64_before_allocation): New. Defined for x86-64. (LDEMUL_BEFORE_ALLOCATION): Likewise. * testsuite/ld-x86-64/pr19609-2a.d: Don't fail. * testsuite/ld-x86-64/pr19609-2b.d: Likewise. * testsuite/ld-x86-64/pr19609-4a.d: Likewise. * testsuite/ld-x86-64/pr19609-5d.d: Likewise. * testsuite/ld-x86-64/pr19609-7a.d: Likewise. * testsuite/ld-x86-64/pr19609-7c.d: Likewise. * testsuite/ld-x86-64/pr32591-1.s: New file. * testsuite/ld-x86-64/pr32591-1a-x32.d: Likewise. * testsuite/ld-x86-64/pr32591-1a.d: Likewise. * testsuite/ld-x86-64/pr32591-1a.t: Likewise. * testsuite/ld-x86-64/pr32591-1b-x32.d: Likewise. * testsuite/ld-x86-64/pr32591-1b.d: Likewise. * testsuite/ld-x86-64/pr32591-1b.t: Likewise. * testsuite/ld-x86-64/pr32591-1c-x32.d: Likewise. * testsuite/ld-x86-64/pr32591-1c.d: Likewise. * testsuite/ld-x86-64/pr32591-1c.t: Likewise. * testsuite/ld-x86-64/pr32591-1d-x32.d: Likewise. * testsuite/ld-x86-64/pr32591-1d.d: Likewise. * testsuite/ld-x86-64/pr32591-1d.t: Likewise. * testsuite/ld-x86-64/pr32591-2.s: Likewise. * testsuite/ld-x86-64/pr32591-2-x32.d: Likewise. * testsuite/ld-x86-64/pr32591-2.d: Likewise. * testsuite/ld-x86-64/pr32591-2.t: Likewise. * testsuite/ld-x86-64/pr32591-3.s: Likewise. * testsuite/ld-x86-64/pr32591-3-x32.d: Likewise. * testsuite/ld-x86-64/pr32591-3.d: Likewise. * testsuite/ld-x86-64/pr32591-3.t: Likewise. * testsuite/ld-x86-64/pr32591-4.s: Likewise. * testsuite/ld-x86-64/pr32591-4-x32.d: Likewise. * testsuite/ld-x86-64/pr32591-4.d: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run PR ld/32591 tests. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-01-31LoongArch: Do not relax against __[start|stop]_SECNAME symbolLulu Cai3-0/+25
2025-01-31x86/APX: correct libbfd's EVEX Rn -> Bn transformationsJan Beulich1-44/+44
In the recent GOTPCREL addition I screwed up, in clearing the Rn bits afterwards rather than setting them. While that ought to be benign (for the bits being ignored in situations like this), we still want to leave "canonical" encodings. The pre-existing GOTTPOFF conversion wasn't doing quite correctly either: We cannot assume the incoming Bn bits to be in a particular state, as for the addressing form in question they're ignored as well. To address both, introduce a helper function. This is then also an overall reduction of (source) code size (and use of "magic" numbers).
2025-01-30x86-64: Remove pr19609-4c.d and pr19609-4d.dH.J. Lu4-30/+11
Remove pr19609-4c.d and pr19609-4d.d since they are identical to pr19609-4a.d and pr19609-4b.d, respectively. * testsuite/ld-x86-64/pr19609-4c.d: Removed. * testsuite/ld-x86-64/pr19609-4d.d: Likewise. * testsuite/ld-x86-64/pr19609-4e.d: Renamed to ... * testsuite/ld-x86-64/pr19609-4c.d: This. * testsuite/ld-x86-64/x86-64.exp: Updated. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-01-27s390: Generate .eh_frame unwind information for .plt sectionJens Remus2-4/+39
Enable unwinding using .eh_frame information through PLT entries. Based on x86-64. This enhances stack traces if the instruction pointer is in a PLT entry. For instance perf call graphs, when using --call-graph=dwarf, and Glibc backtraces, when using backtrace() e.g. from a signal handler. Note that GDB could already unwind through PLT entries using its s390- specific prologue unwinder. Furthermore this lays the foundation to generate SFrame information for the PLT section in the future. bfd/ * elf64-s390.c: Include dwarf2.h. (PLT_CIE_SIZE, PLT_FDE_SIZE, PLT_FDE_START_OFFSET, PLT_FDE_LEN_OFFSET, elf_s390x_eh_frame_plt): New .eh_frame template for .plt section. (elf_s390_link_hash_table): Add plt_eh_frame field. (elf_s390_create_dynamic_sections): New s390-specific wrapper around _bfd_elf_create_dynamic_sections. Create .eh_frame section for .plt section. (elf_backend_create_dynamic_sections): Register s390-specific elf_s390_create_dynamic_sections. (elf_s390_late_size_sections): Fill in .eh_frame section for .plt section. Write .plt section size into .eh_frame FDE covering .plt section. (elf_s390_finish_dynamic_sections): Write .plt section start into .eh_frame FDE covering .plt section. Call _bfd_elf_write_section_eh_frame on on htab->plt_eh_frame section. ld/ * NEWS: Add news entry. * emulparams/elf64_s390.sh: Include plt_unwind.sh. ld/testsuite/ * ld-s390/plt_64-1_eh.wf: New PLT .eh_frame generation test. * ld-s390/s390.exp: Link some existing test cases with --no-ld-generated-unwind-info so that they do not fail. Run new PLT .eh_frame generation test. Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2025-01-27s390: Add basic PLT generation testsJens Remus9-0/+316
ld/testsuite/ * ld-s390/plt_31_non-pic-1.pd: New non-PIC/PIE PLT generation test for 31-bit. * ld-s390/plt_31_pic-1.pd: New PIC/PIE PLT generation test for 31-bit. * ld-s390/plt_31-1.wf: New PLT generation test for 31-bit. * ld-s390/plt_64-1.pd: New PLT generation test for 64-bit. * ld-s390/plt_64-1.wf: Likewise. * ld-s390/plt-1.s: New PLT generation test for 31/64-bit. * ld-s390/pltlib.s: Likewise. * ld-s390/s390.exp: Run new PLT generation tests. Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2025-01-26ld-x86-64/pr19609-2d.d: Move "#pass" to the endH.J. Lu1-1/+1
* testsuite/ld-x86-64/pr19609-2d.d: Move "#pass" to the end. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-01-24x86-64: tighten convert-load-reloc checkingJan Beulich3-0/+37
Even if the assembler avoids using relaxable relocations for inapplicable insns, such relocations can still appear for other reasons. Be more thorough in the opcode checking we do, to avoid bogusly altering other insns. Furthermore correct an opcode mask (even if with the added condition that's now fully benign).
2025-01-24x86/APX: widen @gotpcrel and @gottpoff support (incl to MOVRS)Jan Beulich13-185/+486
If legacy-encoded arithmetic insns are eligible for @gotpcrel relaxation, EVEX-encoded ones ought to be, too. Further anything that MOV-from-memory can be used for (and transformed from) should then also extend to MOVRS. While extending the apx-load* testcases add -mrelax-relocations=yes to the two ones which were missing this: Without this option the intended testing would not occur on configurations defaulting the option to off.
2025-01-23ld: fix alignment issue for ARM thumb long branch stub using PureCode sectionTorbjörn SVENSSON4-1/+57
When pure-code option is activated. The linker creates for M-profile architecures a 2-bytes branch instruction. This causes the section alignment to be set to 2-byte alignment instead of 4-byte alignment. This is a problem for long branch stub without pure-code section as it contains a 32-bit address as data, which is expected to be 4-byte aligned. Hence creating a long branch stub for PureCode section followed by a long branch stub will result in a misalignment for the 32-bit address. An easy fix is to add a nop instruction after the branch to keep the section alignment to 4 bytes. Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com> Co-authored-by: Guillaume VACHERIAS <guillaume.vacherias@st.com>
2025-01-23More ld testsuite fixesAlan Modra2-466/+459
* testsuite/ld-elf/indirect.exp: Run compiler capability checks using run_host_noleak. * testsuite/ld-ifunc/ifunc.exp: Don't exit without restoring ASFLAGS. Don't run ifuncmod5 twice.
2025-01-22ld: replace another @progbits etc in an ELF testcaseJan Beulich1-5/+5
The canonical form (in the testsuite) is %progbits and alike.
2025-01-21asan ld builds without detect_leaks=0Alan Modra2-12/+28
I found that building binutils with -fsanitize=address,undefined results in much of the testsuite not being run. The problem is that running gcc results in linker plugin memory leaks which of course are errors, so the testsuite sees this as lack of compiler support. * testsuite/lib/ld-lib.exp (run_host_noleak): New proc. (check_compiler_available, check_lto_available), (check_lto_fat_available, check_lto_shared_available), (check_ifunc_available, check_ifunc_attribute_available), (check_libdl_available, check_gnu2_tls_available), (compile_one_cc): Use run_host_noleak. * testsuite/config/default.exp (compiler_supports): Likewise.
2025-01-17LoongArch: Allocate GOT entry for TLS DESC when -mno-relax is enabledLulu Cai5-0/+47
The type transition of TLSDESC is only done when -mrelax is enabled. So when -mno-relax is enabled, keep GOT_TLS_GDESC to allocate the GOT entry instead of just keeping GOT_TLS_IE.
2025-01-17ld: Load the object only section when opening the mixed object fileH.J. Lu1-40/+38
Load the object only section when opening the mixed object file, instead of loading it after all other input files have been loaded. This fixed .../ld/collect-ld: /tmp/ccZAoUIW.obj-only.o: in function `main': .../ld/testsuite/ld-plugin/lto-10a.c:4: multiple definition of `main'; /usr/x86_64-w64-mingw32/sys-root/mingw/lib/../lib/libmingw32.a(lib64_libmingw32_a-crtexewin.o):(.text.startup+0x0): first defined here .../ld/collect-ld: /usr/x86_64-w64-mingw32/sys-root/mingw/lib/../lib/libmingw32.a(lib64_libmingw32_a-crtexewin.o):(.text.startup+0xc5): undefined reference to `WinMain' collect2: error: ld returned 1 exit status ... FAIL: LTO 10 for x86_64-w64-mingw32 so that mixing LTO and non-LTO relocatable files for "ld -r" works for both ELF and non-ELF platforms. * ld.texi: Remove "On ELF platforms" from documentation of mixing LTO and non-LTO relocatable files for "ld -r". * ldlang.c (cmdline_load_object_only_section): New. (cmdline_check_object_only_section): Call it. * testsuite/ld-plugin/lto.exp: Enable mixed LTO and non-LTO relocatable output tests for all. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-01-15aarch64: GCS tests for linking issues with dynamic objectsMatthieu Longo18-0/+247
2025-01-15Re: elf: Add GNU_PROPERTY_MEMORY_SEAL gnu propertyAlan Modra9-40/+30
Don't run tests on targets without required support. Supply an explicit -z nomemory-seal rather then relying on the harness default, to lessen confusion for people looking at the test. Don't use numeric labels for the sake of hppa64*-hpux, and run the tests there. Remove incorrect comment about source editing. Also, xfail rather than notarget failing tests with a list of target triples so we check that the list is correct.
2025-01-15Re: ld: Add --enable-memory-seal configure optionAlan Modra1-3/+2
Commit 80dc29527ff9 accidentally removed an assignment to board_flags, resulting in tcl errors 'can't read "board_flags": no such variable' on sh4-linux-gnu. Fix that by calling [get_board_flags] in the condition rather than reinstating the removed line since it seems most configurations don't have a null STATIC_LDFLAGS. Do the same in another similar test too.
2025-01-14ld: Add --enable-memory-seal configure optionAdhemerval Zanella3-1/+19
Add --enable-memory-seal linker configure option to enable memory sealing (GNU_PROPERTY_MEMORY_SEAL) by default. Change-Id: I4ce4ff33657f0f09b1ceb06210b6fcaa501f1799