aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2025-08-22ld: testsuite: Enable ld-shared tests on Solaris/x86Rainer Orth2-2/+7
The ld-shared tests are run on Solaris/SPARC only for no apparent reason. This patch enables them on Solaris in general. It leaves two XPASSes on 32-bit Solaris (both SPARC and x86), which I'll address in a followup. Tested on {amd64,i386}-pc-solaris2.11 and sparc{v9,}-sun-solaris2.11. 2025-07-25 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> ld: * testsuite/ld-shared/shared.exp: Enable on *-*-solaris2* rather than sparc*-*-solaris2* only.
2025-08-22MAINTAINERS: move Jim Wilson to Past MaintainersJan Beulich1-1/+1
..., effectively yielding IA-64 maintainer-less, as per his request: https://sourceware.org/pipermail/binutils/2025-August/143393.html https://sourceware.org/pipermail/binutils/2025-August/143491.html Jim - thanks much for your past work.
2025-08-22gas: make as_tsktsk() output more as_warn()-likeJan Beulich17-154/+145
The lack of a uniform "Warning: " prefix can be irritating. Re-use as_warn_internal(), by moving the warning count increment into the pre- existing callers (where the flag_no_warnings checks also are). At the same time keep the listing_warning() invocation at its place - listings certainly should have such warnings reproduced as well. While there also drop the unnecessary forward declarations of static functions.
2025-08-22ld/aarch64: prune a PE/COFF testJan Beulich2-1/+6
Expecting ___tls_end__ there is entirely random, when there are multiple symbols all at the same address. Help objdump to pick the intended symbol, by making it global and giving it a type.
2025-08-22LoongArch: Improve the reliability of test casesLulu Cai1-13/+17
Fix PR ld/31101 In some distributions, GCC enables --as-needed by default, which may prevent linking to necessary dynamic libraries and cause test failures. When tests require the host GCC, use the --no-as-needed option and place the necessary dynamic libraries after the object files. This prevents test failures and improves the test case reliability.
2025-08-22Don't run cfi-commit-10 test on 32-bit targetsAlan Modra1-1/+3
2025-08-22Automatic date update in version.inGDB Administrator1-1/+1
2025-08-21gdb/python: check return value of PyObject_New in all casesAndrew Burgess3-0/+8
I spotted a few cases where the return value of PyObject_New was not being checked against nullptr, but we were dereferencing the result. All fixed here. The fixed functions can now return NULL, so I checked all the callers, and I believe there will handle a return of NULL correctly. Assuming calls to PyObject_New never fail, there should be no user visible changes after this commit. No tests here as I don't know how we'd go about causing a Python object allocation to fail. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-08-21Automatic date update in version.inGDB Administrator1-1/+1
2025-08-20elf: Clear entsize when clearing SEC_MERGE|SEC_STRINGSH.J. Lu4-0/+25
When generating an output from input SEC_MERGE|SEC_STRINGS sections with different entsizes, we clear the SEC_MERGE|SEC_STRINGS bits. We also need to clear entsize. PR ld/33291 * ldlang.c (lang_add_section): Clearing entsize when clearing SEC_MERGE|SEC_STRINGS. * testsuite/ld-elf/pr33291.d: New file. * testsuite/ld-elf/pr33291a.s: Likewise. * testsuite/ld-elf/pr33291b.s: Likewise. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-08-20i386: Add GLIBC_ABI_GNU_TLS version dependencyH.J. Lu15-5/+169
On Linux/i386, programs and shared libraries compiled with -mtls-dialect=gnu may fail silently at run-time against glibc without the GNU TLS run-time fix for: https://sourceware.org/bugzilla/show_bug.cgi?id=32996 The glibc version tag, GLIBC_ABI_GNU_TLS, has been added to indicate that glibc has the working GNU TLS run-time: commit ed1b7a5a489ab555a27fad9c101ebe2e1c1ba881 Author: H.J. Lu <hjl.tools@gmail.com> Date: Mon Jul 28 12:16:11 2025 -0700 i386: Add GLIBC_ABI_GNU_TLS version [BZ #33221] Add the --gnu-tls-tag option to x86-64 ELF linker to add the GLIBC_ABI_GNU_TLS version dependency in output programs and shared libraries when linking against glibc if input relocatable object files call ___tls_get_addr. The output will fail to load and run at run-time against glibc which doesn't define the GLIBC_ABI_GNU_TLS version. Add the --enable-gnu-tls-tag configure option to enable --gnu-tls-tag by default. If unspecified, linker will add the GLIBC_ABI_GNU_TLS version dependency if input call ___tls_get_addr and libc.so defines the GLIBC_ABI_GNU2_TLS version. bfd/ PR ld/33287 * elf-linker-x86.h (elf_linker_x86_params): Add gnu_tls_version_tag. * elf32-i386.c (elf_backend_add_glibc_version_dependency): Add GLIBC_ABI_GNU_TLS support. * elfxx-x86.c (_bfd_x86_elf_link_check_relocs): Set has_tls_get_addr_call to 1 if ___tls_get_addr is used. * elfxx-x86.h (elf_x86_link_hash_table): Add has_tls_get_addr_call. ld/ PR ld/33287 * Mention --gnu-tls-tag, --no-gnu-tls-tag and --enable-gnu-tls-tag. * config.in: Regenerated. * configure: Likewise. * configure.ac: Add --enable-gnu-tls-tag. * ld.texi: Document --gnu-tls-tag and --enable-gnu-tls-tag. * ldlex.h (option_values): Add OPTION_GNU_TLS_VERSION_TAG and OPTION_NO_GNU_TLS_VERSION_TAG. * emultempl/elf-i386-glibc.em (elf_i386_glibc_before_parse): Initialize params.gnu_tls_version_tag. (PARSE_AND_LIST_LONGOPTS_386): New. (PARSE_AND_LIST_OPTIONS_386): Likewise. (PARSE_AND_LIST_ARGS_CASES_386): Likewise. (PARSE_AND_LIST_LONGOPTS): Append $PARSE_AND_LIST_LONGOPTS_386. (PARSE_AND_LIST_OPTIONS): Append $PARSE_AND_LIST_OPTIONS_386. (PARSE_AND_LIST_ARGS_CASES): Append $PARSE_AND_LIST_ARGS_CASES_386. * testsuite/ld-i386/gnu-tls-1.s: Likewise. * testsuite/ld-i386/gnu-tls-1a.rd: Likewise. * testsuite/ld-i386/gnu-tls-1b.rd: Likewise. * testsuite/ld-i386/i386.exp: Run PR ld/33287 tests. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-08-20x86-64: Add GLIBC_ABI_DT_X86_64_PLT version dependencyH.J. Lu4-9/+25
On Linux/x86-64, programs and shared libraries created with -z mark-plt have the GLIBC_2.36 version tag dependency since -z mark-plt uses the r_addend field of the R_X86_64_JUMP_SLOT relocation to store the offset of the indirect branch instruction. Glibc versions which don't have the commit added to glibc 2.36: commit f8587a61892cbafd98ce599131bf4f103466f084 Author: H.J. Lu <hjl.tools@gmail.com> Date: Fri May 20 19:21:48 2022 -0700 x86-64: Ignore r_addend for R_X86_64_GLOB_DAT/R_X86_64_JUMP_SLOT won't ignore the r_addend value in the R_X86_64_JUMP_SLOT relocation. If glibc versions defines GLIBC_ABI_DT_X86_64_PLT version tag with commit 399384e0c8193e31aea014220ccfa24300ae5938 Author: H.J. Lu <hjl.tools@gmail.com> Date: Thu Aug 14 07:03:20 2025 -0700 x86-64: Add GLIBC_ABI_DT_X86_64_PLT [BZ #33212] to indicate inclusion of the commit: commit f8587a61892cbafd98ce599131bf4f103466f084 Author: H.J. Lu <hjl.tools@gmail.com> Date: Fri May 20 19:21:48 2022 -0700 x86-64: Ignore r_addend for R_X86_64_GLOB_DAT/R_X86_64_JUMP_SLOT we can add GLIBC_ABI_DT_X86_64_PLT version tag dependency, instead of GLIBC_2.36 version tag dependency. PR ld/33213 * elf-bfd.h (_bfd_elf_link_add_glibc_version_dependency): Change return type to bool. * elf64-x86-64.c (elf_x86_64_add_glibc_version_dependency): Add GLIBC_ABI_DT_X86_64_PLT version tag dependency, instead of, GLIBC_2.36 version tag dependency, for -z mark-plt if libc.so defines GLIBC_ABI_DT_X86_64_PLT version tag. * elflink.c (_bfd_elf_link_add_glibc_version_dependency): Change return type to bool. Return false if elf_link_add_glibc_verneed returns false. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-08-20x86: Add GLIBC_ABI_GNU2_TLS version dependencyH.J. Lu35-125/+595
On Linux/x86, programs and shared libraries compiled with -mtls-dialect=gnu2 may fail silently at run-time against glibc without the GNU2 TLS run-time fixes for: https://sourceware.org/bugzilla/show_bug.cgi?id=31501 https://sourceware.org/bugzilla/show_bug.cgi?id=31372 A version tag, GLIBC_ABI_GNU2_TLS, has been added to glibc to indicate that glibc has the working GNU2 TLS run-time. Add the --gnu2-tls-tag option to i386/x86-64 ELF linker to add the GLIBC_ABI_GNU2_TLS version dependency in output programs and shared libraries when linking against glibc if input relocatable object files have R_386_TLS_DESC_CALL or R_X86_64_TLSDESC_CALL relocation. The output will fail to load and run at run-time against glibc which doesn't define the GLIBC_ABI_GNU2_TLS version. Add the --enable-gnu2-tls-tag configure option to enable --gnu2-tls-tag by default. If unspecified, linker will add the GLIBC_ABI_GNU2_TLS version dependency if input object files have R_386_TLS_DESC_CALL or R_X86_64_TLSDESC_CALL relocation and libc.so defines the GLIBC_ABI_GNU2_TLS version. Update elf_link_add_glibc_verneed to properly add the GLIBC_2.36 version dependency when -z mark-plt -z nopack-relative-relocs passed to x86-64 ELF linker. bfd/ PR ld/33130 * elf-bfd.h (_bfd_elf_link_add_glibc_version_dependency): Add a pointer to bool argument. * elf-linker-x86.h (elf_linker_x86_params): Add gnu2_tls_version_tag. * elf32-i386.c (elf_i386_scan_relocs): Set has_tls_desc_call to 1 for R_386_TLS_DESC_CALL. (elf_i386_add_glibc_version_dependency): New. Undef before FreeBSD support. * elf64-x86-64.c (elf_x86_64_scan_relocs): Set has_tls_desc_call to 1 for R_X86_64_TLSDESC_CALL. (elf_x86_64_add_glibc_version_dependency): Add GLIBC_ABI_GNU2_TLS version dependency if GLIBC_ABI_GNU2_TLS dependency isn't disabled and has_tlsdesc_call isn't 0. (elf_backend_add_glibc_version_dependency): Undef before FreeBSD support and redefine for elf32-x86-64. * elflink.c (elf_link_add_glibc_verneed): Changed to return bool. Remove the pointer to elf_find_verdep_info argument. Add a pointer to bool argument, auto_version. Return true if linked against glibc. Otherwise return false. If the version dependency is added, set *auto_version to true. If *auto_version is true, add the version dependency only if libc.so defines the version. (_bfd_elf_link_add_glibc_version_dependency): Add a pointer to bool argument and pass it to elf_link_add_glibc_verneed. (_bfd_elf_link_add_dt_relr_dependency): Pass NULL to _bfd_elf_link_add_glibc_version_dependency. * elfxx-x86.h (elf_x86_link_hash_table): Add has_tls_desc_call. ld/ PR ld/33130 * NEWS: Mention --gnu2-tls-tag, --no-gnu2-tls-tag and --enable-gnu2-tls-tag. * config.in: Regenerated. * configure: Likewise. * configure.ac: Add --enable-gnu2-tls-tag. * ld.texi: Document --gnu2-tls-tag/--no-gnu2-tls-tag. * ldlex.h (option_values): Add OPTION_GNU2_TLS_VERSION_TAG and OPTION_NO_GNU2_TLS_VERSION_TAG. * emulparams/elf32_x86_64.sh (EXTRA_EM_FILE): Changed to "elf-x86-64-glibc". * emulparams/elf_i386.sh (EXTRA_EM_FILE): Set to "elf-i386-glibc". * emulparams/elf_i386_fbsd.sh (EXTRA_EM_FILE): New. Set to "elf-x86". * emulparams/elf_i386_haiku.sh (EXTRA_EM_FILE): Likewise. * emulparams/elf_x86_64.sh (EXTRA_EM_FILE): Likewise. * emulparams/elf_x86_64_fbsd.sh (EXTRA_EM_FILE): New. Set to "elf-x86-64". * emulparams/elf_x86_64_haiku.sh (EXTRA_EM_FILE): Likewise. * (EXTRA_EM_FILE): Likewise. * (EXTRA_EM_FILE): Likewise. * emultempl/elf-i386-glibc.em: New file. * emultempl/elf-x86-64-glibc.em: Likewise. * emultempl/elf-x86-64.em: Likewise. * emultempl/elf-x86-glibc.em: Likewise. * emultempl/elf-x86.em (elf_x86_64_before_parse): Removed. (LDEMUL_BEFORE_PARSE): Likewise. (elf_x86_64_before_allocation): Likewise. (LDEMUL_BEFORE_ALLOCATION): Likewise. * emultempl/solaris2-x86-64.em: New file. * testsuite/ld-i386/gnu2-tls-1.s: Likewise. * testsuite/ld-i386/gnu2-tls-1a.rd: Likewise. * testsuite/ld-i386/gnu2-tls-1b.rd: Likewise. * testsuite/ld-x86-64/gnu2-tls-1.s: Likewise. * testsuite/ld-x86-64/gnu2-tls-1a.rd: Likewise. * testsuite/ld-x86-64/gnu2-tls-1b.rd: Likewise. * testsuite/ld-x86-64/mark-plt-2.rd: Likewise. * testsuite/ld-x86-64/mark-plt-2.s: Likewise. * testsuite/ld-i386/i386.exp: Run GLIBC_ABI_GNU2_TLS tests. * testsuite/ld-x86-64/x86-64.exp: Likewise. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-08-20ld: Compile some tests with -mdirect-extern-accessH.J. Lu9-69/+114
When GCC enables -mno-direct-extern-access by default, some tests fail without -mdirect-extern-access. Define DIRECT_EXTERN_ACCESS_CFLAGS to compile these tests with -mdirect-extern-access. Also pass "-z noindirect-extern-access" to linker to support the C library compiled with -mno-direct-extern-access. PR ld/33267 * testsuite/config/default.exp (DIRECT_EXTERN_ACCESS_CFLAGS): New. * testsuite/ld-elf/linux-x86.exp: Compile some tests with $DIRECT_EXTERN_ACCESS_CFLAGS. * testsuite/ld-elfvers/vers.exp (need_direct_extern_access): New for i?86. Compile tests with $need_direct_extern_access. * testsuite/ld-i386/i386.exp: Compile some tests with $DIRECT_EXTERN_ACCESS_CFLAGS. * testsuite/ld-ifunc/ifunc.exp (need_direct_extern_access): New for i?86. Compile tests with $need_direct_extern_access. * testsuite/ld-shared/shared.exp (need_direct_extern_access): New for i?86. Compile tests with $need_direct_extern_access. * testsuite/ld-srec/srec.exp (CFLAGS_FOR_TARGET_TEST): Add $DIRECT_EXTERN_ACCESS_CFLAGS. (CXXFLAGS_FOR_TARGET_TEST): Likewise. * testsuite/ld-vsb/vsb.exp (need_direct_extern_access): New for i?86. Compile tests with $need_direct_extern_access. * testsuite/ld-x86-64/x86-64.exp: Compile some tests with $DIRECT_EXTERN_ACCESS_CFLAGS and link some tests with "-Wl,-z,noindirect-extern-access". Co-Authored-By: Sam James <sam@gentoo.org> Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Signed-off-by: Sam James <sam@gentoo.org>
2025-08-20gdb: rework _active_linker_namespaces variableGuinevere Larsen7-21/+51
This commit reworks the _active_linker_namespaces convenience variable following Simon's feedback here: https://sourceware.org/pipermail/gdb-patches/2025-August/219938.html This patch implements the renaming to _linker_namespace_count (following the standard set by _inferior_thread_count) and makes the convenience variable more resilient in the multi-inferior case by providing a new function, solib_linker_namespace_count, which counts gets the count of namespaces using the solib_ops of the provided program_space Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-08-20gdb/amd-dbgapi: make get_amd_dbgapi_inferior_info return a referenceSimon Marchi1-107/+112
This function can't return a NULL pointer, so make it return a reference instead. Change-Id: I0970d6d0757181291b300bd840037a48330a7fbb
2025-08-20gdb/MAINTAINERS - ADD Gopi Kumar Bulusu gopi@sankhya.comGopi Kumar Bulusu1-0/+1
Signed-off-by: Gopi Kumar Bulusu <gopi@sankhya.com>
2025-08-20RISC-V: PR33216, Fixed gcc testcases failed for commit 28520d7Nelson Chu3-16/+40
I made a stupid mistake in the commit 28520d7, allow to assemble slli/srli/srai with 0 immediate to hint c.slli/c.srli/c.srai. These hints will be regared as illegal instruction for gdb and qemu, so at least I got following gcc testcases failed, === g++: Unexpected fails for rv64gc lp64d medlow === FAIL: c-c++-common/torture/builtin-arith-overflow-17.c -O0 execution test FAIL: c-c++-common/torture/builtin-arith-overflow-6.c -O0 execution test FAIL: c-c++-common/torture/builtin-arith-overflow-p-17.c -O0 execution test FAIL: c-c++-common/torture/builtin-arith-overflow-p-6.c -O0 execution test === gfortran: Unexpected fails for rv64gc lp64d medlow === FAIL: gfortran.dg/leadz_trailz_2.f90 -O0 execution test === gcc: Unexpected fails for rv64gc lp64d medlow === FAIL: c-c++-common/torture/builtin-arith-overflow-17.c -O0 execution test FAIL: c-c++-common/torture/builtin-arith-overflow-6.c -O0 execution test FAIL: c-c++-common/torture/builtin-arith-overflow-p-17.c -O0 execution test FAIL: c-c++-common/torture/builtin-arith-overflow-p-6.c -O0 execution test So we should just allow c.slli/c.srli/c.srai with zero immediate as hints, but don't allow slli/srli/srai with zero immediate. gas/ PR 33216 * testsuite/gas/riscv/c-zero-imm.d: Only allow c.slli/c.srli/c.srai with zero immediate as hints, but don't allow slli/srli/srai with zero immediate. * testsuite/gas/riscv/c-zero-imm.s: Likewise. opcodes/ PR 33216 * riscv-opc.c (match_slli_as_c_slli): Added back. (match_srxi_as_c_srxi): Likewise. (riscv_opcodes): Only allow c.slli/c.srli/c.srai with zero immediate as hints, but don't allow slli/srli/srai with zero immediate.
2025-08-20Remove cloudabi supportAlan Modra20-153/+6
Apparently the cloudabi project is dead. The cloudabi support branded object files with ELFOSABI_CLOUDABI but other than that didn't do much.
2025-08-19Remove autoconf macro AC_HEADER_STDCPietro Monteiro6-565/+0
Stop using AC_HEADER_STDC since it is no longer supported in autoconf 2.72+. We require a C++ compiler that supports c++17, it's probably safe to assume that the C compiler fully supports C89. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-08-20Automatic date update in version.inGDB Administrator1-1/+1
2025-08-20Re: gas: testsuite: fix regression in cfi-common-10.dAlan Modra1-13/+2
Just match what the test is actually trying to verify, to fix more regressions.
2025-08-19gdb: remove unused includes in inferior.hSimon Marchi5-2/+4
gdbsupport/common-inferior.h was needed by a few .c files, so move it there. Change-Id: Ia3ab8c30b529a1eda09862c8faea9e8c1c8123b5
2025-08-19gas: testsuite: fix regression in cfi-common-10.dIndu Bhagat1-2/+2
A previous commit 09292f4ae2c introduced the new test cfi-common-10.d. The testcase needs some adjustments for it to be useful on a variety of targets.
2025-08-19gdb: remove some unnecessary watchpoint_addr_within_range overridesAndrew Burgess3-25/+0
While looking at the watchpoint code, I realised that AArch64, ARM, and Loongarch all override watchpoint_addr_within_range with an implementation that is the same as the default (but with the logic written slightly differently). Compare the deleted functions to default_watchpoint_addr_within_range in target.c. The only other targets that override watchpoint_addr_within_range are ppc_linux_nat_target and remote_target, in both cases the implementation is different to the default. Lets remove these unnecessary overrides, and just use the default. There should be no user visible changes after this commit. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-08-19Add tests of the linker's --errror-execstack and --error-rwx-segments optionsNick Clifton6-1/+55
2025-08-19gdb: rename address_class -> location_classSimon Marchi48-342/+331
The enum address_class and related fields and methods seem misnamed to me. Generalize it to "location_class". The enumerators in address_class are already prefixed with LOC, so the new name seems logical to me. Rename related fields and methods as well. Plus, address_class could easily be mistaken for other unrelated things named "address class" in GDB or DWARF. Tested by rebuilding. Change-Id: I0dca3738df412b350715286c608041b08e9b4d82 Approved-by: Kevin Buettner <kevinb@redhat.com>
2025-08-19gdb: rename gdbarch_software_single_step -> gdbarch_get_next_pcsSimon Marchi36-59/+57
I spotted this while reviewing a patch adding a new gdbarch_software_single_step implementation. I find the name "software_single_step" a bit misleading or unclear. It makes it sounds as if the function executed a single step. In reality, this function returns the possible next PCs for current instructions. We have a similar concept in GDBserver: linux_process_target::low_get_next_pcs. I like that name, it's clear and straight to the point. Rename gdbarch_software_single_step to gdbarch_get_next_pcs. I find this name more indicative of what happens. There is some code for ARM shared between GDB and GDBserver to implement both sides, also called "get next pcs", so I think it all fits well together. Tested by rebuilding. Change-Id: Ide74011a5034ba11117b7e7c865a093ef0b1dece Approved-by: Kevin Buettner <kevinb@redhat.com> Acked-by: Luis Machado <luis.machado.foss@gmail.com>
2025-08-19ld: testsuite: Mark vers26b3 unsupported on x86_64Rainer Orth2-1/+9
After enabling the ld-elfvers tests on Solaris/x86, one of them FAILs on Solaris/amd64 only: FAIL: vers26b3 /ld-new: tmpdir/vers26b3.o: relocation R_X86_64_32 against symbol `foo' can not be used when making a shared object; recompile with -fPIC ./ld-new: failed to set dynamic section sizes: bad value The error is strange: vers26b3.o *was* compiled with -fPIC and repeating the link with /bin/ld just works. However, the resulting vers26b3.so fails to load: $ ldd -r tmpdir/vers26b3.so [...] ld.so.1: vers26b3.so.ld: fatal: relocation error: R_AMD64_32: file tmpdir/vers26b3.so.ld: symbol foo: value 0x7fff34d00830 does not fit When running the test on Linux/x86_64, it fails with the same ld message as above, so the test is marked unsupported for both Linux/x86_64 and Solaris/amd64. Tested on {amd64,i386}-pc-solaris2.11 and {x86_64,i686}-pc-linux-gnu. 2025-07-31 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> ld: * testsuite/ld-elfvers/vers.exp (vers26b3): Mark unsupported on Linux/x86_64 and Solaris/amd64.
2025-08-19Add missing ChangeLog.Rainer Orth1-0/+7
2025-08-19ld: testsuite: Fix ld-elfvers tests on SolarisRainer Orth2-2/+7
All ld-elfvers tests FAIL on Solaris/SPARC, always with the same failure mode: FAIL: vers1 ./ld-new: _etext: undefined version: vers1.so ./ld-new: _end: undefined version: vers1.so ./ld-new: _edata: undefined version: vers1.so ./ld-new: failed to set dynamic section sizes: bad value This is due to the use of --no-undefined-version, the error being emitted by bfd/elflink.c (bfd_elf_size_dynamic_sections). The affected symbols are mandated by the Solaris ABI in versioned shared objects and are generated by ld/emultempl/solaris2.em (elf_solaris2_before_allocation). The check in bfd_elf_size_dynamic_sections fails since for the base version (vers1.so), both symver and script are 0: vers1.so pattern = "_etext", literal = 1, symver = 0, script = 0, mask = 1 Given that those symbols are generated internally by ld, it seems sensible to set script = 1 for them. This patch does just that, at the same time enabling the tests for Solaris/x86. Not doing this before looks like an oversight: there's no difference between SPARC and x86 in this regard. This introduces one failure on Solaris/amd64 (vers26b3), which I'll address in a followup. Tested no {sparc,sparcv9}-sun-solaris2.11, {i386,amd64}-pc-solaris2.11, and {x86_64,i686}-pc-linux-gnu. 2025-07-25 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> ld: * emultempl/solaris2.em (elf_solaris2_before_allocation): Mark global symbols as generated by linker script. * testsuite/ld-elfvers/vers.exp: Enable on *-*-solaris2* rather than sparc*-*-solaris2* only.
2025-08-19gdb/testsuite: fix invalid assumption about TUI src windowAndrew Burgess1-2/+3
Fix a failing test introduced by this commit: commit e53b88b40ed38651b50f954dfe76066822094c15 Date: Wed Aug 13 15:29:38 2025 +0100 gdb: fix forward/reverse search, when no lines are printed The TUI test added in this commit assumed that the opening '{' of main would be the first statement line (in DWARF terms), and so, would be the initial focus of the TUI src window. This is true for some targets (e.g. x86), but not others (e.g. AArch64), and so gdb.tui/source-search.exp was seen failing on at least some AArch64 targets. Fix this by adding a 'list' command to the test, which forces the initial window contents to be as needed for the rest of the test. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33290 Approved-By: Tom de Vries <tdevries@suse.de>
2025-08-19elf: Prune empty generic propertiesH.J. Lu5-16/+90
Prune empty generic properties before discarding empty property note section and leave processor specific properties to the backend. bfd/ PR ld/33292 * elf-properties.c (elf_prune_empty_properties): New function. (_bfd_elf_link_setup_gnu_properties): Call elf_prune_empty_properties before discarding empty property note section. Move indirect_extern_access processing before elf_prune_empty_properties call. ld/ PR ld/33292 * testsuite/ld-x86-64/pr33292-x32.d: New file. * testsuite/ld-x86-64/pr33292.d: Likewise. * testsuite/ld-x86-64/pr33292.s: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run PR ld/33292 tests. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-08-19bfd: Fix Solaris/x86 ELF_MAXPAGESIZERainer Orth2-4/+13
I noticed that the alignment of the .text and .data sections on Solaris/x86 doesn't match what /bin/ld does: gld uses the original i386 psABI default of 0x1000, while Solaris has moved to larger values as can be seen both in the Oracle Solaris 11.4 Linkers and Libraries Guide, ch. 15, Program Loading and Dynamic Linking, p. 15-6 and the system headers (<sys/elf_{i386,amd64}.h>) that have while the Solaris/SPARC values are already correct. To fix this, on i386 it's sufficient to redefine ELF_MAXPAGESIZE. On x86_64, unlike i386, ELF_COMMONPAGESIZE is hardcoded as 0x1000, the default, so setting ELF_MAXPAGESIZE has no effect on ELF_P_ALIGN. Setting ELF_COMMONPAGESIZE to ELF_MAXPAGESIZE, too, fixes that and brings both target in sync. ELF_MACHINE_CODE is just set to the original value again, so it's removed. Tested on {i386,amd64}-pc-solaris2.11, {i686,x86_64}-pc-linux-gnu, and amd64-pc-freebsd14.0. 2025-07-29 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> bfd: * elf32-i386.c <elf32-i386-sol2> (ELF_MAXPAGESIZE): Redefine. <elf32-iamcu> (ELF_MAXPAGESIZE): Restore previous value. * elf64-x86-64.c (ELF_COMMONPAGESIZE): Define as ELF_MAXPAGESIZE. <elf64-x86-64-sol2> (ELF_MAXPAGESIZE): Redefine <elf32-x86-64> (ELF_MAXPAGESIZE): Restore previous value. (ELF_MACHINE_CODE): Remove.
2025-08-19binutils: dwarf: fix display of large cfa_offsetIndu Bhagat6-4/+58
eh_frame textual dump was not correct when the cfa_offset is a large value. The reason is that the dumping code generally assumes the cfa_offset is an 'int'. cfa_offset values can be updated by various DWARF opcodes, like: - DW_CFA_def_cfa, DW_CFA_def_cfa_offset which bring unsigned leb128 cfa_offset - DW_CFA_def_cfa_sf, DW_CFA_def_cfa_offset_sf which bring signed leb128 cfa_offset Internally, the routines in dwarf.c keep the value as 'uint64_t cfa_offset'. That size of the datatype is expected to work for most of the real-world cases. Care, however, needs to be taken when it comes to the signedness of the value. Fix the buggy behavior by adding an additional field to track whether the value of cfa_offset is signed or unsigned and display accordingly for "frames-interp" output. The display of cfa_offset had issues in both "frames-interp" output (objdump -WF or do_debug_frames_interp) and the "frames" output. Add two new tests: cfi-common-10.s uses a large positive cfa_offset (with "frames output), and cfi-x86_64-2.s uses a negative cfa_offset (with "frames-interp" output). ChangeLog: * binutils/dwarf.c (frame_display_row): Update format string based on signedness. (display_debug_frames): Track signedness. Also fix display of cfa_offset using PRIu64 or PRId64 as applicable. * gas/testsuite/gas/cfi/cfi.exp: Add two new tests. * gas/testsuite/gas/cfi/cfi-common-10.d: New test. * gas/testsuite/gas/cfi/cfi-common-10.s: New test. * gas/testsuite/gas/cfi/cfi-x86_64-2.d: New test. * gas/testsuite/gas/cfi/cfi-x86_64-2.s: New test.
2025-08-18Limit BFD_SUPPORTS_PLUGINS check to plugin.h and targets.cH.J. Lu23-213/+161
Minimize the BFD_SUPPORTS_PLUGINS check to make code more readable and maintainable by: 1. Update bfd/plugin.h to define plugin functions as static inline if BFD_SUPPORTS_PLUGINS is 0. 2. Remove BFD_SUPPORTS_PLUGINS check from all bfd and binutils files except plugin.h and targets.c. 3. Replace the remaining BFD_SUPPORTS_PLUGINS checks with a function so that plugin availability is checked at run time. bfd/ * archive.c: Include plugin.h unconditionally. (_bfd_compute_and_write_armap): Remove the BFD_SUPPORTS_PLUGINS check. * bfd-in.h (bfd_plugin_enabled): New. * bfd-in2.h: Regenerated. * elflink.c: Include plugin.h unconditionally. (elf_link_is_defined_archive_symbol): Remove the BFD_SUPPORTS_PLUGINS check. * format.c: Include plugin.h unconditionally. (bfd_set_lto_type): Remove the BFD_SUPPORTS_PLUGINS check. (bfd_check_format_matches): Replace the BFD_SUPPORTS_PLUGINS check with the bfd_plugin_enabled call. Replace plugin_vec with bfd_plugin_vec. Remove the BFD_SUPPORTS_PLUGINS check. * plugin.c (bfd_plugin_target_p): Removed. * plugin.h (bfd_plugin_vec): New. (bfd_plugin_target_p): Likewise. (bfd_plugin_set_program_name): New. Static inline function if BFD_SUPPORTS_PLUGINS is 0. (bfd_plugin_open_input): Likewise. (bfd_plugin_set_plugin): Likewise. (bfd_link_plugin_object_p): Likewise. (register_ld_plugin_object_p): Likewise. (bfd_plugin_close_file_descriptor): Likewise. (bfd_plugin_vec): Likewise. (bfd_plugin_target_p): Likewise. * xtensa-dynconfig.c (xtensa_load_config): Replace the BFD_SUPPORTS_PLUGINS check with the bfd_plugin_enabled call. ar/ * ar.c: Include plugin.h unconditionally. (plugin_target): Removed. (usage): Replace the BFD_SUPPORTS_PLUGINS check with the bfd_plugin_enabled call. (ranlib_usage): Likewise. (decode_options): Likewise. (ranlib_main): Likewise. (main): Call bfd_plugin_set_program_name unconditionally. * nm.c: Include plugin.h unconditionally. (plugin_target): Removed. (usage): Replace the BFD_SUPPORTS_PLUGINS check with the bfd_plugin_enabled call. (filter_symbols): Remove the BFD_SUPPORTS_PLUGINS check. (display_rel_file): Likewise. (main): Call bfd_plugin_set_program_name unconditionally. Replace the BFD_SUPPORTS_PLUGINS check with the bfd_plugin_enabled call. * objcopy.c: Include plugin.h unconditionally. (strip_usage): Replace the BFD_SUPPORTS_PLUGINS check with the bfd_plugin_enabled call. (copy_archive): Remove the BFD_SUPPORTS_PLUGINS check. Replace BFD_SUPPORTS_PLUGINS with the bfd_plugin_enabled call. (copy_file): Likewise. (strip_main): Likewise. ld/ * ldfile.c: Include plugin.h unconditionally. (ldfile_try_open_bfd): Remove the BFD_SUPPORTS_PLUGINS check. * ldlang.c: Include plugin.h unconditionally. (plugin_insert): Remove the BFD_SUPPORTS_PLUGINS check. (plugin_undefs): Likewise. (open_input_bfds): Likewise. (lang_check): Likewise. (lang_gc_sections): Likewise. (find_next_input_statement): Likewise. (lang_process): Likewise. * ldlang.h (lang_input_statement_flags): Likewise. * ldlex.h (option_values): Likewise. * ldmain.c: Include plugin.h unconditionally. (ld_cleanup): Remove the BFD_SUPPORTS_PLUGINS check. (main): Likewise. (add_archive_element): Likewise. * lexsup.c: Include plugin.h unconditionally. (ld_options): Remove the BFD_SUPPORTS_PLUGINS check. (parse_args): Replace the BFD_SUPPORTS_PLUGINS check with the bfd_plugin_enabled call. Remove the BFD_SUPPORTS_PLUGINS check. (help): Append " (ignored)" to plugin options if bfd_plugin_enabled return false. * libdep_plugin.c: Remove the BFD_SUPPORTS_PLUGINS check. * plugin.c: Likewise. * testplug.c: Likewise. * testplug2.c: Likewise. * testplug3.c: Likewise. * testplug4.c: Likewise. Co-Authored-By: Alan Modra <amodra@gmail.com> Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-08-19Re: windres: don't exit so much on errors in read_coff_rsrcAlan Modra1-0/+8
oss-fuzz found that I missed some error paths in commit 9e68cae4fd. This fix prevents reads of a NULL pointer in sort_resources. * rescoff.c (read_coff_res_dir): Check return of recursive calls and read_coff_data_entry calls. Pass failures up the call chain.
2025-08-19Automatic date update in version.inGDB Administrator1-1/+1
2025-08-18ld: Properly override compiler flags in testsH.J. Lu7-38/+60
Some tests need to be compiled with additional flags. When binutils is built and compiled with CC="gcc -fsanitize=address,undefined" CXX="g++ -fsanitize=address,undefined" some linker tests fail to disable address sanitizer options since proc default_ld_compile has set ccexe $cc set ccparm [string first " " $cc] set ccflags "" if { $ccparm > 0 } then { set ccflags [string range $cc $ccparm end] set ccexe [string range $cc 0 $ccparm] set cc $ccexe } ... set cmd "$cc $flags $ccflags -c $source -o $object" Compiler flags in $CC and $CXX will be the last ones. Add CFLAGS_FOR_TARGET_TEST and CXXFLAGS_FOR_TARGET_TEST to use them in proc default_ld_compile set cflag_test "" set cxxflag_test "" if {[string match "*++*" $ccexe]} { append flags " $CXXFLAGS_FOR_TARGET" set cflag_test "$CXXFLAGS_FOR_TARGET_TEST" } else { append flags " $CFLAGS_FOR_TARGET" set cflag_test "$CFLAGS_FOR_TARGET_TEST" } ... set cmd "$cc $flags $ccflags $cflag_test -c $source -o $object" so that they will be the last flags passed to compiler. Also update run_ld_link_exec_tests and run_cc_link_tests to make CFLAGS_FOR_TARGET_TEST and CXXFLAGS_FOR_TARGET_TEST the last flags passed to compiler. * testsuite/config/default.exp (CFLAGS_FOR_TARGET_TEST): New. (CXXFLAGS_FOR_TARGET_TEST): Likewise. * testsuite/ld-elf/dwarf.exp (CFLAGS_FOR_TARGET): Renamed to ... (CFLAGS_FOR_TARGET_TEST): This. * testsuite/ld-elf/shared.exp: Save, append and restore CFLAGS_FOR_TARGET_TEST and CXXFLAGS_FOR_TARGET_TEST for $build_tests. Save, append and restore CFLAGS_FOR_TARGET_TEST, instead of CFLAGS_FOR_TARGET, for $dlopen_run_tests. * testsuite/ld-plugin/plugin.exp (CFLAGS_FOR_TARGET): Renamed to ... (CFLAGS_FOR_TARGET_TEST): This. * testsuite/ld-shared/shared.exp (CFLAGS_FOR_TARGET): Renamed to ... (CFLAGS_FOR_TARGET_TEST): This. * testsuite/ld-srec/srec.exp (CFLAGS_FOR_TARGET): Renamed to ... (CFLAGS_FOR_TARGET_TEST): This. (CXXFLAGS_FOR_TARGET): Renamed to ... (CXXFLAGS_FOR_TARGET_TEST): This. * testsuite/lib/ld-lib.exp (default_ld_compile): Append CFLAGS_FOR_TARGET_TEST/CXXFLAGS_FOR_TARGET_TEST to compiler flags. (run_ld_link_exec_tests): Append CFLAGS_FOR_TARGET_TEST and CXXFLAGS_FOR_TARGET_TEST to compiler. (run_cc_link_tests): Likewise. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-08-18Fix compile time warning when building with Clang.Nick Clifton1-1/+1
PR 33282
2025-08-18[gdb/testsuite] Fix gdb.tui/tui-mode-switch.exp on aarch64Tom de Vries1-4/+9
On aarch64-linux, occasionally I run into these warnings: ... PASS: gdb.tui/tui-mode-switch.exp: set style enabled off WARNING: timeout in accept_gdb_output PASS: gdb.tui/tui-mode-switch.exp: no boo WARNING: timeout in accept_gdb_output ... The first in more detail: ... Box Dump (40 x 1) @ (0, 11): 11 b(gdb) b WARNING: timeout in accept_gdb_output ... Fix this by waiting for a prompt after leaving TUI before sending "b". Also, while we're at it generate a few more passes. Tested on aarch64-linux.
2025-08-18ld: Set the is_linker_input fieldH.J. Lu1-0/+3
Set the is_linker_input field when adding object only section. * ldlang.c (cmdline_add_object_only_section): Set the is_linker_input field. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-08-18ld: testsuite: Fix no-plt tests on Solaris/i386Rainer Orth8-33/+44
Several no-plt tests FAIL on 32-bit Solaris/x86: FAIL: Build libno-plt-1b.so FAIL: No PLT (dynamic 1a) FAIL: No PLT (dynamic 1b) FAIL: No PLT (dynamic 1c) FAIL: No PLT (PIE 1e) FAIL: No PLT (PIE 1f) FAIL: No PLT (PIE 1g) The failure mode is always similar, e.g. ../binutils/objdump -dwrj.text tmpdir/libno-plt-1b.so > dump.out regexp_diff match failure regexp "^ +[a-f0-9]+: 8b 80 ([0-9a-f]{2} ){4}[ ]+mov +-0x[a-f0-9]+\(%eax\),%eax$" line " 4aa: 8b 80 14 00 00 00 mov 0x14(%eax),%eax" regexp_diff match failure regexp "^ +[a-f0-9]+: ff a0 ([0-9a-f]{2} ){4}[ ]+jmp +\*-0x[0-9a-f]+\(%eax\)$" line " 4ca: ff a0 14 00 00 00 jmp *0x14(%eax)" i.e. there's a positive offset from the GOT instead of the expected negative one. AFAICS that's because there are additional GOT entries on the Solaris side (printed with elfdump -G since there seems to be no support for that in either readelf or objdump): * Solaris/i386: Global Offset Table Section: .got index addr value pending relocation [0] 0x15f4 0x1514 [1] 0x15f8 0 [2] 0x15fc 0 [3] 0x1600 0x3a6 R_386_JMP_SLOT __cxa_finalize [4] 0x1604 0 R_386_GLOB_DAT _ITM_deregisterTMCloneTable [5] 0x1608 0 R_386_GLOB_DAT func * Linux/i686: Global Offset Table Section: .got index addr value pending relocation [0] 0x3fe0 0 R_386_GLOB_DAT _ITM_deregisterTMCloneTable [1] 0x3fe4 0 R_386_GLOB_DAT __cxa_finalize [2] 0x3fe8 0 R_386_GLOB_DAT __gmon_start__ [3] 0x3fec 0 R_386_GLOB_DAT func This patch fixes this by making the sign optional in affected cases. Tested on i386-pc-solaris2.11 and i686-pc-linux-gnu. 2025-07-25 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> ld: * testsuite/ld-i386/libno-plt-1b.dd: Allow for positive GOT offsets. * testsuite/ld-i386/no-plt-1a.dd: Likewise. * testsuite/ld-i386/no-plt-1b.dd: Likewise. * testsuite/ld-i386/no-plt-1c.dd: Likewise. * testsuite/ld-i386/no-plt-1e.dd: Likewise. * testsuite/ld-i386/no-plt-1f.dd: Likewise. * testsuite/ld-i386/no-plt-1g.dd: Likewise.
2025-08-18gas: Record file name in macro locationsAlice Carlotti3-11/+13
This allows the correct file name to be used when emitting messages for lines within a macro. The line numbers were already set and displayed correctly, which resulted in mismatched file names and line numbers. PR 32738
2025-08-18gas: Improve file name in messages headerAlice Carlotti7-13/+33
Message output from gas is prefixed with a line of the form: path/file.s: Assembler messages: Don't use the file name from the first message for this header. Instead, use the source file name specified in the command line.
2025-08-18Don't choose plugin target in binutils/Alan Modra8-90/+48
Instead make bfd_check_format try the plugin target first when the user hasn't supplied a target. bfd/ * format.c (bfd_check_format_matches): Try for a plugin target match first. * targets.c (bfd_find_target): Don't specially treat "plugin". binutils/ * ar.c (plugin_target): Delete. (open_inarch): Don't set target of archive elements. (replace_members): Use target rather than plugin_target when opening replacement or additional files. * arsup.c (plugin_target): Delete. Replace all uses with NULL. (ar_open): Don't set element target. * bucomm.h (set_plugin_target): Delete. * nm.c (plugin_target): Delete. (display_archive): Don't set element target. (display_file): Alway use target when opening file. * objcopy.c (copy_archive): Don't use plugin target for output elements. * NEWS: Mention stricter target checking.
2025-08-18Fix typo in recent update to elf.c's core note handling code.Nick Clifton1-1/+1
PR 33282
2025-08-18ld: Issue an error if group nested too deeplyH.J. Lu10-9/+50
If a linker script has a group nested too deeply by mistake, issue an error instead of hanging forever without outputting any error message. PR ld/33265 * ldlang.c (MAX_NESTED_GROUP_DEPTH): New. (open_input_bfds): Add a pointer argument for the nested group count. Increment the count before the while loop and decrement it after the loop. Issue an error if the nested group count >= MAX_NESTED_GROUP_DEPTH when processing input statement. (lang_process): Update open_input_bfds calls. (cmdline_emit_object_only_section): Likewise. * testsuite/ld-scripts/libpr33265-1.a: New file. * testsuite/ld-scripts/libpr33265-2.a: Likewise. * testsuite/ld-scripts/libpr33265-3a.a: Likewise. * testsuite/ld-scripts/libpr33265-3b.a: Likewise. * testsuite/ld-scripts/libpr33265-3c.a: Likewise. * testsuite/ld-scripts/pr33265-1.d: Likewise. * testsuite/ld-scripts/pr33265-2.d: Likewise. * testsuite/ld-scripts/pr33265-3.d: Likewise. * testsuite/ld-scripts/script.exp: Run PR ld/33265 tests. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-08-18Automatic date update in version.inGDB Administrator1-1/+1
2025-08-17libsframe: testsuite: use SFrame V2 specific APIsIndu Bhagat6-18/+30
Use sframe_encoder_add_funcdesc_v2 instead of sframe_encoder_add_funcdesc. Similarly, use sframe_decoder_get_funcdesc_v2 instead of sframe_decoder_get_funcdesc. sframe_encoder_add_funcdesc, and sframe_decoder_get_funcdesc were first added for SFrame V1. For the purpose of these testcases, the two V2 APIs are (almost) functionally equivalent. In future, we may want to make sframe_encoder_add_funcdesc and sframe_decoder_get_funcdesc internal to libsframe only. Using the V2 named APIs is better for clarity as well. libsframe/testsuite/ * libsframe.encode/encode-1.c: Use V2 named APIs instead. * libsframe.find/findfre-1.c: Likewise. * libsframe.find/findfunc-1.c: Likewise. * libsframe.decode/be-flipping.c: Likewise. * libsframe.decode/frecnt-1.c: Likewise. * libsframe.decode/frecnt-2.c: Likewise.