]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
12 days agoLoongArch: Support R_LARCH_TLS_DTPREL32/64 used in debug section
mengqinggang [Tue, 7 Jul 2026 18:27:02 +0000 (02:27 +0800)] 
LoongArch: Support R_LARCH_TLS_DTPREL32/64 used in debug section

Simplify R_LARCH_TLS_DTPREL32/64 relocations processing.
Return the offset to TLS block for symbol.

Change R_LARCH_TLS_DTPREL32/64 partial_inplace to false since
LoongArch uses RELA relocations.

12 days agoLoongArch: Emit alignment relocations after relaxed instructions
mengqinggang [Tue, 23 Jun 2026 06:03:52 +0000 (14:03 +0800)] 
LoongArch: Emit alignment relocations after relaxed instructions

Alignment cannot change before relaxed instructions.
Emit alignment relocations only after them.

Similar with https://github.com/llvm/llvm-project/pull/150816.

12 days agoLoongArch: Emit fewer relocations for label subtraction
mengqinggang [Sat, 6 Jun 2026 03:43:57 +0000 (11:43 +0800)] 
LoongArch: Emit fewer relocations for label subtraction

Mark the frag and section to indicate if they have a relaxed instruction.

For label subtraction, if there are no relaxed instructions between addsy
and subsy, do not emit relocations.

12 days agoLoongArch: Do not emit relocation if addsy and subsy are in the same frag
mengqinggang [Thu, 4 Jun 2026 06:05:49 +0000 (14:05 +0800)] 
LoongArch: Do not emit relocation if addsy and subsy are in the same frag

Let relaxed instructions and alignment nops in a single frag.
Do not emit relocation if addsy and subsy are in the same frag.

12 days agoLoongArch: Fix the size of tls desc relocations
mengqinggang [Mon, 6 Jul 2026 00:19:27 +0000 (08:19 +0800)] 
LoongArch: Fix the size of tls desc relocations

Change the size of R_LARCH_TLS_DESC64_* from 8 to 4.

12 days agoAutomatic date update in version.in
GDB Administrator [Fri, 10 Jul 2026 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 days agogdb/hip: Prepare for DWARF-assembler-based HIP testcases
Pedro Alves [Fri, 3 Oct 2025 16:45:39 +0000 (17:45 +0100)] 
gdb/hip: Prepare for DWARF-assembler-based HIP testcases

Compiling a testcase with debug info (by passing passing "debug" as
gdb_compile option) has the effect of passing -g to the compiler.  -g
in turn enables an LLVM option that is essential for debugging:
'-mllvm -amdgpu-spill-cfi-saved-regs'.

That option affects code generation, and some features of the DWARF
assembler machinery rely on code generated by the compiler without -g
to be the exact same as the code generated with -g.

This patch addresses that by always compiling with the LLVM option
that -g would enable.

Approved-by: Lancelot Six <lancelot.six@amd.com> (amdgpu)
Change-Id: I64a938edf97c85d0ea9fc34b37071daa560de7e7

12 days agoMAINTAINERS: update my email address
Nick Alcock [Mon, 27 Apr 2026 22:10:44 +0000 (23:10 +0100)] 
MAINTAINERS: update my email address

12 days agoAVR: Fix typo / white space in include/opcode/avr.h
Georg-Johann Lay [Thu, 9 Jul 2026 11:07:44 +0000 (13:07 +0200)] 
AVR: Fix typo / white space in include/opcode/avr.h

include/
* opcode/avr.h: Fix typo in comment + trailing space.

12 days agoreadelf: Save and dump the original section header values
H.J. Lu [Thu, 2 Jul 2026 02:14:10 +0000 (10:14 +0800)] 
readelf: Save and dump the original section header values

validate_section_info clears the garbage values in the section header
to avoid crash later.  Save and dump the original section header values
to make the garbage values in the section header visible when dumping
section headers.

Note: orig_section_headers, instead of sane_section_headers, is added to
filedata since filedata->section_headers is used in many places.  Replace
filedata->section_headers with filedata->sane_section_headers requires
a much bigger change.

* readelf.c (filedata): Add orig_section_headers.
(save_original_section_header_values): New.
(validate_section_info): Add a pointer to the original section
header and call save_original_section_header_values to save the
original section header values before clearing the section header
fields.
(get_32bit_section_headers): Allocate the original section header
buffer.  Pass the original section header pointer to
validate_section_info.
(get_64bit_section_headers): Likewise.
(process_section_headers): Dump the original section header
values if they exist.
(process_relocs): Pass a dummy original section pointer to
validate_section_info.
(free_filedata): Free filedata->orig_section_headers.
* testsuite/binutils-all/corrupt-1.elf.bz2: New file.
* testsuite/binutils-all/corrupt-1.r: Likewise.
* testsuite/binutils-all/readelf.exp: Run corrupt-1.elf test.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
13 days agogdb: z80: Fix endless loop in frame unwinder and validate saved register types
Ronald Hecht [Mon, 15 Jun 2026 07:04:01 +0000 (09:04 +0200)] 
gdb: z80: Fix endless loop in frame unwinder and validate saved register types

In z80_frame_unwind_cache, the loop scanning for the frame base pointer
(for (;; ++sp)) could run into an endless loop or scan too far if the
termination condition (sp < this_base) was not met due to corrupted
or unexpected stack layouts. This patch introduces a loop_count to
limit the scan to a maximum of 2 * addr_len iterations.

Additionally, when iterating through saved registers to adjust their
offsets into concrete addresses, the code now explicitly checks if
the register actually holds an address using is_addr() before calling
addr(). This prevents potential assertions or undefined behavior for
registers that do not contain valid address data.

gdb/ChangeLog:

* z80-tdep.c (z80_frame_unwind_cache): Limit stack scanning
to 2 * addr_len iterations to prevent endless loops. Check
is_addr() before adjusting saved register addresses.

Approved-By: Kevin Buettner <kevinb@redhat.com>
13 days agoRISC-V: Minor cleanup for opcodes/riscv-opc.c
Nelson Chu [Thu, 9 Jul 2026 03:26:08 +0000 (11:26 +0800)] 
RISC-V: Minor cleanup for opcodes/riscv-opc.c

Unify vendor extension comments.

13 days agoRISC-V: Check for conflicting extensions when the linker merges arch attributes
Ethan Y. C. Liang [Mon, 6 Jul 2026 11:44:28 +0000 (19:44 +0800)] 
RISC-V: Check for conflicting extensions when the linker merges arch attributes

The linker validates the arch of each input when parsing it, but never
checks the merged arch as a whole, so conflicting extensions could
silently slip through.  The merge can even imply extensions that
neither input implies alone, e.g. `c' from one input and `d' from
another imply `zcd', which conflicts with `zcmp'.

After merging the input archs, add the implicit extensions to the
merged arch, then run the conflict checks on it and reject the merge
if any conflict is found.  Add tests for such merges.

13 days agoRISC-V: Release subset lists on all paths when the linker merges arch attributes
Ethan Y. C. Liang [Mon, 6 Jul 2026 11:44:27 +0000 (19:44 +0800)] 
RISC-V: Release subset lists on all paths when the linker merges arch attributes

riscv_merge_arch_attr_info returned early on the error paths without
releasing in_subsets, out_subsets and merged_subsets, so the nodes
already added to them were leaked.  The leaked nodes of in_subsets
and out_subsets also carry over into the next merge.

Route every post-parse error path through a single cleanup exit that
releases all three subset lists, and drop the now-redundant reset of
merged_subsets at entry.

13 days agoRISC-V: Minor cleanup for include/opcode/riscv-opc.h and vendor gas testcases
Nelson Chu [Thu, 9 Jul 2026 00:46:00 +0000 (08:46 +0800)] 
RISC-V: Minor cleanup for include/opcode/riscv-opc.h and vendor gas testcases

For include/opcode/riscv-opc.h, reorder zicfiss and zicfilp stuff, and unify
vendor extension comments.  For gas tescases, unify vendor testcase names.

13 days agoAutomatic date update in version.in
GDB Administrator [Thu, 9 Jul 2026 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

13 days agoaarch64: Fix %dtprel relocations size.
Srinath Parvathaneni [Wed, 8 Jul 2026 21:12:27 +0000 (21:12 +0000)] 
aarch64: Fix %dtprel relocations size.

The AArch64 ELF ABI [1] requires DTPREL relocations to be
8 bytes wide, so added a check to reject %dtprel when used
with anything other than .xword.

[1] https://github.com/ARM-software/abi-aa/blob/main/aaelf64/aaelf64.rst#5715dynamic-relocations

13 days agogdb, amd-dbgapi-target: fix extra space in wave_coordinates
Tankut Baris Aktemur [Wed, 8 Jul 2026 09:05:20 +0000 (04:05 -0500)] 
gdb, amd-dbgapi-target: fix extra space in wave_coordinates

In commit 57f5450 ("gdb, amd-dbgapi-target: split
wave_coordinates::to_string"), I mistakenly left extra space in the
output of wave_coordinates' string methods.  Fix this.

Approved-by: Lancelot Six <lancelot.six@amd.com> (amdgpu)
13 days agogdb/python: remove frame_object::frame_id_is_next as unnecessary
Andrew Burgess [Mon, 1 Jun 2026 15:07:49 +0000 (16:07 +0100)] 
gdb/python: remove frame_object::frame_id_is_next as unnecessary

Remove the frame_object::frame_id_is_next field.  This has been part
of how Python handles frames since this code was first added in commit
f8f6f20b6e37e6d219940fcad58b1f66124d11c1 back in 2009.  The motivation
for this field can be found in a couple of comments, there's this one
on frame_id_is_next:

  /* Marks that the FRAME_ID member actually holds the ID of the frame next
     to this, and not this frames' ID itself.  This is a hack to permit Python
     frame objects which represent invalid frames (i.e., the last frame_info
     in a corrupt stack).  The problem arises from the fact that this code
     relies on FRAME_ID to uniquely identify a frame, which is not always true
     for the last "frame" in a corrupt stack (it can have a null ID, or the same
     ID as the  previous frame).  Whenever get_prev_frame returns NULL, we
     record the frame_id of the next frame and set FRAME_ID_IS_NEXT to 1.  */

And this one in frame_info_to_frame_object:

  /* Try to get the previous frame, to determine if this is the last frame
    in a corrupt stack.  If so, we need to store the frame_id of the next
    frame and not of this one (which is possibly invalid).  */

This field is dealing with a problem that was present in older
versions of GDB where not every stack frame had a valid frame-id, if
the stack was corrupted in some way then the last frame might have an
invalid frame-id.  However, that is no longer the case.  With current
GDB there is a promise that every frame has a valid frame-id.  I don't
have a single commit to point to where this became the reality, but it
is my understanding of current GDB.

As an example, the frame-id of every frame (except #0) is computed as
the frame is created, any frames with a  duplicate frame-id, or any
errors during computation of the frame-id, and the new frame is
discarded.

Additionally, our frame_info_ptr::reinflate mechanism relies on unique
and valid frame-ids.

The problem with the existing code is that the last frame in a
corrupted stack will hold the frame-id of the next frame, that is, the
more inner frame.  This means we have two frames holding the same
frame-id, and the only difference is the frame_id_is_next flag.

However, the frapy_str function, which prints a string representation
of the frame, doesn't take frame_id_is_next into account, so printing
the last two frames in a corrupted stack, will print the same
frame-id.

We could fix this in frapy_str and also frapy_repr by checking the
frame_id_is_next flag and then fetching the previous frame-id, but
this would still assume that the previous frame has a valid-id, so we
might as well just drop the frame_id_is_next flag and make everything
simpler.

There's a new test which exposes the incorrectly printed frame-id
problem.

While testing I needed to "fix" the results for two existing tests.

In frame_info_to_frame_object, in order to figure out if we should use
the next frame, we called get_prev_frame.  This would cause GDB to
always unwind 1 extra level of the stack.

What this means is that, if there is an error, or some diagnostic
output, when unwinding frame #1, then this will show up when trying to
access frame #0 via the Python API as frame_info_to_frame_object on
frame #0 would call get_prev_frame, which would then unwind frame #1.

After this commit this is no longer the case.  We only see
output (either errors, or diagnostic output) associated with frame #1
when we actually try to unwind to frame #1.  The two tests that needed
updating were expecting output associated with frame #1 while printing
frame #0.  This is now fixed and the output for frame #1 occurs later
on.  I think this is an improvement.

13 days agogdb/testsuite: don't overwrite test executable in py-frame.exp
Andrew Burgess [Mon, 1 Jun 2026 10:32:53 +0000 (11:32 +0100)] 
gdb/testsuite: don't overwrite test executable in py-frame.exp

In gdb.python/py-frame.exp when we re-compile the test executable
without debug information, give it a new, unique, name to make
re-running the tests outside the testsuite easier.

While I was in the area I removed a `gdb_exit` call that was not
necessary, `prepare_for_testing` calls `clean_restart` which already
does a `gdb_exit`.

There should be no change in what is being tested after this commit.

2 weeks agoAutomatic date update in version.in
GDB Administrator [Wed, 8 Jul 2026 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 weeks ago[gdbserver] Use const_target_desc_up for regformat tdescs
Keith Seitz [Tue, 7 Jul 2026 19:10:08 +0000 (12:10 -0700)] 
[gdbserver] Use const_target_desc_up for regformat tdescs

Regformat tdescs are now declared 'const_target_desc_up' by
gdb's regdat.sh, so update the various gdbserver target descriptions
to observe this API change.

There should be no user visible changes.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2 weeks agoregdat.sh: generate const_target_desc_up for register descriptions
Keith Seitz [Tue, 7 Jul 2026 19:10:08 +0000 (12:10 -0700)] 
regdat.sh: generate const_target_desc_up for register descriptions

Late last year, a patch propagated the use of target_desc unique
pointers (commit 1a5362ce51ef79ffb61caa20c93284dc368dc74a).  At the
time, the "old regformats/regdat.sh [weren't] changed because their
target_desc objects are statically allocated in the generated files."

Unfortunately that re-introduced ODR violations on ppc64le:

CXXLD  gdbserver
../../src/gdbserver/../gdb/arch/ppc-linux-tdesc.h:46:29: error: ‘tdesc_powerpc_isa207_htm_vsx64l’ violates the C++ One Definition Rule [-Werror=odr]
   46 | extern const_target_desc_up tdesc_powerpc_isa207_htm_vsx64l;
      |                             ^
powerpc-isa207-htm-vsx64l-generated.cc:26:27: note: ‘tdesc_powerpc_isa207_htm_vsx64l’ was previously declared here
   26 | const struct target_desc *tdesc_powerpc_isa207_htm_vsx64l;
      |                           ^
powerpc-isa207-htm-vsx64l-generated.cc:26:27: note: code may be misoptimized unless ‘-fno-strict-aliasing’ is used

Update regdat.sh so that generated init_registers_* code matches the
const-unique_ptr-based target description API, resolving the ODR violation.

A follow-up patch updates various gdbserver architectures to
accommodate this API change.

Tested on ppc64le and s390x Fedora 43 and mips-linux
cross build (all with LTO).

Approved-By: Simon Marchi <simon.marchi@efficios.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28444

2 weeks agogdb/record-full: make record_full_arch_list_add take an rvalue ref
Simon Marchi [Mon, 6 Jul 2026 16:40:09 +0000 (12:40 -0400)] 
gdb/record-full: make record_full_arch_list_add take an rvalue ref

record_full_arch_list_add moves its `rec` argument, so it should take an
rvalue ref to reflect that.  Otherwise the fact that the object is moved
from can be a "surprise" to the callers.

Change-Id: Ibeb56b1523ad8aee077d3bc3cad1f00d6b47ea2f
Approved-By: Guinevere Larsen <guinevere@redhat.com>
2 weeks agoCheck the result of two bfd_alloc calls in elf.c
Alan Modra [Tue, 7 Jul 2026 08:10:28 +0000 (17:40 +0930)] 
Check the result of two bfd_alloc calls in elf.c

PR 34131
* elf.c: Remove unnecessary casts on bfd_[zm]*alloc return value.
Do without "amt" temp var in a few cases.
(assign_section_numbers): Check for NULL return from bfd_zalloc.
(elfobj_grok_stapsdt_note_1): Likewise for bfd_alloc.

2 weeks agoRe: LoongArch: Fix relaxation alignment with ld -r (PR 33236)
Alan Modra [Tue, 7 Jul 2026 01:32:00 +0000 (11:02 +0930)] 
Re: LoongArch: Fix relaxation alignment with ld -r (PR 33236)

Correct sh_size and sh_entsize to use external reloc size.
loongarch32-elf  +FAIL: Linkonce sections with assembler generated notes
loongarch32-elf  +FAIL: ld-loongarch-elf/relax-align-ld-r

2 weeks agoalpha, rl78, rx: UB in reloc handling
Alan Modra [Tue, 7 Jul 2026 00:38:18 +0000 (10:08 +0930)] 
alpha, rl78, rx: UB in reloc handling

This patch avoids undefined behaviour and divide by zero exceptions in
some relocation processing.  In most cases, unsigned arithmetic is
used which has defined overflow characteristics.  Arithmetic right
shift, division, and modulo operations have more special cases.  See
the explanation in commit 30200464e9dd.

* coff-alpha.c (alpha_ecoff_get_relocated_section_contents): Avoid
UB in RSHIFT reloc.
(alpha_relocate_section): Likewise.
* elf32-rl78.c (rl78_compute_complex_reloc): Avoid UB in reloc
arithmetic.
* elf32-rx.c (rx_elf_relocate_section): Likewise.
(rx_offset_for_reloc): Likewise.

2 weeks agoRe: gas: add --reloc-section-sym option
Alan Modra [Mon, 6 Jul 2026 09:54:25 +0000 (19:24 +0930)] 
Re: gas: add --reloc-section-sym option

* testsuite/gas/elf/reloc-section-sym-none.d: Accept mips64 relocs.

2 weeks agoPR 34353 objcopy: null-pointer dereference bfd/section.c:1433
Alan Modra [Mon, 6 Jul 2026 01:56:24 +0000 (11:26 +0930)] 
PR 34353 objcopy: null-pointer dereference bfd/section.c:1433

objcopy --update-section specifying a SHT_GROUP section hits a case
where output_section is NULL.

* objcopy.c (copy_object): Don't segfault when update_sections
output_section is NULL.  Remove the "not found" part of
existing error so this message can be used.
* testsuite/binutils-all/update-section.exp: Update to suit.

2 weeks agoAutomatic date update in version.in
GDB Administrator [Tue, 7 Jul 2026 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 weeks agoWindows/rocm-solib: Don't hardcode namespaces support
Pedro Alves [Wed, 24 Jun 2026 13:45:56 +0000 (14:45 +0100)] 
Windows/rocm-solib: Don't hardcode namespaces support

rocm_solib_ops currently unconditionally returns true to
solib_ops::supports_namespaces.  That works OK on Linux where the
underlying solib ops is svr4.  But on Windows, the underlying solib
ops is solib-target, which does not support namespaces.  The result
is:

 (gdb) info shared
 /home/pedro/rocm/gdb/build/gdb/solib.h:270: internal-error: num_active_namespaces: namespaces not supported
 A problem internal to GDB has been detected,
 further debugging may prove unreliable.
 ...
 Thread 1 hit Breakpoint 1, internal_verror (file=0x7ff71a27fc80 <SCRIPTING_SEARCH_FLAG+52> "/home/pedro/rocm/gdb/build/gdb/solib.h", line=270,
     fmt=0x7ff71a27fc5e <SCRIPTING_SEARCH_FLAG+18> "%s: namespaces not supported", ap=0xfff1a8 "\270\374'", <incomplete sequence \367\177>)
     at /home/pedro/rocm/gdb/build/gdb/utils.c:514
 514       internal_vproblem (&internal_error_problem, file, line, fmt, ap);
 (gdb) bt
 #0  internal_verror (file=0x7ff71a27fc80 <SCRIPTING_SEARCH_FLAG+52> "/home/pedro/rocm/gdb/build/gdb/solib.h", line=270,
     fmt=0x7ff71a27fc5e <SCRIPTING_SEARCH_FLAG+18> "%s: namespaces not supported", ap=0xfff1a8 "\270\374'", <incomplete sequence \367\177>)
     at /home/pedro/rocm/gdb/build/gdb/utils.c:514
 #1  0x00007ff719c75cf4 in internal_error_loc (file=0x7ff71a27fc80 <SCRIPTING_SEARCH_FLAG+52> "/home/pedro/rocm/gdb/build/gdb/solib.h", line=270,
     fmt=0x7ff71a27fc5e <SCRIPTING_SEARCH_FLAG+18> "%s: namespaces not supported") at /home/pedro/rocm/gdb/build/gdbsupport/errors.cc:57
 #2  0x00007ff719f0aafe in solib_ops::num_active_namespaces (this=0xbb3a0b0) at /home/pedro/rocm/gdb/build/gdb/solib.h:270
 #3  0x00007ff719eca99e in rocm_solib_ops::num_active_namespaces (this=0xc9388a0) at /home/pedro/rocm/gdb/build/gdb/solib-rocm.c:211
 #4  0x00007ff719a14d33 in print_solib_list_table (solib_list=..., print_namespace=true) at /home/pedro/rocm/gdb/build/gdb/solib.c:1011
 #5  0x00007ff719a15833 in info_sharedlibrary_command (pattern=0x0, from_tty=1) at /home/pedro/rocm/gdb/build/gdb/solib.c:1115

rocm_solib_ops will stop sitting on top of another solib
implementation once the multi solib provider work lands, but
meanwhile, it'd be helpful to not crash.

Fix this by making rocm_solib_ops::supports_namespaces() delegate to
the underlying host solib ops like other methods do.

Approved-by: Lancelot Six <lancelot.six@amd.com> (amdgpu)
Change-Id: I1627c6e2f1b1c171c013c8457e9bfca92d5f4dc5

2 weeks agogdb.rocm: Don't include unistd.h when not necessary
Pedro Alves [Tue, 5 Aug 2025 22:47:24 +0000 (23:47 +0100)] 
gdb.rocm: Don't include unistd.h when not necessary

gdb.rocm/code-object-load-while-breakpoint-hit.cpp is including
unistd.h unnecessarily AFAICS.  Don't include it, so this test can
compile on Windows (x86_64-pc-windows-msvc) as well.

Approved-by: Lancelot Six <lancelot.six@amd.com> (amdgpu)
Change-Id: I9f469fd4b061ab9895c8bbbd408939e4df2a4e92

2 weeks agogdb.rocm/multi-inferior-gpu.exp: Use allow_fork_tests
Pedro Alves [Wed, 6 Aug 2025 01:37:08 +0000 (02:37 +0100)] 
gdb.rocm/multi-inferior-gpu.exp: Use allow_fork_tests

The program of gdb.rocm/multi-inferior-gpu.exp uses fork, so make the
testcase require allow_fork_tests.

Approved-by: Lancelot Six <lancelot.six@amd.com> (amdgpu)
Change-Id: I4c762be8d19c168f15962c68f8cbcc22ec3d6556

2 weeks agoWindows: Normalize backslashes to forward slashes
Pedro Alves [Fri, 12 Dec 2025 12:12:30 +0000 (12:12 +0000)] 
Windows: Normalize backslashes to forward slashes

Currently, on native Windows, GDB presents a mix of backslashes and
forward slashes to users, like e.g.:

 ...
 attach 15044
 Attaching to program: C:\msys2\home\alves\gdb\build-testsuite\outputs\gdb.base\attach\attach.exe, process 15044
 ...
 [Switching to thread 1 (Thread 15044.0x1294)]
 main () at C:/rocgdb/src/gdb/testsuite/gdb.base/attach.c:19
 19        while (! should_exit)
 (gdb) FAIL: gdb.base/attach.exp: do_attach_failure_tests: first attach
 ...

Note how above, the "attach" command uses backslashes, and the source
path uses forward slashes.

Most annoyingly, depending on compiler, you can end up with mixed
slash styles in the same path:

  Temporary breakpoint 1 at 0x1400010ec: file C:/rocgdb/src/gdb/testsuite/gdb.rocm\simple.cpp, line 33.
                                                                                  ^

A while ago, in commit a63213cd37 ("MSYS2+MinGW testing: Unix <->
Windows path conversion"), I had made the testsuite normalize
backslashes to forward slashes, among other things.  I had said in the
commit log there:

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

After running into some other tests that would need backslash
adjustment, and also because this is something user-visible, not just
a testsuite issue, I decided to bite the bullet and make GDB itself do
the slashes normalization.

This patch fixes all the cases of backslashes that I could find:

 - source files and compilation directory
 - executable name, and shared library names
 - cd/pwd commands

It does this by normalizing slashes at some strategic places.  The
conversion is only attempted if needed -- i.e., if debugging on
Windows, or cross-debugging Windows programs from a non-Windows host.

For executable/shared library names, this is doing the backslash ->
forward slash conversion completely on the host side in common code,
without touching the target backend files in either GDB or GDBserver,
by design, so that this is all completely a client side decision, and
works the same against any Windows GDBserver version, against remote
servers other than ours (e.g., Wine's), so we can change it later if
we want, etc.

I did tweak the gdb and gdbserver backends for the other way around
(forward slash => backslash), to make sure that they pass backslashes
to CreateProcess, so that inferiors see native backslashes in their
own argv[0].  For GDBserver, it would already have been possible to
launch an executable with forward slashes before (e.g., when debugging
from a Linux or Cygwin client), so this makes Windows gdbserver
behavior more consistent, independently of client, too.

I did not add an option to make this configurable at runtime on
purpose.  I don't see the point, it'd just add more complication and
testing surface.  Always normalizing keeps it simple.

For the source paths, I considered doing the normalization earlier in
the DWARF reader, but decided against it, because that would force
extra copying of strings -- the DWARF reader works mostly by passing
around const char pointers.  Also, the places I picked in principle
will automatically handle PDB if/when we get to it.

The buildsym.c change takes care of compilation directory paths.

The allocate_symtab change takes care of source paths.  That one
required a (temporary) copy, but I think that that's acceptable there.

The gdb_realpath change is needed because just before the touched code
there's a GetFullPathName call, which itself normalizes to
backslashes.

The exec.c and solib.c changes take care of executable and shared
libraries.

The change to testsuite/lib/gdb.exp, to adjust to forward-slash style
for DOS full names, are necessary otherwise MI tests break.  E.g.:

  *stopped,reason="breakpoint-hit",disp="del",bkptno="1",frame={addr="0x00007ff780461508",
  func="main",args=[],file="C:/rocgdb/src/gdb/testsuite/gdb.mi/basics.c",
  fullname="C:/rocgdb/src/gdb/testsuite/gdb.mi/basics.c",line="64",arch="i386:x86-64"},
  thread-id="1",stopped-threads="all"
  FAIL: gdb.mi/gdb2549.exp: mi runto main (unknown output after running)

gdb.base/set-cwd.exp was the only test I found (so far at least) that
required adjustment, but note that without this patch that testcase
fails and throws TCL errors, like:

  ...
  FAIL: gdb.base/set-cwd.exp: test_cwd_reset: inferior cwd is correctly set
  ERROR: couldn't compile regular expression pattern: invalid escape \ sequence
  ...

It passes cleanly with the patch.

Below's the before / after comparison of different commands / output.

Before:

  Reading symbols from ./outputs/gdb.rocm/simple/simple...
  (gdb)
  start
  Temporary breakpoint 1 at 0x1400010ec: file C:/rocgdb/src/gdb/testsuite/gdb.rocm\simple.cpp, line 33.
  Starting program: C:\msys2\home\alves\gdb\build-testsuite\outputs\gdb.rocm\simple\simple

  Thread 1 hit Temporary breakpoint 1, main () at C:/rocgdb/src/gdb/testsuite/gdb.rocm\simple.cpp:33
  33        hipError_t error = hipMalloc (&result_ptr, sizeof (int));

  Thread 1 hit Temporary breakpoint 1, main () at C:/rocgdb/src/gdb/testsuite/gdb.rocm\simple.cpp:33
  33        hipError_t error = hipMalloc (&result_ptr, sizeof (int));
  (gdb)

  (gdb) info inferiors
    Num  Description       Connection           Executable
  * 1    process 15620     1 (native)           C:\msys2\home\alves\gdb\build-testsuite\outputs\gdb.rocm\simple\simple

  (gdb) info sharedlibrary
  From                To                  Syms Read   Shared Object Library
  0x00007ffd22f91000  0x00007ffd231a69a8  Yes (*)     C:\Windows\SYSTEM32\ntdll.dll
  0x00007ffd21af1000  0x00007ffd21bb2520  Yes (*)     C:\Windows\System32\kernel32.dll
  0x00007ffd20091000  0x00007ffd20432548  Yes (*)     C:\Windows\System32\KernelBase.dll
  0x00007ffcc89c1000  0x00007ffcc9b145bc  Yes (*)     C:\Windows\SYSTEM32\amdhip64_7.dll
  0x00007ffd22911000  0x00007ffd22d829b0  Yes (*)     C:\Windows\System32\setupapi.dll
  0x00007ffd216c1000  0x00007ffd217653f0  Yes (*)     C:\Windows\System32\msvcrt.dll
  0x00007ffd22431000  0x00007ffd224de5c8  Yes (*)     C:\Windows\System32\advapi32.dll
  0x00007ffd21a41000  0x00007ffd21ae52b8  Yes (*)     C:\Windows\System32\sechost.dll
  0x00007ffd20651000  0x00007ffd20676af0  Yes (*)     C:\Windows\System32\bcrypt.dll
  0x00007ffd21f31000  0x00007ffd22045860  Yes (*)     C:\Windows\System32\rpcrt4.dll
  0x00007ffd22d91000  0x00007ffd22f40e50  Yes (*)     C:\Windows\System32\user32.dll
  0x00007ffd20781000  0x00007ffd207a43d8  Yes (*)     C:\Windows\System32\win32u.dll
  0x00007ffd228d1000  0x00007ffd228f73d8  Yes (*)     C:\Windows\System32\gdi32.dll
  0x00007ffd207b1000  0x00007ffd208d09c8  Yes (*)     C:\Windows\System32\gdi32full.dll
  0x00007ffd20b91000  0x00007ffd20c28410  Yes (*)     C:\Windows\System32\msvcp_win.dll
  0x00007ffd20471000  0x00007ffd2057f410  Yes (*)     C:\Windows\System32\ucrtbase.dll
  0x00007ffd21541000  0x00007ffd215afbc8  Yes (*)     C:\Windows\System32\ws2_32.dll
  0x00007ffd223f1000  0x00007ffd2241fc40  Yes (*)     C:\Windows\System32\imm32.dll

  (gdb) info source
  Current source file is C:/rocgdb/src/gdb/testsuite/gdb.rocm\simple.cpp
  Compilation directory is C:\msys2\home\alves\gdb\build-testsuite
  Located in C:\rocgdb\src\gdb\testsuite\gdb.rocm\simple.cpp

  (gdb) info sources
  C:\msys2\home\alves\gdb\build-testsuite\outputs\gdb.rocm\simple\simple:

  C:\rocgdb\src\gdb\testsuite\gdb.rocm\simple.cpp, C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_stdio_config.h,
  C:\Program Files\AMD\ROCm\7.1\include\hip\hip_runtime_api.h, C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include\stdint.h,
  C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\stdio.h, C:\Program Files\AMD\ROCm\7.1\lib\clang\21\include\__stddef_nullptr_t.h,
  C:\Program Files\AMD\ROCm\7.1\lib\clang\21\include\__stddef_size_t.h, C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include\cstdlib,
  C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\stdlib.h, C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_search.h,
  C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_malloc.h,
  ...

  (gdb) detach
  Detaching from program: C:\msys2\home\alves\gdb\build-testsuite\outputs\gdb.rocm\simple\simple, process 20800
  [Inferior 1 (process 20800) detached]

  (gdb) cd /tmp
  Working directory C:\tmp.
  (gdb) pwd
  Working directory C:\tmp.

After:

  Reading symbols from ./outputs/gdb.rocm/simple/simple...
  (gdb) start
  Temporary breakpoint 1 at 0x1400010ec: file C:/rocgdb/src/gdb/testsuite/gdb.rocm/simple.cpp, line 33.
  Starting program: C:/msys2/home/alves/gdb/build-testsuite/outputs/gdb.rocm/simple/simple

  Thread 1 hit Temporary breakpoint 1, main () at C:/rocgdb/src/gdb/testsuite/gdb.rocm/simple.cpp:33
  33        hipError_t error = hipMalloc (&result_ptr, sizeof (int));

  (gdb) info sources
  C:/msys2/home/alves/gdb/build-testsuite/outputs/gdb.rocm/simple/simple:

  C:/rocgdb/src/gdb/testsuite/gdb.rocm/simple.cpp, C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/ucrt/corecrt_stdio_config.h,
  C:/Program Files/AMD/ROCm/7.1/include/hip/hip_runtime_api.h, C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.39.33519/include/stdint.h,
  C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/ucrt/stdio.h, C:/Program Files/AMD/ROCm/7.1/lib/clang/21/include/__stddef_nullptr_t.h,
  C:/Program Files/AMD/ROCm/7.1/lib/clang/21/include/__stddef_size_t.h, C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.39.33519/include/cstdlib,
  C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/ucrt/stdlib.h, C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/ucrt/corecrt_search.h,
  C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/ucrt/corecrt_malloc.h,
  ...

  (gdb) info inferiors
    Num  Description       Connection           Executable
  * 1    process 19920     1 (native)           C:/msys2/home/alves/gdb/build-testsuite/outputs/gdb.rocm/simple/simple

  (gdb) info shared
  From                To                  Syms Read   Shared Object Library
  0x00007ffd22f91000  0x00007ffd231a69a8  Yes (*)     C:/Windows/SYSTEM32/ntdll.dll
  0x00007ffd21af1000  0x00007ffd21bb2520  Yes (*)     C:/Windows/System32/kernel32.dll
  0x00007ffd20091000  0x00007ffd20432548  Yes (*)     C:/Windows/System32/KernelBase.dll
  0x00007ffcc89c1000  0x00007ffcc9b145bc  Yes (*)     C:/Windows/SYSTEM32/amdhip64_7.dll
  0x00007ffd22911000  0x00007ffd22d829b0  Yes (*)     C:/Windows/System32/setupapi.dll
  0x00007ffd216c1000  0x00007ffd217653f0  Yes (*)     C:/Windows/System32/msvcrt.dll
  0x00007ffd22431000  0x00007ffd224de5c8  Yes (*)     C:/Windows/System32/advapi32.dll
  0x00007ffd21a41000  0x00007ffd21ae52b8  Yes (*)     C:/Windows/System32/sechost.dll
  0x00007ffd20651000  0x00007ffd20676af0  Yes (*)     C:/Windows/System32/bcrypt.dll
  0x00007ffd21f31000  0x00007ffd22045860  Yes (*)     C:/Windows/System32/rpcrt4.dll
  0x00007ffd22d91000  0x00007ffd22f40e50  Yes (*)     C:/Windows/System32/user32.dll
  0x00007ffd20781000  0x00007ffd207a43d8  Yes (*)     C:/Windows/System32/win32u.dll
  0x00007ffd228d1000  0x00007ffd228f73d8  Yes (*)     C:/Windows/System32/gdi32.dll
  0x00007ffd207b1000  0x00007ffd208d09c8  Yes (*)     C:/Windows/System32/gdi32full.dll
  0x00007ffd20b91000  0x00007ffd20c28410  Yes (*)     C:/Windows/System32/msvcp_win.dll
  0x00007ffd20471000  0x00007ffd2057f410  Yes (*)     C:/Windows/System32/ucrtbase.dll
  0x00007ffd21541000  0x00007ffd215afbc8  Yes (*)     C:/Windows/System32/ws2_32.dll
  0x00007ffd223f1000  0x00007ffd2241fc40  Yes (*)     C:/Windows/System32/imm32.dll
  (*): Shared library is missing debugging information.

  (gdb) detach
  Detaching from program: C:/msys2/home/alves/gdb/build-testsuite/outputs/gdb.rocm/simple/simple, process 7816
  [Inferior 1 (process 7816) detached]

  (gdb) cd /tmp
  Working directory C:/tmp.
  (gdb) pwd
  Working directory C:/tmp.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Reviewed-By: Andrew Burgess <aburgess@redhat.com>
Change-Id: I6366c41d200938259330e60bc1e98b576f787518

2 weeks agogdb/record-full: fix some -Wpessimizing-move errors
Simon Marchi [Mon, 6 Jul 2026 14:38:46 +0000 (14:38 +0000)] 
gdb/record-full: fix some -Wpessimizing-move errors

Compiling record-full.c with clang shows:

    /home/smarchi/src/binutils-gdb/gdb/record-full.c:2386:14: error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move]
     2386 |         rec.entry = std::move (record_full_reg_entry::from_bfd
          |                     ^
    /home/smarchi/src/binutils-gdb/gdb/record-full.c:2386:14: note: remove std::move call here
     2386 |         rec.entry = std::move (record_full_reg_entry::from_bfd
          |                     ^~~~~~~~~~~
     2387 |                                 (cbfd, osec, bfd_offset));
          |                                                         ~
    /home/smarchi/src/binutils-gdb/gdb/record-full.c:2393:14: error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move]
     2393 |         rec.entry = std::move (record_full_mem_entry::from_bfd
          |                     ^
    /home/smarchi/src/binutils-gdb/gdb/record-full.c:2393:14: note: remove std::move call here
     2393 |         rec.entry = std::move (record_full_mem_entry::from_bfd
          |                     ^~~~~~~~~~~
     2394 |                                 (cbfd, osec, bfd_offset));
          |                                                         ~

It's indeed not recommended to std::move the return value of a
function.  Remove the std::moves.

Change-Id: I80d947aa3d917fe3fcaaad0c3e329cb1de48a8ee

2 weeks agos390: Deprecate s390 32-bit target "s390-*"
Jens Remus [Mon, 6 Jul 2026 14:34:26 +0000 (16:34 +0200)] 
s390: Deprecate s390 32-bit target "s390-*"

The s390 32-bit target (s390-*) is deprecated and planned for removal
in a future release, along with the elf32-s390 target format.  Emit an
error for this target during configure, which can be overridden using
option --enable-obsolete.

Linux Kernel 6.19 removed s390 32-bit compatibility support. [1]
Glibc 2.43 [2] and GCC 16.1 (compiler option -m31) [3] deprecated
s390 32-bit with the intent to remove it in a future release.

The s390 64-bit target (s390x-*) remains supported.

[1]: Linux kernel 6.19 commit 8e0b986c59c6 ("s390: Remove compat support"),
     https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8e0b986c59c6
[2]: Glibc 2.43 commit 638d437dbf9c ("Deprecate s390-linux-gnu (31bit)"),
     https://sourceware.org/git/glibc.git?a=commitdiff;h=638d437dbf9c
[3]: GCC 16 commit 5886bb453a6a ("s390: Deprecate -m31"),
     https://gcc.gnu.org/git/gcc.git?h=5886bb453a6a

bfd/
* config.bfd: Require --enable-obsolete to build s390 32-bit
target "s390-*".

binutils/
* NEWS: Deprecate s390 32-bit target "s390-*".

gdb/
* NEWS: Deprecate s390 32-bit target "s390-*".

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2 weeks agos390: Add store CPU counter multiple instruction
Jens Remus [Mon, 6 Jul 2026 14:11:50 +0000 (16:11 +0200)] 
s390: Add store CPU counter multiple instruction

IBM z13 introduced the "store CPU counter multiple" (stcctm) instruction
with the Store-CPU-Counter-Multiple Facility, which is part of the
CPU-Measurement Facilities (CPUMF) [1].

While at it add a comment to the s390 opcode table for the existing
CPUMF instructions.

[1]: The Load-Program-Parameter and the CPU-Measurement Facilities,
     SA23-2260-08,
     https://www.ibm.com/docs/en/module_1678991624569/pdf/SA23-2260-08.pdf

opcodes/
* s390-opc.txt (stcctm): Add store CPU counter multiple
instruction.  Add comment on CPUMF instructions.

gas/testsuite/
* gas/s390/zarch-z13.d (stcctm): Add test for store CPU counter
multiple instruction.
* gas/s390/zarch-z13.s (stcctm): Likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2 weeks agoaarch64: Fix assembler internal error for %dtprel relocations
Srinath Parvathaneni [Mon, 6 Jul 2026 11:41:08 +0000 (11:41 +0000)] 
aarch64: Fix assembler internal error for %dtprel relocations

The current implementation creates the DTPREL fixup before reserving
the storage for the corresponding ".xword". GCC's "%dtprel" support
for TLS DWARF debug information exposed this during an AArch64 bootstrap,
where the libsanitizer/tsan DWARF layout places the DTPREL fixup at a
frag boundary. Reserving the storage before creating the fixup avoids
this corner case.

gas/
PR binutils/34357
* config/tc-aarch64.c (s_aarch64_cons) : Fix the storage order for
DTPREL.

2 weeks agogdb, amd-dbgapi-target: split wave_coordinates::to_string
Tankut Baris Aktemur [Mon, 6 Jul 2026 10:33:04 +0000 (05:33 -0500)] 
gdb, amd-dbgapi-target: split wave_coordinates::to_string

wave_coordinates::to_string() produces a string in the following format:

  AMDGPU Wave a:q:d:w (x,y,z)/i

Split the method into smaller pieces:

  a:q:d:w   : hierarchy_str
  (x,y,z)   : workgroup_coord_str
  (x,y,z)/i : dispatch_pos_str

This is a refactoring to allow reusing pieces and also to let the code
document itself better.  Currently the reuse opportunity exists in the
downstream debugger.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
Approved-by: Lancelot Six <lancelot.six@amd.com> (amdgpu)
2 weeks agogdb, amd-dbgapi-target: use pulongest more
Tankut Baris Aktemur [Mon, 6 Jul 2026 10:33:04 +0000 (05:33 -0500)] 
gdb, amd-dbgapi-target: use pulongest more

The group id coordinates and the wave number in workgroup that are
being formatted to a string in wave_coordinates::to_string are
uint32_t.  Use pulongest to print them.

Approved-by: Lancelot Six <lancelot.six@amd.com> (amdgpu)
2 weeks agoLoongArch: Fix relaxation alignment with ld -r (PR 33236)
mengqinggang [Fri, 22 May 2026 01:38:49 +0000 (09:38 +0800)] 
LoongArch: Fix relaxation alignment with ld -r (PR 33236)

LoongArch has the same issue as RISC-V for PR 33236 [1].

Section alignment can't be adjusted for objects generated by ld -r.
If previous sections are relaxed, the subsequent section maybe misaligned.

To fix this, add an align section and an align relocation before each
section when ld -r. And change the section alignment to 4 to disable
the default section start address calculation.

ld.lld has fixed this issue in the following two patches [2] [3].

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=33236
[2] https://github.com/llvm/llvm-project/pull/151639
[3] https://github.com/llvm/llvm-project/pull/198147

2 weeks agoLoongArch: Fix linker relaxation alignment
mengqinggang [Tue, 16 Jun 2026 11:10:26 +0000 (19:10 +0800)] 
LoongArch: Fix linker relaxation alignment

When linking multiple objects, relaxation can cause alignment issues.
Input section's output_offset is updated in relaxation without considering
alignment. Update section output_offset by align_opwer.

2 weeks agoAutomatic date update in version.in
GDB Administrator [Mon, 6 Jul 2026 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 weeks agogas: add --reloc-section-sym={all,internal,none} option for ELF
Fangrui Song [Sun, 8 Feb 2026 19:56:49 +0000 (11:56 -0800)] 
gas: add --reloc-section-sym={all,internal,none} option for ELF

When generating relocations for non-ifunc local symbols that satisfies
several conditions, GAS converts them to reference the section symbol
(STT_SECTION) instead, folding the original symbol's offset into the
addend.  This allows the original local symbol to be omitted from
.symtab, but the STT_SECTION symbol itself must be present, so the
conversion saves .symtab entries only when a section has more than one
local symbol referenced by relocations.

Add --reloc-section-sym to control this conversion:

- all (default): convert all eligible local symbols
- internal: only convert compiler-generated locals (.L prefix)
- none: never convert; keep all symbols as-is in relocations

This is useful for debugging and for tools that benefit from preserved
symbol names.

PR gas/33885

2 weeks agoAutomatic date update in version.in
GDB Administrator [Sun, 5 Jul 2026 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 weeks agopr34322: assertion failure in get_or_create_member_type
Alan Modra [Sat, 4 Jul 2026 10:27:43 +0000 (19:57 +0930)] 
pr34322: assertion failure in get_or_create_member_type

I thought about warning "DW_TAG_member without struct/union parent"
here but decided that doesn't help much as the warning is disconnected
from output.  As it is the --map-global-vars code silently ignores
unexpected attributes that might be found in fuzzed files.  I'm fine
with that too.

PR 34322
* dwarf.c (get_or_create_member_type): Return NULL on NULL parent.
(insert_element_in_list): Ignore DW_TAG_member without struct
or union parent.

2 weeks agoAVR: Adhere to GNU coding style
Georg-Johann Lay [Fri, 3 Jul 2026 20:01:09 +0000 (22:01 +0200)] 
AVR: Adhere to GNU coding style

This patch fixes some style nits:

- Fix indentations
- Using TABs for indentation
- Breaking long lines
- Remove ; after the closing } of a code block

bfd/
* cpu-avr.c: Adhere to GNU coding style.
* elf32-avr.c: Same.
* elf32-avr.h: Same.

gas/
* config/tc-avr.c: Adhere to GNU coding style.

opcodes/
* avr-dis.c: Adhere to GNU coding style.

include/
* opcode/avr.h: Adhere to GNU coding style.

2 weeks agoAutomatic date update in version.in
GDB Administrator [Sat, 4 Jul 2026 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 weeks agoPR 34275 double free in ctf_link_deduplicating_per_cu
xuqing yang [Wed, 10 Jun 2026 14:12:05 +0000 (14:12 +0000)] 
PR 34275 double free in ctf_link_deduplicating_per_cu

* ctf-link.c (ctf_link_deduplicating_per_cu): Don't call
ctf_next_destroy twice on error path.

2 weeks agogdb/record: add support for BMI2 instructions
Guinevere Larsen [Tue, 16 Jun 2026 19:03:43 +0000 (16:03 -0300)] 
gdb/record: add support for BMI2 instructions

This commit adds support for recording all instructions in the Bit
Manipulation Instruction set 2, for x86 cpus. The specific instructions
are:

* mulx
* pdep
* pext
* rorx
* sarx
* sh[r|l]x
* bzhi

And adds them to the AVX test, for the same reason as the previous
commit.

Approved-By: Guinevere Larsen <guinevere@redhat.com>
2 weeks agogdb/record: Add support for recording BMI1 instructions
Guinevere Larsen [Wed, 3 Jun 2026 11:58:10 +0000 (08:58 -0300)] 
gdb/record: Add support for recording BMI1 instructions

This commit adds support for recording all instructions of the Bit
Manipulation Instruction set 1, for x86 cpus. The specific instructions
are:

* andn
* bls[i|r|msk]
* bextr
* [l|t]zcnt

Also add them to the avx test. While BMI is a different set of
instructions, there are no currently existing CPUs that have access to
AVX2 and don't have access to BMI1 and BMI2, so it seems like a
reasonable idea to keep them together, as the avx test already requires
AVX2.

Approved-By: Guinevere Larsen <guinevere@redhat.com>
2 weeks agoreadelf: Update dynamic tag processing and validate section info
H.J. Lu [Wed, 1 Jul 2026 02:15:30 +0000 (10:15 +0800)] 
readelf: Update dynamic tag processing and validate section info

Count DT_RELR relocations using dynamic tags when section header isn't
used.  Ignore section sh_offset and sh_size if they are larger than file
size.

One side effect is that we now display

readelf: Warning: Ignore the out of range sh_offset value of 2199023261148 for section 17
readelf: Warning: Ignore the out of range sh_size value of 13 for section 17 with sh_offset value of 2199023261148
...
  [17] .fini             PROGBITS        00000000000015dc 000000 000000 00  AX  0   0  4
...

instead of

...
  [17] .fini             PROGBITS        00000000000015dc 200000015dc 00000d 00  AX  0   0  4
...

and segfault.

binutils/

PR binutils/34326
PR binutils/34339
* readelf.c (update_all_relocations): Skip if nentries == 0.
(validate_section_info): New.
(get_32bit_section_headers): Call validate_section_info.
(get_64bit_section_headers): Likewise.
(process_relocs): Call count_relr_relocations for relocations
from dynamic tags.  Skip if values in DT_RELENT/DT_RELAENT
are larger than values in DT_RELSZ/DT_RELASZ.
(process_got_section_contents): Skip if all_relocations_count
== 0.

ld/
PR binutils/34339
* testsuite/ld-x86-64/binutils.exp: Run PR binutils/34339 tests.
* testsuite/ld-x86-64/got-2.s: New file.
* testsuite/ld-x86-64/libgot-2.rd: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2 weeks agogdb/record: rename record_full_list to record_full_log
Guinevere Larsen [Fri, 15 May 2026 14:57:04 +0000 (11:57 -0300)] 
gdb/record: rename record_full_list to record_full_log

Now that we no longer use a linked list to manage the history, the name
"record_full_list" is no longer meaningful. This commit changes the name
to record_full_log since it is the execution log. I decided to not say
"record_full_execution_log" to avoid overly long lines when accessing
it.

Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Reviewed-By: Christina Schimpe <christina.schimpe@intel.com>
Approved-By: Guinevere Larsen <guinevere@redhat.com>
2 weeks agogdb/record: Define new version of the record-save section
Guinevere Larsen [Wed, 15 Apr 2026 13:17:29 +0000 (10:17 -0300)] 
gdb/record: Define new version of the record-save section

With the changes to the internal representation of the history, we can
no longer support the previous record save format. This commit makes it
official, documenting the new format and changing the magic number.

Reviewed-By: Christina Schimpe <christina.schimpe@intel.com>
Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Guinevere Larsen <guinevere@redhat.com>
2 weeks agogdb/record: extract the PC to record_full_instruction
Guinevere Larsen [Mon, 1 Jun 2026 19:54:09 +0000 (16:54 -0300)] 
gdb/record: extract the PC to record_full_instruction

This commit makes it so the PC is not saved as part of the
record_full_instruction effects, but rather gets a special location.
That is because a couple of commands would really benefit from it being
easy to find the PC (especially ones from record-btrace that's haven't
been implemented to record-full yet, such as the ones in PR
record/18059), while also possibly allowing for one fewer resizing of
the effect vector (and saving an entire byte in the process).

This commit also refactored record_full_read_entry_from_bfd and
record_full_write_entry_to_bfd, to make them methods of
record_full_reg_entry and record_full_mem_entry, and also creates
similar methods for record_full_entry and record_full_instruction.
These could be turned into constructors in a future step of
c++ification, but it felt like too much change for a single commit.

Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Reviewed-By: Christina Schimpe <christina.schimpe@intel.com>
Approved-By: Guinevere Larsen <guinevere@redhat.com>
2 weeks agogdb/record: make record_full_history more c++-like
Guinevere Larsen [Mon, 1 Jun 2026 19:42:41 +0000 (16:42 -0300)] 
gdb/record: make record_full_history more c++-like

This commit moves the function record_full_exec_insn to be a method of
the record_full_instruction class.

Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Reviewed-By: Christina Schimpe <christina.schimpe@intel.com>
Approved-By: Guinevere Larsen <guinevere@redhat.com>
2 weeks agogdb/record: c++ify internal structures of record-full.c
Guinevere Larsen [Tue, 7 Apr 2026 13:55:13 +0000 (10:55 -0300)] 
gdb/record: c++ify internal structures of record-full.c

This commit adds a constructor, destructor, and some methods to the
structures record_full_entry, record_full_reg_entry and
record_full_mem_entry. This is a move to disentangle the internal
representation of the data and how record-full manipulates it for
replaying.

Along with this change, record_full_entry is changed to use an
std::variant, since it was basically doing that already, but now we have
the stdlibc++ error checking to make sure we're only accessing elements
we're allowed to.

Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Reviewed-By: Christina Schimpe <christina.schimpe@intel.com>
Approved-By: Guinevere Larsen <guinevere@redhat.com>
2 weeks agogdb/record: remove record_full_insn_num
Guinevere Larsen [Wed, 8 Apr 2026 19:25:00 +0000 (16:25 -0300)] 
gdb/record: remove record_full_insn_num

Now that record_full_list uses a deque, we don't need a variable to
track the amount of items recorded, so it is just dropped.

Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Reviewed-By: Christina Schimpe <christina.schimpe@intel.com>
Approved-By: Guinevere Larsen <guinevere@redhat.com>
2 weeks agogdb/record: factor out reading and writing the execution log to corefile
Guinevere Larsen [Fri, 29 May 2026 16:42:40 +0000 (13:42 -0300)] 
gdb/record: factor out reading and writing the execution log to corefile

Before this commit, the functions to read and write the execution log to
a corefile would would have a large section dedicated to handling a
single entry from the log.  This commit factors out those large sections
into their own functions, record_full_read_entry_from_bfd and
record_full_write_entry_to_bfd, respectively.

There should be no functional changes after this commit.

Reviewed-By: Christina Schimpe <christina.schimpe@intel.com>
Approved-By: Guinevere Larsen <guinevere@redhat.com>
2 weeks agogdb/record: Refactor record history
Guinevere Larsen [Thu, 28 May 2026 18:36:33 +0000 (15:36 -0300)] 
gdb/record: Refactor record history

This is the first step in a large refactor in how GDB keeps execution
history.  Rather than using a linked list where multiple entries can
describe a single instruction, the history will now be stored in an
std::deque, each instruction being one entry in the deque.

The choice was initially to use an std::vector, but it would become
unwieldy because it needs all the memory to be consecutive, which is
hard for 200 thousand entries. Deque was picked because it was a nice
midpoint between vector (maximum cache cohesion) and linked list
(maximum ease of finding space to store more).

Each instruction in memory will be now one record_full_instruction
entry, which for this commit just contains a vector of
record_full_entry for the effects of the instruction, and the data that
was stored in the record_full_end entry (that is, the instruction number
and the signal, if any).

This change introduced a minimal performance improvement (what's
important is that it isn't a degradation) and a  reduction in the total
memory footprint of roughly 20% if the entire history is used.

Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Reviewed-By: Christina Schimpe <christina.schimpe@intel.com>
Approved-By: Guinevere Larsen <guinevere@redhat.com>
2 weeks agogdb, amd-dbgapi-target: use pulongest to print id handles
Tankut Baris Aktemur [Fri, 3 Jul 2026 12:32:10 +0000 (07:32 -0500)] 
gdb, amd-dbgapi-target: use pulongest to print id handles

In amd-dbgapi-target, there are a number of cases where identifier
handles that are obtained from dbgapi are being printed.  Those
handles are defined to have type uint64_t.  Use pulongest when
printing them for improved portability.

In one case, `ptid.tid ()` was being printed for the wave id.  Change
this to use `wave_id.handle` for consistency with the other cases.

Approved-by: Lancelot Six <lancelot.six@amd.com> (amdgpu)
2 weeks agogdb/testsuite: fix gdb.rocm/interrupt-twice
Lancelot SIX [Wed, 1 Jul 2026 16:09:25 +0000 (17:09 +0100)] 
gdb/testsuite: fix gdb.rocm/interrupt-twice

Since 246aecb1cd1 "gdb/testsuite: make gdb_breakpoint, runto and
runto_main use parse_args", gdb_breakpoint arguments changed.  The
gdb.rocm/interrupt-twice.exp testcase was not updated to call
gdb_breakpoint with correct arguments.  This due to the new test being
reviewed before the gdb_breakpoint landed, but it being pushed after.

This patch fixes this issue.

Change-Id: I0204e2c3cc9b704c79ce01386134e13b018593b8
Reviewed-By: Tankut Baris Aktemur <TankutBaris.Aktemur@amd.com>
2 weeks agox86/gas: add missing RegBND to debugging code
Jan Beulich [Fri, 3 Jul 2026 09:19:00 +0000 (11:19 +0200)] 
x86/gas: add missing RegBND to debugging code

This must have been overlooked when MPX support was added.

2 weeks agogdb: replace alloca with gdb::unique_xmalloc_ptr in remote-fileio.c
Luis Machado [Wed, 1 Jul 2026 19:01:56 +0000 (14:01 -0500)] 
gdb: replace alloca with gdb::unique_xmalloc_ptr in remote-fileio.c

remote_fileio_extract_ptr_w_len parsed a debuggee controlled 64 bit
length, narrowed it to int with no bounds check, and the value flowed
directly into alloca() across RSP File I/O handlers (Fopen, Frename,
Funlink, Fstat, Fsystem).  A malicious inferior or remote stub could
send a crafted packet with a large path length, displacing the stack
pointer by up to 2 GiB and potentially crashing the debugger.

remote_fileio_extract_ptr_w_len now rejects negative lengths, lengths
that would overflow the int result (greater than INT_MAX), and zero.
An allow_zero_length flag lets the Fsystem handler opt in to the zero
length sentinel that signals a NULL cmdline query.  All other handlers
use the default and are protected without any per call checks.  Oversized
names are rejected naturally by the underlying syscall with ENAMETOOLONG.
All alloca(length) calls have been replaced with
gdb::unique_xmalloc_ptr<char>, so an oversized but positive length now
fails as a graceful heap allocation error rather than corrupting the
stack.

Add a selftest that exercises various problematic cases.

Signed-off-by: Luis Machado <luis.machado@amd.com>
Approved-By: Pedro Alves <pedro@palves.net>
2 weeks agogdb/testsuite: deduplicate --offload-arch targets in hcc_amdgpu_targets
Luis Machado [Mon, 29 Jun 2026 13:56:13 +0000 (08:56 -0500)] 
gdb/testsuite: deduplicate --offload-arch targets in hcc_amdgpu_targets

On systems with multiple identical GPUs, find_amdgpu_devices returns one
entry per device, causing hcc_amdgpu_targets to emit redundant
--offload-arch flags when compiling HIP test programs (e.g. eight
--offload-arch=gfx942 flags on an 8-GPU MI300 system).

Deduplicate the target list in hcc_amdgpu_targets, preserving order, so
each unique architecture appears exactly once regardless of how many
physical devices share it.  The same deduplication is applied when the
list comes from the HCC_AMDGPU_TARGET environment variable.  An array
is used for the seen-set to give O(1) membership tests.

Add gdb.rocm/hcc-amdgpu-targets.exp to unit-test the deduplication
logic across both the env-var and device-enumeration code paths, without
requiring a GPU.

Approved-by: Lancelot Six <lancelot.six@amd.com>
2 weeks agoPR 34342 SIGSEGV libctf/ctf-types.c:1603
Alan Modra [Fri, 3 Jul 2026 00:10:01 +0000 (09:40 +0930)] 
PR 34342 SIGSEGV libctf/ctf-types.c:1603

* ctf-open.c (init_static_types_internal): Sanity check variable
length record bytes against type section length.
(upgrade_types_v1): Likewise.  Don't check unused "size" here.

2 weeks agoAutomatic date update in version.in
GDB Administrator [Fri, 3 Jul 2026 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 weeks agoHandle -1 in ptid_t::parse
Tom Tromey [Thu, 2 Jul 2026 18:12:49 +0000 (12:12 -0600)] 
Handle -1 in ptid_t::parse

ptid_t::parse fails to correctly handle the -1 return from
hex_or_minus_one in the 'p' case.  As Mark Wielaard pointed out, it
does this check:

      if (hex != ((unsigned_lwp_type) lwp))

However on 32-bit, this means that it will mishandle (ULONGEST) -1.

This patch fixes the problem by adding a check for the -1 case.

I built a -m32 gdb and verified this fix; I'm checking it in.

2 weeks agoobjdump: Fix private header ('-p') import table output for pe-aarch64
Jon Turney [Fri, 19 Jun 2026 12:47:03 +0000 (13:47 +0100)] 
objdump: Fix private header ('-p') import table output for pe-aarch64

The private header ('-p') import table output for pe-aarch64 (and
probably all other 64-bit arches apart from x86_64) is truncated after the
first import.

The distinction between the conditional branches here should be between
PE32 (32-bit) and PE32+ (somewhat confusingly, the 64-bit version of the
PE format).

PE file format specification [1] states under "Import Lookup Table":

"An import lookup table is an array of 32-bit numbers for PE32 or an
array of 64-bit numbers for PE32+."

[1] https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#import-lookup-table

2026-06-19  Jon Turney  <jon.turney@dronecode.org.uk>

* peXXigen.c (pe_print_idata): Fix conditional.

2 weeks agobfd/readelf: Add core file support for FEAT_S1POE
Srinath Parvathaneni [Thu, 2 Jul 2026 13:57:25 +0000 (13:57 +0000)] 
bfd/readelf: Add core file support for FEAT_S1POE

Add support for `NT_ARM_POE` dumps/reads for core files.

2 weeks agoaarch64: Adjust architecture version for mpamv2 tests
Richard Earnshaw [Thu, 2 Jul 2026 12:51:03 +0000 (13:51 +0100)] 
aarch64: Adjust architecture version for mpamv2 tests

Armv9.3a now permits mpamv2, so lower the version needed for the tests.

2 weeks agoFix ptid_t selftest crash
Tom Tromey [Thu, 2 Jul 2026 12:51:36 +0000 (06:51 -0600)] 
Fix ptid_t selftest crash

Sam James pointed out that my recent patch to add ptid_t::parse caused
a selftest crash.

At first I couldn't see why this did not crash for me, but then I
realized that ptid_t::parse didn't unconditionally initialize '*obuf'.
Initializing it to nullptr made this crash reliably.

The underlying bug is that some code paths in ptid_t::parse don't set
obuf on return.  This patch fixes the bug by passing 'obuf' down to
hex_or_minus_one.

Since this is straightforward and fixes a new crash, I'm checking it
in.

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

2 weeks agoNEWS: Update for withdrawal of the MPAMv2_VID feature.
Richard Earnshaw [Mon, 29 Jun 2026 16:07:01 +0000 (17:07 +0100)] 
NEWS: Update for withdrawal of the MPAMv2_VID feature.

2 weeks agoaarch64: Remove +mpamv2 feature option
Richard Earnshaw [Mon, 29 Jun 2026 15:46:27 +0000 (16:46 +0100)] 
aarch64: Remove +mpamv2 feature option

The remaining mpamv2 details only use system registers; so by our
conventions we do not use a feature option to enable them.  Remove the
now redundant +mpamv2 architecture option and adjust the tests
accordingly.

2 weeks agoRevert "aarch64: Add FEAT_MPAMv2_VID system registers"
Richard Earnshaw [Mon, 29 Jun 2026 15:36:22 +0000 (16:36 +0100)] 
Revert "aarch64: Add FEAT_MPAMv2_VID system registers"

This reverts commit 5fc6b09c078532fa4206a350e34d82488b80a5fb.

2 weeks agoRevert "aarch64: Add support for MLBI system instructions"
Richard Earnshaw [Mon, 29 Jun 2026 15:35:01 +0000 (16:35 +0100)] 
Revert "aarch64: Add support for MLBI system instructions"

This reverts commit d8e004f124877849c654c0f24c2960970dbc1ee8.

2 weeks agoaarch64: remove MLBI from sys-rt-alias test.
Richard Earnshaw [Mon, 29 Jun 2026 16:03:49 +0000 (17:03 +0100)] 
aarch64: remove MLBI from sys-rt-alias test.

2 weeks agoaarch64: warn if the TME feature is used during assembly.
Richard Earnshaw [Thu, 25 Jun 2026 13:09:28 +0000 (14:09 +0100)] 
aarch64: warn if the TME feature is used during assembly.

Arm has obsoleted the unimplemented TME feature.  Warn if instructions
from this feature are encountered.

Also tweak warn_unpredictable_ldst to use const more often, since the
arguments are the same as for the new warn_deprecated function.

2 weeks agoaarch64: Remove a stray comment from opcode/aarch64.h
Richard Earnshaw [Thu, 25 Jun 2026 10:32:23 +0000 (11:32 +0100)] 
aarch64: Remove a stray comment from opcode/aarch64.h

When flag bit 28 was removed in an earlier patch, the comment describing
it was left behind.  This just cleans that up.

2 weeks agold/testsuite: add support for remote testing in ld-cdtest
Clément Chigot [Fri, 20 Feb 2026 14:43:03 +0000 (15:43 +0100)] 
ld/testsuite: add support for remote testing in ld-cdtest

This converts the existing to code to use "remote_load" allowing
execution on both native and remote targets.

The "diff" between the output and the expected result has been
transformed to the usual regexp_diff. The previous could have been
transformed into `remote_exec build diff` but tends to be fickled with
new lines.

2 weeks agoRe: x86: Disable AMX-TF32 by default
Alan Modra [Thu, 2 Jul 2026 04:10:36 +0000 (13:40 +0930)] 
Re: x86: Disable AMX-TF32 by default

Regenerate opcodes/i386-init.h, which was listed in the changelog but
not committed.

2 weeks agoPR 34327 More out of bounds accesses in reloc special functions
Alan Modra [Thu, 2 Jul 2026 01:34:13 +0000 (11:04 +0930)] 
PR 34327 More out of bounds accesses in reloc special functions

I don't claim to have caught all places where reloc special functions
don't sanity check input, but this should be most of them.  Hopefully
this does not expose odd reloc howto entries like the mmix one in the
previous patch.

* coff-arm.c (aoutarm_fix_pcrel_26): Sanity check reloc offset.
Remove some unnecessary casts.
(coff_thumb_pcrel_common): Likewise.
* coff-mips.c (mips_generic_reloc): Remove unnecessary casts.
(mips_refhi_reloc): Likewise.
(mips_gprel_reloc): Likewise.  Use bfd_reloc_offset_in_range.
* cpu-ns32k.c (do_ns32k_reloc): Likewise.
* elf32-m68hc1x.c (m68hc11_elf_special_reloc): Likewise.  Don't
abort, return notsupported instead.
* elf32-pj.c (pj_elf_reloc): Sanity check reloc offset.
* elf32-pru.c (pru_elf32_do_s10_pcrel_relocate): Update reloc
offset sanity check.
(pru_elf32_do_ldi32_relocate): Likewise.
* elf32-s390.c (s390_elf_ldisp_reloc): Use bfd_reloc_offset_in_range.
Remove unnecessary casts.
* elf32-score7.c (score_elf_got_lo16_reloc): Remove redundant old
reloc offset sanity check.
* elf32-sh.c (sh_elf_reloc): Use bfd_reloc_offset_in_range.
* elf32-v850.c (v850_elf_reloc): Likewise.

2 weeks agoPR 34327 Out of bounds accesses in reloc special functions.
Alan Modra [Thu, 2 Jul 2026 01:18:34 +0000 (10:48 +0930)] 
PR 34327 Out of bounds accesses in reloc special functions.

As per the PR, s12z lacked any reloc offset sanity checking, the
others all just checked that the offset started within the section
rather than checking the field was contained in the section.

Using the proper check for mmix exposed a problem in the howto table,
present since the initial mmix commit.  The R_MMIX_BASE_PLUS_OFFSET
field is actually two bytes, located at the reloc address.  Making it
an eight byte field is just wrong, as doing that indicates the field
is at the reloc address plus six bytes for a big-endian target.
Presumably this was done for overlow reporting, which is properly done
by appropriately setting complain_on_overflow.

* elf32-d30v.c (bfd_elf_d30v_reloc, bfd_elf_d30v_reloc_21): Use
bfd_reloc_offset_in_range
* elf32-s12z.c (opru18_reloc): Likewise.
* elf32-spu.c (spu_elf_rel9): Likewise.
* elf32-xstormy16.c (xstormy16_elf_24_reloc): Likewise.
* elf32-visium.c (visium_elf_howto_parity_reloc): Likewise.
Remove unnecessary casts too.
* elf64-s390.c (s390_elf_ldisp_reloc): Likewise.
* elfxx-sparc.c (init_insn_reloc): Likewise.
* elf64-mmix.c (mmix_elf_reloc): Likewise.  Remove unnecessary
variable too.
(elf_mmix_howto_table[R_MMIX_BASE_PLUS_OFFSET]): Correct size,
bitsize and complain_on_overflow.

2 weeks agoPR 34165 aarch64 assertion fail and segv
Alan Modra [Wed, 1 Jul 2026 01:28:53 +0000 (10:58 +0930)] 
PR 34165 aarch64 assertion fail and segv

* elfnn-aarch64.c (dtpoff_base, tpoff_base): Don't assert that
tls_sec is non-NULL, return zero instead.

2 weeks agox86: Disable AMX-TF32 by default
Haochen Jiang [Tue, 30 Jun 2026 07:58:35 +0000 (15:58 +0800)] 
x86: Disable AMX-TF32 by default

AMX-TF32 got depublished in ISE062. Just like AMX-TRANSPOSE, we
will keep the AMX-TF32 support for now in case there are x86 vendors
want to utilize the feature. AMX-TF32 will not show up on any
Intel/AMD hardware. Also in foreseeable future, no hardware will
support AMX-TF32, we will disable it by default. For testcases,
we will simply add .arch .amx_tf32 to keep the original test
intuition.

gas/ChangeLog:

        * testsuite/gas/i386/x86-64-amx-tf32.s: Add .amx_tf32.
        * testsuite/gas/i386/x86-64-amx-tf32-inval.s: Ditto.
        * testsuite/gas/i386/x86-64-amx-transpose.s: Ditto.
        * testsuite/gas/i386/x86-64-amx-transpose-inval.s: Ditto.
        * testsuite/gas/i386/x86-64-amx-tf32-inval.l: Adjust line
number.
        * testsuite/gas/i386/x86-64-amx-transpose-inval.l: Ditto.

opcodes/ChangeLog:

        * i386-gen.c: Disable AMX-TF32 by default.
        * i386-init.h: Regenerated.

2 weeks agoAutomatic date update in version.in
GDB Administrator [Thu, 2 Jul 2026 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 weeks agoreadelf: Avoid may be used uninitialized warning from GCC 14
H.J. Lu [Wed, 1 Jul 2026 23:02:48 +0000 (07:02 +0800)] 
readelf: Avoid may be used uninitialized warning from GCC 14

GCC 14 fails to recognize that rel_entsz and entsz_name are unused when
process_relocs returns early for error:

.../binutils/readelf.c:10127:18: error: ‘rel_entsz’ may be used uninitialized [-Werror=maybe-uninitialized]
10127 |               if (rel_entsz == 0)
      |                  ^
...
.../binutils/readelf.c:10129:19: error: ‘entsz_name’ may be used uninitialized [-Werror=maybe-uninitialized]
10129 |                   printf (_("<missing or corrupt dynamic tag: %s>\n"),
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10130 |                           entsz_name);

Clear them before returning error.  Also replace reltype_unknown with
default since GCC 14 fails to see that reltype_unknown is the only
unhandled value for relocation_type enum.

PR binutils/34324
* readelf.c (process_relocs): Clear rel_entsz and entsz_name
before returning error on missing DT_REL and DT_RELA dynamic
tags.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2 weeks agoreadelf: Check missing DT_REL and DT_RELA dynamic tags
H.J. Lu [Tue, 30 Jun 2026 23:31:42 +0000 (07:31 +0800)] 
readelf: Check missing DT_REL and DT_RELA dynamic tags

PR binutils/34324
* readelf.c (process_relocs): Return error on missing DT_REL and
DT_RELA dynamic tags.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2 weeks agoDo not write negative PID or TID in remote protocol
Tom Tromey [Wed, 11 Mar 2026 20:17:50 +0000 (14:17 -0600)] 
Do not write negative PID or TID in remote protocol

Currently both gdb and gdbserver can write a negative number for the
PID or TID.  However, the only negative value that really makes sense
is the special case of "-1" -- in other cases if the PID or TID has
the high bit set, it should still be written as a positive number.

This patch attempts to fix the bug.

v2 of this patch combines the implementations and moves them to
gdbsupport.  I tried making these standalone functions in rsp-low.cc,
but that runs afoul of libipa.  So, I made them methods of ptid_t.

The new unit tests pointed out that round-tripping a sign-extended
number didn't really work, because the checks were done via ULONGEST.
It's kind of unfortunate that the PID and LWP are host-dependent
types.  This should probably be fixed, but I haven't done so here.
Meanwhile I changed the checks to use the corresponding unsigned type.

v1 is here

    https://inbox.sourceware.org/gdb-patches/20260311202152.2704410-1-tromey@adacore.com/

Regression tested on x86-64 Fedora 43.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=25111
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33979
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33983

3 weeks agolibiberty d_compact_number signed integer overflow
Alan Modra [Wed, 1 Jul 2026 01:27:51 +0000 (10:57 +0930)] 
libiberty d_compact_number signed integer overflow

https://lists.gnu.org/archive/html/bug-binutils/2026-06/msg00189.html
Fix this by doing the addition in unsigned arithmetic.

3 weeks agoAutomatic date update in version.in
GDB Administrator [Wed, 1 Jul 2026 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 weeks agold/testsuite: Add comprehensive PE COFF weak external tests
Peter Damianov [Tue, 23 Jun 2026 21:38:07 +0000 (17:38 -0400)] 
ld/testsuite: Add comprehensive PE COFF weak external tests

Add tests covering the full matrix of weak/strong symbol interactions
for PE COFF weak externals, based on testcases by Martin Storsjo.
The archive test covers PE weak externals whose public name is backed
by a real fallback definition, and ensures weak declarations with the
null fallback are not advertised as archive providers.

ld/testsuite/

* ld-pe/pe-compile.exp (weak_ext_test): New proc.  Compiles
source files, links via gcc, and runs natively if possible.
(weak_ext_archive_test): New proc.
Add tests: normal, weak-undef, weak-defined,
weak-decl-weak-def, strong-undef-weak-def-archive, weak-use,
weak-override, weak-duplicate, weak-def-override, weak-def-use.
* ld-pe/weak-ext-main.c: New file.
* ld-pe/weak-ext-main-weak.c: New file.
* ld-pe/weak-ext-main-weak-def.c: New file.
* ld-pe/weak-ext-add2.c: New file.
* ld-pe/weak-ext-add1-weak-chained.c: New file.
* ld-pe/weak-ext-dummy.c: New file.
* ld-pe/weak-ext-expected1.c: New file.
* ld-pe/weak-ext-expected3.c: New file.
* ld-pe/weak-ext-expected5.c: New file.
* ld-pe/weak-ext-expected3-add1-weak.c: New file.

3 weeks agobfd: Handle PE weak externals with real fallbacks in archives
Peter Damianov [Tue, 23 Jun 2026 21:38:06 +0000 (17:38 -0400)] 
bfd: Handle PE weak externals with real fallbacks in archives

PE weak externals are canonicalized as undefined BFD symbols, even
when their auxiliary entry names a real fallback definition in the same
object.  Archive map generation therefore skipped the public weak name,
so a strong undefined reference to that name could not extract the
archive member.

Include such PE weak externals in the archive map, but only when the
fallback is a real definition rather than the absolute-zero null symbol
used for weak declarations with no fallback.  Also avoid extracting an
archive member again during repeated archive searches once the weak
external resolves through a defined fallback.

Fixes: https://gcc.gnu.org/PR124263
bfd/

* archive.c: Include coff-bfd.h.
(_bfd_compute_and_push_armap): Include PE weak externals in
the archive map when their fallback is a real definition.
* coff-bfd.c (bfd_coff_pe_weak_external_has_real_fallback): New
function.
* coff-bfd.h (bfd_coff_pe_weak_external_has_real_fallback):
Declare.
* cofflink.c (coff_link_hash_pe_weak_external_has_real_fallback):
New function.
(coff_link_check_archive_element): Avoid extracting an archive
member again for a PE weak external whose real fallback is
already defined.

3 weeks agoPE-COFF: Prefer weak external with defined fallback over null fallback
Peter Damianov [Tue, 23 Jun 2026 21:38:05 +0000 (17:38 -0400)] 
PE-COFF: Prefer weak external with defined fallback over null fallback

When two PE COFF weak externals for the same symbol are linked (both
C_NT_WEAK with aux records), the generic linker takes no action on the
second one (NOACT: weak undef meets existing weak undef).  This means
the first file's fallback alias always wins regardless of whether it
points to a real definition or to NULL.

This causes a problem when a weak declaration (fallback = NULL,
i.e. "resolve to NULL if nothing provides it") is linked before a
weak definition (fallback = actual function body).  The symbol resolves
to address 0 at runtime, causing a crash when called.

Fix this by comparing the fallback targets when two weak externals
meet: if the incoming weak external's fallback resolves to a defined
symbol and the existing one does not (or points to NULL),
update the aux record to use the better fallback.

This matches the behavior of lld after:
  https://github.com/llvm/llvm-project/commit/7ca5698b4c3698d06065e0941df7f23d72913d23

bfd/
* cofflink.c (coff_link_add_symbols): When two PE COFF weak
externals meet, prefer the one whose fallback alias resolves
to a defined symbol.

3 weeks agoPE-COFF: Fix weak external symbol resolution when strong undef is seen first
Peter Damianov [Tue, 23 Jun 2026 21:38:04 +0000 (17:38 -0400)] 
PE-COFF: Fix weak external symbol resolution when strong undef is seen first

When linking PE-COFF objects, a weak external symbol (C_NT_WEAK with an
aux record specifying a fallback alias) may fail to resolve if a strong
undefined reference to the same symbol is encountered before the weak
definition.  This causes "undefined reference" errors for symbols like
operator new or personality routines that GCC emits as weak externals
with a fallback to a default implementation.

There are two problems:

1. In coff_link_add_symbols, when the generic linker resolves a weak
   undefined against an existing strong undefined (NOACT in the action
   table), the COFF-specific symbol_class and aux record were not stored
   because the existing hash entry already had non-null class/type from
   the first (strong) object file.

2. In _bfd_coff_generic_relocate_section, the weak alias fallback only
   triggered for bfd_link_hash_undefweak symbols.  When a strong undef
   is seen first, the hash type stays bfd_link_hash_undefined (the
   generic linker does not downgrade it), so the fallback was skipped.

Fix by extending the condition in coff_link_add_symbols to also update
symbol_class and aux when the incoming symbol is a PE weak external
with aux and the existing hash is still undefined.  Also extend the
relocation handler to resolve the weak alias fallback for
bfd_link_hash_undefined symbols that carry C_NT_WEAK class and have
an aux record.

bfd/
        * cofflink.c (coff_link_add_symbols): Also store symbol_class
        and aux record when a PE weak external with aux meets an
        existing undefined hash entry.
        (_bfd_coff_generic_relocate_section): Also resolve weak alias
        fallback for undefined symbols with C_NT_WEAK class and aux.

3 weeks agoRISC-V: Fix zvdota altfmt disassemble format issue
Jiawei [Tue, 30 Jun 2026 16:24:20 +0000 (00:24 +0800)] 
RISC-V: Fix zvdota altfmt disassemble format issue

Fix-up vtype altfmt disassembly extension check.

Only print the altfmt vtype names when the object advertises one of the
extensions that defines that encoding, or when disassembling with all
extensions enabled.

Validated with:
  make check RUNTEST=... RUNTESTFLAGS="riscv.exp"

Result:
  PASS: gas/riscv/vector-insns
  PASS: gas/riscv/zvdota
  # of expected passes: 360

gas/ChangeLog:

* testsuite/gas/riscv/zvdota.d: Fix format.

opcodes/ChangeLog:

* riscv-dis.c (riscv_vtype_altfmt_supported): Add ext check.
(print_insn_args): Use altfmt check.

3 weeks agoRISC-V: Add Zvbdota extension support
Jiawei [Tue, 30 Jun 2026 13:55:11 +0000 (07:55 -0600)] 
RISC-V: Add Zvbdota extension support

This patch supports the RISC-V Zvbdota family of batched dot-product
extensions [1].

Compared to the non-batched Zvdota family, Zvbdota computes up to eight
dot products at a time.  These instructions use an EMUL=8 `vs2` vector
register group and a scaled-by-8 `ci` immediate encoded in `vs2[2:0]`.
This patch adds assembler/disassembler support for those additional
operand constraints.

The Zvbdota extension family includes the following extensions:

* Zvqwbdota8i: batched dot product of 8-bit integers with 32-bit
  accumulation.
* Zvqwbdota16i: batched dot product of 16-bit integers with 64-bit
  accumulation.
* Zvfwbdota16bf: batched dot product of bfloat16 floating-point numbers
  with 32-bit accumulation.
* Zvfqwbdota8f: batched dot product of 8-bit floating-point numbers with
  32-bit accumulation.
* Zvfbdota32f: batched dot product of 32-bit single-precision
  floating-point numbers with 32-bit accumulation.

[1] https://github.com/riscv/riscv-isa-manual/blob/zvbdot/src/zvdota.adoc

bfd/ChangeLog:

* elfxx-riscv.c (riscv_implicit_subsets): New implies.
(riscv_supported_std_z_ext): New extensions.
(riscv_multi_subset_supports): Ditto.
(riscv_multi_subset_supports_ext): Ditto.

gas/ChangeLog:

* NEWS: Add zvqwbdota8i, zvqwbdota16i, zvfwbdota16bf,
zvfqwbdota8f and zvfbdota32f extensions.
* config/tc-riscv.c (validate_riscv_insn): Add Zvbdota operand
type 'q' and 'r' bits validation.
(riscv_vtype_altfmt_supported): Add Zvbdota extensions.
(my_getVsetvliExpression): Update altfmt error message.
(riscv_ip): Add 'q' operand for VS2 EMUL=8 alignment check
and 'r' operand for ci immediate.
* testsuite/gas/riscv/march-help.l: Ditto.
* testsuite/gas/riscv/zvbdota.d: New test.
* testsuite/gas/riscv/zvbdota.s: Ditto.
* testsuite/gas/riscv/zvbdota-operands-fail.d: Ditto.
* testsuite/gas/riscv/zvbdota-operands-fail.l: Ditto.
* testsuite/gas/riscv/zvbdota-operands-fail.s: Ditto.
* testsuite/gas/riscv/zvbdota-zvqwbdota16i.d: Ditto.
* testsuite/gas/riscv/zvbdota-zvqwbdota16i.s: Ditto.

include/ChangeLog:

* opcode/riscv-opc.h (MATCH_VQWBDOTAU_VV, MASK_VQWBDOTAU_VV):
New encoding.
(MATCH_VQWBDOTAS_VV, MASK_VQWBDOTAS_VV): Ditto.
(MATCH_VFWBDOTA_VV, MASK_VFWBDOTA_VV): Ditto.
(MATCH_VFQWBDOTA_VV, MASK_VFQWBDOTA_VV): Ditto.
(MATCH_VFQWBDOTA_ALT_VV, MASK_VFQWBDOTA_ALT_VV): Ditto.
(MATCH_VFBDOTA_VV, MASK_VFBDOTA_VV): Ditto.
(DECLARE_INSN): New declarations.
* opcode/riscv.h (enum riscv_insn_class): New extension classes.

opcodes/ChangeLog:

* riscv-dis.c (print_insn_args): Add 'q' and 'r' operand types
for Zvbdota.
* riscv-opc.c (riscv_opcodes): New instructions.

3 weeks agoRISC-V: Add Zvdota extension classes
Jiawei [Tue, 30 Jun 2026 13:54:21 +0000 (07:54 -0600)] 
RISC-V: Add Zvdota extension classes

Zvfqwdota8f: dot product of 8-bit floating-point numbers with 32-bit accumulation.

Zvdota also uses the vtype alternative format bit, altfmt, which is bit 8 of the vtype CSR. This patch adds symbolic e8alt and e16alt vsew constants for vsetvli/vsetivli so that assembly code can select the alternative element formats required by these dot-product instructions.

[1] https://github.com/riscv/riscv-isa-manual/blob/zvbdot/src/zvdota.adoc

bfd/ChangeLog:

* elfxx-riscv.c (riscv_implicit_subsets): New implies.
(riscv_supported_std_z_ext): New extensions.
(riscv_multi_subset_supports): Ditto.
(riscv_multi_subset_supports_ext): Ditto.

gas/ChangeLog:

* NEWS: Add zvqwdota8i, zvqwdota16i, zvfwdota16bf and
zvfqwdota8f extensions.
* config/tc-riscv.c (riscv_vsew_altfmt): New vsew altfmt
constants array for e8alt and e16alt.
(riscv_vtype_altfmt_supported): New function.
(my_getVsetvliExpression): Ditto.
* testsuite/gas/riscv/march-help.l: New test.
* testsuite/gas/riscv/vector-vtype-altfmt.d: Ditto.
* testsuite/gas/riscv/vector-vtype-altfmt.s: Ditto.
* testsuite/gas/riscv/zvdota.d: Ditto.
* testsuite/gas/riscv/zvdota.s: Ditto.

include/ChangeLog:

* opcode/riscv-opc.h (MATCH_VQWDOTAU_VV, MASK_VQWDOTAU_VV): New encoding.
(MATCH_VQWDOTAS_VV, MASK_VQWDOTAS_VV): Ditto.
(MATCH_VFWDOTA_VV, MASK_VFWDOTA_VV): Ditto.
(MATCH_VFQWDOTA_VV, MASK_VFQWDOTA_VV): Ditto.
(MATCH_VFQWDOTA_ALT_VV, MASK_VFQWDOTA_ALT_VV): Ditto.
(DECLARE_INSN): New declarations.
* opcode/riscv.h (OP_MASK_VTYPE_ALTFMT, OP_SH_VTYPE_ALTFMT): New vtype altfmt.
(enum riscv_insn_class): New extension classes.

opcodes/ChangeLog:

* riscv-dis.c (print_insn_args): Add altfmt support.
* riscv-opc.c (riscv_opcodes): New instructions.

3 weeks agoreadelf: Also set do_got_section_contents to false
H.J. Lu [Mon, 29 Jun 2026 22:37:05 +0000 (06:37 +0800)] 
readelf: Also set do_got_section_contents to false

Also set do_got_section_contents to false if section headers are failed
to load.

PR binutils/34323
* readelf.c (process_object): Also set do_got_section_contents.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
3 weeks agold testsuite alpha_ld_flags
Alan Modra [Tue, 30 Jun 2026 02:56:46 +0000 (12:26 +0930)] 
ld testsuite alpha_ld_flags

This is how alpha can use -Ttext-segment on just those tests that need
it.  And since the way run_dump_test uses $opts(ld) allows tcl procs to
be embedded, there is no need to specially expand [big_or_little_endian].

binutils/
* testsuite/lib/binutils-common.exp (run_dump_test <opts(ld)>): No
need to handle big_or_little_endian specially.
ld/
* testsuite/ld-elf/elf.exp (alpha_ld_flags): New proc.
(LDFLAGS): Don't set -Ttext-segment for alpha globally.
* testsuite/ld-elf/compress1a.d: Add alpha_ld_flags.
* testsuite/ld-elf/compressed1a.d: Likewise.
* testsuite/ld-elf/eh5.d: Likewise.