aboutsummaryrefslogtreecommitdiff
path: root/ld
AgeCommit message (Collapse)AuthorFilesLines
6 hoursLTO: Restore the wrapper symbol check for standard functionHEADmasterH.J. Lu5-2/+58
Call unwrap_hash_lookup to restore the wrapper symbol check for standard function since reference to standard function may not show up in LTO symbol table: [hjl@gnu-tgl-3 pr31956-3]$ nm foo.o 00000000 T main U __real_malloc 00000000 T __wrap_malloc [hjl@gnu-tgl-3 pr31956-3]$ lto-dump -list foo.o Type Visibility Size Name function default 0 malloc function default 0 __real_malloc function default 3 main function default 5 __wrap_malloc [hjl@gnu-tgl-3 pr31956-3]$ make gcc -O2 -flto -Wall -c -o foo.o foo.c gcc -Wl,--wrap=malloc -O2 -flto -Wall -o x foo.o /usr/local/bin/ld: /tmp/ccsPW0a9.ltrans0.ltrans.o: in function `main': <artificial>:(.text.startup+0xa): undefined reference to `__wrap_malloc' collect2: error: ld returned 1 exit status make: *** [Makefile:22: x] Error 1 [hjl@gnu-tgl-3 pr31956-3]$ Also add a test to verify that the unused wrapper is removed. PR ld/31956 * plugin.c (get_symbols): Restore the wrapper symbol check for standard function. * testsuite/ld-plugin/lto.exp: Run the malloc test and the unused test. * testsuite/ld-plugin/pr31956c.c: New file. * testsuite/ld-plugin/pr31956d.c: New file. * testsuite/ld-plugin/pr31956d.d: New file. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2 daysLoongArch: Fix ld FAIL test casesLulu Cai1-17/+24
To avoid differences in C library paths on different systems use gcc instead of ld to perform the test. Problems caused by adding options to different distributions will not be fixed.
2 daysld/PDB: handle empty LF_FIELDLIST typesMark Harmstone4-4/+25
Empty structs in C++ lead to empty LF_FIELDLIST types in the .debug$T section, but we were mistakenly rejecting these as invalid. Allow CodeView types of two bytes, and add a test for this.
3 dayslibctf: improve ECTF_NOPARENT error messageNick Alcock1-1/+1
This erorr doesn't just indicate that there is no parent dictionary (that's routine, and true of all dicts that are parents themselves) but that a parent is *needed* but wasn't found. include/ * ctf-api.h (_CTF_ERRORS) [ECTF_NOPARENT]: Improve error message. ld/ * testsuite/ld-ctf/diag-parname.d: Adjust.
3 daysfix the framework errorAlan Modra1-18/+5
Running the testsuite for an x86_64-w64-mingw32 target using the Ubuntu package gcc-mingw-w64-x86-64 version 13.2.0-6ubuntu1+26.1 results in a number of messages: ERROR: can't decipher gcc version number, fix the framework! Someone in their wisdom decided this compiler should advertise itself with a version of 13-win32, breaking the ld testsuite version checks. (It is also configured using --with-as=/usr/bin/x86_64-w64-mingw32-as --with-ld=/usr/bin/x86_64-w64-mingw32-ld which renders the -B flag inoperative for testing the newly built gas and ld. You'd need to install binutils over the top of the Ubuntu versions before testing, a rather unsatisfactory process.) * testsuite/lib/ld-lib.exp (at_least_gcc_version): Use preprocessor test of __GNUC__ and __GNUC_MINOR__ rather than output of gcc --version. Correct removal of -Wl options.
4 daysgas/NEWS, ld/NEWS: Announce LoongArch changes in 2.43Lulu Cai1-0/+4
5 daysUpdated translations for the bfd, binutils, gas, ld and opcodes directoriesNick Clifton3-7133/+7306
5 daysFixes to "PR 31728 testcases"Alan Modra6-23/+55
This brings us down to just these fails for the set of targets I usually test when making testsuite changes. aarch64-pe +FAIL: ld-pe/symbols-ordinals-hints-imports-ld arm-pe +FAIL: ld-pe/symbols-ordinals-hints-exports-dlltool arm-pe +FAIL: ld-pe/symbols-ordinals-hints-imports-dlltool The aarch64 one is likely due to the target missing support somewhere. It is fairly new, I haven't investigated. The arm-pe fails are due to arm-pe being a target that adds underscores to symbol names (see config.bfd) whereas dlltool thinks it does not (see dlltool.c:asm_prefix). arm-wince-pe on the other hand doesn't add underscores. I would guess the right fix for dlltool is to get this symbol info from bfd using bfd_get_target_info. Note I'm not very happy about the creative use of ld_after_inputfile in symbols-ordinals-hints-imports-ld.d, which is likely to break with some future run_dump_test change.
5 daysPR 31728 testcasesPali Rohár12-12/+148
8 daysRemove srcdir from x86 testcase "source:" linesAlan Modra3-3/+3
It's wrong to have ${srcdir} in run_dump_test "source:" lines, as run_dump_test adds $srcdir/$subdir/ to the line passed to the shell except when the source path starts with "./". The tests work currently because the shell expands ${srcdir} to an empty string. PR 31728 * testsuite/ld-i386/code16.d: Correct "source:". * testsuite/ld-x86-64/code16.d: Likewise. * testsuite/ld-x86-64/rela.d: Likewise.
9 daysx86: Improve TLS transition error checkH.J. Lu18-6/+91
Provide detailed TLS transition errors when unsupported instructions are used. Treat R_X86_64_CODE_4_GOTTPOFF and R_X86_64_CODE_6_GOTTPOFF as R_X86_64_GOTTPOFF when performing TLS transition. bfd/ PR ld/32017 * elf32-i386.c (elf_i386_check_tls_transition): Return different enums for different errors. (elf_i386_tls_transition): Change argument from r_symndx to sym. Call _bfd_x86_elf_link_report_tls_transition_error to report TLS transition errors. (elf_i386_scan_relocs): Pass isym instead of r_symndx to elf_i386_tls_transition. (elf_i386_relocate_section): Pass sym instead of r_symndx to elf_i386_tls_transition. * elf64-x86-64.c (elf_x86_64_check_tls_transition): Return different enums for different errors. (elf_x86_64_tls_transition): Change argument from r_symndx to sym. Treat R_X86_64_CODE_4_GOTTPOFF and R_X86_64_CODE_6_GOTTPOFF as R_X86_64_GOTTPOFF. Call _bfd_x86_elf_link_report_tls_transition_error to report TLS transition errors. (elf_x86_64_scan_relocs): Pass isym instead of r_symndx to elf_x86_64_tls_transition. (elf_x86_64_relocate_section): Pass sym instead of r_symndx to elf_x86_64_tls_transition. * elfxx-x86.c (_bfd_x86_elf_link_report_tls_transition_error): New. * elfxx-x86.h (elf_x86_tls_error_type): Likewise. (_bfd_x86_elf_link_report_tls_transition_error): Likewise. ld/ PR ld/32017 * testsuite/ld-i386/i386.exp: Run tlsgdesc1 and tlsgdesc2. * testsuite/ld-i386/tlsie2.d: Updated. * testsuite/ld-i386/tlsie3.d: Likewise. * testsuite/ld-i386/tlsie4.d: Likewise. * testsuite/ld-i386/tlsie5.d: Likewise. * testsuite/ld-x86-64/tlsie2.d: Likewise. * testsuite/ld-x86-64/tlsie3.d: Likewise. * testsuite/ld-i386/tlsgdesc1.d: New file. * testsuite/ld-i386/tlsgdesc1.s: Likewise. * testsuite/ld-i386/tlsgdesc2.d: Likewise. * testsuite/ld-i386/tlsgdesc2.s: Likewise. * testsuite/ld-x86-64/tlsdesc3.d: Likewise. * testsuite/ld-x86-64/tlsdesc3.s: Likewise. * testsuite/ld-x86-64/tlsdesc4.d: Likewise. * testsuite/ld-x86-64/tlsdesc4.s: Likewise. * testsuite/ld-x86-64/tlsie5.d: Likewise. * testsuite/ld-x86-64/tlsie5.s: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run tlsie5, tlsdesc3 and tlsdesc4. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
9 daysAdd /usr/lib32 to the native search paths for FreeBSD systems.Nick Clifton1-1/+1
PR 31395
12 daysDon't trim trailing newline in run_host_cmdAlan Modra28-35/+34
Testcases like ld-elf/pr19719a.c that printf ("PASS\n"); on success ought to see the whole output for "string match". Similarly, the ld-pe/ pdb*.d files shouldn't need to remove the last newline to match. For most of the testsuite it doesn't matter whether the trailing newline is present or not, and there are only a few cases where we need to remove it. * testsuite/lib/ld-lib.exp (run_host_cmd): Don't regsub away output trailing newline. Do string trim for gcc/ld version checks. * testsuite/config/default.exp (plug_so): Do string trim output of run_host_cmd. * testsuite/ld-elf/shared.exp (mix_pic_and_non_pic): Adjust string match to include trailing newline. * testsuite/ld-i386/i386.exp (undefined_weak): Likewise. * testsuite/ld-x86-64/x86-64.exp (undefined_weak): Likewise. * testsuite/ld-plugin/libdep.exp (run_test): Likewise. * testsuite/ld-plugin/lto.exp (PR ld/28138 run): Likewise. * testsuite/ld-pe/pdb-strings.d, * testsuite/ld-pe/pdb-syms1-globals.d, * testsuite/ld-pe/pdb-syms1-records.d, * testsuite/ld-pe/pdb-syms1-symbols1.d, * testsuite/ld-pe/pdb-syms1-symbols2.d, * testsuite/ld-pe/pdb-syms2-symbols1.d, * testsuite/ld-pe/pdb-types1-hashlist.d, * testsuite/ld-pe/pdb-types1-skiplist.d, * testsuite/ld-pe/pdb-types1-typelist.d, * testsuite/ld-pe/pdb-types2-hashlist.d, * testsuite/ld-pe/pdb-types2-skiplist.d, * testsuite/ld-pe/pdb-types2-typelist.d, * testsuite/ld-pe/pdb-types3-hashlist.d, * testsuite/ld-pe/pdb-types3-skiplist.d, * testsuite/ld-pe/pdb-types3-typelist.d, * testsuite/ld-pe/pdb1-publics.d, * testsuite/ld-pe/pdb1-sym-record.d, * testsuite/ld-pe/pdb2-section-contrib.d, * testsuite/ld-pe/pdb3-c13-info1.d, * testsuite/ld-pe/pdb3-c13-info2.d, * testsuite/ld-pe/pdb3-source-info.d: Add trailing newline.
14 daysld/testsuite: add missing definition to PDB testMark Harmstone3-13/+14
The file pdb-syms1a.s was missing a definition for T_VOID, which was causing some types not to be deduplicated. It also meant that the test couldn't be run against LLVM's lld, which throws an error for this. This particular test only tests the symbols stream, not the types stream, which is why the deduplication doesn't result in a change in the file size.
14 daysld/PDB: use correct hashing algorithm in add_globals_refMark Harmstone2-38/+37
add_globals_ref was hashing using CRC32 rather than the hashing algorithm used for symbols, which meant that windbg was unable to put breakpoints against unmangled names.
14 daysCorrect version for binutils 2.43 NEWS entries.H.J. Lu1-1/+1
Change 2.42 to 2.43 for binutils 2.43 NEWS entries. binutils/ * NEWS: Change 2.42 to 2.43 for 2.43 NEWS entries. ld/ * NEWS: Change 2.42 to 2.43 for 2.43 NEWS entries. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
14 daysChange version to 2.43.50Nick Clifton2-2322/+2350
14 daysAdd markers for 2.43 branch/releaseNick Clifton2-0/+6
2024-07-19MIPS: correct macro use in gas and ld testsuitesJan Beulich3-3/+3
Whitespace in macro arguments either needs quoting / parenthesizing to reliably not be mistaken for an argument separator, or respective macro parameters need to be marked as covering all remaining arguments. The former appears more appropriate here, as the macro parameters already have ":req".
2024-07-13Revert "MIPS: Use N64 by default for mips*64*-*-linux-gnuabi64"Maciej W. Rozycki2-9/+4
This reverts commit d49f2dd78b08efa4e1ee51f5df5058846c2eb4fa. It was applied unapproved.
2024-07-13LoongArch: Fix dwarf3 test cases from XPASS to PASSLulu Cai1-5/+0
In the past, the .align directive generated a label that did not match the regular expression, and we set it to XFAIL. But now it matches fine so it becomes XPASS. We fix it with PASS.
2024-07-12s390: Avoid reloc overflows on undefined weak symbols (cont)Jens Remus3-1/+38
This complements and reuses logic from Andreas Krebbel's commit 896a639babe2 ("s390: Avoid reloc overflows on undefined weak symbols"). Replace relative long addressing instructions of weak symbols, which will definitely resolve to zero, with either a load address of 0 or a a trapping insn. This prevents the PLT32DBL relocation from overflowing in case the binary will be loaded at 4GB or more. bfd/ * elf64-s390.c (elf_s390_relocate_section): Replace instructions using undefined weak symbols with relative addressing to avoid relocation overflows. ld/ * testsuite/ld-s390/s390.exp: Add new test. * testsuite/ld-s390/weakundef-2.s: New test. * testsuite/ld-s390/weakundef-2.dd: Likewise. Reported-by: Alexander Gordeev <agordeev@linux.ibm.com> Suggested-by: Ilya Leoshkevich <iii@linux.ibm.com> Suggested-by: Andreas Krebbel <krebbel@linux.ibm.com> Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-07-12s390: Do not replace brcth referencing undefined weak symbolJens Remus2-4/+3
Branch Relative on Count High (brcth) is a conditional branch relative instruction. It is not guaranteed that it only appears within loops that sooner or later will take the branch. It may very well be used to check a condition that will prevent the branch from ever being taken. bfd/ * elf64-s390.c (elf_s390_relocate_section): Do not replace brcth referencing undefined weak symbol with a trap. ld/ * testsuite/ld-s390/weakundef-1.s: Update test case accordingly. * testsuite/ld-s390/weakundef-1.dd: Likewise. Fixes: 896a639babe2 ("s390: Avoid reloc overflows on undefined weak symbols") Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-07-12MIPS: Use N64 by default for mips*64*-*-linux-gnuabi64YunQiang Su2-4/+9
the ABI section of the triple explicitly asks for N64, and in fact GCC also does so. It can fix the test failure: FAIL: libdep test: did not get expected output from the linker with Debian's mipsisa64r6el-linux-gnuabi64 toolchain.
2024-07-11LoongArch: Not alloc dynamic relocs if symbol is absoluteJinyang He4-0/+17
The absolute symbol should be resolved to const when link to dso or exe. Alloc dynamic relocs will cause extra space and R_LARCH_NONE finally.
2024-07-10x86-64: Skip -z mark-plt tests on MUSLH.J. Lu1-0/+7
Skip -z mark-plt tests, which are specific to glibc, on MUSL. PR ld/31970 * ld/testsuite/ld-x86-64/x86-64.exp: Skip -z mark-plt tests on MUSL. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-07-09LTO: Properly check wrapper symbolH.J. Lu4-8/+45
Add wrapper_symbol to bfd_link_hash_entry and set it to true for wrapper symbol. Set wrap_status to wrapper if wrapper_symbol is true in LTO. Note: Calling unwrap_hash_lookup to check for the wrapper symbol works only when there is a definition for the wrapped symbol since references to the wrapped symbol have been redirected to the wrapper symbol. bfd/ PR ld/31956 * linker.c (bfd_wrapped_link_hash_lookup): Set wrapper_symbol for wrapper symbol. include/ PR ld/31956 * bfdlink.h (bfd_link_hash_entry): Add wrapper_symbol. ld/ PR ld/31956 * plugin.c (get_symbols): Set wrap_status to wrapper if wrapper_symbol is set. * testsuite/ld-plugin/lto.exp: Run PR ld/31956 tests. * testsuite/ld-plugin/pr31956a.c: New file. * testsuite/ld-plugin/pr31956b.c: Likewise. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-07-05LoongArch: Add DT_RELR testsXi Ruoyao19-0/+485
Most tests are ported from AArch64. The relr-addend test is added to make sure the addend (link-time address) is correctly written into the relocated section. Doing so is not strictly needed for RELA, but strictly needed for RELR). Signed-off-by: Xi Ruoyao <xry111@xry111.site>
2024-07-05LoongArch: Add DT_RELR supportXi Ruoyao1-0/+1
The logic is same as a71d87680110 ("aarch64: Add DT_RELR support"). As LoongArch does not have -z dynamic-undefined-weak, we don't need to consider UNDEFWEAK_NO_DYNAMIC_RELOC. The linker relaxation adds another layer of complexity. When we delete bytes in a section during relaxation, we need to fix up the offset in the to-be-packed relative relocations against this section. Signed-off-by: Xi Ruoyao <xry111@xry111.site>
2024-07-05LoongArch: Make protected function symbols local for -sharedXi Ruoyao4-1/+25
On LoongArch there is no reason to treat STV_PROTECTED STT_FUNC symbols as preemptible. See the comment above LARCH_REF_LOCAL for detailed explanation. Signed-off-by: Xi Ruoyao <xry111@xry111.site>
2024-07-05LoongArch: Fix bad reloc with mixed visibility ifunc symbols in shared librariesXi Ruoyao3-0/+75
With a simple test case: .globl ifunc .globl ifunc_hidden .hidden ifunc_hidden .type ifunc, %gnu_indirect_function .type ifunc_hidden, %gnu_indirect_function .text .align 2 ifunc: ret ifunc_hidden: ret test: bl ifunc bl ifunc_hidden "ld -shared" produces a shared object with one R_LARCH_NONE (instead of R_LARCH_JUMP_SLOT as we expect) to relocate the GOT entry of "ifunc". It's because the indices in .plt and .rela.plt mismatches for STV_DEFAULT STT_IFUNC symbols when another PLT entry exists for a STV_HIDDEN STT_IFUNC symbol, and such a mismatch breaks the logic of loongarch_elf_finish_dynamic_symbol. Fix the issue by reordering .plt so the indices no longer mismatch. Signed-off-by: Xi Ruoyao <xry111@xry111.site>
2024-07-05LoongArch: Reject R_LARCH_32 from becoming a runtime reloc in ELFCLASS64Xi Ruoyao3-0/+8
We were converting R_LARCH_32 to R_LARCH_RELATIVE for ELFCLASS64: $ cat t.s .data x: .4byte x .4byte 0xdeadbeef $ as/as-new t.s -o t.o $ ld/ld-new -shared t.o $ objdump -R a.out: file format elf64-loongarch DYNAMIC RELOCATION RECORDS OFFSET TYPE VALUE 00000000000001a8 R_LARCH_RELATIVE *ABS*+0x00000000000001a8 But this is just wrong: at runtime the dynamic linker will run *(uintptr *)&x += load_address, clobbering the next 4 bytes of data ("0xdeadbeef" in the example). If we keep the R_LARCH_32 reloc as-is in ELFCLASS64, it'll be rejected by the Glibc dynamic linker anyway. And it does not make too much sense to modify Glibc to support it. So we can just reject it like x86_64: relocation R_X86_64_32 against `.data' can not be used when making a shared object; recompile with -fPIC or RISC-V: relocation R_RISCV_32 against non-absolute symbol `a local symbol' can not be used in RV64 when making a shared object Signed-off-by: Xi Ruoyao <xry111@xry111.site>
2024-07-04gas: Skip SFrame FDE if CFI specifies non-FP/SP base registerJens Remus1-1/+0
Do not generate SFrame FDE if DWARF CFI directives .cfi_def_cfa or .cfi_def_cfa_register specify a CFA base register number other than the architecture-specific stack-pointer (SP) or frame-pointer (FP) register numbers. This also causes the assembler to print a warning message, so that skipping of the SFrame FDE does not occur silently. Update the generic ld SFrame test case to be architecture independent. Do not use CFI directive .cfi_def_cfa, as the specified CFA base register number is not a valid SP/FP register number on all architectures. An invalid SP/FP register number will now cause the assembler to print a warning message and skip SFrame FDE generation. Remove the offending CFI directive, that cannot be coded architecture- independent, as the test case requires SFrame information to be generated. This was reported by the Linaro-TCWG-CI for AArch64. gas/ * gen-sframe.c: Skip SFrame generation if CFI specifies non-FP/SP base register. ld/testsuite/ * ld-sframe/discard.s: Update generic SFrame test case to be architecture independent. Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-07-04readelf/objdump: Display SFrame fixed RA offset as 'f' in dumpJens Remus2-12/+12
For the SFrame FRE frame-pointer (FP) offset from CFA a 'u' is displayed if it is unavailable. For the SFrame FRE return-address (RA) offset from CFA a 'u' was displayed if the ABI uses a fixed RA offset from CFA. By chance a 'u' was also displayed if the RA offset is unavailable, as the string buffer was not initialized after formatting the FP offset. Note that it could not occur that the FP offset was erroneously displayed as RA offset, as the SFrame format cannot have a FRE with FP offset without RA offset. For the FRE RA offset display 'f' if the ABI uses a fixed RA offset from CFA. Display a 'u' if it is unavailable. libsframe/ * sframe-dump.c: Display SFrame fixed RA offset as 'f' in dump. gas/testsuite/ * gas/cfi-sframe/cfi-sframe-common-4.d: Test for RA displayed either as 'u' (if RA tracking) or as 'f' (fixed RA offset if no RA tracking). * gas/cfi-sframe/cfi-sframe-common-5.d: Likewise. * gas/cfi-sframe/cfi-sframe-common-6.d: Likewise. * gas/cfi-sframe/cfi-sframe-common-7.d: Likewise. * gas/cfi-sframe/cfi-sframe-common-8.d: Likewise. * gas/cfi-sframe/cfi-sframe-x86_64-1.d: Test for RA displayed as 'f' (fixed RA offset), as x86-64 does not use RA tracking. * gas/scfi/x86_64/scfi-cfi-sections-1.d: Likewise. * gas/scfi/x86_64/scfi-dyn-stack-1.d: Likewise. ld/testsuite/ * ld-x86-64/sframe-plt-1.d: Test for RA displayed as 'f' (fixed RA offset), as x86-64 does not use RA tracking. * ld-x86-64/sframe-simple-1.d: Likewise. Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-07-04readelf/objdump: Dump SFrame CFA fixed FP and RA offsetsJens Remus2-0/+2
The SFrame format allows architectures to specify fixed offsets from the CFA, if any, from which the frame pointer (FP) and/or return address (RA) may be recovered. These offsets are stored in the SFrame header. For instance the SFrame generation in the assembler for x86 AMD64 specifies a fixed offset from the CFA, from which the return address (RA) may be recovered. When dumping the SFrame header, for instance in readelf/objdump with option --sframe, do also dump the specified fixed offsets from the CFA, if any, from which the frame pointer (FP) and return address (RA) may be recovered. Update the common SFrame test case verification patterns to allow for the optional dumping of the CFA fixed FP/RA offsets. Update the x86- specific SFrame and SCFI test case verification patterns to require a CFA fixed RA offset of -8. libsframe/ * sframe-dump.c: Dump CFA fixed FP and RA offsets. gas/testsuite/ * gas/cfi-sframe/cfi-sframe-common-1.d: Test for optional fixed FP and RA offsets. * gas/cfi-sframe/cfi-sframe-common-2.d: Likewise. * gas/cfi-sframe/cfi-sframe-common-3.d: Likewise. * gas/cfi-sframe/cfi-sframe-common-4.d: Likewise. * gas/cfi-sframe/cfi-sframe-common-5.d: Likewise. * gas/cfi-sframe/cfi-sframe-common-6.d: Likewise. * gas/cfi-sframe/cfi-sframe-common-7.d: Likewise. * gas/cfi-sframe/cfi-sframe-common-8.d: Likewise. * gas/cfi-sframe/cfi-sframe-x86_64-1.d: Test for fixed RA offset. * gas/cfi-sframe/common-empty-1.d: Test for optional fixed FP and RA offsets. * gas/cfi-sframe/common-empty-2.d: Likewise. * gas/cfi-sframe/common-empty-3.d: Likewise. * gas/scfi/x86_64/scfi-cfi-sections-1.d: Test for SFrame fixed RA offset. * gas/scfi/x86_64/scfi-dyn-stack-1.d: Likewise. ld/testsuite/ * ld-x86-64/sframe-plt-1.d: Test for SFrame fixed RA offset. * ld-x86-64/sframe-simple-1.d: Likewise. Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-07-03x86-64: Support APX NF TLS IE with 2 operandsLingling Kong3-18/+34
Support APX NF TLS IE with 2 operands.Verify it with ld and gold. gas/ * config/tc-i386.c (md_assemble): Allow APX NF TLS IE with 2 operands. * testsuite/gas/i386/x86-64-gottpoff.d: Updated. * testsuite/gas/i386/x86-64-gottpoff.s: Add APX NF TLS IE tests with 2 operands. gold/ * testsuite/x86_64_ie_to_le.s: Add APX NF TLS IE tests with 2 operands. * testsuite/x86_64_ie_to_le.sh: Updated. ld/ * testsuite/ld-x86-64/tlsbindesc.s: Add APX NF TLS IE tests with 2 operands. * testsuite/ld-x86-64/tlsbindesc.d: Updated. * testsuite/ld-x86-64/tlsbindesc.rd: Likewise.
2024-07-01x86-64: Verify that TLS IE works with APX NFkonglin13-18/+50
Verify that {nf} add %reg1, foo@gottpoff(%rip), %reg2 {nf} add foo@gottpoff(%rip), %reg, %reg2 work correctly with ld and gold. gas/ * testsuite/gas/i386/x86-64-gottpoff.d: Updated. * testsuite/gas/i386/x86-64-gottpoff.s: Add tests for "{nf} add %reg1, foo@gottpoff(%rip), %reg2" and "{nf} add foo@gottpoff(%rip), %reg, %reg2". gold/ * testsuite/x86_64_ie_to_le.s: Add tests for "{nf} add %reg1, foo@gottpoff(%rip), %reg2" and "{nf} add foo@gottpoff(%rip), %reg, %reg2". * testsuite/x86_64_ie_to_le.sh: Updated. ld/ * testsuite/ld-x86-64/tlsbindesc.s: Add R_X86_64_CODE_6_GOTTPOFF for APX NF tests. * testsuite/ld-x86-64/tlsbindesc.d: Updated. * testsuite/ld-x86-64/tlsbindesc.rd: Likewise. Co-Authored-By: H.J. Lu <hjl.tools@gmail.com> Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-07-01ld: Move foo before delete in dl5.ccH.J. Lu1-1/+1
* testsuite/ld-elf/dl5.cc (main): Move foo before delete. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-07-01LoongArch: Remove unused code in ld test suiteXi Ruoyao2-9/+0
These seems some left over from MIPS code and they do not make any sense for LoongArch. Signed-off-by: Xi Ruoyao <xry111@xry111.site>
2024-06-30ld: Avoid folding new and delete pairsH.J. Lu3-10/+19
GCC 15 may fold new and delete pairs, like A *bb = new A[10]; delete [] bb; bb = new (std::nothrow) A [10]; delete [] bb; as shown in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115712 Avoid folding new and delete pairs by adding a function call between new and delete. * testsuite/ld-elf/dl5.cc: Include "dl5.h". (A): Removed. Call foo between new and delete. * testsuite/ld-elf/dl5.h: New file. * testsuite/ld-elf/new.cc: Include "dl5.h". (foo): New function. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-06-29ld: pass -g for ld-elf testsSam James2-2/+2
The "DWARF parse during linker error" and "Build warn libbar.so" tests require debug information. configure defaults to "-O2 -g" but if overriding *FLAGS when building tests, this might be lost. Explicitly pass -g given these tests require it. Originally reported downstream in Gentoo at https://bugs.gentoo.org/934149. ld/ * testsuite/ld-elf/dwarf.exp: Pass -g for "DWARF parse during linker error". * testsuite/ld-elf/shared.exp: Ditto for "Build warn libbar.so".
2024-06-28ld/doc: drop stray blankJan Beulich1-4/+3
Old enough tools demand no blank between @option and the opening figure brace. Re-wrap the paragraph as well while at it.
2024-06-28RISC-V: PR27180, Update relocation for riscv_zero_pcrel_hi_reloc.Nelson Chu2-0/+27
When pcrel access overflow, the riscv_zero_pcrel_hi_reloc may convert pcrel relocation to absolutly access if possible at the relocate stage. We used to encode the target address into r_sym of R_RISCV_HI20 if it is converted from R_RISCV_PCREL_HI20. But that may cause segfault if --emit-relocs is set, since r_sym becomes an address rather than a symbol index. Although the relocate result is correct, it does not meet the definition, so may cause unexpected behaviors. This patch encodes the target address into r_addend, rather than r_sym, if riscv_zero_pcrel_hi_reloc converts the relocation. Besdies, since the corresponding pcrel_lo relocation are also changed to absolutly access, we should also update them to R_RISCV_LO12_I/S. bfd/ PR 27180 * elfnn-riscv.c (riscv_pcrel_hi_reloc): New boolean `absolute', to inform corresponding pcrel_lo that the pcrel_hi relocation was already converted to hi20 relocation. (riscv_record_pcrel_hi_reloc): Likewise, record `absolute'. (riscv_pcrel_lo_reloc): Removed `const' for Elf_Internal_Rela *reloc, since we may need to convert it from pcrel_lo to lo relocation. (riscv_record_pcrel_lo_reloc): Likewise. Convert pcrel_lo to lo relocation if corresponding pcrel_hi was converted to hi relocation. (riscv_zero_pcrel_hi_reloc): Encode target absolute address into r_addend rather than r_sym. Clear the `addr' to avoid duplicate relocate in the perform_relocation. (riscv_elf_relocate_section): Updated. ld/ PR 27180 * testsuite/ld-riscv-elf/pcrel-lo-addend-3a-emit-relocs.d: New testcase. Segfault without applying this patch. * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated.
2024-06-27Improve comments describing the Import Directory TablePali Roh?r1-1/+1
PR 31728
2024-06-27Fix new libdep test so that if the plugin cannot be located the test fails ↵Nick Clifton1-3/+4
gracefully.
2024-06-26Revert: 35fd2ddeb1d90f1750401cfb6d01fe055656b88dNick Clifton12-33/+248
PR 20814
2024-06-25Revert 4ee1d7e401a8c1aedfdc86aac7faa8267eab1e5cNick Clifton1-9/+2
PR 20880
2024-06-25aarch64: Add DT_RELR tests for ILP32 ABISzabolcs Nagy5-0/+165
2024-06-25aarch64: Add DT_RELR support for ILP32 ABISzabolcs Nagy2-0/+4
Extend the 64bit DT_RELR support to work on 32bit ELF too. For this only a few changes were needed in the sizing and creation of the relr relocations.
2024-06-24libdep plugin: fix bugs in parser and drop escapingHarmen Stoppels1-94/+80
PR ld/31906 * libdep_plugin.c (str2vec): Fix bug where null byte was not copied on memmove during quote handling and escaping, causing repeat of the last character in the last argument. Fix buffer overflow in **res when arguments were separated by `\t` instead of ` `. Remove handling of the escape character `\`, as it made it impossible to specify paths containing `\` -- the implementation merely dropped `\`, and was affected by the memmove bug, so this should not be breaking; just single and double quotes are sufficient to deal with white space and quote characters, there is no need for escaping. Handle syntax errors on unterminated quotes. Make the parser linear time instead of quadratic.