aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-scripts
AgeCommit message (Collapse)AuthorFilesLines
2023-08-022.41 Release sourcesbinutils-2_41-releaseNick Clifton26-26/+23
2023-07-28testsuite: Also discard the `.MIPS.options' sectionYunQiang Su1-1/+1
Also discard the `.MIPS.options' section, used with n64 MIPS binaries, along with similar other MIPS sections (`.reginfo', `.MIPS.abiflags') not relevant for the test cases concerned, fixing these regressions: mips64-openbsd -FAIL: ld-elf/group3a mips64-openbsd -FAIL: ld-elf/group3b mips64-openbsd -FAIL: Place orphan sections (map file check) mips64-openbsd -FAIL: ld-elf/orphan-region mips64-openbsd -FAIL: ld-elf/orphan mips64-openbsd -FAIL: overlay size (map file check) mips64-openbsd -FAIL: overlay size mips64el-openbsd -FAIL: ld-elf/group3a mips64el-openbsd -FAIL: ld-elf/group3b mips64el-openbsd -FAIL: Place orphan sections (map file check) mips64el-openbsd -FAIL: ld-elf/orphan-region mips64el-openbsd -FAIL: ld-elf/orphan mips64el-openbsd -FAIL: overlay size (map file check) mips64el-openbsd -FAIL: overlay size Co-Authored-By: Maciej W. Rozycki <macro@orcam.me.uk> binutils/ * testsuite/binutils-all/strip-3.d: Add `-R .MIPS.options' to the `strip' tag. ld/ * testsuite/ld-elf/group.ld: Also discard `.MIPS.options'. * testsuite/ld-elf/orphan-region.ld: Likewise. * testsuite/ld-elf/orphan.ld: Likewise. * testsuite/ld-mips-elf/got-page-1.ld: Likewise. * testsuite/ld-scripts/overlay-size.t: Likewise.
2023-07-28ldscripts/empty-address vs. xcoffAlan Modra5-2/+5
The empty-address tests check that if a section is removed by ld due to being empty then properties of that section don't affect following addresses. The xcoff backend doesn't remove the empty .data section created by empty-address-2* and empty-address-3* for some reason, and therefore fails the test. * testsuite/ld-scripts/empty-address-1.d: Accept more symbols. * testsuite/ld-scripts/empty-address-2a.d: xfail for xcoff. * testsuite/ld-scripts/empty-address-2b.d: Likewise. * testsuite/ld-scripts/empty-address-3a.d: Likewise. * testsuite/ld-scripts/empty-address-3b.d: Likewise.
2023-07-27/DISCARD/ in ld testsuiteAlan Modra21-21/+21
The canonical form to discard all sections not mentioned earlier in the script is /DISCARD/ : { *(*) } not /DISCARD/ : { *(.*) } ".*" happens to work with the usual section names starting with a dot, but let's not promote something not quite right.
2023-06-15Revert "MIPS: fix -gnuabi64 testsuite"Maciej W. Rozycki1-1/+1
This reverts commit cb81e84c72933a7fad10b75b7e270d92d8d65251. It was applied unapproved.
2023-06-15Re: Add some expected failures for bfin linker testsAlan Modra6-7/+8
After commit 7ade0f1582c4 I was seeing bfin-elf +XPASS: weak symbols, and on looking into the bfin targets a little, discovered we have two bfin-linux targets. One, bfin-uclinux, is like bfin-elf in that ld -m elf32bfin is the default, and the other, bfin-linux-uclibc where ld -m elf32bfinfd is the default. So putting bfin-*-*linux* in test xfails or elsewhere is wrong. We want bfin-*-linux* instead to just select the fdpic bfin target. This patch corrects wrong bfin target triples in the ld testsuite, not just the recent change but others I'd added to xfails too. It also fixes the bfin-linux-uclibc ld-elf/64ksec fail
2023-06-14Add some expected failures for bfin linker testsNick Clifton6-4/+7
2023-06-05MIPS: fix -gnuabi64 testsuiteYunQiang Su1-1/+1
Test on: mips64-linux-gnuabi64 mips64el-linux-gnuabi64 mipsisa64-linux-gnuabi64 mipsisa64el-linux-gnuabi64 mipsisa64r2-linux-gnuabi64 mipsisa64r2el-linux-gnuabi64 mipsisa64r6-linux-gnuabi64 mipsisa64r6el-linux-gnuabi64
2023-05-10Add linker option to include local symbols in the linker map.Nick Clifton3-0/+33
PR 16566 * ldlang.c (ld_is_local_symbol): New function. (print_input_section): Add code to display local symbols in the section. * ldlex.h (enum option_values): Add OPTION_PRINT_MAP_LOCALS and OPTION_PRINT_MAP_LOCALS. * lexsup.c (ld_options[]): Add entries for --print-map-locals and --no-print-map-locals. * NEWS: Mention the new feature. * ld.h (struct ld_config_type): Add print_map_locals field. * ld.texi: Document the new command line option. * testsuite/ld-scripts/sizeof.s: Add a local symbol. * testsuite/ld-scripts/map-locals.d: New test control file. * testsuite/ld-scripts/map-address.exp: Run the new test.
2023-03-16Re: Add --enable-linker-version optionChristophe Lyon2-2/+2
The recently-added ld-version*.d tests expect .*GNU ld \(GNU Binutils\) 2.* in the .comment section. However, when buidling --with-pkgversion=XXX, we get GNU ld (XXX) 2.[...] instead, leading to a spurious FAIL. This small patch replaces "GNU Binutils" with ".*" instead. I inspected other testcases to see if we already had similar occurrences but I couldn't see any, so I hope this fix is OK for the purpose? Thanks, Christophe
2023-03-16Re: Add --enable-linker-verssionAlan Modra1-1/+0
Output sections without any input sections to initialise their flags have their flags initialised by data statements to LOAD, ALLOC, HAS_CONTENTS by default. This is wrong for .comment. Fix that by making the script initialise the section type to INFO, one of the noalloc section types. That also allows the address of .comment to be set to zero, as is usual for non-alloc sections. Also, use source_sh for all of the sourced scripts to set up make dependencies. PR 30187 * scripttempl/misc-sections.sc: Set .comment address to zero and type to INFO. * scripttempl/ft32.sc: Fix breakages from last edit. * scripttempl/arclinux.sc: Use source_sh to source DWARF.sc and misc-sections.sc. * scripttempl/avr.sc: Likewise. * scripttempl/dlx.sc: Likewise. * scripttempl/elf.sc: Likewise. * scripttempl/elf32cr16.sc: Likewise. * scripttempl/elf32crx.sc: Likewise. * scripttempl/elf32msp430.sc: Likewise. * scripttempl/elf64bpf.sc: Likewise. * scripttempl/elf64hppa.sc: Likewise. * scripttempl/elf_chaos.sc: Likewise. * scripttempl/elfarc.sc: Likewise. * scripttempl/elfarcv2.sc: Likewise. * scripttempl/elfd10v.sc: Likewise. * scripttempl/elfd30v.sc: Likewise. * scripttempl/elfm68hc11.sc: Likewise. * scripttempl/elfm68hc12.sc: Likewise. * scripttempl/elfm9s12z.sc: Likewise. * scripttempl/elfmicroblaze.sc: Likewise. * scripttempl/elfxgate.sc: Likewise. * scripttempl/elfxtensa.sc: Likewise. * scripttempl/epiphany_4x4.sc: Likewise. * scripttempl/i386beos.sc: Likewise. * scripttempl/i386go32.sc: Likewise. * scripttempl/ia64vms.sc: Likewise. * scripttempl/ip2k.sc: Likewise. * scripttempl/iq2000.sc: Likewise. * scripttempl/mep.sc: Likewise. * scripttempl/mmo.sc: Likewise. * scripttempl/nds32elf.sc: Likewise. * scripttempl/pru.sc: Likewise. * scripttempl/v850.sc: Likewise. * scripttempl/v850_rh850.sc: Likewise. * scripttempl/visium.sc: Likewise. * scripttempl/xstormy16.sc: Likewise. * scripttempl/z80.sc: Likewise. * testsuite/ld-scripts/ld-version-2.d: Don't skip ft32 or pru.
2023-03-15Add --enable-linker-version option to bfd linker to add an entry in the ↵Nick Clifton4-0/+26
.comment section. PR 30187 * NEWS: Mention the new feature. * ld.texi: Document the new feature. * ldgram.y: Handle LINKER_VERSION token. * ldlang.c (lang_add_version): New function. (enable_linker_version): New global variable. * ldlang.h (land_add_version): Prototype. (enable_linker_version): Export. * ldlex.h (OPTION_ENABLE_LINKER_VERSION): Define. (OPTION_DISABLE_LINKER_VERSION): Define. * ldlex.l (LINKER_VERSION): Add token. * lexsup.c (ld_options): Add --enable-linker-version and --disable-linker-version. (parse_args): Handle the new options. * scripttempl/arclinux.sc: Remove stabs and comment sections and replace with inclusion of misc-sections.sc * scripttempl/avr.sc: Likewise. * scripttempl/dlx.sc: Likewise. * scripttempl/elf.sc: Likewise. * scripttempl/elf32cr16.sc: Likewise. * scripttempl/elf32crx.sc: Likewise. * scripttempl/elf32msp430.sc: Likewise. * scripttempl/elf64bpf.sc: Likewise. * scripttempl/elf64hppa.sc: Likewise. * scripttempl/elf_chaos.sc: Likewise. * scripttempl/elfarc.sc: Likewise. * scripttempl/elfarcv2.sc: Likewise. * scripttempl/elfd10v.sc: Likewise. * scripttempl/elfd30v.sc: Likewise. * scripttempl/elfm68hc11.sc: Likewise. * scripttempl/elfm68hc12.sc: Likewise. * scripttempl/elfm9s12z.sc: Likewise. * scripttempl/elfmicroblaze.sc: Likewise. * scripttempl/elfxgate.sc: Likewise. * scripttempl/elfxtensa.sc: Likewise. * scripttempl/epiphany_4x4.sc: Likewise. * scripttempl/ft32.sc: Likewise. * scripttempl/ip2k.sc: Likewise. * scripttempl/iq2000.sc: Likewise. * scripttempl/mep.sc: Likewise. * scripttempl/nds32elf.sc: Likewise. * scripttempl/pru.sc: Likewise. * scripttempl/v850.sc: Likewise. * scripttempl/v850_rh850.sc: Likewise. * scripttempl/visium.sc: Likewise. * scripttempl/xstormy16.sc: Likewise. * scripttempl/z80.sc: Likewise. * testsuite/ld-scripts/script.exp: Run new tests. * scripttempl/misc-sections.sc: New file. * testsuite/ld-scripts/ld-version-2.d: New file. * testsuite/ld-scripts/ld-version.d: New file. * testsuite/ld-scripts/ld-version.t: New file.
2023-03-10Revert ld ASCII supportAlan Modra4-75/+0
Revert "Prevent the ASCII linker script directive from generating huge amounts of padding if the size expression is not a constant." This reverts commit adbe951fc95943016325af08d677f18e8c177ac1. Revert "ld test asciz and ascii fails" This reverts the ascii.d part of commit 5f497256bee624f0fa470949aa41534093bc5b25. Revert "Add support for the ASCII directive inside linker scripts." This mostly reverts commit 9fe129a4105bb59398f73ce96938a94f19265b79 leaving the asciz.d and asciz.t changes in place.
2023-03-10Revert ld DIGEST supportAlan Modra57-1386/+0
This is a hopefully temporary reversion of new ld features for embedded processors by Ulf Samuelsson, plus some followup patches. Squashed together from the following: Revert "lddigest 32-bit support and gcc-4 compile errors" This reverts commit d7ee19be87110a8f5342cec6e323d83d01c641d1. Revert "ld: Use correct types for crc64 calculations" This reverts commit 9a534b9f8e3d0f3cdb5a20f19ff165693fbb84d2. Revert "Re: DIGEST: testsuite" This reverts commit c8e85484d8a0fe9f7b88e00a6b9ae63bcb53ba32. Revert "Regen potfiles" This reverts commit 4d98c966f8bf305ab25badd34cb295631873cf7c. Revert "DIGEST: Makefile.*" This reverts commit 78ef6ab03f56ce83a606d974bb8a9f34b5d6e0b7. Revert "DIGEST: calculation" This reverts commit 5243990191e683d5066d3dd622c76deaba0bf15c. Revert "DIGEST: ldlang.*: add timestamp" This reverts commit bd9466d4aa277a469a9d8b12f0a6e6fa51678e36. Revert "DIGEST: ldmain.c" This reverts commit c8f8653fa7eeb3dc0769ac23039eadb5c5f09dff. Revert "DIGEST: ldgram.y" This reverts commit d73c01be2669e9c5267fab669a269f95a32048c9. Revert "DIGEST: ldlex.l" This reverts commit 48b5163a9dd5759cc87171331bbd6e902c547b5a. Revert "DIGEST: testsuite" This reverts commit a4135d1a4886400ea29af2da782dd8dd40ccad23. Revert "DIGEST: Documentation" This reverts commit 3ec28966c3e4c63704212778f96c517cbf2e0090. Revert "DIGEST: NEWS" This reverts commit 099bf2927d446424e8585a60cf4ce63209999aa2. Revert "DIGEST: LICENSING" This reverts commit 5c8a0c6654fb55926985edf3b360b62d4f20691d.
2023-03-09lddigest 32-bit support and gcc-4 compile errorsAlan Modra3-3/+3
* ld.texi: Revert 2023-03-08 commit 9a534b9f8e3d. * testsuite/ld-scripts/crc64-poly.d: Likewise. * testsuite/ld-scripts/crc64-poly.t: Likewise. * lddigest.c: Formatting. (get_uint64_t): New function. (lang_add_digest): Take etree_type* args. Replace "illegal" with "invalid" in error message. * lddigest.h (lang_add_digest): Update prototype. * lddigest_tab.c (algorithms): Work around gcc-4 errors. * ldgram.y (polynome): Adjust lang_add_digest call. * testsuite/ld-scripts/crc64-poly-size.d: Update expected error.
2023-03-08ld: Use correct types for crc64 calculationsNick Clifton2-2/+2
2023-03-08Re: DIGEST: testsuiteAlan Modra15-50/+25
Correct test target/skip lines to fix fails on alpha-dec-vms, alpha-linux-gnuecoff, i386-bsd, i386-msdos, ns32k-openbsd, ns32k-pc532-mach, pdp11-dec-aout, rs6000-aix*, tic4x-coff, and tic54x-coff.
2023-03-07DIGEST: testsuiteUlf Samuelsson57-0/+1411
Signed-off-by: Ulf Samuelsson <ulf@emagii.com>
2023-02-17ld test asciz and ascii failsAlan Modra2-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.
2023-02-16Add support for the ASCII directive inside linker scripts.Nick Clifton6-26/+91
* 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.
2023-02-14ASCIZ Command for output sectionUlf Samuelsson4-0/+49
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.
2023-01-31testsuite XPASSesAlan Modra2-6/+3
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-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 Harmstone1-0/+1
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-02obsolete target tidyAlan Modra5-9/+5
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 Modra32-32/+32
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-11-30section-select: Fix exclude-file-3Michael Matz1-1/+3
this testcase wasn't correctly testing everything, it passed, even though sections from an excluded file were included. Fixing this reveals a problem in the new section selector. This fixes that as well.
2022-11-28Only use wild_sort_fastMichael Matz4-0/+36
there's no reason why the tree-based variant can't always be used when sorting is required, it merely needs to also support filename sorting and have a fast path for insertion at end (aka rightmost tree leaf). The filename sorting isn't tested anywhere and the only scripttempl that uses it is avr (for 'SORT(*)(.ctors)'), and I believe even there it was a mistake. Either way, this adds a testcase for filename sorting as well. Then the non-BST based sorting can be simplified to only support the fast case of no sorting required at all (at the same time renaming the two variants to _sort and _nosort).
2022-04-21ld testsuite xcoff XPASSAlan Modra1-2/+0
* testsuite/ld-scripts/defined5.d: Don't xfail xcoff targets.
2022-02-16ld: Support customized output section typeFangrui Song2-7/+18
bfd/ PR ld/28841 * bfd-in2.h (struct bfd_section): Add type. (discarded_section): Add field. * elf.c (elf_fake_sections): Handle bfd_section::type. * section.c (BFD_FAKE_SECTION): Add field. * mri.c (mri_draw_tree): Update function call. ld/ PR ld/28841 * ld.texi: Document new output section type. * ldlex.l: Add new token TYPE. * ldgram.y: Handle TYPE=exp. * ldlang.h: Add type_section to list of section types. * ldlang.c (lang_add_section): Handle type_section. (map_input_to_output_sections): Handle type_section. * testsuite/ld-scripts/output-section-types.t: Add tests. * testsuite/ld-scripts/output-section-types.d: Update.
2022-01-05elf: Set p_align to the minimum page size if possibleH.J. Lu2-2/+2
Currently, on 32-bit and 64-bit ARM, it seems that ld generates p_align values of 0x10000 even if no section alignment is greater than 0x1000. The issue is more general and probably affects other targets with multiple page sizes. While file layout absolutely must take 64K page size into account, that does not have to be reflected in the p_align value. If running on a 64K kernel, the file will be loaded at a 64K page boundary by necessity. On a 4K kernel, 64K alignment is not needed. The glibc loader has been fixed to honor p_align: https://sourceware.org/bugzilla/show_bug.cgi?id=28676 similar to kernel: commit ce81bb256a224259ab686742a6284930cbe4f1fa Author: Chris Kennelly <ckennelly@google.com> Date: Thu Oct 15 20:12:32 2020 -0700 fs/binfmt_elf: use PT_LOAD p_align values for suitable start address This means that on 4K kernels, we will start to do extra work for 64K p_align, but this pointless for pretty much all binaries (whose section alignment rarely exceeds 16). The minimum page size is used, instead of the maximum section alignment due to this glibc bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28688 It has been fixed in glibc 2.35. But linker output must work on existing glibc binaries. 1. Set p_align to the minimum page size while laying out segments aligning to the maximum page size or section alignment. The run-time loader can align segments to the minimum page size or above, depending on system page size. 2. If -z max-page-size=NNN is used, p_align will be set to the maximum page size or the largest section alignment. 3. If a section requires alignment higher than the minimum page size, don't set p_align to the minimum page size. 4. If a section requires alignment higher than the maximum page size, set p_align to the section alignment. 5. For objcopy, when the minimum page size != the maximum page size, p_align may be set to the minimum page size while segments are aligned to the maximum page size. In this case, the input p_align will be ignored and the maximum page size will be used to align the ouput segments. 6. Update linker to disallow the common page size > the maximum page size. 7. Update linker to avoid the common page size > the maximum page size. 8. Adjust pru_irq_map-1.d to expect p_align == sh_addralign: Section Headers: [Nr] Name Type Addr Off Size ES Flg Lk Inf Al [ 0] NULL 00000000 000000 000000 00 0 0 0 [ 1] .text PROGBITS 20000000 00007c 000004 00 AX 0 0 4 ... Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x000074 0x00000000 0x00000000 0x00008 0x00008 RW 0x1 LOAD 0x00007c 0x20000000 0x20000000 0x00004 0x00004 R E 0x4 vs. Section Headers: [Nr] Name Type Addr Off Size ES Flg Lk Inf Al [ 0] NULL 00000000 000000 000000 00 0 0 0 [ 1] .text PROGBITS 20000000 00007c 000004 00 AX 0 0 4 ... Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x000074 0x00000000 0x00000000 0x00008 0x00008 RW 0x1 LOAD 0x00007c 0x20000000 0x20000000 0x00004 0x00004 R E 0x1 To enable this linker optimization, the backend should define ELF_P_ALIGN to ELF_MINPAGESIZE. bfd/ PR ld/28689 PR ld/28695 * elf-bfd.h (elf_backend_data): Add p_align. * elf.c (assign_file_positions_for_load_sections): Set p_align to the default p_align value while laying out segments aligning to maximum page size or section alignment. (elf_is_p_align_valid): New function. (copy_elf_program_header): Call elf_is_p_align_valid to determine if p_align is valid. * elfxx-target.h (ELF_P_ALIGN): New. Default to 0. (elfNN_bed): Add ELF_P_ALIGN. * elfxx-x86.h (ELF_P_ALIGN): New. Set to ELF_MINPAGESIZE. include/ PR ld/28689 PR ld/28695 * bfdlink.h (bfd_link_info): Add maxpagesize_is_set. ld/ PR ld/28689 PR ld/28695 * emultempl/elf.em (gld${EMULATION_NAME}_handle_option): Set link_info.maxpagesize_is_set for -z max-page-size=NNN. * ldelf.c (ldelf_after_parse): Disallow link_info.commonpagesize > link_info.maxpagesize. * testsuite/ld-elf/elf.exp: Pass -z max-page-size=0x4000 to linker to build mbind2a and mbind2b. * testsuite/ld-elf/header.d: Add -z common-page-size=0x100. * testsuite/ld-elf/linux-x86.exp: Add PR ld/28689 tests. * testsuite/ld-elf/p_align-1.c: New file. * testsuite/ld-elf/page-size-1.d: New test. * testsuite/ld-elf/pr26936.d: Add -z common-page-size=0x1000. * testsuite/ld-elf/seg.d: Likewise. * testsuite/ld-scripts/rgn-at5.d: Likewise. * testsuite/ld-pru/pru_irq_map-1.d: Append 1 to name. Adjust expected PT_LOAD segment alignment. * testsuite/ld-pru/pru_irq_map-2.d: Append 2 to name. * testsuite/ld-scripts/pr23571.d: Add -z max-page-size=0x1000.
2022-01-02Update year range in copyright notice of binutils filesAlan Modra32-32/+32
The result of running etc/update-copyright.py --this-year, fixing all the files whose mode is changed by the script, plus a build with --enable-maintainer-mode --enable-cgen-maint=yes, then checking out */po/*.pot which we don't update frequently. The copy of cgen was with commit d1dd5fcc38ead reverted as that commit breaks building of bfp opcodes files.
2021-10-28ASSERT in empty output section with addressAlan Modra4-0/+22
* ldlang.c (lang_do_assignments_1): Correct "dot" inside ignored sections. * testsuite/ld-scripts/empty-address-4.d, * testsuite/ld-scripts/empty-address-4.s, * testsuite/ld-scripts/empty-address-4.t: New test. * testsuite/ld-scripts/empty-address.exp: Run it.
2021-09-03ld testsuite tidyAlan Modra1-9/+2
Fixes a few issues: 1) If you use "-fsanitize=address,undefined" in CFLAGS, the Makefile attempt to trim off -fsanitize options left us with ",undefined". 2) ld_compile adds CFLAGS_FOR_TARGET itself, no need to pass it. 3) CFLAGS might be needed linking bootstrap test. * Makefile.am (CFLAGS_FOR_TARGET, CXXFLAGS_FOR_TARGET): Trim off all -fsanitize=*. * Makefile.in: Regenerate. * testsuite/ld-bootstrap/bootstrap.exp: Use CFLAGS when linking. * testsuite/ld-cdtest/cdtest.exp: Use CFLAGS_FOR_TARGET when linking. * testsuite/ld-auto-import/auto-import.exp: Don't pass CFLAGS_FOR_TARGET to ld_compile. * testsuite/ld-cygwin/exe-export.exp: Likewise. * testsuite/ld-elfvers/vers.exp: Likewise. * testsuite/ld-elfvsb/elfvsb.exp: Likewise. * testsuite/ld-elfweak/elfweak.exp: Likewise. * testsuite/ld-gc/gc.exp: Likewise. * testsuite/ld-pe/pe-compile.exp: Likewise. * testsuite/ld-pe/pe-run.exp: Likewise. * testsuite/ld-pe/pe-run2.exp: Likewise. * testsuite/ld-plugin/plugin.exp: Likewise. * testsuite/ld-shared/shared.exp: Likewise. * testsuite/ld-elfcomm/elfcomm.exp: Likewise, and don't allow nios2 testing to trash CFLAGS_FOR_TARGET. * testsuite/ld-scripts/crossref.exp: Don't pass options in CC_FOR_TARGET, do so in CFLAGS_FOR_TARGET instead. * testsuite/ld-srec/srec.exp: Likewise, and for CXX.
2021-09-03CC_FOR_TARGET et alAlan Modra1-20/+20
The top level Makefile, the ld Makefile and others, define CC_FOR_TARGET to be a compiler for the binutils target machine. This is the compiler that should be used for almost all tests with C source. There are _FOR_TARGET versions of CFLAGS, CXX, and CXXFLAGS too. This was all supposed to work with the testsuite .exp files using CC for the target compiler, and CC_FOR_HOST for the host compiler, with the makefiles passing CC=$CC_FOR_TARGET and CC_FOR_HOST=$CC to the runtest invocation. One exception to the rule of using CC_FOR_TARGET is the native-only ld bootstrap test, which uses the newly built ld to link a copy of itself. Since the files being linked were created with the host compiler, the boostrap test should use CC and CFLAGS, in case some host compiler option provides needed libraries automatically. However, bootstrap.exp used CC where it should have used CC_FOR_HOST. I set about fixing that problem, then decided that playing games in the makefiles with CC was a bad idea. Not only is it confusing, but other dejagnu code knows about CC_FOR_TARGET. See dejagnu/target.exp. So this patch gets rid of the makefile variable renaming and changes all the .exp files to use the correct _FOR_TARGET variables. CC_FOR_HOST and CFLAGS_FOR_HOST disappear. A followup patch will correct bootstrap.exp to use CFLAGS, and a number of other things I noticed. binutils/ * testsuite/lib/binutils-common.exp (run_dump_test): Use CC_FOR_TARGET and CFLAGS_FOR_TARGET rather than CC and CFLAGS. ld/ * Makefile.am (check-DEJAGNU): Don't set CC to CC_FOR_TARGET and similar. Pass variables with unchanged names. Don't set CC_FOR_HOST or CFLAGS_FOR_HOST. * Makefile.in: Regenerate. * testsuite/config/default.exp: Update default CC and similar. (compiler_supports, plug_opt): Use CC_FOR_TARGET. * testsuite/ld-cdtest/cdtest.exp: Replace all uses of CC with CC_FOR_TARGET, and similarly for CFLAGS, CXX and CXXFLAGS. * testsuite/ld-auto-import/auto-import.exp: Likewise. * testsuite/ld-cygwin/exe-export.exp: Likewise. * testsuite/ld-elf/dwarf.exp: Likewise. * testsuite/ld-elf/indirect.exp: Likewise. * testsuite/ld-elf/shared.exp: Likewise. * testsuite/ld-elfcomm/elfcomm.exp: Likewise. * testsuite/ld-elfvers/vers.exp: Likewise. * testsuite/ld-elfvsb/elfvsb.exp: Likewise. * testsuite/ld-elfweak/elfweak.exp: Likewise. * testsuite/ld-gc/gc.exp: Likewise. * testsuite/ld-ifunc/ifunc.exp: Likewise. * testsuite/ld-mn10300/mn10300.exp: Likewise. * testsuite/ld-pe/pe-compile.exp: Likewise. * testsuite/ld-pe/pe-run.exp: Likewise. * testsuite/ld-pe/pe-run2.exp: Likewise. * testsuite/ld-pie/pie.exp: Likewise. * testsuite/ld-plugin/lto.exp: Likewise. * testsuite/ld-plugin/plugin.exp: Likewise. * testsuite/ld-scripts/crossref.exp: Likewise. * testsuite/ld-selective/selective.exp: Likewise. * testsuite/ld-sh/sh.exp: Likewise. * testsuite/ld-shared/shared.exp: Likewise. * testsuite/ld-srec/srec.exp: Likewise. * testsuite/ld-undefined/undefined.exp: Likewise. * testsuite/ld-unique/unique.exp: Likewise. * testsuite/ld-x86-64/tls.exp: Likewise. * testsuite/lib/ld-lib.exp: Likewise. libctf/ * Makefile.am (check-DEJAGNU): Don't set CC to CC_FOR_TARGET. Pass CC and CC_FOR_TARGET. Don't set CC_FOR_HOST. * Makefile.in: Regenerate. * testsuite/config/default.exp: Update default CC and similar. * testsuite/lib/ctf-lib.exp (run_native_host_cmd): Use CC rather than CC_FOR_HOST. (run_lookup_test): Use CC_FOR_TARGET and CFLAGS_FOR_TARGET.
2021-07-21Allows linker scripts to set the SEC_READONLY flag.Luca Boccassi3-0/+21
* ld.texi: Document new output section type. * ldgram.y: Add new token. * ldlang.c: Handle the new flag. * ldlang.h: Add readonly_section to list of section types. * ldlex.l: Add a new identifier. * testsuite/ld-scripts/output-section-types.t: New example linker script. * testsuite/ld-scripts/output-section-types.d: Test driver. * testsyute/ld-scripts/script.exp: Run the new test.
2021-03-12PE image base falloutAlan Modra1-1/+5
Fixes x86_64-w64-mingw32 tests that failed with the recent diagnosis for out of range RVA, and a couple of other gc-sections tests that failed for other reasons. * testsuite/ld-gc/gc.exp: Pass "-image-base 0" to ld for PE, and arrange to define __main for some run_dump_test tests. * testsuite/ld-gc/pr13683.d: Accept more symbols. * testsuite/ld-gc/pr14265.d: Likewise, and ordering. * testsuite/ld-scripts/crossref.exp: Pass "-image-base 0" to ld for PE. * testsuite/ld-srec/srec.exp: Likewise. * testsuite/lib/ld-lib.exp (ld_link_defsyms): Use is_pecoff_format.
2021-03-10bfd: strip symbols not representable in COFF/PE symbol tableJan Beulich2-3/+2
The offset-within-section field in the symbol table entry is only 32 bits wide, so rather than emitting bogus entries omit them, and issue a diagnostic identifying the issue. This requires adjusting the PR/22267 test to no longer produce symbols with out of range values on 64-bit BFD. This also depends on adjustments to testsuite/ld-scripts/map-address.* made by an earlier patch. The purpose of the test can very well be achieved nevertheless.
2021-03-09bfd: don't silently wrap or truncate PE image section RVAsJan Beulich10-12/+35
In PE images section addresses get expressed as addresses relative to the image base. Therefore the VA of a section must be no less than the image base, and after subtraction of the image base the resulting value should fit in 32 bits. (The issue is particularly obvious to notice when sections, perhaps because of ELF assumptions, get placed at VA 0 by default. Debugging info sections as well as .comment, when input files are ELF, are a good example. All such sections need proper mentioning in the linker script to avoid this warning.) There are a number of test cases which previously produced bogus images, yet still declared the test a success. Like done for other tests already, force a zero image base for these. This then also allows (and requires) dropping again xfail-s which 39a7b38fac0e ("Fix linker tests to work with 16-bit targets") had added to ld-scripts/default-script*.d (originally as skip-s). This also depends on similar adjustments to testsuite/ld-scripts/map-address.* made by an earlier patch. For ld-scripts/print-memory-usage.* I suppose xcoff could be dropped from the exclusion list by suppressing garbage collection, just like already done in e.g. (as seen in the diff here) ld-scripts/data.*, but I didn't want to make unrelated adjustments.
2021-03-04ld: adjust ld-scripts/map-address.*Jan Beulich2-4/+13
Without setting an image base address and without naming at least .text, this test produces entirely bogus PE output. To be honest, even the ELF output looks odd: .text gets placed at 0x10204, and both foo and bar get associated with .text despite living below its start address. Since neither image base nor .text placement are the subject of this test, specify .text placement explicitly and in the PE case force the image base to zero.
2021-02-21Warn when a script redefines a symbolAlan Modra1-2/+3
Note that we don't even warn if scripts adjust a symbol as in ld-elf/var1 and ld-scripts/pr14962. include/ * bfdlink.h (struct bfd_link_info): Add warn_multiple_definition. ld/ * ldexp.c (exp_fold_tree_1): Warn on script defining a symbol defined in an object file. * ldmain.c (multiple_definition): Heed info->warn_multiple_definition. * testsuite/ld-scripts/defined5.d: Expect a warning.
2021-02-14ld testsuite: change unresolved to unsupported/failAlan Modra13-32/+17
"unresolved" as a test result means runtest returns an error, which can be confusing when there is no apparent error unless you look in .log files. In particular many tests are skipped without reporting an error if no target C compiler is found, but if a target C compiler is found but won't compile a testcase for some reason we used to mark the test as unresolved. Which is no more worthy of an error than when lacking a C compiler entirely. * testsuite/ld-cdtest/cdtest.exp, * testsuite/ld-checks/checks.exp, * testsuite/ld-elf/binutils.exp, * testsuite/ld-elf/compress.exp, * testsuite/ld-elf/dwarf.exp, * testsuite/ld-elf/exclude.exp, * testsuite/ld-elf/frame.exp, * testsuite/ld-elf/indirect.exp, * testsuite/ld-elf/linux-x86.exp, * testsuite/ld-elf/sec-to-seg.exp, * testsuite/ld-elf/tls_common.exp, * testsuite/ld-elfcomm/elfcomm.exp, * testsuite/ld-elfvers/vers.exp, * testsuite/ld-elfvsb/elfvsb.exp, * testsuite/ld-elfweak/elfweak.exp, * testsuite/ld-ifunc/binutils.exp, * testsuite/ld-mips-elf/mips-elf-flags.exp, * testsuite/ld-misc/defsym.exp, * testsuite/ld-mn10300/mn10300.exp, * testsuite/ld-plugin/lto.exp, * testsuite/ld-plugin/plugin.exp, * testsuite/ld-scripts/align.exp, * testsuite/ld-scripts/assert.exp, * testsuite/ld-scripts/crossref.exp, * testsuite/ld-scripts/defined.exp, * testsuite/ld-scripts/extern.exp, * testsuite/ld-scripts/log2.exp, * testsuite/ld-scripts/map-address.exp, * testsuite/ld-scripts/phdrs.exp, * testsuite/ld-scripts/phdrs2.exp, * testsuite/ld-scripts/script.exp, * testsuite/ld-scripts/section-flags.exp, * testsuite/ld-scripts/sizeof.exp, * testsuite/ld-scripts/weak.exp, * testsuite/ld-selective/selective.exp, * testsuite/ld-sh/sh.exp, * testsuite/ld-shared/shared.exp, * testsuite/ld-srec/srec.exp, * testsuite/ld-tic6x/tic6x.exp, * testsuite/ld-undefined/undefined.exp, * testsuite/ld-undefined/weak-undef.exp, * testsuite/lib/ld-lib.exp: Don't use unresolved except after perror. Instead report "unsupported" or "fail".
2021-01-08sh-pe ld XPASSesAlan Modra3-4/+4
* testsuite/ld-scripts/fill.d: Skip sh-*-pe rather than xfail. * testsuite/ld-scripts/fill16.d: Don't xfail sh-*-pe. * testsuite/ld-scripts/segment-start.d: Likewise.
2021-01-08xfail more cases of complaints about relocs in read-only sectionsAlan Modra1-0/+1
* testsuite/ld-elf/comm-data5.d: xfail targets that complain about dynamic relocations in read-only sections. * testsuite/ld-elf/ehdr_start-shared.d: Likewise. * testsuite/ld-elf/ehdr_start.d: Likewise. * testsuite/ld-scripts/pr22267.d: Likewise. * testsuite/ld-elf/shared.exp: Likewise for DT_TEXTREL tests and pr20995 text. * testsuite/ld-elf/sec64k.exp: Don't run 64ksec on lm32-linux.
2021-01-07ld: xfail riscv64*-*-* for ld-scripts/empty-address-2 tests.Marcus Comstedt2-2/+2
For now we have supported the riscv big endian targets, so xfail riscv64*-*-* for ld-scripts/empty-address-2 tests, to cover both little endian and big endian targets. ld/ * testsuite/ld-scripts/empty-address-2a.d: xfail riscv64*-*-*. * testsuite/ld-scripts/empty-address-2b.d: Likewise.
2021-01-06ld rgn-at10 and rgn-at11 testAlan Modra2-3/+2
These fail on v850 due to that target using different .tbss section flags. * testsuite/ld-scripts/rgn-at10.d: xfail v850. * testsuite/ld-scripts/rgn-at11.d: Likewise.
2021-01-05ld sysroot-prefix test failsAlan Modra1-0/+9
* testsuite/ld-scripts/sysroot-prefix.exp: Exclude some targets.
2021-01-05Re: elf: Allow mixed ordered/unordered inputs for non-relocatable linkAlan Modra1-3/+0
PR ld/26256 * testsuite/ld-elf/pr26256-1b.d: xfail s12z. * testsuite/ld-scripts/crossref.exp (cross1): Don't xfail ia64.
2021-01-01Update year range in copyright notice of binutils filesAlan Modra32-32/+32
2020-12-24PR27100, final link failed: bad valueAlan Modra7-8/+18
The failure on this PR is due to using the same bfd section for multiple output sections. Commit 21401fc7bf67 managed to create duplicate linker script output section statements, but not the actual bfd sections. PR 27100 * ldlang.h (lang_output_section_statement_type): Add dup_output. * ldlang.c (lang_output_section_statement_lookup): Set dup_output. (init_os): Test dup_output rather than constraint. * testsuite/ld-scripts/pr27100.d, * testsuite/ld-scripts/pr27100.s, * testsuite/ld-scripts/pr27100.t: New test. * testsuite/ld-scripts/data.exp: Run it. Don't exclude aout here. * testsuite/ld-scripts/data.d: Do so here instead. * testsuite/ld-scripts/fill.d: Likewise. * testsuite/ld-scripts/fill16.d: Likewise.