aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-elf
AgeCommit message (Collapse)AuthorFilesLines
12 daysImprove the placement of orphan note sections.Nick Clifton2-4/+3
PR 32219
2024-09-27Enable -z separate-code, -z common and -z text for more targetsAlan Modra3-3/+3
Fix a mis-placed "fi".
2024-09-26ld: Ignore .note.gnu.build-id when placing orphaned notesH.J. Lu4-2/+42
The commits: e8e10743f7b Add --rosegment option to BFD linker to stop the '-z separate-code' from generating two read-only segments. bf6d7087de0 ld: Move the .note.build-id section to near the start of the memory map place .note.gnu.build-id before text sections when --rosegment is used. Ignore .note.gnu.build-id when placing orphaned notes if --rosegment and -z separate-code are used together to avoid putting any note sections between .note.gnu.build-id and text sections in the same PT_LOAD segment. PR ld/32191 * ldlang.c (lang_insert_orphan): Ignore .note.gnu.build-id when placing orphaned notes. * testsuite/ld-elf/pr23658-1a.d: Pass --no-rosegment to ld. * testsuite/ld-elf/pr23658-1c.d: Likewise. * testsuite/ld-elf/pr23658-1e.d: New file. * testsuite/ld-elf/pr23658-1f.d: Likewise. * testsuite/ld-i386/i386.exp: Run PR ld/32191 test. * testsuite/ld-i386/pr32191.d: New file. * testsuite/ld-x86-64/lam-u48.rd: Updated. * testsuite/ld-x86-64/lam-u57.rd: Likewise. * testsuite/ld-x86-64/pr32191-x32.d: New file. * testsuite/ld-x86-64/pr32191.d: Likewise. * testsuite/ld-x86-64/pr32191.s: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run PR ld/32191 tests. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-09-24ld: support --build-id=xx modeFrank Ch. Eigler2-39/+74
The is patch adds a new ld build-id computation mode, "xx", using xxhash in its 128-bit mode. The patch prereqs the xxhash-devel headers being installed, and uses the "all-inlined" model, so no run-time or link-time library dependence exists. The xxhash mode performs well, saving roughly 20% of total userspace run time from an ld job over a 800MB shared library relative to sha1. 128 bits of good hash should be collision-resistant to a number of distinct binaries that numbers in the 2**32 - 2**64 range, even if not "crypto" level hash. Confirmations of this are in progress. ld/configury: add --with-xxhash mode, different from gdb case because only using it in inline mode ld/ldbuildid.c: add "xx" mode, #if WITH_XXHASH ld/NEWS, ld.texi: mention new option ld/lexsup.c: add enumeration of --build-id STYLES to --help ld/testsuite/ld-elf/build-id.exp: add test case for 0xHEX case and conditional for xx case; also, simply tcl list syntax https://inbox.sourceware.org/binutils/20240917201509.GB26396@redhat.com/ Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
2024-09-21ld: Use --no-rosegment to ld for PR ld/22393 testsH.J. Lu3-7/+7
The commit bf6d7087de0 ld: Move the .note.build-id section to near the start of the memory map moves the .note.build-id section before text sections. When --rosegment and -z separate-code are used together, the .note.gnu.property section is placed between the .note.build-id section and text sections in the same PT_LOAD segment by orphan placement. Pass --no-rosegment to ld for PR ld/22393 tests to avoid linker test failures. PR ld/32190 * testsuite/ld-elf/pr22393-2a.rd: Pass --no-rosegment to ld. * testsuite/ld-elf/pr22393-2b.rd: Likewise. * testsuite/ld-elf/shared.exp: Pass --no-rosegment to ld when building pr22393-2 tests. * testsuite/ld-x86-64/pr22393-3a.rd: Pass --no-rosegment to ld. * testsuite/ld-x86-64/pr22393-3b.rd: Likewise. * testsuite/ld-x86-64/x86-64.exp: Pass --no-rosegment to ld when building pr22393-3 tests. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-08-07loongarch ld testsuite xpassesAlan Modra1-1/+1
Some tests started passing with commit 3a83f0342e54. However, supporting a changed ld output format is not so simple, and the change to the loongarch_elf_hash_table macro needs further changes to the rest of the code. It is true that some uses of loongarch_elf_hash_table do not need to check the type of the hash table, but others like loongarch_elf_relax_section do need to check. bfd_relax_section is called in lang_size_sections using the input bfd, not the output bfd. If the input bfd may be of different type to the output, then the hash table type must be checked before accessing elements of the hash table. This patch corrects loongarch_elf_relax_section. I haven't checked all the uses of the hash table throughout the loongarch backend. bfd/ * elfnn-loongarch.c (loongarch_elf_relax_section): Don't relax unless the hash table is loongarch_elf_link_hash_table. Move variable declarations. Formatting. ld/ * testsuite/ld-elf/pr21884.d: Don't xfail loongarach. * testsuite/ld-unique/pr21529.d: Likewise.
2024-07-22Don't trim trailing newline in run_host_cmdAlan Modra1-1/+1
Testcases like ld-elf/pr19719a.c that printf ("PASS\n"); on success ought to see the whole output for "string match". Similarly, the ld-pe/ pdb*.d files shouldn't need to remove the last newline to match. For most of the testsuite it doesn't matter whether the trailing newline is present or not, and there are only a few cases where we need to remove it. * testsuite/lib/ld-lib.exp (run_host_cmd): Don't regsub away output trailing newline. Do string trim for gcc/ld version checks. * testsuite/config/default.exp (plug_so): Do string trim output of run_host_cmd. * testsuite/ld-elf/shared.exp (mix_pic_and_non_pic): Adjust string match to include trailing newline. * testsuite/ld-i386/i386.exp (undefined_weak): Likewise. * testsuite/ld-x86-64/x86-64.exp (undefined_weak): Likewise. * testsuite/ld-plugin/libdep.exp (run_test): Likewise. * testsuite/ld-plugin/lto.exp (PR ld/28138 run): Likewise. * testsuite/ld-pe/pdb-strings.d, * testsuite/ld-pe/pdb-syms1-globals.d, * testsuite/ld-pe/pdb-syms1-records.d, * testsuite/ld-pe/pdb-syms1-symbols1.d, * testsuite/ld-pe/pdb-syms1-symbols2.d, * testsuite/ld-pe/pdb-syms2-symbols1.d, * testsuite/ld-pe/pdb-types1-hashlist.d, * testsuite/ld-pe/pdb-types1-skiplist.d, * testsuite/ld-pe/pdb-types1-typelist.d, * testsuite/ld-pe/pdb-types2-hashlist.d, * testsuite/ld-pe/pdb-types2-skiplist.d, * testsuite/ld-pe/pdb-types2-typelist.d, * testsuite/ld-pe/pdb-types3-hashlist.d, * testsuite/ld-pe/pdb-types3-skiplist.d, * testsuite/ld-pe/pdb-types3-typelist.d, * testsuite/ld-pe/pdb1-publics.d, * testsuite/ld-pe/pdb1-sym-record.d, * testsuite/ld-pe/pdb2-section-contrib.d, * testsuite/ld-pe/pdb3-c13-info1.d, * testsuite/ld-pe/pdb3-c13-info2.d, * testsuite/ld-pe/pdb3-source-info.d: Add trailing newline.
2024-07-13LoongArch: Fix dwarf3 test cases from XPASS to PASSLulu Cai1-5/+0
In the past, the .align directive generated a label that did not match the regular expression, and we set it to XFAIL. But now it matches fine so it becomes XPASS. We fix it with PASS.
2024-07-01ld: Move foo before delete in dl5.ccH.J. Lu1-1/+1
* testsuite/ld-elf/dl5.cc (main): Move foo before delete. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-06-30ld: Avoid folding new and delete pairsH.J. Lu3-10/+19
GCC 15 may fold new and delete pairs, like A *bb = new A[10]; delete [] bb; bb = new (std::nothrow) A [10]; delete [] bb; as shown in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115712 Avoid folding new and delete pairs by adding a function call between new and delete. * testsuite/ld-elf/dl5.cc: Include "dl5.h". (A): Removed. Call foo between new and delete. * testsuite/ld-elf/dl5.h: New file. * testsuite/ld-elf/new.cc: Include "dl5.h". (foo): New function. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-06-29ld: pass -g for ld-elf testsSam James2-2/+2
The "DWARF parse during linker error" and "Build warn libbar.so" tests require debug information. configure defaults to "-O2 -g" but if overriding *FLAGS when building tests, this might be lost. Explicitly pass -g given these tests require it. Originally reported downstream in Gentoo at https://bugs.gentoo.org/934149. ld/ * testsuite/ld-elf/dwarf.exp: Pass -g for "DWARF parse during linker error". * testsuite/ld-elf/shared.exp: Ditto for "Build warn libbar.so".
2024-06-13Adjust linker tests that are sensitive to --rosegmentNick Clifton3-3/+3
2024-06-13Add --rosegment option to BFD linker to stop the '-z separate-code' from ↵Nick Clifton2-0/+29
generating two read-only segments. PR 30907
2024-05-08ld: Add PR ld/31710 testsH.J. Lu4-0/+63
PR ld/31710 * testsuite/ld-elf/wrap.exp: Run ld/31710 tests. * testsuite/ld-elf/wrap2.h: New file. * testsuite/ld-elf/wrap2a.c: Likewise. * testsuite/ld-elf/wrap2b.c: Likewise.
2024-05-08ld: Run --wrap tests only if supportedH.J. Lu1-19/+15
Run --wrap tests with shared library only if -shared is supported. * testsuite/ld-elf/wrap.exp: Run --wrap tests with shared library only if -shared is supported.
2024-04-24Update readelf's display of RELR sections to include the number of locations ↵Nick Clifton5-5/+5
relocated
2024-04-23ignore some symbols in elf.c:swap_out_symsAlan Modra1-1/+1
The reason behind this patch was noticing that generic ELF targets fail to remove "bar" in the recently committed ld-elf/undefweak-1 test. (Despite that, those targets pass the test due to it being too strict when matching symbols. "bar" gets turned into a local weak defined absolute symbol.) swap_out_syms currently drops local section syms that are defined in discarded sections. Extend that to also drop other symbols in discarded sections too, even global symbols. The linker goes to quite a lot of effort to ensure globals in discarded section take a definition from the kept linkonce or comdat group section. So the global sym change should only affect cases where something is quite wrong about the set of linkonce or comdat group sections. However that change to elf_map_symbols meant we dropped _DYNAMIC_LINK / _DYNAMIC_LINKING for mips, a global absolute symbol given STT_SECTION type for some reason. That problem is fixed by reverting the pr14493 change which is no longer needed due to a) BSF_SECTION_SYM_USED on x86, and b) fixing objcopy to use copy_private_symbol_data. bfd/ PR 14493 * elf.c (ignore_sym): Rename from ignore_section_sym. Return true for any symbol without a section or in a discarded section. Revert pr14493 change. (elf_map_symbols): Tidy. Use ignore_sym on all symbols. (swap_out_syms): Tidy. ld/ * testsuite/ld-elf/undefweak-1.rd: Match any "bar".
2024-04-23xfail undefweak-1 test for alphaAlan Modra1-1/+1
".set" has a different meaning on alpha. Changing it to ".equ" runs into ".equ" having a different meaning on hppa, and changing it to "=" runs into trouble on bfin. * testsuite/ld-elf/elf.exp (undefweak-1): xfail on alpha, don't xfail for genelf.
2024-04-20LoongArch: Add -mignore-start-align optionmengqinggang1-0/+5
Ignore .align at the start of a section may result in misalignment when partial linking. Manually add -mignore-start-align option without partial linking. Gcc -falign-functions add .align 5 to the start of a section, it causes some error message mismatch. Set these testcases to xfail on LoongArch target.
2024-04-18elf: Strip unreferenced weak undefined symbolsH.J. Lu4-0/+49
Linker will resolve an undefined symbol only if it is referenced by relocation. Unreferenced weak undefined symbols serve no purpose. Weak undefined symbols appear in the dynamic symbol table only when they are referenced by dynamic relocation. Mark symbols with relocation and strip undefined weak symbols if they don't have relocation and aren't in the dynamic symbol table. bfd/ PR ld/31652 * elf-bfd.h (elf_link_hash_entry): Add has_reloc. * elf-vxworks.c (elf_vxworks_emit_relocs): Set has_reloc. * elflink.c (_bfd_elf_link_output_relocs): Likewise. (elf_link_output_extsym): Strip undefined weak symbols if they don't have relocation and aren't in the dynamic symbol table. ld/ PR ld/31652 * testsuite/ld-elf/elf.exp: Run undefweak tests. * testsuite/ld-elf/undefweak-1.rd: New file. * testsuite/ld-elf/undefweak-1a.s: Likewise. * testsuite/ld-elf/undefweak-1b.s: Likewise. * testsuite/ld-x86-64/weakundef-1.nd: Likewise. * testsuite/ld-x86-64/weakundef-1a.s: Likewise. * testsuite/ld-x86-64/weakundef-1b.s: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run undefweak tests.
2024-04-16Simplify readelf's RELR relocation display.Fangrui Song5-10/+10
2024-04-11Improve readelf's display of RELR relocs.Nick Clifton5-5/+24
2024-04-05elf: Always honor the first definition in shared object and archiveH.J. Lu5-0/+78
GCC doesn't put builtin function symbol references, which are defined in the shared C library, in the IR symbol table. When linker rescans shared objects and archives for newly added symbol references generated from the IR inputs, it skips definitions of the builtin functions in shared objects and archives. Add first_hash to elf_link_hash_table to track unreferenced definitions defined first in shared objects and archives. Always use them to resolve any references. bfd/ PR ld/31482 PR ld/31489 * elf-bfd.h (elf_link_hash_table): Add first_hash. * elflink.c (elf_link_add_to_first_hash): New function. (elf_link_add_object_symbols): Initialize first_hash for an IR input. Always use the first definition in shared object. Add the first unreferenced dynamic definition to first_hash. (_bfd_elf_archive_symbol_lookup): Add the first unreferenced definition to first_hash.. (elf_link_add_archive_symbols): Use the symbol definition in archive if symbol is defined first in this archive. (_bfd_elf_link_hash_table_free): Also free first_hash. ld/ PR ld/31482 PR ld/31489 * testsuite/ld-plugin/lto.exp: Add PR ld/31482 and PR ld/31489 tests. * testsuite/ld-elf/pr31482a-no-lto.c: New file. * testsuite/ld-elf/pr31482b-no-lto.c: Likewise. * testsuite/ld-elf/pr31482c-no-lto.c: Likewise. * testsuite/ld-elf/pr31482d-no-lto.c: Likewise. * testsuite/ld-plugin/pass1.out: Likewise. * testsuite/ld-plugin/pr31482a.c: Likewise. * testsuite/ld-plugin/pr31482b.c: Likewise. * testsuite/ld-plugin/pr31482c.c: Likewise.
2024-01-26elf: Rename is_standard_elf to uses_elf_emH.J. Lu6-6/+6
Rename is_standard_elf to uses_elf_em for targets which use elf.em. binutils/ PR ld/31289 * testsuite/lib/binutils-common.exp (is_standard_elf): Renamed to ... (uses_elf_em): This. ld/ PR ld/31289 * testsuite/ld-elf/fatal-warnings-2a.d: Replace is_standard_elf with uses_elf_em. * testsuite/ld-elf/fatal-warnings-2b.d: Likewise. * testsuite/ld-elf/fatal-warnings-3a.d: Likewise. * testsuite/ld-elf/fatal-warnings-3b.d: Likewise. * testsuite/ld-elf/fatal-warnings-4a.d: Likewise. * testsuite/ld-elf/fatal-warnings-4b.d: Likewise.
2024-01-26Remove -pie from command line of fatal-warnings 1a and 1b tests.Nick Clifton2-2/+2
2024-01-25elf: Add is_standard_elfH.J. Lu6-12/+12
PR ld/31289 tests failed for fr30-elf, frv-elf, ft32-elf, iq2000-elf, mn10200-elf, ms1-elf and msp430-elf targets: FAIL: ld-elf/fatal-warnings-2a FAIL: ld-elf/fatal-warnings-2b FAIL: ld-elf/fatal-warnings-3a FAIL: ld-elf/fatal-warnings-3b FAIL: ld-elf/fatal-warnings-4a FAIL: ld-elf/fatal-warnings-4b even though PR ld/31289 targets xfail for [is_generic] targets. These targets not only don't use the generic_link_hash_table linker, but also don't use the standard ELF emulation. Add is_standard_elf for ELF targets which use the standard ELF emulation and replace [is_generic] with ![is_standard_elf] in PR ld/31289 tests. binutils/ PR ld/31289 * testsuite/lib/binutils-common.exp (is_standard_elf): New. ld/ PR ld/31289 * testsuite/lib/binutils-common.exp (is_generic): Return 1 for fr30-*-*, frv-*-elf, ft32-*-*, iq2000-*-*, mn10200-*-*, moxie-*-moxiebox*, msp430-*-* and mt-*-*. * testsuite/ld-elf/fatal-warnings-2a.d: Replace [is_generic] with ![is_standard_elf]. * testsuite/ld-elf/fatal-warnings-2b.d: Likewise. * testsuite/ld-elf/fatal-warnings-3a.d: Likewise. * testsuite/ld-elf/fatal-warnings-3b.d: Likewise. * testsuite/ld-elf/fatal-warnings-4a.d: Likewise. * testsuite/ld-elf/fatal-warnings-4b.d: Likewise.
2024-01-25ld: Improve --fatal-warnings for unknown command-line optionsH.J. Lu8-0/+48
There are 2 problems with --fatal-warnings for unknown command-line options: 1. --fatal-warnings doesn't trigger an error for an unknown command-line option when --fatal-warnings is the last command-line option. 2. When --fatal-warnings triggers an error for an unknown command-line option, the message says that the unknown command-line option is ignored. This patch queues unknown command-line option warnings and outputs queued command-line option warnings after all command-line options have been processed so that --fatal-warnings can work for unknown command-line options regardless of the order of --fatal-warnings. When --fatal-warnings is used, the linker message is changed from ld: warning: -z bad-option ignored to ld: error: unsupported option: -z bad-option The above also applies to "-z dynamic-undefined-weak" when the known "-z dynamic-undefined-weak" option is ignored. PR ld/31289 * ldelf.c (ldelf_after_parse): Use queue_unknown_cmdline_warning to warn the ignored -z dynamic-undefined-weak option. * ldmain.c (main): Call output_unknown_cmdline_warnings after calling ldemul_after_parse. * ldmisc.c (CMDLINE_WARNING_SIZE): New. (cmdline_warning_list): Likewise. (cmdline_warning_head): Likewise. (cmdline_warning_tail): Likewise. (queue_unknown_cmdline_warning): Likewise. (output_unknown_cmdline_warnings): Likewise. * ldmisc.h (queue_unknown_cmdline_warning): Likewise. (output_unknown_cmdline_warnings): Likewise. * emultempl/elf.em (gld${EMULATION_NAME}_handle_option): Use queue_unknown_cmdline_warning to warn unknown -z option. * testsuite/ld-elf/fatal-warnings-1a.d: New file. * testsuite/ld-elf/fatal-warnings-1b.d: Likewise. * testsuite/ld-elf/fatal-warnings-2a.d: Likewise. * testsuite/ld-elf/fatal-warnings-2b.d: Likewise. * testsuite/ld-elf/fatal-warnings-3a.d: Likewise. * testsuite/ld-elf/fatal-warnings-3b.d: Likewise. * testsuite/ld-elf/fatal-warnings-4a.d: Likewise. * testsuite/ld-elf/fatal-warnings-4b.d: Likewise.
2024-01-06ld: Adjust x86 and x86-64 tests for -z mark-pltH.J. Lu2-2/+2
To support -z mark-plt enabled by default, adjust x86 tests to accept non-zero r_addend for JUMP_SLOT relocation and pass -z nomark-plt to x86-64 tests if -z mark-plt changes the expected outputs. * testsuite/ld-elf/indirect-extern-access-2.rd: Allow non-zero r_addend for JUMP_SLOT relocation. * testsuite/ld-elf/pr23161d.rd: Likewise. * testsuite/ld-ifunc/ifunc-25c-x86.d: Likewise. * testsuite/ld-ifunc/ifunc-16-x86-64-now.d: Pass -z nomark-plt to linker. * testsuite/ld-ifunc/ifunc-16-x86-64.d: Likewise. * testsuite/ld-ifunc/ifunc-2-local-x86-64-now.d: Likewise. * testsuite/ld-ifunc/ifunc-2-local-x86-64.d: Likewise. * testsuite/ld-ifunc/ifunc-2-x86-64-now.d: Likewise. * testsuite/ld-ifunc/ifunc-2-x86-64.d: Likewise. * testsuite/ld-ifunc/ifunc-20-x86-64.d: Likewise. * testsuite/ld-ifunc/ifunc-5b-x86-64.d: Likewise. * testsuite/ld-ifunc/pr17154-x86-64-now.d: Likewise. * testsuite/ld-ifunc/pr17154-x86-64.d: Likewise. * testsuite/ld-x86-64/dt-relr-1a-x32.d: Likewise. * testsuite/ld-x86-64/dt-relr-1a.d: Likewise. * testsuite/ld-x86-64/dt-relr-1b-x32.d: Likewise. * testsuite/ld-x86-64/dt-relr-1b.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2a-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2a.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3a-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3a.d: Likewise. * testsuite/ld-x86-64/pr19636-2d.d: Likewise. * testsuite/ld-x86-64/pr19636-2e.d: Likewise. * testsuite/ld-x86-64/pr19636-2f.d: Likewise. * testsuite/ld-x86-64/pr19636-2l.d: Likewise. * testsuite/ld-x86-64/x86-64.exp: Pass -z nomark-plt to linker in 6 tests.
2024-01-04Update year range in copyright notice of binutils filesAlan Modra26-26/+26
Adds two new external authors to etc/update-copyright.py to cover bfd/ax_tls.m4, and adds gprofng to dirs handled automatically, then updates copyright messages as follows: 1) Update cgen/utils.scm emitted copyrights. 2) Run "etc/update-copyright.py --this-year" with an extra external author I haven't committed, 'Kalray SA.', to cover gas testsuite files (which should have their copyright message removed). 3) Build with --enable-maintainer-mode --enable-cgen-maint=yes. 4) Check out */po/*.pot which we don't update frequently.
2023-12-22LoongArch: Add support for the third expression of .align for R_LARCH_ALIGNmengqinggang1-0/+2
If the symbol index is not zero, the addend is used to represent the first and the third expressions of the .align. The lowest 8 bits are used to represent the first expression. Other bits are used to represent the third expression. The addend of R_LARCH_ALIGN for ".align 5, ,4" is 0x405. The addend of R_LARCH_ALIGN for ".balign 32, ,4" is 0x405.
2023-11-10Add ability to change linker warning messages into errors when reporting ↵Nick Clifton27-38/+38
executable stacks and/or executable segments. include * bfdlink.h (struct bfd_link_info): Update descriptions of the 'execstack', 'noexecstack' and 'warn_execstack' fields. Add 'error_exectack' and 'warn_is_error_for_rwx_segments' fields. bfd * elf.c (assign_file_positions_except_relocs): Turn warnings about executable segments into errors if so requested. * elflink.c (bfd_elf_size_dynamic_sections): Turn warnings about executable stacks into errors if so requested. ld * ldlex.h (enum option_values): Add OPTION_ERROR_EXECSTACK, OPTION_NO_ERROR_EXECSTACK, OPTION_WARN_EXECSTACK_OBJECTS, OPTION_ERROR_RWX_SEGMENTS and OPTION_NO_ERROR_RWX_SEGMENTS. (struct ld_option): Add new long options. (parse_args): Parse new long options. (elf_static_list_options): Display the new options. * ld.texi: Document the new command line options. * configure.ac (error-execstack): New configuration option. (error-rwx-segments): New configuration option. * emultempl/elf.em (_before_parse): Initialse the new linkinfo fields. * NEWS: Mention the new features. * config.in: Regenerate. * configure: Regenerate. * testsuite/ld-elf/commonpage2.d: Disable errors for RWX segments and/or executable stacks. * testsuite/ld-elf/elf.exp: Likewise. * testsuite/ld-elf/header.d: Likewise. * testsuite/ld-elf/loadaddr1.d: Likewise. * testsuite/ld-elf/loadaddr2.d: Likewise. * testsuite/ld-elf/maxpage4.d: Likewise. * testsuite/ld-elf/nobits-1.d: Likewise. * testsuite/ld-elf/note-1.d: Likewise. * testsuite/ld-elf/orphan-10.d: Likewise. * testsuite/ld-elf/orphan-11.d: Likewise. * testsuite/ld-elf/orphan-12.d: Likewise. * testsuite/ld-elf/orphan-5.d: Likewise. * testsuite/ld-elf/orphan-7.d: Likewise. * testsuite/ld-elf/orphan-8.d: Likewise. * testsuite/ld-elf/orphan-9.d: Likewise. * testsuite/ld-elf/orphan-region.d: Likewise. * testsuite/ld-elf/orphan.d: Likewise. * testsuite/ld-elf/pr19539.d: Likewise. * testsuite/ld-elf/pr26256-1a.d: Likewise. * testsuite/ld-elf/pr26907.d: Likewise. * testsuite/ld-elf/pr28597.d: Likewise. * testsuite/ld-elf/retain2.d: Likewise. * testsuite/ld-elf/shared.exp: Likewise. * testsuite/ld-elf/size-1.d: Likewise. * testsuite/ld-elf/textaddr7.d: Likewise. * testsuite/ld-elf/warn1.d: Likewise. * testsuite/ld-elf/warn2.d: Likewise. * testsuite/ld-i386/discarded1.d: Likewise. * testsuite/ld-i386/pr19175.d: Likewise. * testsuite/ld-i386/pr19539.d: Likewise. * testsuite/ld-i386/pr23189.d: Likewise. * testsuite/ld-plugin/lto-3r.d: Likewise. * testsuite/ld-plugin/lto-5r.d: Likewise. * testsuite/ld-plugin/lto.exp: Likewise. * testsuite/ld-powerpc/ppc476-shared.d: Likewise. * testsuite/ld-powerpc/ppc476-shared2.d: Likewise. * testsuite/ld-powerpc/pr28827-2.d: Likewise. * testsuite/ld-s390/s390.exp: Likewise. * testsuite/ld-scripts/align2a.d: Likewise. * testsuite/ld-scripts/align2b.d: Likewise. * testsuite/ld-scripts/align5.d: Likewise. * testsuite/ld-scripts/alignof.exp: Likewise. * testsuite/ld-scripts/crossref.exp: Likewise. * testsuite/ld-scripts/defined2.d: Likewise. * testsuite/ld-scripts/defined3.d: Likewise. * testsuite/ld-scripts/defined5.d: Likewise. * testsuite/ld-scripts/pr14962.d: Likewise. * testsuite/ld-scripts/pr18963.d: Likewise. * testsuite/ld-scripts/pr20302.d: Likewise. * testsuite/ld-scripts/print-memory-usage.exp: Likewise. * testsuite/ld-scripts/rgn-at1.d: Likewise. * testsuite/ld-scripts/rgn-at10.d: Likewise. * testsuite/ld-scripts/rgn-at4.d: Likewise. * testsuite/ld-scripts/rgn-at6.d: Likewise. * testsuite/ld-scripts/rgn-at8.d: Likewise. * testsuite/ld-scripts/rgn-at9.d: Likewise. * testsuite/ld-scripts/rgn-over1.d: Likewise. * testsuite/ld-scripts/rgn-over2.d: Likewise. * testsuite/ld-scripts/rgn-over4.d: Likewise. * testsuite/ld-scripts/rgn-over5.d: Likewise. * testsuite/ld-scripts/rgn-over6.d: Likewise. * testsuite/ld-scripts/script.exp: Likewise. * testsuite/ld-scripts/sizeof.exp: Likewise. * testsuite/ld-scripts/sort-file.d: Likewise. * testsuite/ld-x86-64/discarded1.d: Likewise. * testsuite/ld-x86-64/pr19175.d: Likewise. * testsuite/ld-x86-64/pr19539a.d: Likewise. * testsuite/ld-x86-64/pr19539b.d: Likewise. * testsuite/ld-x86-64/pr23189.d: Likewise.
2023-10-05Fix: ld: Test case pr28158 fails on x86_64-linux-musl when index is > 19A. Wilcox1-1/+1
PR 30905 * testsuite/ld-elf/pr28158.rd: Adjust regexp to allow for section indicies larger than 9.
2023-10-05Fix: ld testsuite: glibc-specific DT_RELR tests should not be run on musl ↵A. Wilcox1-0/+4
systems PR 30917 * testsuite/ld-elf/dt-relr.exp: Skip for MUSL targets.
2023-09-25RISC-V: Protect .got with relroAndreas Schwab1-1/+0
Move .got before .data so that it can be protected with -zrelro. Also separate .got.plt from .got if -znow is not in effect; the first two words of .got.plt are placed within the relro region. ld: PR ld/30877 * emulparams/elf32lriscv-defs.sh (DATA_GOT, SEPARATE_GOTPLT): Define. * emulparams/elf64lriscv-defs.sh (SEPARATE_GOTPLT): Define. * testsuite/ld-elf/binutils.exp (binutils_test): Remove riscv*-*-* from relro_got expression.
2023-08-31elf: Adjust PR ld/30791 testsH.J. Lu2-0/+7
Adjust PR ld/30791 tests: 1. Generic linker targets don't comply with all orhpan section merging rules. 2. z80 fails since a, b, c, d are registers for z80. 3. hppa fails since .text sections aren't merged for relocatable link. PR ld/30791 * testsuite/ld-elf/pr30791a.d: Xfail for generic and z80 targets. * testsuite/ld-elf/pr30791b.d: Xfail for hppa and z80 targets.
2023-08-30elf: Don't merge sections with different SHF_LINK_ORDERH.J. Lu6-0/+107
For relocatable link, don't merge 2 SHF_LINK_ORDER sections if output sections of their linked to sections are different. * ldelf.c (elf_orphan_compatible): Don't merge sections with different SHF_LINK_ORDER. * testsuite/ld-elf/pr30791a.d: New file. * testsuite/ld-elf/pr30791a.s: Likewise. * testsuite/ld-elf/pr30791b.d: Likewise. * testsuite/ld-elf/pr30791b.s: Likewise. * testsuite/ld-elf/pr30791c.s: Likewise. * testsuite/ld-elf/pr30791d.s: Likewise.
2023-08-16kvx: New port.Paul Iannetta2-1/+3
2023-08-14ld: fix relocatable, retain7a target pattens for HPPASam James2-2/+2
Fix issue reported by Dave and Alan. Put back the old pattern for hppa-*-linux* and add hppa[12]*-*-linux* to cover Gentoo's hppa1.1 and hppa2.0 without including hppa64 inadvertently like I did before. ld/ PR 30733 PR 30734 * ld/testsuite/ld-elf/relocatable.d: Use better pattern to exclude hppa64 but include hppa1.1, hppa2.0. * ld/testsuite/ld-elf/retain7a.d: Ditto. Fixes: 0e339f6b4f2df25ed351cb94dc7fe16868626f49 Fixes: e3b66187192ce6840df283c00f6395bb0ff15cf5 Signed-off-by: Sam James <sam@gentoo.org>
2023-08-08ld: Fix retain7a.d XFAIL/notarget entry for hppaSam James1-1/+1
PR 30733 * ld/testsuite/ld-elf/retain7a.d: Fix XFAIL entry for hppa to match hppa{1.1,2.0}*, like hppa2.0-unknown-linux-gnu which Gentoo uses. Signed-off-by: Sam James <sam@gentoo.org>
2023-08-08ld: Fix relocatable.d XFAIL/notarget entry for hppaSam James1-1/+1
PR 30734 * ld/testsuite/ld-elf/relocatable.d: Fix notarget entry for hppa to match hppa{1.1,2.0}*, like hppa2.0-unknown-linux-gnu which Gentoo uses. Signed-off-by: Sam James <sam@gentoo.org>
2023-08-02Revert "2.41 Release sources"Sam James11-11/+11
This reverts commit 675b9d612cc59446e84e2c6d89b45500cb603a8d. See https://sourceware.org/pipermail/binutils/2023-August/128761.html.
2023-08-022.41 Release sourcesbinutils-2_41-releaseNick Clifton11-11/+11
2023-07-28testsuite: Also discard the `.MIPS.options' sectionYunQiang Su3-3/+3
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-27/DISCARD/ in ld testsuiteAlan Modra11-11/+11
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-07-17PR10957, Missing option to really print section+offsetAlan Modra1-2/+2
Many of the reloc error messages have already been converted from using %C to using %H in ld.bfd, to print section+offset as well as file/line/function. This catches a few remaining, and changes gold to do the same. PR 10957 bfd/ * elf32-sh.c (sh_elf_relocate_section): Use %H in error messages. gold/ * object.cc (Relocate_info::location): Always report section+offset. * testsuite/debug_msg.sh: Adjust to suit. * testsuite/x32_overflow_pc32.sh: Likewise. * testsuite/x86_64_overflow_pc32.sh: Likewise. ld/ * emultempl/pe.em (read_addend): Use %H in error message. * emultempl/pep.em (read_addend): Likewise. * ldcref.c (check_reloc_refs): Likewise. * ldmain.c (warning_find_reloc, undefined_symbol): Likewise. * pe-dll.c (pe_create_import_fixup): Likewise. * testsuite/ld-cris/undef2.d: Adjust expected output to suit. * testsuite/ld-cris/undef3.d: Likewise. * testsuite/ld-elf/shared.exp: Likewise. * testsuite/ld-i386/compressed1.d: Likewise. * testsuite/ld-ia64/line.exp: Likewise. * testsuite/ld-plugin/lto.exp: Likewise. * testsuite/ld-undefined/undefined.exp: Likewise. * testsuite/ld-x86-64/compressed1.d: Likewise. * testsuite/ld-x86-64/line.exp: Likewise. * testsuite/ld-x86-64/pr27587.err: Likewise.
2023-07-06Use run_host_cmd to run $CC and other no-section-header test fixesAlan Modra7-54/+54
We should be using run_host_cmd everywhere we invoke a compiler in the ld testsuite, if we want to use ld/ld-new just built. run_host_cmd properly inserts $gcc_B_opt in cases where a user wants to test binutils with a newly built compiler, ie. when $CC specifies -B itself. Also, it is not good practice to exclude tests when non-native except of course those tests that run a target binary. Compiling and linking often shows up problems. * testsuite/ld-elf/no-section-header.exp (binutils_run_test): Use run_host_cmd to invoke $CC_FOR_TARGET. Run all tests non-native too, except for attempting to run the binaries. Run tests for ELF in general, not just linux. * testsuite/ld-elf/pr25617-1-no-sec-hdr.rd: Allow localentry symbol decoration, and support either sorting of symbols. * testsuite/ld-elf/pr25617-1a-no-sec-hdr.rd: Likewise. * testsuite/ld-elf/pr25617-1a-sec-hdr.rd: Likewise. * testsuite/ld-elf/pr25617-1a-no-sec-hdr.nd: Accept D function syms. * testsuite/ld-elf/start-shared-noheader-sysv.rd: Accept mips-sgi-irix symbol output. * testsuite/ld-elf/start-shared-noheader.nd: Likewise.
2023-07-06ld: Use run_host_cmd_yesno in indirect.exp instead of catch execYunQiang Su1-4/+1
Catch "exec $CC_FOR_TARGET" won't use the gas/ld that we just build, and in fact run_host_cmd_yesno is a better choice for it. ld/ChangeLog: * testsuite/ld-elf/indirect.exp: use run_host_cmd_yesno instead of handwrite catch exec $CC_FOR_TARGET.
2023-07-06ld: Use [list ] syntax to define run_tests in indirect.expYunQiang Su1-62/+62
Currently, the var run_tests is defined by syntax {{}}, while in this case, variables cannot be used. Thus $NOPIE_CFLAGS and $NOPIE_LDFLAGS are passed to cmd as names instead of values: gcc ... $NOPIE_CFLAGS -c .../indirect5a.c -o tmpdir/indirect5a.o Let's use [list [list ]] syntax instead. ld/ChangeLog: * testsuite/ld-elf/indirect.exp(run_tests): use [list [list]] syntax instead of {{}}.
2023-06-29ld: Add tests for -z nosectionheader and --strip-section-headersH.J. Lu14-0/+559
Add tests to verify that the linker option, -z nosectionheader and objcopy and strip option, --strip-section-headers, work correctly as well as linker issues an error when dynamic symbol table from PT_DYNAMIC segment is used. PR ld/25617 * testsuite/ld-elf/hash-2.d: New file. * testsuite/ld-elf/no-section-header.exp: Likewise. * testsuite/ld-elf/pr25617-1-no-sec-hdr.nd: Likewise. * testsuite/ld-elf/pr25617-1-no-sec-hdr.rd: Likewise. * testsuite/ld-elf/pr25617-1-static-no-sec-hdr.rd: Likewise. * testsuite/ld-elf/pr25617-1a-no-sec-hdr.nd: Likewise. * testsuite/ld-elf/pr25617-1a-no-sec-hdr.rd: Likewise. * testsuite/ld-elf/pr25617-1a-sec-hdr.rd: Likewise. * testsuite/ld-elf/pr25617-1a.c: Likewise. * testsuite/ld-elf/pr25617-1b.c: Likewise. * testsuite/ld-elf/start-noheader.rd: Likewise. * testsuite/ld-elf/start-shared-noheader-gnu.rd: Likewise. * testsuite/ld-elf/start-shared-noheader-sysv.rd: Likewise. * testsuite/ld-elf/start-shared-noheader.nd: Likewise.
2023-06-29ld: Add simple tests for -z nosectionheaderKaylee Blake2-0/+18
2020-06-06 Kaylee Blake <klkblake@gmail.com> H.J. Lu <hongjiu.lu@intel.com> PR ld/25617 * testsuite/ld-elf/nosectionheader-1.d: New file. * testsuite/ld-elf/nosectionheader-2.d: Likewise.