aboutsummaryrefslogtreecommitdiff
path: root/ld
AgeCommit message (Collapse)AuthorFilesLines
2023-02-02ld/doc: use "stack trace" instead of "unwind" for SFrameIndu Bhagat1-1/+1
SFrame format is meant for generating stack traces only. ld/ * ld.texi: Replace the use of "unwind" with "stack trace".
2023-02-02ld-elf/merge test updateAlan Modra7-35/+27
The merge test fais on numerous targets because they don't support the necessary pc-relative relocs. This patch removes that part of the merge test, and makes references to the merged strings from .data rather than .text to better support targets that relax text by default.
2023-01-31Re: Another fix for EFI generation with LTO enabledAlan Modra2-16/+2
Revert 1c66b8a03989 and instead fix the broken list pointer. PR 29998 * pe-dll.c (build_filler_bfd): Revert last change. * ldlang.c (lang_process): When rescanning archives for lto, fix file_chain.tail pointer if the insert point happens to be at the end of the list.
2023-01-31testsuite XPASSesAlan Modra5-10/+12
This adjusts the testsuite to get rid of a number of XPASSes that have appeared. Someone might like to look into a better patch for the s390 change. aarch64-pe XPASS: weak symbols arm-nacl XPASS: rgn-over8 mcore-pe XPASS: ld-scripts/provide-8 mips64-linux-gnuabi64 XPASS: vers4 mips64-linux-gnuabi64 XPASS: vers4b mips-linux-gnu XPASS: vers4 mips-linux-gnu XPASS: vers4b s390-linux-gnu XPASS: undefined line sh4-linux-gnu XPASS: --gc-sections with __start_SECTIONNAME sh-coff XPASS: objcopy object (simple copy) sh-coff XPASS: objcopy executable (pr25662) binutils/ * testsuite/binutils-all/objcopy.exp: Don't xfail "simple copy" and "pr25662" on sh-*-coff. Remove all non-ELF xfails on "ELF unknown section type" test. ld/ * testsuite/ld-elfvers/vers.exp (vers4, vers4b): Don't xfail all mips, just xfail mips irix. * testsuite/ld-gc/pr19161.d: Don't xfail sh. * testsuite/ld-scripts/rgn-over8-ok.d: Don't xfail nacl. * testsuite/ld-scripts/weak.exp: Don't xfail aarch64-pe. * testsuite/ld-undefined/undefined.exp: Conditionally xfail "undefined line" depending on gcc version for s390.
2023-01-27Another fix for EFI generation with LTO enabled.Nick Clifton2-11/+33
PR 29998 * pe-dll.c (build_filler_bfd): Initialise the next field of the filler input statement, so that it does not break the file chain.
2023-01-27Call bfd_close_all_done in ld_cleanupAlan Modra3-42/+57
This is similar to "Call bfd_close_all_done in output_file_close", but with some code tidying in the pe/pep write_build_id functions. write_build_id is passed the output bfd as its parameter, so there is no need to go looking for the output bfd via link_info (and doing so will no longer work since I clear link_info.output_bfd before calling bfd_close). * emultempl/pe.em (write_build_id): Rename t to td. Formatting. Don't access pe_data(link_info.output_bfd), use td instead. (setup_build_id): Rename t to td. Formatting. * emultempl/pep.em: As for pe.em. * ldmain.c (ld_cleanup): Call bfd_close_all_done on linker bfds. (main): Clear link_info.output_bfd when closing.
2023-01-25ld/testsuite: Add missing targets to PDB testsMark Harmstone1-1/+7
2023-01-25ld: Add pdb support to aarch64-w64-mingw32Mark Harmstone16-900/+917
This extends PDB support to the aarch64 PE targets. The changes to the test files are just to make it so they can be assembled as either x86, x86_64, or aarch64, mainly by changing the comment style. The only actual code change here is in adding the architecture constants to pdb.c.
2023-01-25i386: Pass -Wl,--no-as-needed to compiler as neededH.J. Lu1-3/+4
Pass -Wl,--no-as-needed to linker tests to fix FAIL: Run pr19031 FAIL: Run got1 FAIL: Undefined weak symbol (-fPIE -no-pie) FAIL: Undefined weak symbol (-fPIE -pie) when --as-needed is passed to linker by compiler. PR ld/30050 * testsuite/ld-i386/i386.exp: Pass -Wl,--no-as-needed to compiler as needed.
2023-01-24Fix seg-fault when generating an empty DLL with LTO enabled.Nick Clifton2-22/+51
ld PR 29998 * pe-dll.c (generate_reloc): Handle sections with no assigned output section. Terminate early of there are no relocs to put in the .reloc section. (pe_exe_fill_sections): Do not emit an empty .reloc section. bfd * cofflink.c (_bfd_coff_generic_relocate_section): Add an assertion that the output section is set for defined, global symbols.
2023-01-24ld: Avoid magic numbers for subsystems in pe.em and pep.emMark Harmstone2-6/+6
2023-01-23ld: Set default subsystem for arm-pe to IMAGE_SUBSYSTEM_WINDOWS_GUIMark Harmstone1-1/+4
This fixes the test failures introduced by 87a5cf5c, by changing the default subsystem for arm-pe from 9 (IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) to 2 (IMAGE_SUBSYSTEM_WINDOWS_GUI), which matches what happens with other PE targets. As far as I can tell there's no working modern Windows CE toolchain knocking about anyway, so this change shouldn't inconvenience anyone.
2023-01-23Add support for secidx relocations to aarch64-w64-mingw32Mark Harmstone2-0/+29
This patch adds support for the .secidx directive and its corresponding relocation to aarch64-w64-mingw32. As with x86, this is a two-byte LE integer which gets filled in with the 1-based index of the output section that a symbol ends up in. This is needed for PDBs, which represent addresses as a .secrel32, .secidx pair. The test is substantially the same as for amd64, but with changes made for padding and alignment.
2023-01-20Add testcase ld-elf/merge4Michael Matz4-0/+55
to check a situation that once failed with the new section merging when it mishandled offsets pointing into alignment padding in mergable string sections (i.e. pointing to zeros). It made bootstrap.exp fail but that depends on many factors to actually go wrong so this is a more explicit variant of it.
2023-01-20arm32: Fix rodata-merge-mapMichael Matz2-4/+4
the test expects a second, but useless, $d mapping symbol for the partially merged section, and specifically disallows one for the completely merged section. The new merging algorithm makes it so that also the partially merged sections are conceptually SEC_EXCLUDED, except the first merge section (e.g. as if the very first object file already contains all strings). So that second mapping symbol is now missing. It never was needed anyway. So, adjust the test.
2023-01-16Correct ld-pe/aarch64.d test outputAlan Modra1-12/+12
"foo" is at 0x2010. This corrects the expected output for .long and .word referencing foo, showing a problem with relocation handling. * testsuite/ld-pe/aarch64.d: Correct expected output.
2023-01-12ld/testsuite: Adjust for ELF_MAXPAGESIZE 0x1000Hans-Peter Nilsson7-29/+32
Many tests reflect a setting of ELF_MAXPAGESIZE to 64 KiB. With ELF_MAXPAGESIZE changed to 4 KiB, layout is sometimes different and symbols end up in other places. Avoid churn and regexpification of old test patterns by passing the max-page-size setting active at the time. ld/testsuite: * testsuite/ld-arm/arm-elf.exp, testsuite/ld-arm/non-contiguous-arm2.d, testsuite/ld-arm/non-contiguous-arm3.d, testsuite/ld-arm/non-contiguous-arm5.d, testsuite/ld-arm/non-contiguous-arm6.d, testsuite/ld-arm/thumb-plt-got.d, testsuite/ld-arm/thumb-plt.d: Pass -z max-page-size=0x10000 explicitly to test that rely on that value in output-matching patterns.
2023-01-12Use __func__ rather than __FUNCTION__Alan Modra3-10/+10
We already use C99's __func__ in places, use it more generally. This patch doesn't change uses in the testsuite. I've also left one in gold.h that is protected by GCC_VERSION < 4003. If any of the remaining uses bothers anyone I invite patches. bfd/ * bfd-in.h: Replace __FUNCTION__ with __func__. * elf32-bfin.c: Likewise. * elfnn-aarch64.c: Likewise. * elfxx-sparc.c: Likewise. * bfd-in2.h: Regenerate. gas/ * config/tc-cris.c: Replace __FUNCTION__ with __func__. * config/tc-m68hc11.c: Likewise. * config/tc-msp430.c: Likewise. gold/ * dwp.h: Replace __FUNCTION__ with __func__. * gold.h: Likewise, except for use inside GCC_VERSION < 4003. ld/ * emultempl/pe.em: Replace __FUNCTION__ with __func__. * emultempl/pep.em: Likewise. * pe-dll.c: Likewise.
2023-01-11Fix XPASS weak symbols on x86_64-mingw32Alan Modra1-10/+11
Fixes commit 16fea92ccd99. * testsuite/ld-scripts/weak.exp: Don't xfail x86_64 PE targets. Do xfail other PE OS triplets by moving code setting xfails.
2023-01-10Add aarch64-w64-mingw32 targetMark Harmstone6-15/+28
This adds a mingw target for aarch64, including windres and dlltool. Note that the old value of jmp_aarch64_bytes was wrong, and this does the same thing as MSVC does.
2023-01-10Add .secrel32 for pe-aarch64Mark Harmstone1-0/+2
Adds the .secrel32 pseudo-directive and its corresponding relocation.
2023-01-10Add pe-aarch64 relocationsMark Harmstone4-2/+333
This adds the remaining pe-aarch64 relocations, and gets them working. It also brings in the constant directives from ELF, as otherwise .word would be 2 rather than 4 bytes, and .xword and .dword wouldn't be defined.
2023-01-10IBM zSystems: Fix offset relative to static TLSStefan Schulze Frielinghaus2-0/+20
For local exec TLS relocations of the form foo@NTPOFF+x the addend was ignored. bfd/ChangeLog: * elf32-s390.c (elf_s390_relocate_section): Honor addend for R_390_TLS_LE32. * elf64-s390.c (elf_s390_relocate_section): Honor addend for R_390_TLS_LE64. ld/ChangeLog: * testsuite/ld-s390/reloctlsle-1.d: New test. * testsuite/ld-s390/reloctlsle-1.s: New test.
2023-01-09Skip ld/pr23169 test on arm.Christophe Lyon1-3/+4
The test is already skipped on several targets (including AArch64) because it's invalid. * testsuite/ld-ifunc/ifunc.exp: Skip pr23169 on arm.
2023-01-09Fix PR18841 ifunc relocation orderingChristophe Lyon3-39/+39
In order to get the ifunc relocs properly sorted the correct class needs to be returned. The code mimics what has been done for AArch64. Fixes: FAIL: Run pr18841 with libpr18841b.so FAIL: Run pr18841 with libpr18841c.so FAIL: Run pr18841 with libpr18841bn.so (-z now) FAIL: Run pr18841 with libpr18841cn.so (-z now) bfd/ PR ld/18841 * elf32-arm.c (elf32_arm_reloc_type_class): Return reloc_class_ifunc for ifunc symbols. ld/testsuite/ * ld-arm/ifunc-12.rd: Update relocations order. * ld-arm/ifunc-3.rd: Likewise. * ld-arm/ifunc-4.rd: Likewise.
2023-01-06ld: yet another PDB build fix (or workaround)Jan Beulich2-16/+24
Older bash looks to improperly deal with backslashes in here-documents, leaving them in place on the escaped double quotes inside the parameter expansion. Convert to a model without using such a construct, by simply splitting the here-documents into three ones.
2023-01-06Updated Bulgarian and Russian translations for LD and BFD respectivelyNick Clifton2-2332/+2921
2023-01-06Tidy pe flag in coff_dataAlan Modra3-3/+3
Make it a bool, use obj_pe accessor everywhere.
2023-01-05Add an extra emulation called arm64pe to the aarch64pe emulation.Nick Clifton8-141/+175
2023-01-05Un xfail the PR19719 test for the AArch64 architectureAndreas K. Huettel2-1/+6
2023-01-04Re: Avoid unaligned pointer reads in PEP .idata sectionAlan Modra3-50/+50
Fix testsuite fallout. * testsuite/ld-pe/cfi.d: Adjust for changed .idata padding. * testsuite/ld-pe/secidx_64.d: Likewise. * testsuite/ld-pe/secrel_64.d: Likewise.
2023-01-04Fix AArch64 linker testsuite failures trigeered by differences in build ↵Andreas K. Huettel3-5/+12
environments. PR 29843 * testsuite/ld-aarch64/bti-plt-5.d: Relax regxps slightly to allow for differences in build environments. * testsuite/ld-aarch64/tls-relax-gdesc-le-now.d: Likewise.
2023-01-04Avoid unaligned pointer reads in PEP .idata sectionMark Harmstone1-0/+1
This is something I discovered when working on aarch64, though it's relevant to x86_64 too. The PE32+ imports are located in the .idata section, which starts off with a 20-byte structure for each DLL, containing offsets into the rest of the section. This is the Import Directory Table in https://learn.microsoft.com/en-us/windows/win32/debug/pe-format, which is a concatenation of the .idata$2 sections. This is then followed by an 20 zero bytes generated by the linker script, which calls this .idata$3. After this comes the .idata$4 entries for each function, which the loader overwrites with the function pointers. Because there's no padding between .idata$3 and .idata$4, this means that if there's an even number of DLLs, the function pointers won't be aligned on an 8-byte boundary. Misaligned reads are slower on x86_64, but this is more important on aarch64, as the e.g. `ldr x0, [x0, :lo12:__imp__func]` the compiler might generate requires __imp__func (the .idata$4 entry) to be aligned to 8 bytes. Without this you get IMAGE_REL_ARM64_PAGEOFFSET_12L overflow errors.
2023-01-03Updated translations for various languages and sub-directoriesNick Clifton2-1986/+2505
2023-01-02obsolete target tidyAlan Modra10-31/+6
Delete a few files only used for obsolete targets, and tidy config, xfails and other pieces of support specific to those targets. And since I was editing target triplets in test files, fix the nm alpha-linuxecoff fails.
2023-01-01Update year range in copyright notice of binutils filesAlan Modra349-557/+557
The newer update-copyright.py fixes file encoding too, removing cr/lf on binutils/bfdtest2.c and ld/testsuite/ld-cygwin/exe-export.exp, and embedded cr in binutils/testsuite/binutils-all/ar.exp string match.
2022-12-31Update version number and regenerate filesNick Clifton2-2082/+2624
2022-12-31Add markers for 2.40 branchNick Clifton2-0/+6
2022-12-31ld/testsuite: Don't add index to sizes in pdb.expMark Harmstone1-3/+3
2022-12-31ld: Handle LF_VFTABLE types in PDBsMark Harmstone6-4/+73
2022-12-31ld: Handle extended-length data structures in PDB typesMark Harmstone6-28/+344
A few fixes to minor issues I've discovered in my PDB patches. * If sizes or offsets are greater than 0x8000, they get encoded as extended values in the same way as for enum values - e.g. a LF_ULONG .short followed by a .long. * I've managed to coax MSVC to produce another type, LF_VFTABLE, which is seen when dealing with COM. I don't think LLVM emits this. Note that we can't just implement everything in Microsoft's header files, as most of it is obsolete. * Fixes a stupid bug in the test program, where I was adding an index to a size. The index was hard-coded to 0, so this didn't cause any actual issues.
2022-12-27x86-64: Allocate input section memory if neededH.J. Lu1-0/+17
When --no-keep-memory is used, the input section memory may not be cached. Allocate input section memory for -z pack-relative-relocs if needed. bfd/ PR ld/29939 * elfxx-x86.c (elf_x86_size_or_finish_relative_reloc): Allocate input section memory if needed. ld/ PR ld/29939 * testsuite/ld-elf/dt-relr-2i.d: New test.
2022-12-26Add support for x86_64-*-gnu-* targets to build x86_64 gnumach/hurdFlavio Cruz1-0/+5
2022-12-23ld: Write linker symbols in PDBMark Harmstone3-34/+327
2022-12-23ld: Copy other symbols into PDB fileMark Harmstone5-0/+1076
2022-12-23ld: Write globals stream in PDBMark Harmstone9-40/+2230
2022-12-23ld: Parse LF_UDT_SRC_LINE records when creating PDB fileMark Harmstone8-10/+459
2022-12-23ld: Write types into IPI stream of PDBMark Harmstone8-18/+699
2022-12-23ld: Write types into TPI stream of PDBMark Harmstone8-22/+2270
2022-12-23ld: Write DEBUG_S_LINES entries in PDB fileMark Harmstone5-6/+204