aboutsummaryrefslogtreecommitdiff
path: root/ld
AgeCommit message (Collapse)AuthorFilesLines
2023-02-11objdump -D of bss sections and -s with -jAlan Modra13-56/+53
There is some inconsistency between the behaviour of objdump -D and objdump -s, both supposedly operating on all sections by default. objdump -s ignores bss sections, while objdump -D dissassembles the zeros. Fix this by making objdump -D ignore bss sections too. Furthermore, "objdump -s -j .bss" doesn't dump .bss as it should, since the user is specifically asking to look at all those zeros. This change does find some tests that used objdump -D with expected output in bss-style sections. I've updated all the msp430 tests that just wanted to find a non-empty section to look at section headers instead, making the tests slightly more stringent. The ppc xcoff and spu tests are fixed by adding -j options to objdump, which makes the tests somewhat more lenient. binutils/ * objdump.c (disassemble_section): Ignore sections without contents, unless overridden by -j. (dump_section): Allow -j to override the default of not displaying sections without contents. * doc/binutils.texi (objdump options): Update -D, -s and -j description. gas/ * testsuite/gas/ppc/xcoff-tls-32.d: Select wanted objdump sections with -j. * testsuite/gas/ppc/xcoff-tls-64.d: Likewise. ld/ * testsuite/ld-msp430-elf/main-bss-lower.d, * testsuite/ld-msp430-elf/main-bss-upper.d, * testsuite/ld-msp430-elf/main-const-lower.d, * testsuite/ld-msp430-elf/main-const-upper.d, * testsuite/ld-msp430-elf/main-text-lower.d, * testsuite/ld-msp430-elf/main-text-upper.d, * testsuite/ld-msp430-elf/main-var-lower.d, * testsuite/ld-msp430-elf/main-var-upper.d: Expect -wh output. * testsuite/ld-msp430-elf/msp430-elf.exp: Use objdump -wh rather than objdump -D or objdump -d with tests checking for non-empty given sections. * testsuite/ld-spu/ear.d, * testsuite/ld-spu/icache1.d, * testsuite/ld-spu/ovl.d, * testsuite/ld-spu/ovl2.d: Select wanted objdump sections.
2023-02-10RISC-V: Reduce effective linker relaxation passsesTsukasa OI1-1/+1
Commit 43025f01a0c9 ("RISC-V: Improve link time complexity.") reduced the time complexity of the linker relaxation but some code portions did not reflect this change. This commit fixes a comment describing each relaxation pass and reduces actual number of passes for the RISC-V linker relaxation from 3 to 2. Though it does not change the functionality, it marginally improves the performance while linking large programs (with many relocations). bfd/ChangeLog: * elfnn-riscv.c (_bfd_riscv_relax_section): Fix a comment to reflect current roles of each relaxation pass. ld/ChangeLog: * emultempl/riscvelf.em: Reduce the number of linker relaxation passes from 3 to 2.
2023-02-06ppc32 and "LOAD segment with RWX permissions"Alan Modra2-0/+10
When using a bss-plt we'll always trigger the RWX warning, which disturbs gcc test results. On the other hand, there may be reason to want the warning when gcc is configured with --enable-secureplt. So turning off the warning entirely for powerpc might not be the best solution. Instead, we'll turn off the warning whenever a bss-plt is generated, unless the user explicitly asked for the warning. bfd/ * elf32-ppc.c (ppc_elf_select_plt_layout): Set no_warn_rwx_segments on generating a bss plt, unless explicity enabled by the user. Also show the bss-plt warning when --warn-rwx-segments is given without --bss-plt. include/ * bfdlink.h (struct bfd_link_info): Add user_warn_rwx_segments. ld/ * lexsup.c (parse_args): Set user_warn_rwx_segments. * testsuite/ld-elf/elf.exp: Pass --secure-plt for powerpc to the rwx tests.
2023-02-06[PR 30082] Pass $JANSSON_LIBS and $ZSTD_LIBS to ld-bootstrap/bootrap.expRomain Geissler3-2/+4
2023-02-04ld: pru: Add optional section alignmentsDimitar Dimitrov1-3/+11
The Texas Instruments SoCs with AARCH64 host processors have stricter alignment requirements than ones with ARM32 host processors. It's not only the requirement for resource_table to be aligned to 8. But also any loadable segment size must be a multiple of 4 [1]. The current PRU default linker script may output a segment size not aligned to 4, which would cause firmware load failure on AARCH64 hosts. Fix this by using COMMONPAGESIZE and MAXPAGESIZE to signify respectively the section memory size requirement and the resource table section's start address alignment. This would avoid penalizing the ARM32 hosts, for which the default values (1 and 1) are sufficient. For AARCH64 hosts, the alignments would be overwritten from GCC spec files using the linker command line, e.g.: -z common-page-size=4 -z max-page-size=8 [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/remoteproc/pru_rproc.c?h=v6.1#n555 ld/ChangeLog: * scripttempl/pru.sc (_data_end): Remove the alignment. (.data): Align output section size to COMMONPAGESIZE. (.resource_table): Ditto. Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2023-02-04ld: pru: Merge the bss input sections into dataDimitar Dimitrov2-11/+15
The popular method to load PRU firmware is through the remoteproc Linux kernel driver. In order to save a few bytes from the firmware, the PRU CRT0 is spared from calling memset for the bss segment [1]. Instead the host loader is supposed to zero out the bss segment. This is important for PRU, which typically has only 8KB for instruction memory. The legacy non-mainline PRU host driver relied on the default behaviour of the kernel core remoteproc [2]. That default is to zero out the loadable memory regions not backed by file storage (i.e. the bss sections). This worked for the libgloss' CRT0. But the PRU loader merged in mainline Linux explicitly changes the default behaviour [3]. It no longer is zeroing out memory regions. Hence the bss sections are not initialized - neither by CRT0, nor by the host loader. This patch fixes the issue by aligning the GNU LD default linker script with the mainline Linux kernel expectation. Since the mainline kernel driver is submitted by the PRU manufacturer itself (Text Instruments), we can consider that as defining the ABI. This change has been tested on Beaglebone AI-64 [4]. Static counter variables in the firmware are now always starting from zero, as expected. There was only one new toolchain test failure in orphan3.d, due to reordering of the output sections. I believe this is a harmless issue. I could not rewrite the PASS criteria to ignore the output section ordering, so I have disabled that test case for PRU. [1] https://sourceware.org/git/?p=newlib-cygwin.git;a=blob;f=libgloss/pru/crt0.S;h=b3f0d53a93acc372f461007553e7688ca77753c9;hb=HEAD#l40 [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/remoteproc/remoteproc_elf_loader.c?h=v6.1#n228 [3] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/remoteproc/pru_rproc.c?h=v6.1#n641 [4] https://beagleboard.org/ai-64 ld/ChangeLog: * scripttempl/pru.sc (.data): Merge .bss input sections into the .data output section. * testsuite/ld-elf/orphan3.d: Disable for PRU. Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
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