summaryrefslogtreecommitdiff
path: root/ld
Commit message (Collapse)AuthorAgeFilesLines
...
* Build ldintUlf Samuelsson2023-03-072-8/+61
| | | | Signed-off-by: Ulf Samuelsson <ulf@emagii.com>
* DIGEST: Makefile.*Ulf Samuelsson2023-03-072-0/+18
| | | | | | | | | | | | | | The Makefile.in was generated using automake after adding a few files. When adding the ldreflect.* files, the autotools versions were wrong. After upgrading the host OS, autotools were upgraded to 2.71 reinstalling the desired 2.69 still generates a lot of changes. Makefile.ini has therefore been manually edited. Signed-off-by: Ulf Samuelsson <ulf@emagii.com>
* DIGEST: calculationUlf Samuelsson2023-03-077-0/+1717
| | | | Signed-off-by: Ulf Samuelsson <ulf@emagii.com>
* DIGEST: ldlang.*: add timestampUlf Samuelsson2023-03-072-0/+10
| | | | Signed-off-by: Ulf Samuelsson <ulf@emagii.com>
* DIGEST: ldmain.cUlf Samuelsson2023-03-071-0/+2
| | | | Signed-off-by: Ulf Samuelsson <ulf@emagii.com>
* DIGEST: ldgram.yUlf Samuelsson2023-03-071-1/+60
| | | | Signed-off-by: Ulf Samuelsson <ulf@emagii.com>
* DIGEST: ldlex.lUlf Samuelsson2023-03-071-0/+7
| | | | Signed-off-by: Ulf Samuelsson <ulf@emagii.com>
* DIGEST: testsuiteUlf Samuelsson2023-03-0757-0/+1411
| | | | Signed-off-by: Ulf Samuelsson <ulf@emagii.com>
* DIGEST: DocumentationUlf Samuelsson2023-03-071-4/+494
| | | | Signed-off-by: Ulf Samuelsson <ulf@emagii.com>
* DIGEST: NEWSUlf Samuelsson2023-03-071-4/+73
| | | | Signed-off-by: Ulf Samuelsson <ulf@emagii.com>
* DIGEST: LICENSINGUlf Samuelsson2023-03-072-0/+70
| | | | Signed-off-by: Ulf Samuelsson <ulf@emagii.com>
* Prevent the ASCII linker script directive from generating huge amounts of ↵Nick Clifton2023-03-032-1/+9
| | | | | | padding if the size expression is not a constant. PR 30193 * ldgram.y (ASCII): Fail if the size is not a constant.
* Fix typo with my email addressNick Clifton2023-03-011-1/+1
|
* ld: Sort section contributions in PDB filesMark Harmstone2023-02-282-22/+66
| | | | | | Microsoft's DIA library, and thus also MSVC and WinDbg, expects section contributions to be ordered by section number and offset, otherwise it's unable to resolve line numbers.
* testsuite: prune DOS drive letter in test outputsClément Chigot2023-02-241-2/+2
| | | | | | | | | | | | | | | | | | | | | | On DOS systems, absolute paths start with the drive letter. This can trigger failures in the regexp from dump tests, especially for those checking for warnings or errors. They are usually skipping everything before the first ":" as it has to be the file path. | [^:]*: warning: ... In order to avoid modifying many regexps to allow such drive letters, prune them from all the outputs if they are found at the beginning of a line. binutils/ChangeLog: * testsuite/lib/binutils-common.exp (prune_dump_output): New (run_dump_test): Use it. ld/ChangeLog: * testsuite/ld-elf/noinit-sections-2.l: Remove DOS drive letter handler.
* PR30155, ld segfault in _bfd_nearby_sectionAlan Modra2023-02-241-13/+52
| | | | | | | | | | | | | | | | | The segfault was a symptom of messing with the absolute section next field, confusing bfd_section_removed_from_list in linker.c:fix_syms. That's not all that was going wrong. The INSERT list of output sections was being inserted into itself, ie. lost from the main list of linker statements. PR 30155 * ldlang.c (process_insert_statements): Handle pathological case of the insert script being inserted before the first output section statement in the default script. (output_prev_sec_find): Don't test section owner here. (insert_os_after): Change parameter to a list union pointer. (lang_insert_orphan): Test section owner here and adjust insert_os_after call.
* RISC-V: Add --[no-]relax-gp to ldFangrui Song2023-02-236-1/+69
| | | | | | | | | | | | | | | | | | | | | | | | | --relax enables all relaxations. --no-relax-gp disables GP relaxation to allow measuring its effect. The option can test effectiveness of GP relaxation and support some ABI variants that use GP for other purposes. Link: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/issues/298 bfd/ * elfnn-riscv.c (struct riscv_elf_link_hash_table): Add params. (riscv_elfNN_set_options): New. (riscv_info_to_howto_rela): Check relax_gp. (_bfd_riscv_relax_section): Likewise. * elfxx-riscv.h (struct riscv_elf_params): New. (riscv_elf32_set_options): New. (riscv_elf64_set_options): New. ld/ * emultempl/riscvelf.em: Add option parsing. * testsuite/ld-riscv-elf/code-model-relax-medlow-01-norelaxgp.d: New. * testsuite/ld-riscv-elf/pcgp-relax-01-norelaxgp.d: New. * testsuite/ld-riscv-elf/pcgp-relax-02.d: Test --relax --relax-gp can be used together.
* bfd: xtensa: fix __stop_SECTION literal dropAlexey Lapshin2023-02-234-0/+30
|
* ld/testsuite: don't output to /dev/nullClément Chigot2023-02-211-1/+3
| | | | | | | | | | | | Mingw doesn't have /dev/null and thus "-o /dev/null" will fail. Currently, all the options are checked using this "-o /dev/null", resulting in them being disabled on mingw hosts. Fix that by outputting to a real file for all targets. ld/ChangeLog: * testsuite/config/default.exp: Replace "-o /dev/null" by a file.
* Both FAIL and PASS "check sections 2"?Alan Modra2023-02-211-9/+10
| | | | | * testsuite/ld-checks/checks.exp (check sections 2): Don't continue on with rest of test past first fail.
* ld-libs test on alpha-vmsAlan Modra2023-02-211-0/+5
| | | | * testsuite/ld-libs/libs.exp: Don't run for alpha-vms.
* alpha-*-vms missing librariesAlan Modra2023-02-211-1/+1
| | | | | | | | | | | | | | | | For this: ./ld-new: cannot find -limagelib: No such file or directory ./ld-new: cannot find -lstarlet: No such file or directory ./ld-new: cannot find -lsys$public_vectors: No such file or directory the logs showed creating dummy tmpdir/libimagelib: creating dummy No creating dummy such etc. So rubbish instead of tmpdir/libimagelib.a and the other required libs. * testsuite/config/default.exp: Correct regex detecting missing libraries automatically searched by alpha-dec-vms-ld.
* ld/testsuite: handle Windows drive letter in a noinit testClément Chigot2023-02-201-2/+2
| | | | | | | | | | | The regexp in "noinit sections (ld -r)" is skipping the file path before the first ":". However, on Windows, a path can start with "C:". Adjust the regexp to allow such cases. ld/ChangeLog: * testsuite/ld-elf/noinit-sections-2.l: Allow Windows paths (starting with C:).
* ld/testsuite: adjust to Windows path separator.Clément Chigot2023-02-207-7/+7
| | | | | | | | | | | | | | | | In some tests, the path reported on Windows will have a \ instead of a /. This occurs when a file is concatened with the search path in ldfile.c.: "ld -Ltmpdir -ltext" will result into "tmpdir\libtext.a". ld/ChangeLog: * testsuite/ld-elf/retain5.map: Allow \ path separator. * testsuite/ld-plugin/plugin-10.d: Likewise. * testsuite/ld-plugin/plugin-11.d: Likewise. * testsuite/ld-plugin/plugin-18.d: Likewise. * testsuite/ld-plugin/plugin-19.d: Likewise. * testsuite/ld-plugin/plugin-20.d: Likewise. * testsuite/ld-plugin/plugin-22.d: Likewise.
* So the linker from producing an export data table when run with ↵Nick Clifton2023-02-202-1/+8
| | | | | | --exclude-all-symbols. PR 30004 * pe-dll.c (pe_dll_build_sections): Do not build an edata section if all symbols are being excluded.
* ld test asciz and ascii failsAlan Modra2023-02-172-5/+5
| | | | | | | | | | | | | | | | | | | Fix these fails: alpha-dec-vms +FAIL: ld-scripts/asciz alpha-dec-vms +FAIL: ld-scripts/ascii i386-go32 +FAIL: ld-scripts/asciz sh-coff +FAIL: ld-scripts/asciz It's better to positively select targets for .section support than to try to exclude all targets that don't. Make a new is_coff_format so we can easily select such. binutils/ * testsuite/lib/binutils-common.exp (is_coff_format): New. ld/ * testsuite/ld-scripts/ascii.d: Use is_elf_format and is_coff_format to select targets, exclude ti coff. * testsuite/ld-scripts/asciz.d: Likewise. Accept trailing zeros.
* Add support for the ASCII directive inside linker scripts.Nick Clifton2023-02-1613-59/+221
| | | | | | | | | | | | | | | * ldlex.l: Add ASCII token. * ldgram.y: Add parsing of the ASCII command. * ldlang.c (lang_add_string): Add maximum size parameter. Move escape character handling code into separate function. * ldlang.h (lang_add_string): Update prototype. * NEWS: Mention the new feature. * ld.texi (Output Section Data): Document the new directives. * testsuite/ld-scripts/asciz.t: Adjust to work on more architectures and to test more aspects of the ASCIZ directive. * testsuite/ld-scripts/asciz.d: Adjust to match the changes to the test linker script. * testsuite/ld-scripts/ascii.d: New test driver. * testsuite/ld-scripts/ascii.s: New test assembler source. * testsuite/ld-scripts/ascii.t: New test script. * testsuite/ld-scripts/script.exp: Run the new test.
* Delete PROGRESS macrosAlan Modra2023-02-161-5/+0
| | | | | | | | | | | | | | | | | | | | | I don't see much point in cluttering the source with the PROGRESS macros, which of course do nothing at all with the definitions in progress.h. progress.h is unchanged apart from the copyright comment since commit d4d4c53c68f0 in 1994. binutils/ * ar.c: Don't include progress.h, or invoke PROGRESS macros. * nm.c: Likewise. * objcopy.c: Likewise. * objdump.c: Likewise. gas/ * as.h: Don't include progress.h. * as.c: Don't invoke PROGRESS macros. * write.c: Likewise. include/ * progress.h: Delete. ld/ * ldmain.c: Don't include progress.h, or invoke PROGRESS macros.
* Fix the linker's merge4 test for the HPPA architecture.Nick Clifton2023-02-152-5/+12
| | | | PR 30078 * testsuite/ld-elf/merge4b.s: Use .asciz instead of .string in order to avoid the special behaviour of the .string directive on HPPA architectures.
* Mention that the -plugin command line option is used to load plugins.Nick Clifton2023-02-142-0/+8
|
* ASCIZ Command for output sectionUlf Samuelsson2023-02-1410-3/+157
| | | | | Adds a new directive to the linker script syntax: ASCIZ. This inserts a zero-terminated string into the output at the place where it is used.
* Fix PR30079: abort on mingwMichael Matz2023-02-131-1/+2
| | | | | | | | the early-out in wild_sort is not enough, it might still be that filenames are equal _and_ the wildcard list doesn't specify a sort order either. Don't call compare_section then. Tested on all targets.
* objdump -D of bss sections and -s with -jAlan Modra2023-02-1113-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.
* RISC-V: Reduce effective linker relaxation passsesTsukasa OI2023-02-101-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.
* ppc32 and "LOAD segment with RWX permissions"Alan Modra2023-02-062-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.
* [PR 30082] Pass $JANSSON_LIBS and $ZSTD_LIBS to ld-bootstrap/bootrap.expRomain Geissler2023-02-063-2/+4
|
* ld: pru: Add optional section alignmentsDimitar Dimitrov2023-02-041-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>
* ld: pru: Merge the bss input sections into dataDimitar Dimitrov2023-02-042-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>
* ld/doc: use "stack trace" instead of "unwind" for SFrameIndu Bhagat2023-02-021-1/+1
| | | | | | | SFrame format is meant for generating stack traces only. ld/ * ld.texi: Replace the use of "unwind" with "stack trace".
* ld-elf/merge test updateAlan Modra2023-02-027-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.
* Re: Another fix for EFI generation with LTO enabledAlan Modra2023-01-312-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.
* testsuite XPASSesAlan Modra2023-01-315-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.
* Another fix for EFI generation with LTO enabled.Nick Clifton2023-01-272-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.
* Call bfd_close_all_done in ld_cleanupAlan Modra2023-01-273-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.
* ld/testsuite: Add missing targets to PDB testsMark Harmstone2023-01-251-1/+7
|
* ld: Add pdb support to aarch64-w64-mingw32Mark Harmstone2023-01-2516-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.
* i386: Pass -Wl,--no-as-needed to compiler as neededH.J. Lu2023-01-251-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.
* Fix seg-fault when generating an empty DLL with LTO enabled.Nick Clifton2023-01-242-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.
* ld: Avoid magic numbers for subsystems in pe.em and pep.emMark Harmstone2023-01-242-6/+6
|
* ld: Set default subsystem for arm-pe to IMAGE_SUBSYSTEM_WINDOWS_GUIMark Harmstone2023-01-231-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.