]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
5 weeks agogdb, gdbserver: Add support of Intel shadow stack pointer register.
Christina Schimpe [Fri, 29 Mar 2019 15:38:50 +0000 (16:38 +0100)] 
gdb, gdbserver: Add support of Intel shadow stack pointer register.

This patch adds the user mode register PL3_SSP which is part of the
Intel(R) Control-Flow Enforcement Technology (CET) feature for support
of shadow stack.
For now, only native and remote debugging support for shadow stack
userspace on amd64 linux are covered by this patch including 64 bit and
x32 support.  32 bit support is not covered due to missing Linux kernel
support.

This patch requires fixing the test gdb.base/inline-frame-cycle-unwind
which is failing in case the shadow stack pointer is unavailable.
Such a state is possible if shadow stack is disabled for the current thread
but supported by HW.

This test uses the Python unwinder inline-frame-cycle-unwind.py which fakes
the cyclic stack cycle by reading the pending frame's registers and adding
them to the unwinder:

~~~
for reg in pending_frame.architecture().registers("general"):
     val = pending_frame.read_register(reg)
     unwinder.add_saved_register(reg, val)
     return unwinder
~~~

However, in case the python unwinder is used we add a register (pl3_ssp) that is
unavailable.  This leads to a NOT_AVAILABLE_ERROR caught in
gdb/frame-unwind.c:frame_unwind_try_unwinder and it is continued with standard
unwinders.  This destroys the faked cyclic behavior and the stack is
further unwinded after frame 5.

In the working scenario an error should be triggered:
~~~
bt
0  inline_func () at /tmp/gdb.base/inline-frame-cycle-unwind.c:49^M
1  normal_func () at /tmp/gdb.base/inline-frame-cycle-unwind.c:32^M
2  0x000055555555516e in inline_func () at /tmp/gdb.base/inline-frame-cycle-unwind.c:45^M
3  normal_func () at /tmp/gdb.base/inline-frame-cycle-unwind.c:32^M
4  0x000055555555516e in inline_func () at /tmp/gdb.base/inline-frame-cycle-unwind.c:45^M
5  normal_func () at /tmp/gdb.base/inline-frame-cycle-unwind.c:32^M
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) PASS: gdb.base/inline-frame-cycle-unwind.exp: cycle at level 5: backtrace when the unwind is broken at frame 5
~~~

To fix the Python unwinder, we simply skip the unavailable registers.

Also it makes the test gdb.dap/scopes.exp fail.  The shadow stack feature is
disabled by default, so the pl3_ssp register which is added with my CET
shadow stack series will be shown as unavailable and we see a TCL error:
~~
>>> {"seq": 12, "type": "request", "command": "variables", "arguments": {"variablesReference": 2, "count": 85}}
Content-Length: 129^M
^M
{"request_seq": 12, "type": "response", "command": "variables", "success": false, "message": "value is not available", "seq": 25}FAIL: gdb.dap/scopes.exp: fetch all registers success
ERROR: tcl error sourcing /tmp/gdb/testsuite/gdb.dap/scopes.exp.
ERROR: tcl error code TCL LOOKUP DICT body
ERROR: key "body" not known in dictionary
    while executing
"dict get $val body variables"
    (file "/tmp/gdb/testsuite/gdb.dap/scopes.exp" line 152)
    invoked from within
"source /tmp/gdb/testsuite/gdb.dap/scopes.exp"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 source /tmp/gdb/testsuite/gdb.dap/scopes.exp"
    invoked from within
"catch "uplevel #0 source $test_file_name" msg"
UNRESOLVED: gdb.dap/scopes.exp: testcase '/tmp/gdb/testsuite/gdb.dap/scopes.exp' aborted due to Tcl error
~~

I am fixing this by enabling the test for CET shadow stack, in case we
detect that the HW supports it:
~~~
    # If x86 shadow stack is supported we need to configure GLIBC_TUNABLES
    # such that the feature is enabled and the register pl3_ssp is
    # available.  Otherwise the reqeust to fetch all registers will fail
    # with "message": "value is not available".
    if { [allow_ssp_tests] } {
append_environment GLIBC_TUNABLES "glibc.cpu.hwcaps" "SHSTK"
    }
~~~

Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Luis Machado <luis.machado@arm.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
5 weeks agogdb, gdbserver: Use xstate_bv for target description creation on x86.
Christina Schimpe [Tue, 3 Dec 2024 16:32:10 +0000 (08:32 -0800)] 
gdb, gdbserver: Use xstate_bv for target description creation on x86.

The XSAVE function set is organized in state components, which are a set of
registers or parts of registers.  So-called XSAVE-supported features are
organized using state-component bitmaps, each bit corresponding to a
single state component.

The Intel Software Developer's Manual uses the term xstate_bv for a
state-component bitmap, which is defined as XCR0 | IA32_XSS.  The control
register XCR0 only contains a state-component bitmap that specifies user state
components, while IA32_XSS contains a state-component bitmap that specifies
supervisor state components.

Until now, XCR0 is used as input for target description creation in GDB.
However, a following patch will add userspace support for the CET shadow
stack feature by Intel.  The CET state is configured in IA32_XSS and consists
of 2 state components:
- State component 11 used for the 2 MSRs controlling user-mode
  functionality for CET (CET_U state)
- State component 12 used for the 3 MSRs containing shadow-stack pointers
  for privilege levels 0-2 (CET_S state).

Reading the CET shadow stack pointer register on linux requires a separate
ptrace call using NT_X86_SHSTK.  To pass the CET shadow stack enablement
state we would like to pass the xstate_bv value instead of xcr0 for target
description creation.  To prepare for that, we rename the xcr0 mask
values for target description creation to xstate_bv.  However, this
patch doesn't add any functional changes in GDB.

Future states specified in IA32_XSS such as CET will create a combined
xstate_bv_mask including xcr0 register value and its corresponding bit in
the state component bitmap.  This combined mask will then be used to create
the target descriptions.

Reviewed-By: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Approved-By: Luis Machado <luis.machado@arm.com>
5 weeks agogdb: Sync up x86-gcc-cpuid.h with cpuid.h from gcc 14 branch.
Christina Schimpe [Thu, 22 Feb 2024 10:34:47 +0000 (05:34 -0500)] 
gdb: Sync up x86-gcc-cpuid.h with cpuid.h from gcc 14 branch.

This is required for a later commit which requires "bit_SHSTK".

Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Approved-By: Tom Tromey <tom@tromey.com>
Approved-By: Luis Machado <luis.machado@arm.com>
5 weeks agogdbserver: Add assert in x86_linux_read_description.
Christina Schimpe [Tue, 6 Feb 2024 18:37:27 +0000 (13:37 -0500)] 
gdbserver: Add assert in x86_linux_read_description.

On x86 the PTRACE_GETREGSET request is currently only used for the xstate regset.
The size of the xstate regset is initialized to 0 such that it can be reset to
the appropriate size once we know it is supported for the current target
in x86_linux_read_description.

However, this configuration would not just affect the xstate regset but any regset
with PTRACE_GETREGSET request that is added in the future.  The new regset  would be
misconfigured with the xstate regset size.  To avoid this we add an assert for
unsupported regsets and check explicitly for the note type of the register set.

Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Approved-By: Luis Machado <luis.machado@arm.com>
5 weeks agogdbserver: Add optional runtime register set type.
Christina Schimpe [Mon, 18 Dec 2023 17:47:09 +0000 (18:47 +0100)] 
gdbserver: Add optional runtime register set type.

Some register sets can be activated and deactivated by the OS during the runtime of
a process.  One example register is the Intel CET shadow stack pointer.  This patch
adds a new type of register set to handle such cases.  We shouldn't deactivate these
regsets and should not show a warning if the register set is not active but supported
by the kernel.  However, it is safe to deactivate them, if they are unsupported by the
kernel.  To differentiate those scenarios we can use the errno returned by the ptrace
call.

Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Approved-By: Luis Machado <luis.machado@arm.com>
5 weeks agogdb, testsuite: Extend core_find procedure to save program output.
Christina Schimpe [Fri, 27 Jun 2025 16:09:17 +0000 (09:09 -0700)] 
gdb, testsuite: Extend core_find procedure to save program output.

From: Thiago Jung Bauermann <thiago.bauermann@linaro.org>

The change comes from ARM's GCS series:

[PATCH v3 5/9] GDB, gdbserver: aarch64-linux: Initial Guarded Control Stack support.

We need it for testing coredump files, too.  So include it in this patch series.

Abridged-by: Christina Schimpe <christina.schimpe@intel.com>
Approved-By: Luis Machado <luis.machado@arm.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
---
This is the patch mentioned above:

https://sourceware.org/pipermail/gdb-patches/2025-June/218892.html

Minus everything except for the change in gdb.exp's corefind procedure.

5 weeks agogdb/objfiles: make objfile::sections yield references
Simon Marchi [Wed, 27 Aug 2025 14:38:13 +0000 (10:38 -0400)] 
gdb/objfiles: make objfile::sections yield references

I wrote this as a preparatory patch while attempting to make
objfile::section_iterator use filtered_iterator.  It turned out not so
easy, so I have put it aside for now.  But now I have this patch, so I
thought I'd send it by itself.

Since the `obj_section *` yielded by the iterator can't be nullptr, I
think it makes sense for the iterator to yield references instead.
Just like you would get if you iterated on an std::vector<obj_section>.

Change-Id: I7bbee50ed52599e64c4f3b06bdbbde597feba9aa

5 weeks ago[gdb/testsuite] Fix overlapping CUs in gdb.dwarf2/dw2-linkage-name-trust.exp
Tom de Vries [Fri, 29 Aug 2025 15:31:58 +0000 (17:31 +0200)] 
[gdb/testsuite] Fix overlapping CUs in gdb.dwarf2/dw2-linkage-name-trust.exp

When running test-case gdb.dwarf2/dw2-linkage-name-trust.exp with target board
cc-with-gdb-index, I get:
...
(gdb) file dw2-linkage-name-trust^M
Reading symbols from dw2-linkage-name-trust...^M
warning: .gdb_index address table has a range (0x4006ac - 0x4006cc) that \
  overlaps with an earlier range, ignoring .gdb_index^M
(gdb) delete breakpoints^M
...

Fix this by compiling with nodebug.

Tested on aarch64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
PR testsuite/33315
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33315

5 weeks ago[gdb/testsuite] Fix overlapping CUs in gdb.dwarf2/dw2-entry-points.exp
Tom de Vries [Fri, 29 Aug 2025 15:31:58 +0000 (17:31 +0200)] 
[gdb/testsuite] Fix overlapping CUs in gdb.dwarf2/dw2-entry-points.exp

When running test-case gdb.dwarf2/dw2-entry-points.exp with target board
cc-with-gdb-index, I get:
...
(gdb) file dw2-entry-points^M
Reading symbols from dw2-entry-points...^M
warning: .gdb_index address table has a range (0x40066c - 0x4006e4) that \
  overlaps with an earlier range, ignoring .gdb_index^M
(gdb) delete breakpoints^M
...

Fix this by copying function bar_helper to barso_helper, and using it where
appropriate.

Tested on aarch64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
PR testsuite/33315
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33315

5 weeks agogdb: use kill() in gdbpy_interrupt for hosts with signal support
Andrew Burgess [Mon, 4 Aug 2025 14:44:04 +0000 (15:44 +0100)] 
gdb: use kill() in gdbpy_interrupt for hosts with signal support

For background, see this thread:

  https://inbox.sourceware.org/gdb-patches/20250612144607.27507-1-tdevries@suse.de

Tom describes the issue clearly in the above thread, here's what he
said:

  Once in a while, when running test-case gdb.base/bp-cmds-continue-ctrl-c.exp,
  I run into:
  ...
  Breakpoint 2, foo () at bp-cmds-continue-ctrl-c.c:23^M
  23        usleep (100);^M
  ^CFAIL: $exp: run: stop with control-c (unexpected) (timeout)
  FAIL: $exp: run: stop with control-c
  ...

  This is PR python/32167, observed both on x86_64-linux and powerpc64le-linux.

  This is not a timeout due to accidental slowness, gdb actually hangs.

  The backtrace at the hang is (on cfarm120 running AlmaLinux 9.6):
  ...
  (gdb) bt
   #0  0x00007fffbca9dd94 in __lll_lock_wait () from
       /lib64/glibc-hwcaps/power10/libc.so.6
   #1  0x00007fffbcaa6ddc in pthread_mutex_lock@@GLIBC_2.17 () from
       /lib64/glibc-hwcaps/power10/libc.so.6
   #2  0x000000001067aee8 in __gthread_mutex_lock ()
       at /usr/include/c++/11/ppc64le-redhat-linux/bits/gthr-default.h:749
   #3  0x000000001067afc8 in __gthread_recursive_mutex_lock ()
       at /usr/include/c++/11/ppc64le-redhat-linux/bits/gthr-default.h:811
   #4  0x000000001067b0d4 in std::recursive_mutex::lock ()
       at /usr/include/c++/11/mutex:108
   #5  0x000000001067b380 in std::lock_guard<std::recursive_mutex>::lock_guard ()
       at /usr/include/c++/11/bits/std_mutex.h:229
   #6  0x0000000010679d3c in set_quit_flag () at gdb/extension.c:865
   #7  0x000000001066b6dc in handle_sigint () at gdb/event-top.c:1264
   #8  0x00000000109e3b3c in handler_wrapper () at gdb/posix-hdep.c:70
   #9  <signal handler called>
   #10 0x00007fffbcaa6d14 in pthread_mutex_lock@@GLIBC_2.17 () from
       /lib64/glibc-hwcaps/power10/libc.so.6
   #11 0x000000001067aee8 in __gthread_mutex_lock ()
       at /usr/include/c++/11/ppc64le-redhat-linux/bits/gthr-default.h:749
   #12 0x000000001067afc8 in __gthread_recursive_mutex_lock ()
       at /usr/include/c++/11/ppc64le-redhat-linux/bits/gthr-default.h:811
   #13 0x000000001067b0d4 in std::recursive_mutex::lock ()
       at /usr/include/c++/11/mutex:108
   #14 0x000000001067b380 in std::lock_guard<std::recursive_mutex>::lock_guard ()
       at /usr/include/c++/11/bits/std_mutex.h:229
   #15 0x00000000106799cc in set_active_ext_lang ()
       at gdb/extension.c:775
   #16 0x0000000010b287ac in gdbpy_enter::gdbpy_enter ()
       at gdb/python/python.c:232
   #17 0x0000000010a8e3f8 in bpfinishpy_handle_stop ()
       at gdb/python/py-finishbreakpoint.c:414
  ...

  What happens here is the following:
  - the gdbpy_enter constructor attempts to set the current extension language
    to python using set_active_ext_lang
  - set_active_ext_lang attempts to lock ext_lang_mutex
  - while doing so, it is interrupted by sigint_wrapper (the SIGINT handler),
    handling a SIGINT
  - sigint_wrapper calls handle_sigint, which calls set_quit_flag, which also
    tries to lock ext_lang_mutex
  - since std::recursive_mutex::lock is not async-signal-safe, things go wrong,
    resulting in a hang.

  The hang bisects to commit 8bb8f834672 ("Fix gdb.interrupt race"), which
  introduced the lock, making PR python/32167 a regression since gdb 15.1.

  Commit 8bb8f834672 fixes PR dap/31263, a race reported by ThreadSanitizer:
  ...
  WARNING: ThreadSanitizer: data race (pid=615372)

    Read of size 1 at 0x00000328064c by thread T19:
      #0 set_active_ext_lang(extension_language_defn const*) gdb/extension.c:755
      #1 scoped_disable_cooperative_sigint_handling::scoped_disable_cooperative_sigint_handling()
         gdb/extension.c:697
      #2 gdbpy_interrupt gdb/python/python.c:1106
      #3 cfunction_vectorcall_NOARGS <null>

    Previous write of size 1 at 0x00000328064c by main thread:
      #0 scoped_disable_cooperative_sigint_handling::scoped_disable_cooperative_sigint_handling()
         gdb/extension.c:704
      #1 fetch_inferior_event() gdb/infrun.c:4591
      ...

    Location is global 'cooperative_sigint_handling_disabled' of size 1 at 0x00000328064c

    ...

  SUMMARY: ThreadSanitizer: data race gdb/extension.c:755 in \
    set_active_ext_lang(extension_language_defn const*)
  ...

  The problem here is that gdb.interrupt is called from a worker thread, and its
  implementation, gdbpy_interrupt races with the main thread on some variable.

The fix presented here is based on the fix that Tom proposed, but
fills in the missing Mingw support.

The problem is basically split into two: hosts that support unix like
signals, and Mingw, which doesn't support signals.

For signal supporting hosts, I've adopted the approach that Tom
suggests, gdbpy_interrupt uses kill() to send SIGINT to the GDB
process.  This is then handled in the main thread as if the user had
pressed Ctrl+C.  For these hosts no locking is required, so the
existing lock is removed.  However, everywhere the lock currently
exists I've added an assert:

    gdb_assert (is_main_thread ());

If this assert ever triggers then we're setting or reading the quit
flag on a worker thread, this will be a problem without the mutex.

For Mingw, the current mutex is retained.  This is fine as there are
no signals, so no chance of the mutex acquisition being interrupted by
a signal, and so, deadlock shouldn't be an issue.

To manage the complexity of when we need an assert, and when we need
the mutex, I've created 'struct ext_lang_guard', which can be used as
a RAII object.  This object either performs the assertion check, or
acquires the mutex, depending on the host.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32167
Co-Authored-By: Tom de Vries <tdevries@suse.de>
Approved-By: Tom Tromey <tom@tromey.com>
5 weeks agoreadelf: Add --got-contents option
H.J. Lu [Thu, 28 Aug 2025 21:15:18 +0000 (14:15 -0700)] 
readelf: Add --got-contents option

Add --got-contents option to readelf, inspired by the -G option on Solaris,
to display contents of GOT sections:

$ readelf --got-contents libfoo.so

Global Offset Table '.got' contains 1 entry:
 Index:    Address       Reloc         Sym. Name + Addend/Value
     0: 000000200340 R_X86_64_GLOB_DAT foo + 0

Global Offset Table '.got.plt' contains 4 entries:
 Index:    Address       Reloc         Sym. Name + Addend/Value
     0: 000000200348                   200220
     1: 000000200350                   0
     2: 000000200358                   0
     3: 000000200360 R_X86_64_JUMP_SLO bar + 0

When --got-content options are used:

1. Allocate an array, all_relocations, to hold all relocations.
2. Update dump_relr_relocations and dump_relocations to scan relocations
and cache them in all_relocations.  Don't display relocations if not
requested.
3. Add process_got_section_contents to display contents of GOT sections
by matching the GOT entry offset against the cached relocations.
4. Update process_mips_specific to only display the GOT related contents
for --got-contents.

binutils/

* NEWS: Mention "readelf --got-contents".
* readelf.c (do_got_section_contents): New.
(elf_relocation): Likewise.
(all_relocations_root): Likewise.
(all_relocations): Likewise.
(all_relocations_count): Likewise.
(update_all_relocations): Likewise.
(dump_relr_relocations): Add a bool argument to indicate if
relocations should be displayed.  Populate all_relocations if
do_got_section_contents is true.
(dump_relocations): Likewise.
(long_option_values): Add OPTION_GOT_CONTENTS.
(options): Add --got-contents.
(usage): Show --got-contents.
(parse_args): Support --got-contents.
(display_relocations): Add a bool argument, dump_reloc, to
indicate if relocations should be displayed.  Call
update_all_relocations.  Pass dump_reloc to dump_relr_relocations
and dump_relocations.
(process_relocs): Check do_got_section_contents.  Handle
do_got_section_contents for dynamic relocations.
(process_section_contents): Pass true to display_relocations.
(process_mips_specific): Add a bool argument, dump_got, to
indicate if only the GOT related contents should be displayed.
Display all MIPS specific information if dump_got is false.
(elf_relocation_cmp): New.
(display_elf_relocation_at): Likewise.
(process_got_section_contents): Likewise.
(process_object): Call process_got_section_contents.
* doc/binutils.texi: Document --got-contents.

ld/

* testsuite/ld-i386/binutils.exp: New file.
* testsuite/ld-i386/got-1.s: Likewise.
* testsuite/ld-i386/libgot-1a.rd: Likewise.
* testsuite/ld-i386/libgot-1b.rd: Likewise.
* testsuite/ld-i386/libgot-1c.rd: Likewise.
* testsuite/ld-i386/libgot-1d.rd: Likewise.
* testsuite/ld-x86-64/binutils.exp: Likewise.
* testsuite/ld-x86-64/got-1.s: Likewise.
* testsuite/ld-x86-64/libgot-1a-x32.rd: Likewise.
* testsuite/ld-x86-64/libgot-1a.rd: Likewise.
* testsuite/ld-x86-64/libgot-1b-x32.rd: Likewise.
* testsuite/ld-x86-64/libgot-1b.rd: Likewise.
* testsuite/ld-x86-64/libgot-1c-x32.rd: Likewise.
* testsuite/ld-x86-64/libgot-1c.rd: Likewise.
* testsuite/ld-x86-64/libgot-1d-x32.rd: Likewise.
* testsuite/ld-x86-64/libgot-1d.rd: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
5 weeks agold: drop bogus %F format modifiers
Jan Beulich [Fri, 29 Aug 2025 10:12:24 +0000 (12:12 +0200)] 
ld: drop bogus %F format modifiers

Support for %F was dropped in 6d74c1f313df ("PR 32603 followup, remove
%F from einfo").

5 weeks agox86: add "udb" opcode (permanent official #UD in 64-bit mode)
H. Peter Anvin (Intel) [Fri, 29 Aug 2025 10:11:45 +0000 (12:11 +0200)] 
x86: add "udb" opcode (permanent official #UD in 64-bit mode)

The opcode D6 has been officially reserved as a single-byte permanent
undefined (#UD) opcode in 64-bit mode with the mnemonic UDB.  This is
already the behavior of all known 64-bit implementations; this is thus
merely an official statement of forward compatibility and the
assignment of a mnemonic.

This will be documented in the next version of the Intel Software
Developer's Manual; in the meantime I DO speak officially for Intel on
this issue.

The x86 Advisory Council has ratified this decision, and so it is
expected to be honored across vendors, but I obviously cannot make any
official statement on any other vendor's behalf.

I am covered by the Intel-FSF copyright assignment for binutils.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
5 weeks agoAutomatic date update in version.in
GDB Administrator [Fri, 29 Aug 2025 00:00:24 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 weeks agogdb/gdb-gdb.gdb.in: skip gdb::ref_ptr<.*>::get
Simon Marchi [Mon, 25 Aug 2025 17:02:12 +0000 (13:02 -0400)] 
gdb/gdb-gdb.gdb.in: skip gdb::ref_ptr<.*>::get

I think it's uninteresting to step into gdb::ref_ptr::get, so add a skip
entry for it.  I am adding just one to get the party started, but there
are certainly more like this that we could skip.

Change-Id: Ib074535c96a62137de63bbe58ff168a1e913688f
Approved-By: Tom Tromey <tom@tromey.com>
5 weeks agogdb/testsuite: use gdb_test_no_output when dumping in gdb.base/dump.exp
Simon Marchi [Mon, 25 Aug 2025 15:44:22 +0000 (11:44 -0400)] 
gdb/testsuite: use gdb_test_no_output when dumping in gdb.base/dump.exp

I don't know if this is true on all platforms, but from what I can see
on Linux, the dump commands don't output anything.  Use
gdb_test_no_output, which should be a bit more robust than checking for
some specific error patterns.

Change-Id: Idc82298c4752ba7808659dfea2f8324c8a97052d
Approved-By: Tom Tromey <tom@tromey.com>
5 weeks agoFix documentation of -list-[target-]features results
Christian Walther [Wed, 27 Aug 2025 09:38:09 +0000 (11:38 +0200)] 
Fix documentation of -list-[target-]features results

The manual claims that the -list-features and -list-target-features MI
commands return their result in a field named "result". The field is
actually named "features", and always has been since the introduction of
these commands in 084344d and c6ebd6c. See mi_cmd_list_features and
mi_cmd_list_target_features in gdb/mi/mi-main.c.

Approved-By: Tom Tromey <tom@tromey.com>
5 weeks agotestsuite: add untested in case OS corefile is not found
Christina Schimpe [Wed, 6 Aug 2025 20:08:35 +0000 (13:08 -0700)] 
testsuite: add untested in case OS corefile is not found

Even though the core_find proc will log a warning, it's better to log
"untested" and then terminate the test.  This will help to avoid
silently skipped tests, when running the testsuite.  Most of the tests
already do that.  This patch adds the missing ones.

Approved-By: Luis Machado <luis.machado.foss@gmail.com>
5 weeks agoBump flake8 version
Tom Tromey [Wed, 27 Aug 2025 19:28:11 +0000 (13:28 -0600)] 
Bump flake8 version

"pre-commit autoupdate" pointed out that a newer version of flake8 has
been released.  This patch applies the update.  No code changes were
needed.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
5 weeks agogdb/python: check return from final PyObject_New in py-disasm.c
Andrew Burgess [Thu, 21 Aug 2025 11:43:58 +0000 (12:43 +0100)] 
gdb/python: check return from final PyObject_New in py-disasm.c

In this commit:

  commit dbd05b9edcf760a7001985f89bc760358a3c19d7
  Date:   Wed Aug 20 10:45:09 2025 +0100

      gdb/python: check return value of PyObject_New in all cases

I missed a call to PyObject_New in python/py-disasm.c, which this
commit addresses.

Unlike the previous commit, the call to PyObject_New in py-disasm.c is
contained within the scoped_disasm_info_object class, which makes it
harder to check for NULL and return.

So in this commit I've rewritten the scoped_disasm_info_object class,
moving the call to PyObject_New out into gdbpy_print_insn, which is
the only place that scoped_disasm_info_object was being used.

As scoped_disasm_info_object is no longer responsible for creating the
underlying Python object, I figured that I might as well move the
initialisation of that object out of scoped_disasm_info_object too.

With that done, the scoped_disasm_info_object now has just one task,
invalidating the existing disasm_info_object at the end of the scope.

So I renamed scoped_disasm_info_object to
scoped_invalidate_disasm_info, which reflects its only task.

I made a couple of other small adjustments that were requested during
review, these are both in the same code area: updating
disasm_info_fill to take an object reference rather than a pointer,
and removing the local variable insn_disas_obj from gdbpy_print_insn,
and inline its value at the one place it was used.

There should be no user visible changes after this commit. Except for
the PyObject_New call, which now has proper error checking.  But in
the working case, nothing should have changed.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
5 weeks agogdb/objfiles: add comment explaining when obj_section::the_bfd_section is nullptr
Simon Marchi [Wed, 27 Aug 2025 14:07:50 +0000 (10:07 -0400)] 
gdb/objfiles: add comment explaining when obj_section::the_bfd_section is nullptr

Change-Id: Iae17492f468efba7b76463a6ff8526171e412040
Reviewed-By: Tom de Vries <tdevries@suse.de>
5 weeks ago[gdb/testsuite] Use build_executable in gdb.tui/tui-missing-src.exp
Tom de Vries [Thu, 28 Aug 2025 09:36:29 +0000 (11:36 +0200)] 
[gdb/testsuite] Use build_executable in gdb.tui/tui-missing-src.exp

While looking at test-case gdb.tui/tui-missing-src.exp I noticed that
gdb_compile is used to compile multiple sources:
...
if  { [gdb_compile "${srcfiles}" "${binfile}" \
          executable {debug additional_flags=-O0}] != "" } {
...
meaning there are no separate compile and link steps, as is required for
fission [1].

Fix this by using build_executable instead.

Tested on aarch64-linux.

[1] https://gcc.gnu.org/wiki/DebugFission

5 weeks agogdb/record: Support wfi, sfence.vma, sret and mret instructions in risc-v
timurgol007 [Wed, 2 Jul 2025 15:59:34 +0000 (18:59 +0300)] 
gdb/record: Support wfi, sfence.vma, sret and mret instructions in risc-v

During testing of bare-metal applications on QEMU for RISC-V, it was discovered
that the instructions wfi, sfence.vma, sret, and mret were not supported. This
patch introduces support for these instructions. Additionally, it wraps
fetch_instruction function in a try-catch block to gracefully handle errors
that may occur when attempting to read invalid address.

Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
5 weeks ago[gdb/testsuite] Fix require dwarf2_support check in some test-cases, some more
Tom de Vries [Thu, 28 Aug 2025 09:24:42 +0000 (11:24 +0200)] 
[gdb/testsuite] Fix require dwarf2_support check in some test-cases, some more

The Linaro CI reported a regression in test-case
gdb.dwarf2/macro-source-path-clang14-dw4.exp due to recent commit 81e5a23c7b8
("[gdb/testsuite] Fix require dwarf2_support check in some test-cases").

The problem is that the "require dwarf2_support" in its new location doesn't
work because proc dwarf2_support is not defined.

I didn't notice this because I tested all gdb.dwarf2 test-cases together, and
a different test-case had already imported the proc.

Fix this by moving load_lib dwarf.exp earlier.

Tested on x86_64-linux.

5 weeks agoreadelf: Update "-D -r" to dump DT_RELR
H.J. Lu [Wed, 27 Aug 2025 20:17:07 +0000 (13:17 -0700)] 
readelf: Update "-D -r" to dump DT_RELR

1. Update dump_relr_relocations to take relr_size, relr_entsize and
relr_offset, instead of a pointer to Elf_Internal_Shdr, as function
arguments.
2. Update process_relocs to call dump_relr_relocations if relocation
type is reltype_relr.

binutils/

PR binutils/33328
* readelf.c (dump_relr_relocations): Replace a pointer to
Elf_Internal_Shdr argument with relr_size, relr_entsize and
relr_offset.
(display_relocations): Update the dump_relr_relocations call.
(process_relocs): Call dump_relr_relocations if relocation type
is reltype_relr.

ld/

PR binutils/33328
* testsuite/ld-i386/dt-relr-1c.d: New file.
* testsuite/ld-i386/dt-relr-1d.d: Likewise.
* testsuite/ld-x86-64/dt-relr-1c-x32.d: Likewise.
* testsuite/ld-x86-64/dt-relr-1c.d: Likewise.
* testsuite/ld-x86-64/dt-relr-1d-x32.d: Likewise.
* testsuite/ld-x86-64/dt-relr-1d.d: Likewise.
* testsuite/ld-i386/i386.exp: Run PR binutils/33328 tests.
* testsuite/ld-x86-64/x86-64.exp: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
5 weeks agoAutomatic date update in version.in
GDB Administrator [Thu, 28 Aug 2025 00:00:46 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 weeks agogdb/testsuite: get real executable in gdb.gdb/index-file.exp
Simon Marchi [Wed, 6 Aug 2025 19:28:19 +0000 (15:28 -0400)] 
gdb/testsuite: get real executable in gdb.gdb/index-file.exp

Similar to a previous patch, if the gdb executable is in fact a libtool
wrapper, we need to get the path to the real executable to load it in
the top-level gdb.

With this change, the test runs on Cygwin, although I do see two
failures:

    FAIL: gdb.gdb/index-file.exp: debug_names files are identical
    FAIL: gdb.gdb/index-file.exp: debug_str files are identical

Change-Id: Ie06d1ece67e61530e5b664e65b5ef0edccaf6afa
Reviewed-By: Keith Seitz <keiths@redhat.com>
5 weeks agogdb/testsuite: turn thread events off in selftests
Simon Marchi [Wed, 6 Aug 2025 19:28:18 +0000 (15:28 -0400)] 
gdb/testsuite: turn thread events off in selftests

When running gdb.gdb/selftest.exp on Cygwin, the test eventually times
out on this command:

    (gdb) PASS: gdb.gdb/selftest.exp: printed version as pointer
    continue
    Continuing.
    [New Thread 4804.0x1728]
    [New Thread 4804.0x2f24]
    [New Thread 4804.0x934]
    [New Thread 4804.0x23a8]
    [New Thread 4804.0x2cf4]
    [New Thread 4804.0x1408]
    [New Thread 4804.0x2c90]
    [New Thread 4804.0xc58]
    [New Thread 4804.0x1d40]
    [New Thread 4804.0x1824]
    GNU gdb (GDB) 17.0.50.20250530-git
    Copyright (C) 2024 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.
    Type "show copying" and "show warranty" for details.
    This GDB was configured as "x86_64-pc-cygwin".
    Type "show configuration" for configuration details.
    For bug reporting instructions, please see:
    <https://www.gnu.org/software/gdb/bugs/>.
    Find the GDB manual and other documentation resources online at:
        <http://www.gnu.org/software/gdb/documentation/>.

    For help, type "help".
    Type "apropos word" to search for commands related to "word".
    (gdb) [New Thread 4804.0x2c64]
    [New Thread 4804.0x23c4]
    [New Thread 4804.0x2814]
    [Thread 4804.0x1200 exited with code 0]
    [Thread 4804.0x293c exited with code 0]
    [Thread 4804.0x2c9c exited with code 0]
    FAIL: gdb.gdb/selftest.exp: xgdb is at prompt (timeout)

The problem is the new thread notification, and the fact that the test
expects the prompt to be the last thing in the buffer.  To avoid the
thread events interfering with the test, disable them, they are not
useful here.

With this patch, gdb.gdb/selftest.exp mostly runs fine on Cygwin, the
only remaining problem appears to be:

    (gdb) PASS: gdb.gdb/selftest.exp: send ^C to child process
    signal SIGINT
    Continuing with signal SIGINT.
    PASS: gdb.gdb/selftest.exp: send SIGINT signal to child process, top GDB message
    FAIL: gdb.gdb/selftest.exp: send SIGINT signal to child process, bottom GDB message (timeout)

Change-Id: I0b1df0503c1961c042c8de559b4d223c5d3cb95c
Reviewed-By: Keith Seitz <keiths@redhat.com>
5 weeks agogdb/testsuite: use libtool to launch selftests
Simon Marchi [Wed, 27 Aug 2025 19:55:45 +0000 (15:55 -0400)] 
gdb/testsuite: use libtool to launch selftests

When building GDB on Cygwin, gdb/gdb.exe is a libtool wrapper (which
happens to be a PE executable).  The real executable is at
gdb/.libs/gdb.exe.  The "does gdb have debug info test" that
_selftest_setup does is bogus, because it loads the libtool wrapper
(which doesn't have debug info), doesn't see any debug info, and thus
the test is skipped.

The "correct" way to deal with libtool wrappers is to run the shell
command you want to run under `libtool --mode=execute`.  That will
replace any path resembling to a libtool wrapper with the real
executable path.  But it will also add to the environment the library
paths necessary for this executable to find the libraries it needs.

Therefore, modify the `do_self_tests` proc to:

  - run the top-level GDB commands under `libtool --mode=execute`
  - pass the path to the inferior GDB on the command-line of the
    top-level, so that it gets replaced with the real executable's path

However, the "file" command was previously used to detect the presence
of debug info in the GDB executable.  It's not easy to implement this
check when loading the executable directly on the command line. So, add
a separate proc, _selftest_check_executable_debug_info, that spawns a
temporary GDB and does the debug info check through the file command.
This proc uses libtool to obtain the path to the real executable.

When building, we use the bundled libtool.m4 at the top of the tree.
This means that the libtool system package, and therefore the libtool
binary, might not be available.  Check for the presence of the libtool
binary first, and only do the conversion if it is found.  If it is not
found, the test should still work on platforms that don't require the
conversion.

With this commit, the test runs on Cygwin, even though there are
failures later.

Change-Id: Ie7b712cdc84671a5a017655a7e41687ff23f906c
Reviewed-By: Keith Seitz <keiths@redhat.com>
5 weeks agogdb/testsuite: do not copy gdb executable in self tests
Simon Marchi [Wed, 6 Aug 2025 19:28:16 +0000 (15:28 -0400)] 
gdb/testsuite: do not copy gdb executable in self tests

In the ROCm-GDB testing process, we hit a problem that is a combination
of these 3 factors:

1. In the downstream ROCm-GDB packages, the gdb executable is built with
   a relative RUNPATH:

       0x000000000000001d (RUNPATH)            Library runpath: [${ORIGIN}/../lib]

   This is done so that the installation is relocatable (the whole ROCm
   directory can be copied around) and things still work.  For instance,
   the rocgdb executable needs to be able to find the libraries it
   needs, such as `librocm-dbgapi.so.0`.  The relative runpath allows
   that.

2. For testing, we run the testsuite against the gdb executable
   installed from one of those packages.  It is possible to ./configure
   the testsuite directory on its own, and then do:

       $ make check RUNTESTFLAGS="GDB=/opt/rocm/bin/rocgdb"

3. The selftests (such as gdb.gdb/selftest.exp) copy the GDB under test
   to the standard output directory, before trying to debug it.

The problem is that the gdb executable under test that has been copied
can't find the libraries it needs.

With this patch, I propose that we don't copy the gdb executable, but
debug it in place instead.  The comment removed in this patch says "in
case this OS doesn't like to edit its own text space", and has been
there since forever in some form.  But it's not clear if there is a host
OS (where we intend to run this test) that needs this nowadays.  I would
bet that there isn't.  If there is in fact a GDB host OS (where we
intend to run this test) that needs it, we can reinstate the copying,
but as an opt-in operation.

Another situation where this change helps is on Windows, where
gdb/gdb.exe is a libtool wrapper (the real executable is at
gdb/.libs/gdb.exe).  Copying gdb/gdb.exe doesn't accomplish anything
useful.  The next patch does further changes to account for the libtool
wrapper case.

I tested on Linux and Cygwin, more testing would be welcome.

Change-Id: Id4148517d4fc4ecdd49f099c12003e3d16c6a93d
Reviewed-By: Keith Seitz <keiths@redhat.com>
5 weeks agogdb/testsuite: remove function parameter from do_self_tests
Simon Marchi [Wed, 27 Aug 2025 19:54:44 +0000 (15:54 -0400)] 
gdb/testsuite: remove function parameter from do_self_tests

The function to stop at is always main.  Remove the parameter and
hard-code main in _selftest_setup.

Change-Id: Ibbbf598203b1658305eb6bc631d029652c10edac
Reviewed-By: Keith Seitz <keiths@redhat.com>
5 weeks agogdb/testsuite: namespace procs in lib/selftest-support.exp
Simon Marchi [Wed, 6 Aug 2025 19:28:14 +0000 (15:28 -0400)] 
gdb/testsuite: namespace procs in lib/selftest-support.exp

Rename some procs in lib/selftest-support.exp that are only used
internally, to make it a bit clearer that they are just internal
helpers.

Change-Id: Icd399ac42698209fbc8e798bf43a7d8464aa848c
Reviewed-By: Keith Seitz <keiths@redhat.com>
5 weeks agoFix formatting of gdbarch_components.py
Tom Tromey [Wed, 27 Aug 2025 19:29:22 +0000 (13:29 -0600)] 
Fix formatting of gdbarch_components.py

pre-commit pointed out that gdbarch_components.py had a minor
formatting issue, according to the official version of 'black'.  This
patch corrects the oversight.

5 weeks agoobjcopy "strip without global symbol" test
Alan Modra [Wed, 27 Aug 2025 08:06:57 +0000 (17:36 +0930)] 
objcopy "strip without global symbol" test

This binutils test fails with -fsanitize.  NOSANITIZE_CFLAGS isn't
available in the binutils testsuite, and importing it over from ld
requires a huge amount of tcl code to be moved.  So I chose to simply
add -fno-sanitize=all if -fsanitize= is seem in CFLAGS.

* testsuite/binutils-all/objcopy.exp
(objcopy_test_without_global_symbol): Add -fno-sanitize=all to
flags if -fsanitize= is found in CFLAGS_FOR_TARGET.  Tidy use
of objfile.

5 weeks agotekhex test for commit bf0f85df1254
Alan Modra [Tue, 26 Aug 2025 09:20:30 +0000 (18:50 +0930)] 
tekhex test for commit bf0f85df1254

* testsuite/binutils-all/tek2.obj: Change to a 3 byte data file
that triggers tekhex error fixed by commit bf0f85df1254.
* testsuite/binutils-all/ar.exp: Adjust to suit.
* testsuite/binutils-all/objcopy.exp (objcopy_tek2bin): New proc.

5 weeks agoobjcopy "Unable to recognise the format of the input file"
Alan Modra [Tue, 26 Aug 2025 09:49:44 +0000 (19:19 +0930)] 
objcopy "Unable to recognise the format of the input file"

This bogus error comes up when trying something like
objcopy -O binary .../binutils/testsuite/binutils-all/tek2.obj xxx

This is an annoying message, as HJ said in
https://sourceware.org/pipermail/binutils/2002-August/021354.html
and removed it for some cases, eg. I can make it go away by specifying
-I tekhex.  The message is also untrue, as objcopy does in fact know
the format of the input file.

I think the message should be limited to ELF input files that are
being handled by the elf64-little, elf64-big, elf32-little or
elf32-big targets, due to libbfd being compiled with limited target
support.  I'm also changing the message a litle.

* objcopy.c (copy_object): Change "Unable to recognise format"
message to "Unable to recognise architecture" and only report
this error for ELF objects lacking their proper target support.
* testsuite/binutils-all/x86-64/x86-64.exp: Update to suit.

5 weeks agoRevert part of commit 8e885fece150
Alan Modra [Tue, 26 Aug 2025 09:37:14 +0000 (19:07 +0930)] 
Revert part of commit 8e885fece150

After commit 5e83077d552e we no longer choose a "plugin" target in
objcopy so ibfd->target_defaults can again be used to test whether the
user supplied a target.

PR 33230
* objcopy.c (copy_file): Revert change adding a target_defaulted
variable and passing down to..
(copy_archive, copy_object): ..here.  Remove target_defaulted
parameter.  Use ibfd->target_defaulted.

5 weeks agogdb/testsuite: work around empty substring bug in expect
Andrew Burgess [Tue, 26 Aug 2025 12:17:51 +0000 (13:17 +0100)] 
gdb/testsuite: work around empty substring bug in expect

There is a bug in expect, see:

  https://sourceforge.net/p/expect/patches/26/

which causes empty substring matches from a regexp to instead return
the complete input buffer.  To reproduce this bug, try this command:

  expect -c 'spawn sh -c "echo -n -e \"abc\""; \
            expect -re "(a?)(a)(bc)"; \
    puts "\n"; \
    for { set i 1 } { $i < 4 } { incr i } { \
      puts -nonewline "($i): \""; \
      puts -nonewline $expect_out($i,string); \
      puts "\"" \
    }'

For a working expect the output looks like:

  spawn sh -c echo -n -e "abc"
  abc

  (1): ""
  (2): "a"
  (3): "bc"

But for a broken expect the output looks like:

  spawn sh -c echo -n -e "abc"
  abc

  (1): "abc"
  (2): "a"
  (3): "bc"

Notice that (1) is now returning the complete input buffer rather than
the empty string, this is wrong.

This is not the first time this bug has impacted GDB's testsuite,
this commit seems to be working around the same problem:

  commit e579b537353cd91cb8fac1eaeb69901d4936766f
  Date:   Sat Aug 16 20:32:37 2025 +0200

      [gdb/testsuite] Fix TUI tests on freebsd

I recently pushed this commit:

  commit 3825c972a636852600b47c242826313f4b9963b8
  Date:   Wed Jun 18 15:02:29 2025 +0100

      gdb: allow gdb.Color to work correctly with pagination

Which added gdb.python/py-color-pagination.exp.  Bug PR gdb/33321 was
then created as the test was failing on some hosts.  Turns out, this
is same expect bug.

The fix presented here is the same as for e579b537353cd91cb8, avoid
using optional regexp substrings at the start of a regexp, and instead
use two separate regexp patterns.  With this change in place, the test
now passes on all hosts.

There's no change in what is being tested after this commit.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33321

Approved-By: Tom de Vries <tdevries@suse.de>
5 weeks ago[gdb/testsuite] Fix gdb.server/non-existing-program.exp on msys2-ucrt64
Tom de Vries [Wed, 27 Aug 2025 08:49:19 +0000 (10:49 +0200)] 
[gdb/testsuite] Fix gdb.server/non-existing-program.exp on msys2-ucrt64

On msys2-ucrt64, with test-case gdb.server/non-existing-program.exp I get:
...
(gdb) quit^M
gdb_caching_proc allow_xml_test caused gdb_exit to be called
  gdb_caching_proc allow_xml_test marked as called
  gdb_caching_proc get_mount_point_map marked as called
builtin_spawn gdbserver stdio non-existing-program^M
Error creating process "non-existing-program " (error 2): \
  The system cannot find the file specified.^M^M
Exiting^M^M
FAIL: gdb.server/non-existing-program.exp: gdbserver exits cleanly
...

This happens because this regexp fails to match:
...
    # This is what we get on Windows.
    -re "Error creating process\r\n\r\nExiting\r\n" {
...

Fix this by updating the regexp.

Tested on x86_64-w64-mingw32 (msys2-ucrt64).

5 weeks ago[gdb/testsuite] Add have_startup_shell
Tom de Vries [Wed, 27 Aug 2025 08:37:45 +0000 (10:37 +0200)] 
[gdb/testsuite] Add have_startup_shell

Say we disable startup-with-shell, we get:
...
(gdb) run `echo 8`^M
Starting program: a2-run `echo 8`^M
[Thread debugging using libthread_db enabled]^M
Using host libthread_db library "/lib64/libthread_db.so.1".^M
usage:  factorial <number>^M
[Inferior 1 (process 10787) exited with code 01]^M
(gdb) FAIL: gdb.base/a2-run.exp: run "a2-run" with shell (timeout)
...

Fix this by only doing this test if startup-with-shell is supported.

This fixes the test-case on msys2-ucrt64, where startup-with-shell is not
supported.

Likewise in other test-cases.

Tested on x86_64-linux.

5 weeks ago[gdb/testsuite] Add missing require {!is_remote host}
Tom de Vries [Wed, 27 Aug 2025 06:28:34 +0000 (08:28 +0200)] 
[gdb/testsuite] Add missing require {!is_remote host}

I ran test-case gdb.python/py-color-pagination.exp with make-check-all.sh and
noticed failures when using remote host.

So I grepped to find all test-cases using with_ansi_styling_terminal and ran
them with host/target board local-remote-host-native.

Fix the failing test-cases using require {!is_remote host}.

Tested on x86_64-linux.

5 weeks agox86: Don't put R_386_TLS_DESC/R_X86_64_TLSDESC in .rel.plt/.rela.plt
H.J. Lu [Sun, 24 Aug 2025 21:43:44 +0000 (14:43 -0700)] 
x86: Don't put R_386_TLS_DESC/R_X86_64_TLSDESC in .rel.plt/.rela.plt

Since lazy tlsdesc relocation has data races:

https://sourceware.org/bugzilla/show_bug.cgi?id=27137

put R_386_TLS_DESC and R_X86_64_TLSDESC relocation in .rela.tls/.rel.tls
section, instead of .rel.plt/.rela.plt section.

Tested with glibc/i686 and glibc/x86-64 compiled with -mtls-dialect=gnu2
as well as GCC 16 configured with --with-tls=gnu2.

bfd/

PR ld/28387
* elf32-i386.c (elf_i386_relocate_section): Put R_386_TLS_DESC
in rel_tls_desc instead of elf.srelplt.
* elf64-x86-64.c (elf_x86_64_relocate_section): Put
R_X86_64_TLSDESC in rel_tls_desc instead of elf.srelplt.
* elfxx-x86.c (elf_x86_allocate_dynrelocs): Use rel_tls_desc,
instead of elf.srelplt, for GOT_TLS_GDESC_P.
(_bfd_elf_x86_get_reloc_section): New function.
(_bfd_x86_elf_late_size_sections): Use rel_tls_desc, instead of
elf.srelplt, for GOT_TLS_GDESC_P.  Remove next_tls_desc_index.
(_bfd_x86_elf_link_setup_gnu_properties): Allocate
.rela.tls/.rel.tls section for rel_tls_desc.
* elfxx-x86.h (elf_x86_link_hash_table): Add rel_tls_desc.
Remove next_tls_desc_index.
(_bfd_elf_x86_get_reloc_section): New.
(elf_backend_get_reloc_section): Likewise.

ld/

PR ld/28387
* emulparams/elf32_x86_64.sh (OTHER_GOT_RELOC_SECTIONS): New.
* emulparams/elf_i386.sh (OTHER_GOT_RELOC_SECTIONS): Likewise.
* emulparams/elf_x86_64.sh (OTHER_GOT_RELOC_SECTIONS): Likewise.
* testsuite/ld-i386/i386.exp: Run pr28387.
* testsuite/ld-i386/pr17057.d: Adjusted
* testsuite/ld-i386/tlsdesc.rd: Likewise.
* testsuite/ld-i386/tlsdesc2.d: Likewise.
* testsuite/ld-i386/tlsgdesc.rd: Likewise.
* testsuite/ld-x86-64/tlsdesc.pd: Likewise.
* testsuite/ld-x86-64/tlsdesc.rd: Likewise.
* testsuite/ld-x86-64/tlsdesc2.d: Likewise.
* testsuite/ld-x86-64/tlsgdesc.rd: Likewise.
* testsuite/ld-i386/pr28387.d: New file.
* testsuite/ld-i386/pr28387.s: Likewise.
* testsuite/ld-x86-64/pr28387-x32.d: Likewise.
* testsuite/ld-x86-64/pr28387.d: Likewise.
* testsuite/ld-x86-64/pr28387.s: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run pr28387 and pr28387-x32.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
5 weeks agoAutomatic date update in version.in
GDB Administrator [Wed, 27 Aug 2025 00:02:05 +0000 (00:02 +0000)] 
Automatic date update in version.in

5 weeks agogdb/python: return gdbpy_ref<> from gdbpy_create_ptid_object
Andrew Burgess [Tue, 26 Aug 2025 15:56:07 +0000 (16:56 +0100)] 
gdb/python: return gdbpy_ref<> from gdbpy_create_ptid_object

Update gdbpy_create_ptid_object (python/py-infthread.c) to return a
gdbpy_ref<> rather than a 'PyObject *'.  This reduces the chances that
a caller will leak an object, though no such memory leaks are fixed in
this commit, this is just a code improvement patch.

There should be no user visible changes after this commit.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
5 weeks agogdb: use existing argument more in rename_vmcore_idle_reg_sections
Andrew Burgess [Thu, 21 Aug 2025 12:42:44 +0000 (13:42 +0100)] 
gdb: use existing argument more in rename_vmcore_idle_reg_sections

In corelow.c, in the function rename_vmcore_idle_reg_sections, the
argument ABFD holds the core file bfd pointer.  When this function is
called current_program_space->core_bfd() is passed as the argument
value.

Within this function, we sometimes use the function argument, and
sometimes access current_program_space->core_bfd() directly.

This is confusing, and unnecessary.  Lets not do that.

I've renamed the argument to cbfd (for Core file BFD), and then
updated the function to make use of this argument throughout.  This
reduces the number of accesses to global state, which is, I think, a
good thing.

There should be no user visible changes after this commit.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
5 weeks agogdb: more current_program_space->core_bfd() removal
Andrew Burgess [Thu, 21 Aug 2025 12:13:59 +0000 (13:13 +0100)] 
gdb: more current_program_space->core_bfd() removal

This commit changes the signature of the gdbarch_core_info_proc method
so that it takes a 'struct bfd *' as an extra argument.  This argument
is used to pass through the core file bfd pointer.

Now, in corelow.c, when calling gdbarch_core_info_proc, we can pass
through current_program_space->core_bfd() as the argument.  Within the
implementations, (Linux and FreeBSD) we can use this argument rather
than having to access the core file through current_program_space.

This reduces the use of global state, which I think is a good thing.

There should be no user visible changes after this commit.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
5 weeks agogdb: use current_program_space->core_bfd() a little less
Andrew Burgess [Thu, 21 Aug 2025 11:58:30 +0000 (12:58 +0100)] 
gdb: use current_program_space->core_bfd() a little less

The function linux_read_core_file_mappings is passed an argument CBFD,
which is the BFD for the core file.  In
core_target::build_file_mappings, where the function is called, we
pass current_program_space->core_bfd() as the argument.

However, in linux_read_core_file_mappings, in some places we use the
CBFD argument, and in other places we directly use
current_program_space->core_bfd().  This is confusing, and
unnecessary.  Lets not do that.

Standardise on just using CBFD.  This removes some references to
global state in favour of passing the global state in as an argument,
I think this is a good thing.

There should be no user visible changes after this commit.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
5 weeks ago[gdb/tdep] Add XOP support in amd64_get_insn_details
Tom de Vries [Tue, 26 Aug 2025 19:38:22 +0000 (21:38 +0200)] 
[gdb/tdep] Add XOP support in amd64_get_insn_details

Implement support for XOP instructions [1] in amd64_get_insn_details.

The encoding scheme is documented here [2].  Essentially it's a variant of the
VEX3 encoding scheme, with:
- 0x8f as the first byte instead of 0xc4, and
- an opcode map >= 8.

The changes are roughly the same as the XOP part of an earlier submission [3],
hence the tag.

The only real difference is that that patch proposed to implement xop_prefix_p
using:
...
  return pfx[0] == 0x8f && (pfx[1] & 0x38);
...
which tries to resolve the conflict between the XOP prefix (starts with 0x8f)
and the POP instruction (opcode 0x8f) by detecting that it's not a POP
instruction.

Instead, use the way AMD has resolved this conflict in the specification, by
checking for opcode map >= 8:
...
  gdb_byte m = pfx[1] & 0x1f;
  return pfx[0] == 0x8f && m >= 8;
...

Tested on x86_64-linux.

Co-Authored-By: Jan Beulich <jbeulich@suse.com>
Reviewed-By: Klaus Gerlicher<klaus.gerlicher.@intel.com>
[1] https://en.wikipedia.org/wiki/XOP_instruction_set
[2] https://www.amd.com/content/dam/amd/en/documents/archived-tech-docs/programmer-references/43479.pdf
[3] https://sourceware.org/pipermail/gdb-patches/2019-February/155347.html

5 weeks agogdb/python: fix an unlikely memory leak
Andrew Burgess [Sun, 24 Aug 2025 20:09:40 +0000 (21:09 +0100)] 
gdb/python: fix an unlikely memory leak

I noticed a possible memory leak in gdbpy_create_ptid_object, in
py-infthread.c.  We create a Tuple, and hold the reference in a
'PyObject*' local.

If we then fail to create any of the tuple contents we perform an
early exit, returning nullptr, this will leak the Tuple object.

Currently, we create the Tuple as the first action in the function,
but we don't really need the tuple until the end of the function.

In this commit I have:

  1. Moved creation of the Tuple until the end of the function, just
     before we need it.

  2. Stored the Tuple reference in a gdbpy_ref<>.  This is not
     strictly needed any more, but is (I think) good practice as
     future changes to the function will not need to worry about
     releasing the Tuple object.

  3. Taken the opportunity to replace a NULL with nullptr in this
     function.

  4. Inlined the local variable declarations to the point of first
     use.

There should be no user visible changes after this commit.

No tests as I have no idea how to make gdb_py_object_from_longest (and
friends) fail, and so trigger the memory leak.  I suspect we'd never
actually see this leak in the real world, but it doesn't hurt to clean
these things up.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
5 weeks agogdb: LoongArch: Improve loongarch_scan_prologue for correct backtrace
Hui Li [Tue, 26 Aug 2025 01:45:57 +0000 (09:45 +0800)] 
gdb: LoongArch: Improve loongarch_scan_prologue for correct backtrace

(1) Description of Problem:

When debugging the following code, the execution result of
the backtrace command is incorrect.

$ cat test.S
.text
.globl fun1
.type fun1, @function
fun1:
or $r12,$r0,$r0
or $r4,$r12,$r0
jr $r1
.globl fun
.type fun, @function
fun:
addi.d $r3,$r3,-16
st.d $r1,$r3,8
bl fun1
or $r12,$r4,$r0
or $r4,$r12,$r0
ld.d $r1,$r3,8
addi.d $r3,$r3,16
jr $r1
.globl main
.type main, @function
main:
addi.d $r3,$r3,-16
st.d $r1,$r3,8
bl fun
nop
ld.d $r1,$r3,8
addi.d $r3,$r3,16
jr $r1
$ gcc test.S -o test
$ gdb test
...
(gdb) b fun1
Breakpoint 1 at 0x748
(gdb) r
Breakpoint 1, 0x0000555555554748 in fun1 ()
(gdb) bt
  #0  0x0000555555554748 in fun1 ()
  #1  0x0000555555554758 in fun ()
  #2  0x0000555555554758 in fun ()
  #3  0x0000555555554758 in fun ()
....
--Type <RET> for more, q to quit, c to continue without paging

(2) Root Cause Analysis:

The return address of fun() in r1(ra) is saved on the stack:

addi.d $r3,$r3,-16
st.d $r1,$r3,8

The bl instruction in fun () will call the fun1 () and save
the value of pc+4 to r1(ra).

bl fun1
or $r12,$r4,$r0

Because registers such as fp and ra saved in the stack of the sub-function
are not recorded in current code. When trace back fun() to main(), the pc
of the previous frame to be read from ra register instead of the saved location
on the stack. At this time, the value of ra register in fun() is already the
address of the next instruction after the bl. So it is impossible to trace
back to the main().

(3) Solution:

Record the location of ra, fp, s0 to s8 on the stack to ensure the correct
execution of backtrace.

(4) Test:

$ gdb test
...
(gdb) b fun1
Breakpoint 1 at 0x748
(gdb) r
Breakpoint 1, 0x0000555555554748 in fun1 ()
(gdb) bt
  #0  0x0000555555554748 in fun1 ()
  #1  0x0000555555554758 in fun ()
  #2  0x0000555555554778 in main ()

Signed-off-by: Hui Li <lihui@loongson.cn>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
5 weeks agogdb: LoongArch: Improve loongarch_scan_prologue to record stack information
Hui Li [Tue, 26 Aug 2025 01:38:37 +0000 (09:38 +0800)] 
gdb: LoongArch: Improve loongarch_scan_prologue to record stack information

(1) Description of Problem:

When debugging the following code, the execution result of
nexti command is incorrect.

$ cat test.S
.text
.globl fun
.type fun, @function
fun:
or $r12,$r0,$r0
or $r4,$r12,$r0
jr $r1

.globl main
.type main, @function
main:
addi.d $r3,$r3,-16
st.d $r1,$r3,8
bl fun
or $r12,$r4,$r0
or $r4,$r12,$r0
ld.d $r1,$r3,8
addi.d $r3,$r3,16
jr $r1

$ gcc  test.S -o test
$ gdb test
...
(gdb) set disassemble-next-line on
(gdb) start
...
Temporary breakpoint 1, 0x0000555555554754 in main ()
=> 0x0000555555554754 <main+8>: 57ffefff bl           -20 # 0x555555554740 <fun>
(gdb) ni
0x0000555555554740 in fun ()
=> 0x0000555555554740 <fun+0>: 0015000c move         $t0, $zero

(2) Root Cause Analysis:

In the internal execution flow of the ni command, a single-step will be
executed first. After that, it will enter process_event_stop_test (),
some conditions are judged in this function.

  if ((get_stack_frame_id (frame)
       != ecs->event_thread->control.step_stack_frame_id)
      && get_frame_type (frame) != SIGTRAMP_FRAME
      && ((frame_unwind_caller_id (frame)
           == ecs->event_thread->control.step_stack_frame_id)
          && ((ecs->event_thread->control.step_stack_frame_id
               != outer_frame_id)
              || (ecs->event_thread->control.step_start_function
                  != find_pc_function (ecs->event_thread->stop_pc ())))))
    {
...
if (ecs->event_thread->control.step_over_calls == STEP_OVER_ALL)
...
          else
            insert_step_resume_breakpoint_at_caller (frame);

    }

Here, it will be judged whether a sub-function has been called based on
whether the frame id before the single step is not equal to the current
frame id and whether there is a calling relationship.

If a sub-function is called at this time and the current operation is nexti,
it will not stop immediately. Instead, insert_step_resume_breakpoint_at_caller()
will be called to complete the execution of the sub-function and then stop.

In above debugging examples, the executable program being debugged is compiled
from an asm source file that does not contain dwarf information. Therefore, the
frame id of the function is calculated by loongarch_frame_unwind rather than
dwarf2_frame_unwind. However, loongarch_scan_prologue() has not yet recorded
stack information in loongarch_frame_cache, this will cause problems in some
operations related to the frame id information.

(3) Solution:

Improve loongarch_scan_prologue() to record the stack information in
loongarch_frame_cache. And improve the loongarch_frame_unwind_stop_reason()
through the information recorded in loongarch_frame_cache.

(4) Test:

After this patch:

$ gdb test
(gdb) set disassemble-next-line on
(gdb) start
Temporary breakpoint 1, 0x0000555555554754 in main ()
=> 0x0000555555554754 <main+8>: 57ffefff bl           -20 # 0x555555554740 <fun>
(gdb) ni
0x0000555555554758 in main ()
=> 0x0000555555554758 <main+12>: 0015008c move         $t0, $a0
(gdb) ni
0x000055555555475c in main ()
=> 0x000055555555475c <main+16>: 00150184 move         $a0, $t0

Signed-off-by: Hui Li <lihui@loongson.cn>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
5 weeks agogdb: LoongArch: Refactor member functions of loongarch_frame_unwind
Hui Li [Tue, 26 Aug 2025 01:35:11 +0000 (09:35 +0800)] 
gdb: LoongArch: Refactor member functions of loongarch_frame_unwind

In the current code, loongarch_frame_unwind is a LoongArch prologue unwinder,
it contains the required member functions, but they do not calculate a valid
frame id through prologue of a function frame. Refactor these functions and
use loongarch_frame_cache to record the information of the function frame.
No functional change intended.

Signed-off-by: Hui Li <lihui@loongson.cn>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
5 weeks agogdb: LoongArch: Add the definition of loongarch_frame_cache
Hui Li [Tue, 26 Aug 2025 01:28:29 +0000 (09:28 +0800)] 
gdb: LoongArch: Add the definition of loongarch_frame_cache

Add the definition of loongarch_frame_cache for loongarch_frame_unwind,
this is preparation for later patch on LoongArch.

Signed-off-by: Hui Li <lihui@loongson.cn>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
5 weeks agoamd64-tdep: need_modrm = 1 for VEX/EVEX instructions, except vzeroall/vzeroupper
Klaus Gerlicher [Fri, 8 Aug 2025 15:20:33 +0000 (17:20 +0200)] 
amd64-tdep: need_modrm = 1 for VEX/EVEX instructions, except vzeroall/vzeroupper

VEX and EVEX-encoded instructions generally require a ModR/M byte, with the
notable exception of vzeroall and vzeroupper (opcode 0x77), which do not
use ModR/M.

This change sets need_modrm = 1 for VEX instructions, and adds an exception
for instructions where *insn == 0x77, following Intel’s SDM.

EVEX has no exceptions and thus always sets need_modrm to 1.

Additionally, the legacy twobyte_has_modrm table cannot be used for VEX and
EVEX instructions, as these encodings have different requirements and
exceptions. The logic is now explicit for VEX/EVEX handling.

Add vpblendw to selftest amd64_insn_decode.

The Intel SDM says the following:

  1. Intel® 64 and IA-32 Architectures Software Developer’s Manual

  Section 2.2.1.2 — Instruction Prefixes

  "The VEX prefix is a multi-byte prefix that replaces several legacy prefixes
  and opcode bytes. The VEX prefix is not an opcode; it is a prefix that
  modifies the instruction that follows."

  Section 2.2.1.3 — Opcode Bytes

  "The opcode byte(s) follow any instruction prefixes (including VEX). The
  opcode specifies the operation to be performed."

  Section 2.2.2 — Instruction Format

  "If a VEX prefix is present, it is processed as a single prefix, and the
  opcode bytes follow immediately after the VEX prefix."

  Source: Intel® SDM Vol. 2A, Section 2.2.1.2 and 2.2.2 (See Vol. 2A,
  PDF pages 2-4, 2-5, and 2-7)

  2. ModRM Byte Requirement

  Intel® SDM Vol. 2A, Table 2-2 — VEX Prefix Encoding

  "Most VEX-encoded instructions require a ModRM byte, except for a few
  instructions such as VZEROALL and VZEROUPPER."

  Source: Intel® SDM Vol. 2A, Table 2-2 (See Vol. 2A, PDF page 2-13)

Approved-By: Tom de Vries <tdevries@suse.de>
5 weeks ago[gdb/testsuite] Fix require dwarf2_support check in some test-cases
Tom de Vries [Tue, 26 Aug 2025 10:24:19 +0000 (12:24 +0200)] 
[gdb/testsuite] Fix require dwarf2_support check in some test-cases

On x86_64-freebsd, I ran into trouble with test-case
gdb.dwarf2/macro-source-path-clang14-dw4.exp (and similar), and I managed to
reproduce the problem on x86_64-linux by making dwarf2_support return 0.

The failure looks like:
...
UNSUPPORTED: $exp: require failed: dwarf2_support
UNRESOLVED: $exp: testcase aborted due to invalid command name: do_test
ERROR: tcl error sourcing $exp.
...

I fixed a similar problem in commit 3e488d8ccd0 ("[gdb/testsuite] Fix
gdb.dwarf2/dw-form-strx-out-of-bounds.exp with make-check-all.sh").

Fix this by moving "require dwarf2_support" from
gdb.dwarf2/macro-source-path.exp.tcl to the files including it.

Tested on x86_64-linux.

5 weeks agold/PE: don't emit relocations for weak absolute symbols
Jan Beulich [Tue, 26 Aug 2025 08:43:06 +0000 (10:43 +0200)] 
ld/PE: don't emit relocations for weak absolute symbols

First we should check the flag alone, not the entire flags value
matching BSF_WEAK. And then using "else if()" is inappropriate here: A
weak symbol can very well also be absolute, and hence wouldn't want a
relocation emitted despite being defined.

5 weeks agold/ELF: explicitly place .note.gnu.property
Jan Beulich [Tue, 26 Aug 2025 08:42:31 +0000 (10:42 +0200)] 
ld/ELF: explicitly place .note.gnu.property

x86 gas may produce .note.gnu.property by default. Hence the default
linker script would better also deal with that section, rather than
causing diagnostics when using --orphan-handling=. Replace all mis-
spellings that have accumulated.

To avoid needlessly relaxing expectations for two tests when run for
PPC 64-bit ELF targets, suppress the linker generating EH frame data
there.

5 weeks agold: entry size and merge/strings attributes propagation
Jan Beulich [Tue, 26 Aug 2025 08:42:03 +0000 (10:42 +0200)] 
ld: entry size and merge/strings attributes propagation

While commit 9c0adb10c7fc ("elf: Clear entsize when clearing
SEC_MERGE|SEC_STRINGS") addressed the particular issue reported in
PR ld/33291, it didn't go quite far enough to deal with related aspects
as well:

As indicated in other recent commits, the three properties can be
largely independent (ELF generally being the target here): Entry size
doesn't require either of merge/strings, and strings also doesn't
require merge. Commit 98e6d3f5bd4e ("gas/ELF: allow specifying entity
size for arbitrary sections") uncovered issues with ld's handling.

Zap entry size when it doesn't match between input sections. In that
case SEC_MERGE and SEC_STRINGS also need to be removed, as their
underlying granularity is lost. Then deal with SEC_MERGE and
SEC_STRINGS separately.

Otoh record entry size from the first input independent of SEC_MERGE.

5 weeks agoMAINTAINERS: Remove my email address
Vladimir Mezentsev [Mon, 25 Aug 2025 16:45:38 +0000 (09:45 -0700)] 
MAINTAINERS: Remove my email address

My position was eliminated and I don't have access to my oracle email
account.
You need a new gprofng maintainer.

5 weeks agoAutomatic date update in version.in
GDB Administrator [Tue, 26 Aug 2025 00:01:02 +0000 (00:01 +0000)] 
Automatic date update in version.in

5 weeks agoFix tekhex format related gdb.base/dump.exp failures
Kevin Buettner [Sun, 24 Aug 2025 03:54:30 +0000 (20:54 -0700)] 
Fix tekhex format related gdb.base/dump.exp failures

On s390x, a big-endian machine, I'm seeing these test failures:

FAIL: gdb.base/dump.exp: array as memory, tekhex; file restored ok
FAIL: gdb.base/dump.exp: array as memory, tekhex; value restored ok
FAIL: gdb.base/dump.exp: array as value, tekhex; file restored ok
FAIL: gdb.base/dump.exp: array as value, tekhex; value restored ok
FAIL: gdb.base/dump.exp: array copy, tekhex; file restored ok
FAIL: gdb.base/dump.exp: array copy, tekhex; value restored ok
FAIL: gdb.base/dump.exp: array partial, tekhex; file restored ok
FAIL: gdb.base/dump.exp: array partial, tekhex; value restored ok
FAIL: gdb.base/dump.exp: dump array as memory, tekhex
FAIL: gdb.base/dump.exp: dump array as value, tekhex
FAIL: gdb.base/dump.exp: dump struct as memory, tekhex
FAIL: gdb.base/dump.exp: dump struct as value, tekhex
FAIL: gdb.base/dump.exp: reload array as memory, tekhex; value restored ok
FAIL: gdb.base/dump.exp: reload array as value, tekhex; value restored ok
FAIL: gdb.base/dump.exp: reload struct as memory, tekhex; value restored ok
FAIL: gdb.base/dump.exp: reload struct as value, tekhex; value restored ok
FAIL: gdb.base/dump.exp: struct as memory, tekhex; file restored ok
FAIL: gdb.base/dump.exp: struct as memory, tekhex; value restored ok
FAIL: gdb.base/dump.exp: struct as value, tekhex; file restored ok
FAIL: gdb.base/dump.exp: struct as value, tekhex; value restored ok
FAIL: gdb.base/dump.exp: struct copy, tekhex; file restored ok
FAIL: gdb.base/dump.exp: struct copy, tekhex; value restored ok

It turns out that there's a subtle bug in move_section_contents in
bfd/tekhex.c.  The bug is that when attempting to write a buffer that
starts with a zero byte, the function will return false, an error
condition, without writing anything.  But it also doesn't set
bfd_error, so GDB ends up displaying whatever the last unrelated error
was, e.g.:

warning: writing dump file '.../intstr1.tekhex' (No such file or directory)

When I investigated this, the bfd error was set during failure to
open a separate debug file for the test case, which is totally
unrelated to this problem.

The reason this fails on big endian machines is that the test case
writes out structs and arrays of int initialized to small values.  On
little endian machines, the small integer is the first byte, so the
error doesn't occur.  On big endian machines, a zero byte occurs
first, triggering the error.

On the GDB side of things, I've made a one line change to the test
case to cause the error to also happen on little endian machines.  I
simply shift value of the first field in the struct left by 16 bits.
That leaves at least one zero byte on both sides of the non-zero part
of the int.  I shifted it by 16 because, for a moment, there was a
question in my mind about what would happen with a second zero byte,
but it turns out that it's not a problem.

On the bfd side of things, take a look at move_section_contents() and
find_chunk() in tekhex.c.  The scenario is this: we enter
move_section_contents with locationp pointing at a character buffer
whose first byte is zero.  The 'get' parameter is false, i.e. we're
writing, not reading.  The other critical fact is that the
abfd->tdata.tekhex_data->data is NULL (0).

I'm going to go through the execution path pretty much line by line
with commentary below the line(s) just executed.

  char *location = (char *) locationp;
  bfd_vma prev_number = 1;      /* Nothing can have this as a high bit.  */

I can't say that the comment provides the best explanation about
what's happening, but the gist is this: later on, chunk_number will
have it's low bits masked away, therefore no matter what it is, it
can't possibly be equal to prev_number when it's set to 1.

  struct data_struct *d = NULL;

  BFD_ASSERT (offset == 0);
  for (addr = section->vma; count != 0; count--, addr++)
    {

Set d to NULL and enter the loop.

      /* Get high bits of address.  */
      bfd_vma chunk_number = addr & ~(bfd_vma) CHUNK_MASK;
      bfd_vma low_bits = addr & CHUNK_MASK;

Use CHUNK_MASK, which is 0x1fff, to obtain the chunk number, i.e.
whatever's left after masking off the low 13 bits of addr, and
low_bits, which are the low 13 bits of addr.  chunk_number matters for
understanding this bug, low_bits does not.  Remember that no matter
what addr is, once you mask off the low 13 bits, it can't be equal to 1.

      bool must_write = !get && *location != 0;

!get is true, *location != 0 is false, therefore the conjunction is
false, and furthermore must_write is false.  I.e.  even though we are
writing, we don't transfer zero bytes to the chunk - this is why
must_write is false.  (The reason this works is that a chunk, once
allocated, is zero'd as part of the allocation using bfd_zalloc.
Therefore we can skip transferring zero bytes and, if enough of them
are skipped one after another, chunk allocation simply doesn't happen.
That's a good thing.)

      if (chunk_number != prev_number || (!d && must_write))

For the reason provided above, chunk_number != prev_number is true.
The other part of the disjunction doesn't matter since the first part
is true.  This means that the if-block is entered.

          /* Different chunk, so move pointer. */
          d = find_chunk (abfd, chunk_number, must_write);

find_chunk is entered with must_write set to false.  Now, remember
where we left off here, because we're going to switch to find_chunk.

  static struct data_struct *
  find_chunk (bfd *abfd, bfd_vma vma, bool create)
  {

(Above 3 lines indented to distinguish code from commentary.)

When we enter find_chunk, create is false because must_write was false.

  struct data_struct *d = abfd->tdata.tekhex_data->data;

d is set to NULL since abfd->tdata.texhex_data->data is NULL (one of
the conditions for the scenario).

  vma &= ~CHUNK_MASK;
  while (d && (d->vma) != vma)
    d = d->next;

d is NULL, so the while loop doesn't execute.

  if (!d && create)
    ...

d is NULL so !d is true, but create is false, so the condition
evaluates to false, meaning that the if-block is skipped.

  return d;

find_chunk returns NULL, since d is NULL.

Back in move_section_contents:

          if (!d)
            return false;

d is NULL (because that's what find_chunk returned), so
move_section_contents returns false at this point.

Note that find_section_contents has allocated no memory, nor even
tried to transfer any bytes beyond the first (zero) byte.  This
is a bug.

The key to understanding this bug is to observe that find_chunk can
return NULL to indicate that no chunk was found.  This is especially
important for the read (get=true) case.  But it can also be NULL
to indicate a memory allocation error.  I toyed around with the
idea of using a different value to distinguish these cases, i.e.
something like (struct data_struct *) -1, but although bfd contains
plenty of code where -1 is used to indicate various interesting
conditions for scalars, there's no prior art where this is done
for a pointer.  Therefore the idea was discarded in favor of
modifying this statement:

          if (!d)
            return false;

to:
          if (!d && must_write)
            return false;

This works because, in find_chunk, the only way to return a NULL
memory allocation error is for must_write / create to be true.  When
it is true, if bfd_zalloc successfully allocates a chunk, then that
(non-NULL) chunk will be returned at the end of the function.  When it
fails, it'll return NULL early.  The point is that when bfd_zalloc()
fails and returns NULL, must_write (in move_section_contents) / create
(in find_chunk) HAD to be true.  That provides us with an easy test
back in move_section_contents to distinguish a memory-allocation-NULL
from a block-not-found-NULL.

The other NULL return case happens when the end of the function is
reached when either searching for a chunk to read or attempting to
find a chunk to write when abfd->tdata.tekhex_data->data is NULL.  But
for the latter case, must_write was false, which does not (now, with
the above fix) trigger the early return of false.

(Alan Modra approved the bfd/tekhex.c change.)
Approved-By: Simon Marchi <simon.marchi@efficios.com> (GDB)
5 weeks agogdb: fix indentation in objfiles.c
Simon Marchi [Mon, 25 Aug 2025 16:48:17 +0000 (12:48 -0400)] 
gdb: fix indentation in objfiles.c

Change-Id: I3d39ee767a3b2b743b3a90386fb30a6703e9733e

6 weeks agogdb: LoongArch: Handle newly added llsc instructions
Xi Ruoyao [Tue, 19 Aug 2025 07:33:44 +0000 (15:33 +0800)] 
gdb: LoongArch: Handle newly added llsc instructions

We can't put a breakpoint in the middle of a ll/sc atomic sequence,
handle the instructions sc.q, llacq.{w/d}, screl.{w/d} newly added
in the LoongArch Reference Manual v1.10 so a ll/sc atomic sequence
using them won't loop forever being debugged.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
6 weeks agoAutomatic date update in version.in
GDB Administrator [Mon, 25 Aug 2025 00:00:32 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 weeks agoPR 33302, Symbols truncated on i386pep target
Alan Modra [Sat, 23 Aug 2025 03:37:40 +0000 (13:07 +0930)] 
PR 33302, Symbols truncated on i386pep target

Commit 012d44268695 effectively made peXXigen.c _bfd_XXi_swap_aux_out
always use the COFF E_FILNMLEN of 14.  The problem was that the auxent
x_fname field was defined in include/coff/external.h using a length of
14.  Later, E_FILNMLEN is redefined to 18 in coff/pe.h.  This no doubt
falsely tripped memory checking tools.  AUXESZ is 18, so no actual
buffer overrun.

This patch defines x_fname as an 18 char field, the full auxent, and
uses E_FILNMLEN when accessing.

PR 33302
include/
* coff/external.h (union external_auxent): Make x_fname
AUXESZ chars.
bfd/
* coffswap.h (coff_swap_aux_in): Correct #error message.
(coff_swap_aux_out): Likewise.  Use E_FILNMLEN when copying
to ext field.
* peXXigen.c (_bfd_XXi_swap_aux_in): Add #error.  Style fix.
(_bfd_XXi_swap_aux_out): Add #error.  Don't use sizeof, use
E_FILNMLEN when copying to ext field.
gas
* testsuite/gas/pe/long_file_symbol.d,
* testsuite/gas/pe/long_file_symbol.s: New test.
* testsuite/gas/pe/pe.exp: Run it.

Reported-By: Frediano Ziglio <freddy77@gmail.com>
6 weeks agoTidy include/coff/external.h and internal.h
Alan Modra [Sat, 23 Aug 2025 07:09:51 +0000 (16:39 +0930)] 
Tidy include/coff/external.h and internal.h

Mostly whitespace fixes and wrap of long comment lines, removal of block
comments and moving a few defines around.  Nothing much to see here,
but AUXESZ before union external_auxent is needed by the next patch.

 * coff/external.h: Whitespace fixes, wrap long comment lines,
 remove header style comments.  Move some defines.
 (E_FILNMLEN): Remove #ifndef.
 (_ETEXT): Don't define.
 (SYMENT, AUXENT): Don't define, make them typedefs.
 * coff/internal.h: Whitespace fixes, wrap long comment lines,
 remove header style comments.  Move some defines.
 (signed): Don't define.

6 weeks agobfd/pe*.c including bfd/coff*.c
Alan Modra [Sat, 23 Aug 2025 06:57:12 +0000 (16:27 +0930)] 
bfd/pe*.c including bfd/coff*.c

The model of a coff-<arch>.c file providing older COFF support, with a
pe-<arch>.c file defining some macros then including the coff-<arch>.c
file to provide PE support has been followed by a number of
architectures.

Some of them have PE specific code in their coff-<arch>.c files,
unconditionally compiled.  ie. they are not for old COFF support, and
there was no reason to follow the model.  They now get an error if
they are compiled stand-alone rather than being included from
pe-<arch>.c or pei-<arch>.c.

* coff-aarch64.c (COFF_WITH_peAArch64): Don't define here.
(COFF_WITH_PE): Error if not defined.
* coff-ia64.c (COFF_WITH_PE): Error if not defined.
* coff-loongarch64.c (COFF_WITH_peLoongArch64): Don't define here.
(COFF_WITH_PE): Error if not defined.
* coff-mcore.c (COFF_WITH_PE): Error if not defined.
* coff-riscv64.c (COFF_WITH_PE): Error if not defined.
* pei-aarch64.c: Remove duplicate includes.
* pei-loongarch64.c: Likewise.
* pei-riscv64.c: Likewise.
* pei-x86_64.c: Likewise.

6 weeks agogdb: allow gdb.Color to work correctly with pagination
Andrew Burgess [Wed, 18 Jun 2025 14:02:29 +0000 (15:02 +0100)] 
gdb: allow gdb.Color to work correctly with pagination

This commit allows gdb.Color objects to be used to style output from
GDB commands written in Python, and the styled output should work
correctly with pagination.

There are two parts to fixing this:

First, GDB needs to be able to track the currently applied style
within the page_file class.  This means that style changes need to be
achieved with calls to pager_file::emit_style_escape.

Now usually, GDB does this by calling something like fprintf_styled,
which takes care to apply the style for us.  However, that's not
really an option here as a gdb.Color isn't a full style, and as the
gdb.Color object is designed to be converted directly into escape
sequences that can then be printed, we really need a solution that
works with this approach.

However pager_file::puts already has code in place to handle escape
sequences.  Right now all this code does is spot the escape sequence
and append it to the m_wrap_buffer.  But in this commit I propose that
we go one step further, parse the escape sequence back into a
ui_file_style object in pager_file::puts, and then we can call
pager_file::emit_style_escape.

If the parsing doesn't work then we can just add the escape sequence
to m_wrap_buffer as we did before.

But wait, how can this work if a gdb.Color isn't a full style?  Turns
out that's not a problem.  We only ever emit the escape sequence for
those parts of a style that need changing, so a full style that sets
the foreground color will emit the same escape sequence as a gdb.Color
for the foreground.  When we convert the escape sequence back into a
ui_file_style, then we get a style with everything set to default,
except the foreground color.

I had hoped that this would be all that was needed.  But unfortunately
this doesn't work because of the second problem...

... the implementation of the Python function gdb.write() calls
gdb_printf(), which calls gdb_vprintf(), which calls ui_file::vprintf,
which calls ui_out::vmessage, which calls ui_out::call_do_message, and
finally we reach cli_ui_out::do_message.  This final do_message
function does this:

  ui_file *stream = m_streams.back ();
  stream->emit_style_escape (style);
  stream->puts (str.c_str ());
  stream->emit_style_escape (ui_file_style ());

If we imagine the case where we are emitting a style, triggered from
Python like this:

  gdb.write(gdb.Color('red').escape_sequence(True))

the STYLE in this case will be the default ui_file_style(), and STR
will hold the escape sequence we are writing.

After the first change, where pager_file::puts now calls
pager_file::emit_style_escape, the current style of STREAM will have
been updated.  But this means that the final emit_style_escape will
now restore the default style.

The fix for this is to avoid using the high level gdb_printf from
gdb.write(), and instead use gdb_puts instead.  The gdb_puts function
doesn't restore the default style, which means our style modification
survives.

There's a new test included.  This test includes what appears like a
pointless extra loop (looping over a single value), but this makes
sense given the origin of this patch.  I've pulled this commit from a
longer series:

  https://inbox.sourceware.org/gdb-patches/cover.1755080429.git.aburgess@redhat.com

I want to get this bug fix merged before GDB 17 branches, but the
longer series is not getting reviews, so for now I'm just merging this
one fix.  Once the rest of the series gets merged, I'll be extending
the test, and the loop (mentioned above) will now loop over more
values.

6 weeks agoAutomatic date update in version.in
GDB Administrator [Sun, 24 Aug 2025 00:00:39 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 weeks agox86: Distinguish no PLT build and run test names
H.J. Lu [Sat, 23 Aug 2025 21:04:52 +0000 (14:04 -0700)] 
x86: Distinguish no PLT build and run test names

Change no PLT build and run test names from

PASS: No PLT (dynamic 1a)
...
PASS: No PLT (dynamic 1a)

to

PASS: Build no PLT (dynamic 1a)
...
PASS: Run no PLT (dynamic 1a)

in ld.log.

* testsuite/ld-i386/no-plt.exp (run_cc_link_tests): Change
"No PLT" to "Build no PLT" in no PLT build test names.
(run_ld_link_exec_tests): Change "No PLT" to "Run no PLT" in no
PLT run test names.
* testsuite/ld-x86-64/no-plt.exp (run_cc_link_tests): Change
"No PLT" to "Build no PLT" in no PLT build test names.
(run_ld_link_exec_tests): Change "No PLT" to "Run no PLT" in no
PLT run test names.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
6 weeks agoUpdate comment in rust-parse.c
Tom Tromey [Sat, 23 Aug 2025 22:40:35 +0000 (16:40 -0600)] 
Update comment in rust-parse.c

I noticed an out-of-date comment in rust-parse.c.

6 weeks agox86-64: Use the GOT indirection in no-plt-check1.S
H.J. Lu [Sat, 23 Aug 2025 16:35:50 +0000 (09:35 -0700)] 
x86-64: Use the GOT indirection in no-plt-check1.S

There is

cmpq %rax, func_p(%rip)

in no-plt-check1.S which requires copy relocation when func_p, a function
pointer, is defined in a shared library.  Use the GOT indirection to
access func_p

movq func_p@GOTPCREL(%rip), %rdx
cmpq %rax, (%rdx)

to remove copy relocation to support PIE without copy relocation.

PR ld/33237
* testsuite/ld-x86-64/no-plt-check1.S: Use the GOT indirection
to access func_p.
* testsuite/ld-x86-64/no-plt-1a.dd: Adjusted.
* testsuite/ld-x86-64/no-plt-1b.dd: Likewise.
* testsuite/ld-x86-64/no-plt-1a.dd: Likewise.
* testsuite/ld-x86-64/no-plt-1b.dd: Likewise.
* testsuite/ld-x86-64/no-plt-1c.dd: Likewise.
* testsuite/ld-x86-64/no-plt-1d.dd: Likewise.
* testsuite/ld-x86-64/no-plt-1e.dd: Likewise.
* testsuite/ld-x86-64/no-plt-1f.dd: Likewise.
* testsuite/ld-x86-64/no-plt-1g.dd: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
6 weeks agolibsframe: use offsets to FDE and FRE sub-sections
Indu Bhagat [Sat, 23 Aug 2025 19:09:44 +0000 (12:09 -0700)] 
libsframe: use offsets to FDE and FRE sub-sections

In SFrame format, the SFrame FDEs begin at an offset 'sfh_fdeoff' from
the end of the SFrame header.  Similarly, the SFrame FREs begin at an
offset 'sfh_freoff' from the end of the SFrame header.

While the GNU assembler generates these subsections such that sfd_fdeoff
is zero, the correct way to decode the SFrame section (conforming with
the specification) is to use both sfh_fdeoff and sfh_freoff in
sframe_decode.

libsframe/
* sframe.c (sframe_decode): Use offsets to SFrame FDE and FRE
sub-sections as applicable.

6 weeks ago[gdb/testsuite] Require cooked index in two test-cases
Tom de Vries [Sat, 23 Aug 2025 06:44:34 +0000 (08:44 +0200)] 
[gdb/testsuite] Require cooked index in two test-cases

After running the testsuite with target board cc-with-gdb-index I ran found
failures in test-cases:
- gdb.dwarf2/backward-spec-inter-cu.exp
- gdb.dwarf2/forward-spec-inter-cu.exp

Fix this by requiring a cooked index.

Tested on x86_64-linux.

6 weeks ago[gdb/symtab] Turn complaints in create_addrmap_from_gdb_index into warnings
Tom de Vries [Sat, 23 Aug 2025 06:15:51 +0000 (08:15 +0200)] 
[gdb/symtab] Turn complaints in create_addrmap_from_gdb_index into warnings

Rather than issuing a complaint, which is off by default, warn when returning
false in create_addrmap_from_gdb_index, informing the user that the .gdb_index
was ignored, and why.

Tested on aarch64-linux.

6 weeks ago[gdb/symtab] Detect overlapping ranges in create_addrmap_from_gdb_index
Tom de Vries [Sat, 23 Aug 2025 04:11:41 +0000 (06:11 +0200)] 
[gdb/symtab] Detect overlapping ranges in create_addrmap_from_gdb_index

In create_addrmap_from_gdb_index, use the return value of
addrmap_mutable::insert_empty to detect overlapping ranges.

Tested on x86_64-linux.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
6 weeks ago[gdb] Make addrmap_mutable::set_empty return bool
Tom de Vries [Sat, 23 Aug 2025 04:11:41 +0000 (06:11 +0200)] 
[gdb] Make addrmap_mutable::set_empty return bool

Function addrmap_mutable::set_empty has the follow behavior (shortened
comment):
...
/* In the mutable address map MAP, associate the addresses from START
   to END_INCLUSIVE that are currently associated with NULL with OBJ
   instead.  Addresses mapped to an object other than NULL are left
   unchanged.  */
  void set_empty (CORE_ADDR start, CORE_ADDR end_inclusive,
  void *obj);
...

Change the return type to bool, and return true if the full range
[START, END_INCLUSIVE] is mapped to OBJ.

Tested on x86_64-linux.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
6 weeks ago[gdb/symtab] Bail out of create_addrmap_from_gdb_index on error
Tom de Vries [Sat, 23 Aug 2025 04:11:41 +0000 (06:11 +0200)] 
[gdb/symtab] Bail out of create_addrmap_from_gdb_index on error

Currently, in create_addrmap_from_gdb_index, when finding an incorrect entry
in the address table of a .gdb_index section:
- a (by default silent) complaint is made,
- the entry is skipped, and
- the rest of the entries is processed.

This is the use-what-you-can approach, which make sense in general.

But in the case that the .gdb_index section is incorrect while the other debug
info is correct, this approach prevents gdb from building a correct cooked
index (assuming there's no bug in gdb that would cause an incorrect index to
be generated).

Instead, bail out of create_addrmap_from_gdb_index on finding errors in the
address table.

I wonder about the following potential drawback of this approach: in the case
that the .gdb_index section is incorrect because the debug info is incorrect,
this approach rejects the .gdb_index section and spents time rebuilding a
likewise incorrect index.  But I'm not sure if this is a real problem.
Perhaps gdb will refuse to generate such an index, in which case this is a
non-issue.

Tested on aarch64-linux.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
6 weeks agogas: add --enable-default-sframe configure option
Sam James [Thu, 3 Jul 2025 10:08:59 +0000 (11:08 +0100)] 
gas: add --enable-default-sframe configure option

SFrames make the most sense when userland as a whole is built with them,
so add a --enable-default-sframe configure flag to facilitate distributors
and vendors doing that.

The primary motivation for a configure-time flag is that we don't support
SFrame for 32-bit x86 but some packaging uses the same flags (with some
added on top) for multilib builds (to support old binaries like games),
and simply adding `-Wa,--gsframe` to the standard build flags isn't an
option (*).

That aside, I believe it'll be helpful for testing and eventual adoption
in any case.

In summary, combined with the recent --gsframe=[yes|no] support (**):
* Configured with --enable-default-sframe and nothing is passed
  => SFrames (previously no SFrames)
* Configured with --enable-default-sframe and --gsframe=yes is passed
  => SFrames (no change from before)
* Configured with --enable-default-sframe and --gsframe=no is passed
  => No SFrames (no change from before)
* Configured with --enable-default-sframe and --gsframe is passed
  => SFrames (no change from before)

* Configured with --disable-default-sframe and nothing is passed
  => No SFrames (no change from before)
* Configured with --disable-default-sframe and --gsframe=yes is passed
  => SFrames (no change from before)
* Configured with --disable-default-sframe and --gsframe=no is passed
  => No SFrames (no change from before)
* Configured with --disable-default-sframe and --gsframe is passed
  => SFrames (no change from before)

I've introduced a sframe_as_bad macro on Indu's suggestion. A following
patch uses its sibling sframe_as_warn heavily and having symmetry plus
the macro as a form of documentation of intent seems useful.

(*) It gets added to multilib builds too and then we hit the
    `.sframe not supported for target` error in gas/dw2gencfi.c.

(**) I've verbosely listed --gsframe=yes but it's the same as --gsframe.

gas/
PR gas/33126
* as.c (enum gen_sframe_option): Initialize if DEFAULT_SFRAME.
* config.in (DEFAULT_SFRAME): New.
* configure: Regenerate.
* configure.ac: Add --enable-default-sframe.
* doc/as.texi: Document --enable-default-sframe.
* dw2gencfi.c (cfi_finish): Don't warn if SFrames are enabled
by default but unavailable for this target.
* gen-sframe.h (sframe_as_bad): New macro.

6 weeks agoAutomatic date update in version.in
GDB Administrator [Sat, 23 Aug 2025 00:00:29 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 weeks agogdb/doc: qSearch:memory packets use escaped binary patterns
Aaron Griffith [Sat, 16 Aug 2025 20:34:56 +0000 (16:34 -0400)] 
gdb/doc: qSearch:memory packets use escaped binary patterns

The `qSearch:memory` packet uses hex encoding for the address and
length arguments, but the search-pattern argument uses escaped binary.

Approved-By: Eli Zaretskii <eliz@gnu.org>
6 weeks agogdb/testsuite: fix pattern in gdb.base/dlmopen-ns-ids.exp
Simon Marchi [Thu, 14 Aug 2025 20:13:01 +0000 (16:13 -0400)] 
gdb/testsuite: fix pattern in gdb.base/dlmopen-ns-ids.exp

I forgot one spot when updating the "info shared" header from NS to
"Linker NS", fix that.  This fixes the following failure:

    FAIL: gdb.base/dlmopen-ns-ids.exp: check no duplicates: info sharedlibrary

At the same time, fix a couple of things I found when looking at this
code again.  One is bad indentation, the other is an unnecessary
parameter.

Change-Id: Ibbc2062699264dde08fd3ff7c503524265c73b0c

6 weeks agoMSYS2+MinGW testing: Unix <-> Windows path conversion
Pedro Alves [Fri, 8 Aug 2025 23:03:28 +0000 (00:03 +0100)] 
MSYS2+MinGW testing: Unix <-> Windows path conversion

On an MSYS2 system, I have:

 # which tclsh
 /mingw64/bin/tclsh

 # which tclsh86
 /mingw64/bin/tclsh86

 # which tclsh8.6
 /usr/bin/tclsh8.6

 # which expect
 /usr/bin/expect

The ones under /usr/bin are MSYS2 programs (linked with msys-2.0.dll).
I.e., they are really Cygwin (unix) ports of the programs.

The ones under /mingw64 are native Windows programs (NOT linked with
msys-2.0.dll).  You can check that with CYGWIN/MSYS2 ldd.

The MSYS2/Cygwin port of TCL (and thus expect) does not treat a file
name that starts with a drive letter as an absolute file name, while
the native/MinGW port does.  Vis:

 # cat file-join.exp
 puts [file join c:/ d:/]

 # /mingw64/bin/tclsh.exe file-join.exp
 d:/

 # /mingw64/bin/tclsh86.exe file-join.exp
 d:/

 # /usr/bin/expect.exe file-join.exp
 c:/d:

 # /usr/bin/tclsh8.6.exe file-join.exp
 c:/d:

When running the testsuite under MSYS2 to test mingw32 (Windows
native) GDB, we use MSYS2 expect (there is no MinGW port of expect
AFAIK).  Any TCL file manipulation routine will thus not consider
drive letters special, and just treats them as relative file names.

This results in several cases of the testsuite passing to GDB broken
file names, like:

 "C:/foo/C:/foo/bar"

or:

 "/c/foo/C:/foo/bar"

E.g., there is a "file join" in standard_output_file that results in
this:

 (gdb) file C:/gdb/build/outputs/gdb.base/info_sources_2/C:/gdb/build/outputs/gdb.base/info_sources_2/info_sources_2
 C:/gdb/build/outputs/gdb.base/info_sources_2/C:/gdb/build/outputs/gdb.base/info_sources_2/info_sources_2: No such file or directory.
 (gdb) ERROR: (info_sources_2) No such file or directory
 delete breakpoints

The bad "file join" comes from clean_restart $binfile, where $binfile
is an absolute host file name (thus has a drive letter), clean_restart
doing:

set binfile [standard_output_file ${executable}]
return [gdb_load ${binfile}]

and standard_output_file doing:

    # If running on MinGW, replace /c/foo with c:/foo
    if { [ishost *-*-mingw*] } {
        set dir [exec sh -c "cd ${dir} && pwd -W"]
    }
    return [file join $dir $basename]

Here, BASENAME was already an absolute file name that starts with a
drive letter, but "file join" treated it as a relative file name.

Another spot where we mishandle Unix vs drive letter file names, is in
the "dir" command that we issue when starting every testcase under
GDB.  We currently always pass the file name as seen from the build
machine (i.e., from MSYS2), which is a Unix file name that native
Windows GDB does not understand, resulting in:

 (gdb) dir /c/gdb/src/gdb/testsuite/gdb.rocm
 warning: /c/gdb/src/gdb/testsuite/gdb.rocm: No such file or directory
 Source directories searched: /c/gdb/src/gdb/testsuite/gdb.rocm;$cdir;$cwd

This patch introduces a systematic approach to handle all this, by
introducing the concepts of build file names (what DejaGnu sees) vs
host file names (what GDB sees).

This patches implements that in the following way:

1) - Keep standard_output_file's host-side semantics

standard_output_file currently converts the file name to a Windows
file name, using the "cd $dir; pwd -W" trick.  standard_output_file is
used pervasively, so I think it should keep the semantics that it
returns a host file name.

Note there is already a preexisting host_standard_output_file
procedure.  The difference to standard_output_file is that
host_standard_output_file handles remote hosts, while
standard_output_file assumes the build and host machines share a
filesystem.  The MSYS2 Unix path vs MinGW GDB drive letter case fall
in the "shared filesystem" bucket.  An NFS mount on the host at the
same mount point as on the build machine falls in that bucket too.

2) - Introduce build_standard_output_file

In some places, we are calling standard_output_file to find the
build-side file name, most often just to find the standard output
directory file name, and then immediately use that file name with TCL
file manipulation procedures, to do some file manipulation on the
build machine.  clean_standard_output_dir is an example of such a
case.  That code path is responsible for this bogus 'rm -rf' in
current MSYS2 testing:

 Running /c/gdb/src/gdb/testsuite/gdb.base/break.exp ...
 Executing on build: rm -rf /c/msys2/home/alves/gdb/build-testsuite/C:/msys2/home/alves/gdb/build-tests...

For these cases, add a variant of standard_output_file called
build_standard_output_file.  The main difference to
standard_output_file is that it doesn't do the "cd $dir; pwd -W"
trick.  I.e., it returns a path on the build machine.

3) Introduce host_file_sanitize

In some cases, we read an absolute file name out of GDB's output, and
then want to compare it against some other file name.  The file name
may originally come from the DWARF, and sometimes may have forward
slashes, and other times, it may have backward slashes.  Or the drive
letter may be uppercase, or it may be lowercase.  To make comparisons
easier, add a new host_file_sanitize procedure, that normalizes
slashes, and uppercases the drive letter.  It does no other
normalization.  Particularly, it does not turn a relative file name
into an absolute file name.

It's arguable whether GDB itself should do this sanitization.  I
suspect it should.  I personally dislike seeing backward slashes in
e.g., "info shared" output, or worse, mixed backward and forward
slashes.  Still, I propose starting with a testsuite adjustment that
moves us forward, and handle that separately.  I won't be surprised if
we need the new routine for some cases even if we adjust GDB.

4) build_file_normalize / host_file_normalize

In several places in the testsuite, we call "file normalize" on some
file name.  If we pass it a drive-letter file name, that TCL procedure
treats the passed in file name as a relative file name, so produces
something like /c/foo/C:/foo/bar.txt.

If the context calls for a build file name, then the "file normalize"
call should produce /c/foo/bar.txt.  If OTOH we need a host file name,
then it should produce "C:/foo/bar.txt".  Handle this by adding two
procedures that wrap "file normalize":

  - build_file_normalize
  - host_file_normalize

Initialy I implemented them in a very simple way, calling into
cygpath:

 proc build_file_normalize {filename} {
    if { [ishost *-*-mingw*] } {
      return [exec cygpath -ua $filename]
    } else {
      return [file normalize $filename]
    }
 }

 proc host_file_normalize {filename} {
    if { [ishost *-*-mingw*] } {
      return [exec cygpath -ma $filename]
    } else {
      return [file normalize $filename]
    }
 }

"cygpath" is a utility that comes OOTB with both Cygwin and MSYS2,
that does Windows <-> Cygwin file name conversion.

This works well, but because running the testsuite on Windows is so
slow, I thought of trying to avoid or minimize the cost of calling an
external utility ("cygpath").

On my system, calling into cygpath takes between 200ms to 350ms, and
these smallish costs (OK, not so small!) can creep up and compound an
already bad situation.  Note that the current call to "cd $dir; pwd
-W" has about the same cost as a "cygpath" call (though a little bit
cheaper).

So with this patch, we actually don't call cygpath at all, and no
longer use the "cd $dir; pwd -W" trick.  Instead we run the "mount"
command once, and cache the mapping (via gdb_caching_proc) between
Windows file names and Unix mount points, and then use that mapping in
host_file_normalize and build_file_normalize, to do the Windows <=>
Unix file name conversions ourselves.

One other small advantage here is that this approach works the same
for 'cygwin x mingw' testing [1], and 'msys x mingw' testing, while
"pwd -W" only works on MSYS2.

So I think the end result is that we should end up faster (or less
slow) than the current state.

(No, I don't have actual timings for the effect over a whole testsuite
run.)

5) Introduce host_file_join

For the "file join" call done from within standard_output_file (and
probably in future other places), since that procedure works with host
file names, add a new host_file_join procedure that is a wrapper
around "file join" that is aware of Windows drive letters.

======

With the infrastructure described above in place, the "dir" case is
fixed by simply calling host_file_normalize on the directory name,
before passing it to GDB.  That turns:

 (gdb) dir /c/gdb/src/gdb/testsuite/gdb.base
 warning: /c/gdb/src/gdb/testsuite/gdb.base: No such file or directory
 Source directories searched: /c/gdb/src/gdb/testsuite/gdb.base;$cdir;$cwd

Into:

 (gdb) dir C:/gdb/src/gdb/testsuite/gdb.base
 Source directories searched: C:/gdb/src/gdb/testsuite/gdb.base;$cdir;$cwd

Running the testsuite on GNU/Linux reveals that that change requires
tweaks to gdb.guile/scm-parameter.exp and gdb.python/py-parameter.exp,
to run the expected directory by host_file_normalize too, so that it
matches the directory we initially pass GDB at startup time.  Without
that fix, there could be a mismatch if the GDB sources path has a
symlink component, which now gets resolved by the host_file_normalize
call.

The theory is that most standard_output_file uses will not need to be
adjusted.

I grepped for "file normalize" and "file join", to find cases that
might need adjustment, and fixed those that required fixing.  The
fixes are included in this patch, to make it easier to reason about
the overall change.  E.g., in gdb.base/fullname.exp, without the fix,
we get:

 Running /c/gdb/src/gdb/testsuite/gdb.base/fullname.exp ...
 ERROR: tcl error sourcing /c/gdb/src/gdb/testsuite/gdb.base/fullname.exp.
 ERROR: tcl error code NONE
 ERROR: C:/msys2/home/alves/gdb/build-testsuite/outputs/gdb.base/fullname/tmp-fullname.c not a subdir of /c/msys2/home/alves/gdb/build-testsuite

In gdb.base/source-dir.exp, we have several issues.  E.g., we see the
"/c/foo/c:/foo" problem there too:

 dir /c/msys2/home/alves/gdb/build-testsuite/C:/msys2/home/alves/gdb/build-testsuite/outputs/gdb.base/source-dir/C:/msys2/home/alves/gdb/build-testsuite/outputs
 warning: /c/msys2/home/alves/gdb/build-testsuite/C:/msys2/home/alves/gdb/build-testsuite/outputs/gdb.base/source-dir/C:/msys2/home/alves/gdb/build-testsuite/outputs: No such file or directory
 Source directories searched: /c/msys2/home/alves/gdb/build-testsuite/C:/msys2/home/alves/gdb/build-testsuite/outputs/gdb.base/source-dir/C:/msys2/home/alves/gdb/build-testsuite/outputs;$cdir;$cwd
 (gdb) PASS: gdb.base/source-dir.exp: setup source path search directory

...

Executing on host: x86_64-w64-mingw32-gcc  \
  -fno-stack-protector \
  /c/msys2/home/alves/gdb/build-testsuite/C:/msys2/home/alves/gdb/build-testsuite/outputs/gdb.base/macro-source-path/cwd/macro-source-path.c ...
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

... and we need to handle Unix file names that we pass to the compiler
(on the build side), vs file names that GDB prints out (the host
side).

Similarly in the other testcases.

I haven't yet tried to do a full testsuite run on MSYS2, and I'm quite
confident there will be more places that will need similar adjustment,
but I'd like to land the infrastructure early, so that the rest of the
testsuite can be adjusted incrementally, and others can help.

Change-Id: I664dbb86d0efa4fa8db405577bea2b4b4a96a613

6 weeks agogdb/copyright.py: print notice about files that print copyright at runtime
Simon Marchi [Thu, 14 Aug 2025 20:13:01 +0000 (16:13 -0400)] 
gdb/copyright.py: print notice about files that print copyright at runtime

During the last new year process, it seems that we forgot to update the
copyright notices printed by the various programs (see 713b99a9398 "gdb,
gdbserver: update copyright years in copyright notices").  Change
gdb/copyright.py to print a message about this.  For a procedure that
happens once a year, this seems sufficient to me, but if someone wants
to automate it I won't object.

While at it, change the formatting of the previous message, to match the
formatting of the first message (making it end with a colon).

Change-Id: I330f566221d102bab0a953bc324127f2466dd5cf
Approved-By: Tom Tromey <tom@tromey.com>
6 weeks agotestsuite: Introduce gdb_watchdog (avoid unistd.h/alarm)
Pedro Alves [Fri, 8 Aug 2025 22:50:04 +0000 (23:50 +0100)] 
testsuite: Introduce gdb_watchdog (avoid unistd.h/alarm)

There are a good number of testcases in the testsuite that use alarm()
as a watchdog that aborts the test if something goes wrong.

alarm()/SIG_ALRM do not exist on (native) Windows, so those tests fail
to compile there.

For example, testing with x86_64-w64-mingw32-gcc, we see:

 Running /c/rocgdb/src/gdb/testsuite/gdb.base/attach.exp ...
 gdb compile failed, C:/rocgdb/src/gdb/testsuite/gdb.base/attach.c: In function 'main':
 C:/rocgdb/src/gdb/testsuite/gdb.base/attach.c:17:3: error: implicit declaration of function 'alarm' [-Wimplicit-function-declaration]
    17 |   alarm (60);
       |   ^~~~~

While testing with a clang configured to default to
x86_64-pc-windows-msvc, which uses the C/C++ runtime headers from
Visual Studio and has no unistd.h, we get:

 Running /c/rocgdb/src/gdb/testsuite/gdb.base/attach.exp ...
 gdb compile failed, C:/rocgdb/src/gdb/testsuite/gdb.base/attach.c:8:10: fatal error: 'unistd.h' file not found
     8 | #include <unistd.h>
       |          ^~~~~~~~~~

Handle this by adding a new testsuite/lib/gdb_watchdog.h header that
defines a new gdb_watchdog function, which wraps alarm on Unix-like
systems, and uses a timer on Windows.

This patch adjusts gdb.base/attach.c as example of usage.  Testing
gdb.base/attach.exp with clang/x86_64-pc-windows-msvc required a
related portability tweak to can_spawn_for_attach, to not rely on
unistd.h on Windows.

gdb.rocm/mi-attach.cpp is another example adjusted, one which always
runs with clang configured as x86_64-pc-windows-msvc on Windows (via
hipcc).

Approved-by: Kevin Buettner <kevinb@redhat.com>
Change-Id: I3b07bcb60de039d34888ef3494a5000de4471951

6 weeks agoAutomatically handle includes in testsuite/lib/
Pedro Alves [Wed, 13 Aug 2025 00:21:10 +0000 (01:21 +0100)] 
Automatically handle includes in testsuite/lib/

Instead of manually calling lappend_include_file in every testcase
that needs to include a file in testsuite/lib/, handle testsuite/lib/
includes automatically in gdb_compile.

As an example, gdb.base/backtrace.exp is adjusted to no longer
explicitly call lappend_include_file for testsuite/lib/attributes.h.

Tested on x86-64 GNU/Linux with both:

 $ make check RUNTESTFLAGS=" \
     --host_board=local-remote-host-native \
     --target_board=local-remote-host-native \
     HOST_DIR=/tmp/foo/" \
     TESTS="gdb.base/backtrace.exp"

and:

 $ make check TESTS="gdb.base/backtrace.exp"

and confirming that the testcase still compiles and passes cleanly.

Also ran full testsuite on x86-64 GNU/Linux in normal mode.

Approved-by: Kevin Buettner <kevinb@redhat.com>
Change-Id: I5ca77426ea4a753a995c3ad125618c02cd952576

6 weeks agogdb/solib-svr4: fix wrong namespace id for dynamic linker
Simon Marchi [Tue, 29 Jul 2025 14:58:13 +0000 (10:58 -0400)] 
gdb/solib-svr4: fix wrong namespace id for dynamic linker

When running a program that uses multiple linker namespaces, I get
something like:

    $ ./gdb -nx -q --data-directory=data-directory testsuite/outputs/gdb.base/dlmopen-ns-ids/dlmopen-ns-ids -ex "tb 50" -ex r -ex "info shared" -batch
    ...
    From                To                  NS Syms Read   Shared Object Library
    0x00007ffff7fc6000  0x00007ffff7fff000  0  Yes         /lib64/ld-linux-x86-64.so.2
    0x00007ffff7e93000  0x00007ffff7f8b000  0  Yes         /usr/lib/libm.so.6
    0x00007ffff7ca3000  0x00007ffff7e93000  0  Yes         /usr/lib/libc.so.6
    0x00007ffff7fb7000  0x00007ffff7fbc000  1  Yes         /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.base/dlmopen-ns-ids/dlmopen-lib.so
    0x00007ffff7b77000  0x00007ffff7c6f000  1  Yes         /usr/lib/libm.so.6
    0x00007ffff7987000  0x00007ffff7b77000  1  Yes         /usr/lib/libc.so.6
    0x00007ffff7fc6000  0x00007ffff7fff000  1  Yes         /usr/lib/ld-linux-x86-64.so.2
    0x00007ffff7fb2000  0x00007ffff7fb7000  2  Yes         /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.base/dlmopen-ns-ids/dlmopen-lib.so
    0x00007ffff788f000  0x00007ffff7987000  2  Yes         /usr/lib/libm.so.6
    0x00007ffff769f000  0x00007ffff788f000  2  Yes         /usr/lib/libc.so.6
    0x00007ffff7fc6000  0x00007ffff7fff000  1! Yes         /usr/lib/ld-linux-x86-64.so.2
    0x00007ffff7fad000  0x00007ffff7fb2000  3  Yes         /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.base/dlmopen-ns-ids/dlmopen-lib.so
    0x00007ffff75a7000  0x00007ffff769f000  3  Yes         /usr/lib/libm.so.6
    0x00007ffff73b7000  0x00007ffff75a7000  3  Yes         /usr/lib/libc.so.6
    0x00007ffff7fc6000  0x00007ffff7fff000  1! Yes         /usr/lib/ld-linux-x86-64.so.2

Some namespace IDs for the dynamic linker entries (ld-linux) are wrong
(I placed a ! next to those that are wrong).

The dynamic linker is special: it is loaded only once (notice how all
ld-linux entries have the same addresses), but it is visible in all
namespaces.  It is therefore listed separately in all namespaces.

The problem happens like this:

 - for each solib, print_solib_list_table calls solib_ops::find_solib_ns
   to get the namespace ID to print
 - svr4_solib_ops::find_solib_ns calls find_debug_base_for_solib
 - find_debug_base_for_solib iterates on the list of solibs in all
   namespaces, looking for a match for the given solib.  For this, it
   uses svr4_same, which compares two SOs by name and low address.
   Because there are entries for the dynamic linker in all namespaces,
   with the same low address, find_debug_base_for_solib is unable to
   distinguish them, and sometimes returns the wrong namespace.

To fix this, save in lm_info_svr4 the debug base address that this
lm/solib comes from, as a way to distinguish two solibs that would be
otherwise identical.

The code changes are:

 - Add a constructor to lm_info_svr4 accepting the debug base.  Update
   all callers, which sometimes requires passing down the debug base.
 - Modify find_debug_base_for_solib to return the debug base directly
   from lm_info_svr4.
 - Modify svr4_same to consider the debug base value of the two
   libraries before saying they are the same.  While at it, move the
   address checks before the name check, since they are likely less
   expensive to do.
 - Modify svr4_solib_ops::default_debug_base to update the debug base of
   existing solibs when the default debug base becomes known.

I found the last point to be necessary, because when running an
inferior, we list the shared libraries very early (before the first
instruction):

    #0  svr4_solib_ops::current_sos (this=0x7c1ff1e09710)
    #1  0x00005555643c774e in update_solib_list (from_tty=0)
    #2  0x00005555643ca377 in solib_add (pattern=0x0, from_tty=0, readsyms=1)
    #3  0x0000555564335585 in svr4_solib_ops::enable_break (this=0x7c1ff1e09710, info=0x7d2ff1de8c40, from_tty=0)
    #4  0x000055556433c85c in svr4_solib_ops::create_inferior_hook (this=0x7c1ff1e09710, from_tty=0)
    #5  0x00005555643d22cb in solib_create_inferior_hook (from_tty=0)
    #6  0x000055556337071b in post_create_inferior (from_tty=0, set_pspace_solib_ops=true)
    #7  0x00005555633726a2 in run_command_1 (args=0x0, from_tty=0, run_how=RUN_NORMAL)
    #8  0x0000555563372b35 in run_command (args=0x0, from_tty=0)

At this point, the dynamic linker hasn't yet filled the DT_DEBUG slot,
which normally points at the base of r_debug.  Since we're unable to
list shared libraries at this point, we go through
svr4_solib_ops::default_sos, which creates an solib entry for the
dynamic linker.  At this point, we have no choice but to create it with
a debug base of 0 (or some other value that indicates "unknown").  If we
left it as-is, then it would later not be recognized to be part of any
existing namespace and that would cause problems down the line.

With this change, the namespaces of the dynamic linker become correct.

I was not sure if the code in library_list_start_library was conflating
debug base and lmid.  The documentation says this about the "lmid" field
in the response of a qxfer:libraries-svr4:read packet:

    lmid, which is an identifier for a linker namespace, such as the
    memory address of the r_debug object that contains this namespace’s
    load map or the namespace identifier returned by dlinfo (3).

When I read "lmid", I typically think about "the namespace identifier
returned by dlinfo (3)".  In library_list_start_library, we use the
value of the "lmid" attribute as the debug base address.  This is the
case even before this patch, since we do:

      solist = &list->solib_lists[lmid];

The key for the solib_lists map is documented as being the debug base
address.  In practice, GDBserver uses the debug base address for the
"lmid" field, so we're good for now.

If the remote side instead used "the namespace identifier returned by
dlinfo (3)" (which in practice with glibc are sequential integers
starting at 0), I think we would be mostly fine.  If we use the qxfer
packet to read the libraries, we normally won't use the namespace base
address to do any memory reads, as all the information comes from the
XML.  There might be some problems however because we treat the
namespace 0 specially, for instance in
svr4_solib_ops::update_incremental.  In that case, we might need a
different way of indicating that the remote side does not give namespace
information than using namespace 0.  This is just a thought for the
future.

I improved the existing test gdb.base/dlmopen-ns-ids.exp to verify that
"info sharedlibrary" does not show duplicate libraries, duplicate
meaning same address range, namespace and name.

Change-Id: I84467c6abf4e0109b1c53a86ef688b934e8eff99
Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
6 weeks agogdb/solib-svr4: centralize fetching of default debug base
Simon Marchi [Tue, 22 Jul 2025 19:08:40 +0000 (15:08 -0400)] 
gdb/solib-svr4: centralize fetching of default debug base

When running an inferior, solib_ops_svr4::current_sos is called very
early, at a point where the default debug base is not yet accessible.
The inferior is stopped at its entry point, before the dynamic linker
had the time to fill the DT_DEBUG slot.  It only becomes available a
little bit later.  In a following patch, I will want to do some action
when the debug base becomes known (namely, update the debug base in the
previously created lm_info_svr4 instances).

For this reason, add the svr4_solib_ops::default_debug_base method to
centralize where we fetch the default debug base.  I will then be able
to add my code there, when detecting the debug base changes.

This patch brings the following behavior change: since all
svr4_solib_ops entry points now use svr4_solib_ops::default_debug_base
to get the debug base value, they will now all re-fetch the value from
the inferior.  Previously, this was not done consistently, only in two
spots.  It seems to me like it would be good to be consistent about
that, because we can't really predict which methods will get called in
which order in all scenarios.

Some internal methods still access svr4_info::default_debug_base
directly, because it is assumed that their caller would have used
svr4_solib_ops::default_debug_base, updating the value in
svr4_info::default_debug_base if necessary.

Change-Id: Ie08da34bbb3ad6fd317c0e5802c5c94d8c7d1ce5
Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
6 weeks agogdb: make iterate_over_objfiles_in_search_order methods of program_space and solib_ops
Simon Marchi [Tue, 15 Jul 2025 15:52:32 +0000 (11:52 -0400)] 
gdb: make iterate_over_objfiles_in_search_order methods of program_space and solib_ops

Change the "iterate over objfiles in search order" operation from a
gdbarch method to methods on both program_space and solib_ops.

The first motivation for this is that I want to encapsulate solib-svr4's
data into svr4_solib_ops (in a subsequent series), instead of it being
in a separate structure (svr4_info).  It is awkward to do so as long as
there are entry points that aren't the public solib_ops interface.

The second motivation is my project of making it able to have multiple
solib_ops per program space (which should be the subject of said
subsequent series), to better support heterogenousa systems (like ROCm,
with CPU and GPU in the same inferior).  When we have this, when stopped
in GPU code, it won't make sense to ask the host's architecture to do
the iteration, as the logic could be different for the GPU architecture.
Instead, program_space::iterate_over_objfiles_in_search_order will be
responsible to delegate to the various solib_ops using a logic that is
yet to be determined.

I included this patch in this series (rather than the following one)
so that svr4_solib_ops::iterate_over_objfiles_in_search_order can access
svr4_solib_ops::default_debug_base, introduced in a later patch in this
series.

default_iterate_over_objfiles_in_search_order becomes the default
implementation of solib_ops::iterate_over_objfiles_in_search_order.

As far as I know, all architectures using
svr4_iterate_over_objfiles_in_search_order also use solib_ops_svr4, so I
don't expect this patch to cause behavior changes.

Change-Id: I71f8a800b8ce782ab973af2f2eb5fcfe4e06ec76
Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
6 weeks agogdb: rename svr4_same_1 -> svr4_same_name
Simon Marchi [Mon, 28 Jul 2025 19:34:53 +0000 (15:34 -0400)] 
gdb: rename svr4_same_1 -> svr4_same_name

This makes it a bit clearer that it compares shared libraries by name.

While at it, change the return type to bool.

Change-Id: Ib11a931a0cd2e00bf6ae35c5b6e0d620298d46cb
Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
6 weeks agogdb/solib-svr4: add get_lm_info_svr4
Simon Marchi [Wed, 23 Jul 2025 18:12:15 +0000 (14:12 -0400)] 
gdb/solib-svr4: add get_lm_info_svr4

Add this function, as a shortcut of doing the more verbose:

    auto *li = gdb::checked_static_cast<lm_info_svr4 &> (*solib.lm_info);

Change-Id: I0206b3a8b457bdb276f26b354115e8f44416dfcf
Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
6 weeks agogdb/solib: save program space in solib_ops
Simon Marchi [Mon, 21 Jul 2025 15:38:30 +0000 (11:38 -0400)] 
gdb/solib: save program space in solib_ops

In some subsequent patches, solib_ops methods will need to access the
program space they were created for.  We currently access the program
space using "current_program_space", but it would better to remember the
program space at construction time instead.

Change-Id: Icf2809435a23c47ddeeb75e603863b201eff2e58
Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
6 weeks agogdb/solib: adjust info linker-namespaces/sharedlibrary format
Simon Marchi [Wed, 23 Jul 2025 18:11:39 +0000 (14:11 -0400)] 
gdb/solib: adjust info linker-namespaces/sharedlibrary format

I would like to propose some minor changes to the format of "info linker
namespaces" and "info sharedlibrary", to make it a bit tidier and less
chatty.

Here are the current formats (I replaced empty lines with dots, so that
git doesn't collapse them):

    (gdb) info linker-namespaces
    There are 3 linker namespaces loaded
    There are 5 libraries loaded in linker namespace [[0]]
    Displaying libraries for linker namespace [[0]]:
    From                To                  Syms Read   Shared Object Library
    0x00007ffff7fc6000  0x00007ffff7fff000  Yes         /lib64/ld-linux-x86-64.so.2
    0x00007ffff7e94000  0x00007ffff7f8c000  Yes         /usr/lib/libm.so.6
    0x00007ffff7ca4000  0x00007ffff7e94000  Yes         /usr/lib/libc.so.6
    0x00007ffff7fad000  0x00007ffff7fb2000  Yes         /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.mi/mi-dlmopen/dlmopen-lib.1.so
    0x00007ffff7fa8000  0x00007ffff7fad000  Yes         /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.mi/mi-dlmopen/dlmopen-lib-dep.so
    .
    .
    There are 6 libraries loaded in linker namespace [[1]]
    Displaying libraries for linker namespace [[1]]:
    From                To                  Syms Read   Shared Object Library
    0x00007ffff7fb7000  0x00007ffff7fbc000  Yes         /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.mi/mi-dlmopen/dlmopen-lib.1.so
    0x00007ffff7fb2000  0x00007ffff7fb7000  Yes         /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.mi/mi-dlmopen/dlmopen-lib-dep.so
    0x00007ffff7b79000  0x00007ffff7c71000  Yes         /usr/lib/libm.so.6
    0x00007ffff7989000  0x00007ffff7b79000  Yes         /usr/lib/libc.so.6
    0x00007ffff7fc6000  0x00007ffff7fff000  Yes         /usr/lib/ld-linux-x86-64.so.2
    0x00007ffff7f99000  0x00007ffff7f9e000  Yes         /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.mi/mi-dlmopen/dlmopen-lib.2.so
    .
    .
    There are 5 libraries loaded in linker namespace [[2]]
    Displaying libraries for linker namespace [[2]]:
    From                To                  Syms Read   Shared Object Library
    0x00007ffff7fc6000  0x00007ffff7fff000  Yes         /usr/lib/ld-linux-x86-64.so.2
    0x00007ffff7fa3000  0x00007ffff7fa8000  Yes         /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.mi/mi-dlmopen/dlmopen-lib.1.so
    0x00007ffff7f9e000  0x00007ffff7fa3000  Yes         /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.mi/mi-dlmopen/dlmopen-lib-dep.so
    0x00007ffff7891000  0x00007ffff7989000  Yes         /usr/lib/libm.so.6
    0x00007ffff76a1000  0x00007ffff7891000  Yes         /usr/lib/libc.so.6
    (gdb) info sharedlibrary
    From                To                  NS    Syms Read   Shared Object Library
    0x00007ffff7fc6000  0x00007ffff7fff000  [[0]] Yes         /lib64/ld-linux-x86-64.so.2
    0x00007ffff7e94000  0x00007ffff7f8c000  [[0]] Yes         /usr/lib/libm.so.6
    0x00007ffff7ca4000  0x00007ffff7e94000  [[0]] Yes         /usr/lib/libc.so.6
    0x00007ffff7fb7000  0x00007ffff7fbc000  [[1]] Yes         /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.mi/mi-dlmopen/dlmopen-lib.1.so
    0x00007ffff7fb2000  0x00007ffff7fb7000  [[1]] Yes         /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.mi/mi-dlmopen/dlmopen-lib-dep.so
    0x00007ffff7b79000  0x00007ffff7c71000  [[1]] Yes         /usr/lib/libm.so.6
    0x00007ffff7989000  0x00007ffff7b79000  [[1]] Yes         /usr/lib/libc.so.6
    0x00007ffff7fc6000  0x00007ffff7fff000  [[1]] Yes         /usr/lib/ld-linux-x86-64.so.2
    0x00007ffff7fad000  0x00007ffff7fb2000  [[0]] Yes         /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.mi/mi-dlmopen/dlmopen-lib.1.so
    0x00007ffff7fa8000  0x00007ffff7fad000  [[0]] Yes         /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.mi/mi-dlmopen/dlmopen-lib-dep.so
    0x00007ffff7fa3000  0x00007ffff7fa8000  [[2]] Yes         /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.mi/mi-dlmopen/dlmopen-lib.1.so
    0x00007ffff7f9e000  0x00007ffff7fa3000  [[2]] Yes         /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.mi/mi-dlmopen/dlmopen-lib-dep.so
    0x00007ffff7891000  0x00007ffff7989000  [[2]] Yes         /usr/lib/libm.so.6
    0x00007ffff76a1000  0x00007ffff7891000  [[2]] Yes         /usr/lib/libc.so.6
    0x00007ffff7fc6000  0x00007ffff7fff000  [[1]] Yes         /usr/lib/ld-linux-x86-64.so.2
    0x00007ffff7f99000  0x00007ffff7f9e000  [[1]] Yes         /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.mi/mi-dlmopen/dlmopen-lib.2.so

Here is what I would change:

 - I find that the [[...]] notation used everywhere is heavy and noisy.
   I understand that this is the (proposed) notation for specifying a
   namespace id in an expression.  But I don't think it's useful to
   print those brackets everywhere (when it's obvious from the context
   that the number is a namespace id).  I would remove them from the
   messages and from the tables.

 - I find these lines a bit too verbose:

       There are X libraries loaded in linker namespace [[Y]]
       Displaying libraries for linker namespace [[Y]]:

   I think they can be condensed to a single line, without loss of
   information (I think that printing the number of libs in each
   namespace is not essential, but I don't really mind, so I left it
   there).

 - I would add an empty line after the "There are N linker namespaces
   loaded" message, to visually separate it from the first group.  I
   would also finish that line with a period.

 - There are two empty lines between each group I think that one empty
   line is sufficient to do a visual separation.

Here's how it looks with this patch:

    (gdb) info linker-namespaces
    There are 3 linker namespaces loaded.

    5 libraries loaded in linker namespace 0:
    From                To                  Syms Read   Shared Object Library
    0x00007ffff7fc6000  0x00007ffff7fff000  Yes         /lib64/ld-linux-x86-64.so.2
    0x00007ffff7e94000  0x00007ffff7f8c000  Yes         /usr/lib/libm.so.6
    0x00007ffff7ca4000  0x00007ffff7e94000  Yes         /usr/lib/libc.so.6
    0x00007ffff7fad000  0x00007ffff7fb2000  Yes         /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.mi/mi-dlmopen/dlmopen-lib.1.so
    0x00007ffff7fa8000  0x00007ffff7fad000  Yes         /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.mi/mi-dlmopen/dlmopen-lib-dep.so

    6 libraries loaded in linker namespace 1:
    From                To                  Syms Read   Shared Object Library
    0x00007ffff7fb7000  0x00007ffff7fbc000  Yes         /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.mi/mi-dlmopen/dlmopen-lib.1.so
    0x00007ffff7fb2000  0x00007ffff7fb7000  Yes         /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.mi/mi-dlmopen/dlmopen-lib-dep.so
    0x00007ffff7b79000  0x00007ffff7c71000  Yes         /usr/lib/libm.so.6
    0x00007ffff7989000  0x00007ffff7b79000  Yes         /usr/lib/libc.so.6
    0x00007ffff7fc6000  0x00007ffff7fff000  Yes         /usr/lib/ld-linux-x86-64.so.2
    0x00007ffff7f99000  0x00007ffff7f9e000  Yes         /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.mi/mi-dlmopen/dlmopen-lib.2.so

    5 libraries loaded in linker namespace 2:
    From                To                  Syms Read   Shared Object Library
    0x00007ffff7fc6000  0x00007ffff7fff000  Yes         /usr/lib/ld-linux-x86-64.so.2
    0x00007ffff7fa3000  0x00007ffff7fa8000  Yes         /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.mi/mi-dlmopen/dlmopen-lib.1.so
    0x00007ffff7f9e000  0x00007ffff7fa3000  Yes         /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.mi/mi-dlmopen/dlmopen-lib-dep.so
    0x00007ffff7891000  0x00007ffff7989000  Yes         /usr/lib/libm.so.6
    0x00007ffff76a1000  0x00007ffff7891000  Yes         /usr/lib/libc.so.6
    (gdb) info shared
    From                To                  Linker NS Syms Read   Shared Object Library
    0x00007ffff7fc6000  0x00007ffff7fff000  0         Yes         /lib64/ld-linux-x86-64.so.2
    0x00007ffff7e94000  0x00007ffff7f8c000  0         Yes         /usr/lib/libm.so.6
    0x00007ffff7ca4000  0x00007ffff7e94000  0         Yes         /usr/lib/libc.so.6
    0x00007ffff7fb7000  0x00007ffff7fbc000  1         Yes         /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.mi/mi-dlmopen/dlmopen-lib.1.so
    0x00007ffff7fb2000  0x00007ffff7fb7000  1         Yes         /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.mi/mi-dlmopen/dlmopen-lib-dep.so
    0x00007ffff7b79000  0x00007ffff7c71000  1         Yes         /usr/lib/libm.so.6
    0x00007ffff7989000  0x00007ffff7b79000  1         Yes         /usr/lib/libc.so.6
    0x00007ffff7fc6000  0x00007ffff7fff000  1         Yes         /usr/lib/ld-linux-x86-64.so.2
    0x00007ffff7fad000  0x00007ffff7fb2000  0         Yes         /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.mi/mi-dlmopen/dlmopen-lib.1.so
    0x00007ffff7fa8000  0x00007ffff7fad000  0         Yes         /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.mi/mi-dlmopen/dlmopen-lib-dep.so
    0x00007ffff7fa3000  0x00007ffff7fa8000  2         Yes         /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.mi/mi-dlmopen/dlmopen-lib.1.so
    0x00007ffff7f9e000  0x00007ffff7fa3000  2         Yes         /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.mi/mi-dlmopen/dlmopen-lib-dep.so
    0x00007ffff7891000  0x00007ffff7989000  2         Yes         /usr/lib/libm.so.6
    0x00007ffff76a1000  0x00007ffff7891000  2         Yes         /usr/lib/libc.so.6
    0x00007ffff7fc6000  0x00007ffff7fff000  1         Yes         /usr/lib/ld-linux-x86-64.so.2
    0x00007ffff7f99000  0x00007ffff7f9e000  1         Yes         /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.mi/mi-dlmopen/dlmopen-lib.2.so

Change-Id: Iefad340f7f43a15cff24fc8e1301f91d3d7f0278
Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
6 weeks agogdb/solib: don't check filename when checking for duplicate solib
Simon Marchi [Thu, 17 Jul 2025 19:58:05 +0000 (15:58 -0400)] 
gdb/solib: don't check filename when checking for duplicate solib

On Arch Linux, I get:

    FAIL: gdb.base/dlmopen-ns-ids.exp: reopen a namespace

The symptom observed is that after stepping over the last dlmopen of the
test, "info sharedlibrary" does not show the library just opened.  After
digging, I found that when stepping over that dlmopen call, the shlib
event breakpoint (that GDB inserts in glibc to get notified of dynamic
linker activity) does not get hit.  I then saw that after the previous
dlclose, the shlib event breakpoints were suddenly all marked as
pending:

    (gdb) maintenance info breakpoints
    Num     Type             Disp Enb Address            What
    -1      shlib events     keep n   <PENDING>
    -1.1                          y-  <PENDING>

The root cause of this problem is the fact that the dynamic linker path
specified in binaries contains a symlink:

    $ readelf --program-headers /bin/ls | grep "Requesting program interpreter"
          [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
    $ ls -l /lib64
    lrwxrwxrwx 1 root root 7 May  3 15:26 /lib64 -> usr/lib
    $ realpath /lib64/ld-linux-x86-64.so.2
    /usr/lib/ld-linux-x86-64.so.2

As a result, the instances of the dynamic linker in the non-base
namespace have the real path instead of the original path:

    (gdb) info sharedlibrary
    From                To                  NS    Syms Read   Shared Object Library
    0x00007ffff7fc6000  0x00007ffff7fff000  [[0]] Yes         /lib64/ld-linux-x86-64.so.2
    ...
    0x00007ffff7fc6000  0x00007ffff7fff000  [[1]] Yes         /usr/lib/ld-linux-x86-64.so.2
    ...
    0x00007ffff7fc6000  0x00007ffff7fff000  [[1]] Yes         /usr/lib/ld-linux-x86-64.so.2
    ...
    0x00007ffff7fc6000  0x00007ffff7fff000  [[1]] Yes         /usr/lib/ld-linux-x86-64.so.2

Notice that all instances of the dynamic loader have the same address
range.  This is expected: the dynamic loader is really loaded just once
in memory, it's just that it's visible in the various namespaces, so
listed multiple times.  Also, notice that the last three specify
namespace 1... seems like a separate bug to me (ignore it for now).

The fact that the paths differ between the first one and the subsequent
ones is not something we control: we receive those paths as-is from the
glibc link map.

Since these multiple solib entries are really the same mapping, we would
expect this code in solib_read_symbols to associate them to the same
objfile:

  /* Have we already loaded this shared object?  */
  so.objfile = nullptr;
  for (objfile *objfile : current_program_space->objfiles ())
    {
      if (filename_cmp (objfile_name (objfile), so.name.c_str ())
    == 0
  && objfile->addr_low == so.addr_low)
{
  so.objfile = objfile;
  break;
}
    }

But because the filenames differ, we end up creating two different
objfiles with the same symbols, same address ranges, etc.  I would guess
that this is not a state we want.

When the dlclose call closes the last library from the non-base
namespace, the dynamic linker entry for that namespace is also
removed.  From GDB's point of view, it just looks like an solib getting
unloaded.  In update_solib_list, we have this code to check if the
objfile behind the solib is used by other solibs, and avoid deleting the
objfile if so:

  bool still_in_use
    = (gdb_iter->objfile != nullptr
       && solib_used (current_program_space, *gdb_iter));

  /* Notify any observer that the shared object has been
     unloaded before we remove it from GDB's tables.  */
  notify_solib_unloaded (current_program_space, *gdb_iter,
 still_in_use, false);

  /* Unless the user loaded it explicitly, free SO's objfile.  */
  if (gdb_iter->objfile != nullptr
      && !(gdb_iter->objfile->flags & OBJF_USERLOADED)
      && !still_in_use)
    gdb_iter->objfile->unlink ();

Because this is the last solib to use that objfile instance, the objfile
is deleted.  In the process, disable_breakpoints_in_unloaded_shlib (in
breakpoint.c) is called.  The breakpoint locations for the shlib event
breakpoints get marked as "shlib_disabled", which then causes them (I
suppose) to not get inserted and be marked as pending.  And then, when
stepping on the subsequent dlmopen call, GDB misses the load of the new
library.

It seems clear to me that, at least, the duplicate objfile detection in
solib_read_symbols needs to be fixed.  Right now, to conclude that an
solib matches an existing objfile, it checks that:

 - the two have equivalent paths (filename_cmp)
 - the two have the same "low" address

In this patch, I remove the filename check.  This makes it such that all
the solibs for dynamic linker entries will share the same objfile.

This assumes that no two different solibs / objfiles will have the same
low address.  At first glance, it seems like a reasonable assumption to
make, but I don't know if there are some corner cases where this is not
true.

To fix my specific case, I could change the code to resolve the symlinks
and realize that these are all the same file.  But I don't think it
would work in a general way.  For example, if debugging remotely and
using the target: filesystem, we would need to resolve the symlink on
the target, and I don't think we can do that today (there is no
readlink/realpath operation in the target file I/O).

With this patch, gdb.base/dlmopen-ns-ids.exp passes cleanly:

    # of expected passes            44

Change-Id: I3b60051085fb9597b7a72f50122c1104c969908e
Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
6 weeks agogdb/solib-svr4: make "lmid" XML attribute optional
Simon Marchi [Wed, 23 Jul 2025 15:33:59 +0000 (11:33 -0400)] 
gdb/solib-svr4: make "lmid" XML attribute optional

When connecting to a GDBserver 12, which doesn't have support for
non-default linker namespaces and the "lmid" attribute in the
qxfer:libraries-svr4:read response, I get:

    (gdb) c
    Continuing.
    ⚠️  warning: while parsing target library list (at line 1): Required attribute "lmid" of <library> not specified

Given the code in library_list_start_library, I understand that the
"lmid" attribute is meant to be optional.  Mark it as optional in the
attribute descriptions, to avoid this warning.

Change-Id: Ieb10ee16e36bf8a771f944006e7ada1c10f6fbdc
Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
6 weeks agogdb/testsuite: handle dynamic linker path with symlink in dlmopen tests
Simon Marchi [Fri, 18 Jul 2025 13:10:35 +0000 (09:10 -0400)] 
gdb/testsuite: handle dynamic linker path with symlink in dlmopen tests

On my Arch Linux system*, the dynamic linker path specified in ELF
binaries contains a symlink:

    $ readelf --program-headers /bin/ls | grep "Requesting program interpreter"
          [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
    $ ls -l /lib64
    lrwxrwxrwx 1 root root 7 May  3 15:26 /lib64 -> usr/lib
    $ realpath /lib64/ld-linux-x86-64.so.2
    /usr/lib/ld-linux-x86-64.so.2

Because of this, some dlmopen tests think that the dynamic linker
doesn't appear multiple times, when it in fact does (under two different
names), and some parts of the test are disabled:

    UNSUPPORTED: gdb.base/dlmopen.exp: test_solib_unmap_events: multiple copies of the dynamic linker not found

Make the tests compute the real path of the dynamic linker and accept
that as valid path for the dynamic linker.

With this patch, I go from

    # of expected passes            92

to

    # of expected passes            98

* On my Ubuntu 24.04 system, the dynamic linker appears to be a symlink
  too, but the glibc is too old to show the dynamic linker in the
  non-default namespace.

Change-Id: I03867f40e5313816bd8a8401b65713ddef5d620e
Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
6 weeks agold: testsuite: Only xfail "shared (non PIC)" etc. on 64-bit Solaris
Rainer Orth [Fri, 22 Aug 2025 09:04:51 +0000 (11:04 +0200)] 
ld: testsuite: Only xfail "shared (non PIC)" etc. on 64-bit Solaris

Once the ld-shared tests run on both Solaris/SPARC and x86, two tests
XPASS on 32-bit Solaris, both SPARC and x86 (pre-existing on SPARC,
newly revealed on x86):

XPASS: shared (non PIC)
XPASS: shared (PIC main, non PIC so)

Consequently, this patch restricts xfailing them to 64-bit Solaris.

There now remain 1 (32-bit) or 3 (64-bit) XFAILs.  I've checked the
reasons and found all comments in shared.exp are wrong:

* The common one (SPARC and x86, 32 and 64-bit) is

XFAIL: shared (non PIC, load offset)

  The error is always the same:

ld.so.1: shnp: fatal: tmpdir/shnp.so: unknown file type

  Running shnp under truss reveals

26170:  openat(AT_FDCWD, "tmpdir/shnp.so", O_RDONLY)    = 3
26170:  mmapobj(3, MMOBJ_INTERPRET, 0xFFFFFFFF7F5D0058, 0xFFFFFFFF7FFFE8A0, 0x00000000) Err#48 ENOTSUP

  which can be traced in the mmapobj(2) implementation to the
  requirement that a shared object's p_vaddr needs to be 0, which in
  this test is intentionally not the case.

* The other two XFAIL's are 64-bit only and for another reason:

XFAIL: shared (non PIC)
XFAIL: shared (PIC main, non PIC so)

  On sparcv9, shnp execution fails:

ld.so.1: shnp: fatal: relocation error: R_SPARC_H44: file tmpdir/shnp.so: symbol shlibvar2: value 0x3fffffffb9c does not fit

  On amd64, shmpnp.so fails to link:

ld/tmpdir/ld/collect-ld: tmpdir/sh1np.o: relocation R_X86_64_32S against symbol `shlib_shlibvar1' can not be used when making a shared object; recompile with -fPIC
ld/tmpdir/ld/collect-ld: failed to set dynamic section sizes: bad value

  In both cases, this happens with -z text, too, so the comments are
  bogus.  Instead, the issue that the code needs to be PIC.

So I'm updating the comments accordingly.

Tested on sparc{v9,}-sun-solaris2.11 and {amd64,i386}-pc-solaris2.11.

2025-07-30  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

ld:
* testsuite/ld-shared/shared.exp (shared (non PIC)): Update
comment.  xfail on 64-bit Solaris only.
(shared (PIC main, non PIC so)): Likewise.
(shared (non PIC, load offset)): Update comment.

6 weeks agold: testsuite: Enable ld-shared tests on Solaris/x86
Rainer Orth [Fri, 22 Aug 2025 09:00:44 +0000 (11:00 +0200)] 
ld: testsuite: Enable ld-shared tests on Solaris/x86

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.

6 weeks agoMAINTAINERS: move Jim Wilson to Past Maintainers
Jan Beulich [Fri, 22 Aug 2025 05:56:59 +0000 (07:56 +0200)] 
MAINTAINERS: move Jim Wilson to Past Maintainers

..., 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.

6 weeks agogas: make as_tsktsk() output more as_warn()-like
Jan Beulich [Fri, 22 Aug 2025 05:56:28 +0000 (07:56 +0200)] 
gas: make as_tsktsk() output more as_warn()-like

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.