Tom de Vries [Mon, 5 Jan 2026 20:56:55 +0000 (21:56 +0100)]
[gdb/testsuite] Fix gdb.python/py-corefile.py with m32
With target board unix/-m32 and test-case gdb.python/py-corefile.exp I run
into:
...
FAIL: $exp: test mapped files data: diff input and output one
...
due to differences like 0x0000000008048000 vs 0x08048000.
Fix this in gdb.python/py-corefile.py by detecting and handling the
ptr_size == 4 case.
Tested on x86_64-linux.
Approved-By: Andrew Burgess <aburgess@redhat.com>
PR testsuite/33728
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33728
Simon Marchi [Mon, 5 Jan 2026 19:58:09 +0000 (14:58 -0500)]
gdb: remove mdebugread & al
After working on the "gdb: replace msym_bunch with deque" patch, I dug
into the history of the mdebug format, and have come to the conclusion
that it is time to remove that code.
ECOFF and mdebug were apparently relevant up to the mid 90s, after which
they were replaced with ELF and DWARF.
It was apparently possible to have mdebug-in-ELF, which is why elfread.c
calls into mdebugread.c, as well as stabs-in-mdebug(-in-ELF), which is
why mdebugread.c used to call into stabsread.c (following the stabs
removal, mdebugread.c now just errors out when encountering stabs).
Here are some pointers to understand the history of this:
- David Anderson's note about mdebug, which says "SGI moved on to
DWARF2 as its debugging format (as have nearly all modern compilers)"
[1] (modern likely meaning anything in the 2000s).
- Peter Rowell's (from Third Eye Software) post that explains the
history of what became mdebug [2][3].
- The ECOFF spec [4].
- A post on gcc-patches indicating that mdebug for Alpha was obsolete
in 2001 [5].
Simon Marchi [Fri, 19 Dec 2025 18:43:44 +0000 (13:43 -0500)]
gdb/buildsym: replace struct pending with std::vector
Replace `struct pending`, a home-made linked list of chunks of symbols,
with `std::vector<symbol *>`. This removes manual memory management and
simplifies the code.
The change starts by switching m_local_symbols, m_file_symbols and
m_global_symbols in buildsym_compunit to be vectors, and propagates from
there.
~buildsym_compunit no longer needs to manually free the lists (it did
not free m_local_symbols, was it on purpose?).
add_symbol_to_list just appends the symbol to the vector. Obviously,
this sometimes causes a vector reallocation, but it is amortized O(1)
and I did not find that it causes a performance degradation (more
details later). We could try to reserve some space in the vectors up
front if we had an estimate of how many entries we'll have, but I am not
sure we really can have a good idea up front.
collate_pending_symbols_by_language iterates the vector backwards to
keep the existing behavior. I am not sure if this is actually needed.
buildsym_compunit::push_context std::moves m_local_symbols, to avoid
copying the contents of the vector. I don't think
buildsym_compunit::pop_context needs to change, everything should be
efficient thanks to NRVO. Users of buildsym_compunit::pop_context use
std::move to move context_stack::locals back to m_local_symbols.
There is a non-trivial change in coff_read_enum_type, which I can't
test easily.
I did the following test to see if this change would have a performance
impact:
- I added a scoped_time_it in maintenance_expand_symtabs, to measure
just that step
- I use a build of blender compiled with "-O2 -g"
- I run:
$ ./gdb -q -nx --data-directory=data-directory -iex 'maint set dwarf sync on' -iex "maint set per-command time on" -ex "file /data1/smarchi/blender/build-RelWithDebInfo-gcc/bin/blender" -ex "maint expand windowmanager" -batch
- I record the time taken by maintenance_expand_symtabs
Before looks like:
Time for "maintenance_expand_symtabs": wall 34.311, user 32.335, sys 1.829, user+sys 34.164, 99.6 % CPU
Time for "maintenance_expand_symtabs": wall 34.208, user 32.265, sys 1.800, user+sys 34.065, 99.6 % CPU
Time for "maintenance_expand_symtabs": wall 34.420, user 32.378, sys 1.894, user+sys 34.272, 99.6 % CPU
After looks like:
Time for "maintenance_expand_symtabs": wall 34.316, user 32.342, sys 1.838, user+sys 34.180, 99.6 % CPU
Time for "maintenance_expand_symtabs": wall 34.318, user 32.347, sys 1.831, user+sys 34.178, 99.6 % CPU
Time for "maintenance_expand_symtabs": wall 34.357, user 32.272, sys 1.943, user+sys 34.215, 99.6 % CPU
I also measured the execution of the whole command (with "maint set
per-command time off" this time). Before looks like:
Tom Tromey [Mon, 5 Jan 2026 15:13:29 +0000 (08:13 -0700)]
Update copyright dates to include 2026
This updates the copyright headers to include 2026. I did this by
running gdb/copyright.py and then manually modifying a few files as
noted by the script.
Tom Tromey [Thu, 11 Dec 2025 19:31:40 +0000 (12:31 -0700)]
Fix Ada 'Modulus attribute
The internal AdaCore test suite pointed out that my earlier patch to
displaying modular types broke the 'Modulus attribute -- it was
off-by-one.
While fixing this, though, I realized that the earlier 'ptype' problem
also affected this attribute. So, this patch implements a similar fix
in the parser.
This adds some operator+ overloads to gdb_mpz for convenience. That
class still doesn't have the full complement of operators -- they are
added as needed.
This patch adds support for PLB invalidate operation (PLBI) instruction
and the corresponding system registers as operand (<plbi_op>).
Syntax: PLBI <plbi_op>{, <Xt>}
This instruction is an alias to "SYS #<op1>, C10, <Cm>, #<op2>{, <Xt>}"
and PLBI being the preferred disassembly.
The following list of system registers are supported in this patch for the
PLBI instructions enabled by "+poe2" flag and also the "nxs" variants of
these system registers are enabled by "+poe2+xs" flag.
This patch adds support for FEAT_TEV feature enabled by "+tev"
flag along with support for following instructions.
* TENTER
* TEXIT
TENTER instruction uses the existing AARCH64_OPND_NOT_BALANCED_17 operand
to handle the not_balanced (NB) argument , where as a new operand
AARCH64_OPND_NOT_BALANCED_10 is added to support the NB (not_balanced)
argument in TEXIT instruction.
This patch adds support for POE2 system registers which are available
by default, however if guarding restrictions are enabled
using -menable-sysreg-checking than "+poe2" option need to specified
to the -march.
Co-authored-by: Matthew Malcomson <matthew.malcomson@arm.com>
A new operand AARCH64_OPND_NOT_BALANCED_17 is added to the code in this
patch to support the new optional argument "NB" (not_balanced) which
is a 1-bit field in the encoding for all the above mentioned
instructions.
Co-authored-by: Matthew Malcomson <matthew.malcomson@arm.com>
Tom Tromey [Tue, 16 Dec 2025 15:43:43 +0000 (08:43 -0700)]
Fix DAP 'disconnect' implementation
gdb's implementation of the DAP 'disconnect' request was incorrect in
a few ways.
First, the 'terminateDebuggee' field is optional, and has a special
meaning when not supplied: it should do whatever the default is.
Second, if the inferior was attached, it should detach rather than
terminate by default.
Finally, if the inferior was not started at all, it seems reasonable
for this request to simply succeed silently -- currently it returns
"success: false" with the reason being that the inferior isn't
running.
Alan Modra [Sat, 3 Jan 2026 03:26:01 +0000 (13:56 +1030)]
Set ELF_OSABI for x86 and sparc
The idea of this patch is to match the solaris target over other
targets if e_ident contains ELFOSABI_SOLARIS. The solaris target will
continue to recognise ELFOSABI_NONE objects.
This has the side effect of disabling gnu features that require
ELFOSABI_GNU, such as ifuncs. I think that is correct, so I've made
the required testsuite changes to fix the resulting regressions:
FAIL: nm --ifunc-chars (assembly)
FAIL: mbind sections without SHF_ALLOC
The patch also sets ELF_OSABI for the gnu x86 and sparc targets,
for the same reason as the solaris targets. This doesn't mean object
files will automatically be marked ELFOSABI_GNU/LINUX. As before that
will only happen when certain GNU extensions are present.
bfd/
* elf32-i386.c: Define ELF_OSABI for solaris and gnu targets.
* elf32-sparc.c: Likewise.
* elf64-sparc.c: Likewise.
* elf64-x86-64.c: Likewise.
* format.c (bfd_check_format_matches): Bump match_priority
for matching e_ident EI_OSABI.
binutils/
* testsuite/binutils-all/nm.exp: Use !supports_gnu_osabi to
disable ifunc test.
gas/
* testsuite/gas/elf/section13.d: Only run on supports_gnu_osabi
targets. Remove xfails.
Alan Modra [Sat, 3 Jan 2026 03:21:21 +0000 (13:51 +1030)]
ELF OSABI matching
Currently a binutils ELF target with ELF_OSABI defined to something
other than the default ELFOSABI_NONE will only accept object files
with e_ident[EI_OSABI] having the value ELF_OSABI. An ELF target with
ELF_OSABI as ELFOSABI_NONE will match any e_ident[EI_OSABI] value, and
typically that target's object files will have ELFOSABI_NONE or one
other value in e_ident[EI_OSABI]. Given an object file with that
"other value" we'd like to be able to choose the correct target but
currently have no way to do so. This patch is a step towards
implementing better target matching.
It does so by adding an ELF_OSABI_EXACT to the target description,
setting that true for all targets that currently define ELF_OSABI, and
testing the new flag for exact matching. This will allow a future
patch to define ELF_OSABI without forcing exact matching but giving a
hint as to the best target match.
Some other tweaks are done as shown by the changelog below but no
user functional changes should be seen with this patch.
* elf-bfd.h (struct elf_backend_data): Add osabi_exact.
* elf.c (_bfd_elf_final_write_processing): Only set e_ident
from elf_osabi when osabi_exact.
* elfcode.h (elf_object_p): Test osabi_exact to reject
mismatching e_ident. Remove unnecessary EM_NONE test.
* elfcore.h (elf_core_file_p): Likewise.
* elfxx-target.h (ELF_OSABI_EXACT): Provide default of 0,
and init elfNN_bed.
(elf_match_priority): Handle ELF_OSABI_EXACT.
* elf32-arm.c (ELF_OSABI_EXACT): Define and undef along with
ELF_OSABI.
* elf32-hppa.c: Likewise.
* elf32-i386.c: Likewise.
* elf32-mips.c: Likewise.
* elf32-ppc.c: Likewise.
* elf32-tic6x.c: Likewise.
* elf32-visium.c: Likewise.
* elf64-alpha.c: Likewise.
* elf64-hppa.c: Likewise.
* elf64-ia64-vms.c: Likewise.
* elf64-mips.c: Likewise.
* elf64-ppc.c: Likewise.
* elf64-sparc.c: Likewise.
* elf64-x86-64.c: Likewise.
* elfn32-mips.c: Likewise.
* elfnn-ia64.c: Likewise.
* elf32-msp430.c: Likewise. Don't define ELF_OSABI to
ELFOSABI_NONE.
Alan Modra [Sat, 3 Jan 2026 03:20:45 +0000 (13:50 +1030)]
elf_backend_data typedef
"const struct elf_backend_data" appears many places in the source,
and in some cases makes a line too long without wrapping. This patch
introduces a "typedef const struct elf_backend_data elf_backend_data;"
and uses it throughout binutils sources, with a few exceptions for c++
use of header files.
Alan Modra [Sat, 3 Jan 2026 03:13:50 +0000 (13:43 +1030)]
Compact elf_backend_data
* elf-bfd.h (struct elf_backend_data): Make arch, elf_osabi,
elf_machine_code and target_os bitfields, and reorder. Make
maxpagesize, minpagesize, commonpagesize and p_align unsigned
int.
* elfxx-target.h (elfNN_bed): Reorder to suit. Delete useless
comments.
Alan Modra [Sat, 3 Jan 2026 03:12:30 +0000 (13:42 +1030)]
ld/deffilep.y tidies
Formatting. Replace "sizeof (type)" with "sizeof (*varp)" where that
makes sense. Use xcalloc in place of xmalloc+memset. Don't special
case xrealloc of NULL pointer, xrealloc handles that fine.
Tom de Vries [Sat, 3 Jan 2026 15:10:41 +0000 (16:10 +0100)]
[gdb/testsuite] Fix gdb.base/local-env.exp on remote host
With host/target board local-remote-host-native.exp and other remote host
configurations, and test-case gdb.base/local-env.exp I get:
...
(gdb) show environment^M
...
(gdb) FAIL: $exp: show environment displayed variable
...
The test attempt to detect variable GDB_TEST_ENV_VAR in the environment, which
has been set with setenv.
This doesn't work with remote host, so declare the test unsupported. Likewise
in gdb.base/environ.exp.
Tom de Vries [Sat, 3 Jan 2026 15:06:29 +0000 (16:06 +0100)]
[gdb/testsuite] Fix gdb.base/gdb11531.exp with m32 PIE
With test-case gdb.base/gdb11531.exp and target board unix/-m32/-fPIE/-pie I get:
...
(gdb) next^M
34 myrec.x = 5;^M
(gdb) FAIL: gdb.base/gdb11531.exp: watchpoint variable triggers at next
...
For contrast, with target board unix/-m32 I get instead:
...
(gdb) next^M
^M
Hardware watchpoint 2: myrec.x^M
^M
Old value = 0^M
New value = 5^M
main () at /data/vries/gdb/src/gdb/testsuite/gdb.base/gdb11531.c:35^M
35 myrec.y = 3.4;^M
(gdb) PASS: gdb.base/gdb11531.exp: watchpoint variable triggers at next
...
The problem is that the runto_main doesn't set a breakpoint on the same line
in both cases.
Fix this by using runto "$srcfile:34".
[ The underlying problem here is the failure of prologue analysis to deal with
get_pc_thunk. But since there's a PR [1] open about this, and the problem is
unrelated to the test-case, we work around it. ]
Tom de Vries [Sat, 3 Jan 2026 15:04:41 +0000 (16:04 +0100)]
[pre-commit] Move codespell-log back to commit-msg stage
Commit 7acd390ffd9 ("[pre-commit] Move codespell-log to post-commit") moved
the codespell-log hook from the commit-msg to the post-commit stage.
This was deemed to make git rebase too slow [1], so move it back to the
commit-msg stage. Don't do this using a full revert, to keep unrelated
improvements from that commit.
Since we use codespell-log to produce warnings rather than errors, running the
hook at the commit-msg stage requires us to ignore codespell exit status, and
set verbose=true.
Tom de Vries [Sat, 3 Jan 2026 15:01:25 +0000 (16:01 +0100)]
[gdb/testsuite] Fix another timeout in gdb.mi/mi-multi-commands.exp
On aarch64-linux, with a gdb version 16.3 based package, I ran into (edited
for readability):
...
(gdb)
<LOTS-OF-SPACES>-data-evaluate-expression $a
^done,value="\"FIRST COMMAND\""
(gdb) -data-evaluate-expression $b
^done,value="\"TEST COMPLETE\""
(gdb)
PASS: $exp: look for first command output, command length $n
FAIL: $exp: look for second command output, command length $n (timeout)
...
For contrast, a passing example looks like:
...
(gdb)
<LOTS-OF-SPACES>-data-evaluate-expression $a
-data-evaluate-expression $b
^done,value="\"FIRST COMMAND\""
(gdb)
PASS: $exp: look for first command output, command length $n
^done,value="\"TEST COMPLETE\""
(gdb)
PASS: $exp: look for second command output, command length $n
...
The setup is that the test-case issues these two commands at once:
...
-data-evaluate-expression $a
-data-evaluate-expression $b
...
where the length of the first command is artificially increased by prefixing
it with spaces, shown as <LOTS-OF-SPACES> above.
What happens is that gdb, after parsing the first command, executes it, which
generates output and a prompt. Then that prompt intermixes with the echoing
of the second command, and consequently the matching of the prompt fails.
This is very similar to what was fixed in commit 59c9bc5fb6c ("[gdb/testsuite]
Fix timeout in gdb.mi/mi-multi-commands.exp").
Fix this by making the matching of the first prompt optional.
While we're at it, make the test-case more readable using {}, string_to_regexp
and multi_line_input.
Alan Modra [Thu, 1 Jan 2026 21:52:02 +0000 (08:22 +1030)]
Solaris .strtab and .shstrtab flags
These sections have SHF_STRINGS in sh_flags on Solaris. Commit 84865015459b in part implemented this variation by an elf_backend_data
field used to set the flags, but that only works of course if one of
the solaris targets is used. Which in some ways is fair enough. If
you want solaris support then it is reasonable to require the solaris
targets to be compiled in. However if they are not the default, other
ELF targets may be used even when the solaris targets are compiled in,
because many ELF targets allow any ELFOSABI object to match. (Which
is arguably a bug.)
So instead of the current scheme this patch implements the solaris
specific sh_flags in _bfd_elf_final_write_processing. That way either
a solaris target being used, or ELFOSABI_SOLARIS in the object will
get the correct sh_flags.
Alan Modra [Thu, 1 Jan 2026 21:51:31 +0000 (08:21 +1030)]
gas .xstabs missing string results in a segfault
Found by oss-fuzz.
* stabs.c (s_xstab): Check result of demand_copy_C_string.
(s_stab_generic): Remove duplicate warning and ignore_r_o_l
after demand_copy_C_string error.
Alan Modra [Thu, 1 Jan 2026 21:51:16 +0000 (08:21 +1030)]
ld config targ_extra_emuls and targ_extra_libpath
There is no need to duplicate targets in these variables, one or the
other is sufficient. This patch removes such duplication but
otherwise makes no user visible changes. Quite likely some targets
ought to be in targ_extra_emuls rather than targ_extra_libpath.
* configure.tgt: Don't duplicate targ_extra_libpath targets
in targ_extra_emuls, and similarly for targ64 variants.
Alan Modra [Thu, 1 Jan 2026 12:25:19 +0000 (22:55 +1030)]
Update year range in copyright notice of binutils files
Avoid warnings about invalid escapes in etc/update-copyright.py by
using raw strings, add BinutilsFilter to skip psql.rc and add
"Kalray SA." as another copyright holder.
Alice Carlotti [Sat, 27 Dec 2025 18:26:26 +0000 (18:26 +0000)]
aarch64: Remove a space from movaz za operand
The za operands of most movaz instructions were originally printed with
an extra space compared to other za operands. Remove this space, and
reduce code duplication in the process.
Alice Carlotti [Sat, 27 Dec 2025 20:46:25 +0000 (20:46 +0000)]
aarch64: Accept .b/.h/.s in movaz (array to vector)
While the .d form is preferred for disassembly, assemblers should accept
any element size that is used consistently. The sme2_mov class handles
this already for mov instructions, so use that here as well.
Alice Carlotti [Sat, 27 Dec 2025 14:43:40 +0000 (14:43 +0000)]
aarch64: Fix luti2/luti4 decode mask
Neither the opcode mask nor the size determination were checking bit 13,
so some undefined opcodes were being incorrectly disassembled as valid
luti2/luti4 instructions.
Rainer Orth [Mon, 29 Dec 2025 10:16:04 +0000 (11:16 +0100)]
bfd: Re-enable 64-bit support for 32-bit Solaris targets
One of the recent Solaris patches removed want64=true from the 32-bit
Solaris targets. This breaks GCC bootstrap: unlike Linux, GCC on
Solaris is always biarch, both in 32-bit-default and 64-bit-default
configurations, so the 64-bit multilib fails to build.
This patch undoes this incompatible change.
Tested on i386-pc-solaris2.11 and sparc-sun-solaris2.11.
Sivan Shani [Wed, 17 Dec 2025 16:58:52 +0000 (16:58 +0000)]
AArch64: Add FEAT_F16F32MM
This patch includes:
- The feature flag for the FEAT_F16F32MM feature.
- Instruction FMMLA Half-precision matrix multiply-accumulate to single-precision.
Sivan Shani [Wed, 17 Dec 2025 16:36:54 +0000 (16:36 +0000)]
AArch64: Add FEAT_F16F32DOT instructions
This includes the instructions for the F16F32DOT feature:
- FDOT half-precision to single-precision, by element
- FDOT half-precision to single-precision, vector
In addition, new operands:
- OPND_SME_Zmx2_INDEX_22: an operand represents a list of vector registers with an index.
- OPND_SME_Zn7xN_UNTYPED: an operand represents an untyped list of vector registers.
Alan Modra [Fri, 26 Dec 2025 00:26:15 +0000 (10:56 +1030)]
Re: bfd ASSOCIATED_VECS
What I committed in f4e835a40c wasn't wrong but it wasn't elegant.
Unlike looking for a word separated by spaces, it isn't necessary
to prepend and append the separators in the match string.
Alan Modra [Thu, 25 Dec 2025 11:47:10 +0000 (22:17 +1030)]
PR 33726, symbols in excluded sections
This improves "nearby" section choice when memory regions are active,
preferring a section in the same region as the excluded section over
other sections.
The problem lies in existence of "freestanding" code, a code that is
part of a CU but does not have any block associated with it. Consider
following program:
int main(int argc, char **argv) {
return foo(argc);
}
When compiled, the foo function has no block of itself:
Blockvector:
no map
block #000, object at 0x55978957b510, 1 symbols in 0x1129..0x1148
int main(int, char **); block object 0x55978957b380, 0x112d..0x1148 section .text
block #001, object at 0x55978957b470 under 0x55978957b510, 2 symbols in 0x1129..0x1148
typedef int int;
typedef char char;
block #002, object at 0x55978957b380 under 0x55978957b470, 2 symbols in 0x112d..0x1148, function main
int argc; computed at runtime
char **argv; computed at runtime
In this case lookup(0x1129) returns static block and, because of the
change in cc1fc6af4, contains(0x1129) which is wrong.
Such "freestanding" code is perhaps not common but it does exist,
especially in system code. In fact the regressions were at least in part
caused by such "freestanding" code in glibc (libc_sigaction.c).
The whole idea of commit cc1fc6af4 was to handle "holes" in CUs, a case
where one CU spans over multiple disjoint regions, possibly interleaved
with other CUs. Consider somewhat extreme case with two CUs:
This when compiled with a carefully crafted linker script to force code
at certain positions, creates following layout:
0x080000..0x080007 # "freestanding" bar from hole-2.c
0x080008..0x080016 # give_me_zero() from hole-2.c
0x080109..0x080114 # main from hole-1.c
0xf00000..0xf0000b # baz() from hole-2.c
0xf0000b..0xf00011 # "freestanding" foo from hole-2.
0xf0000b..0xf0001c # gice_me_one() from hole-2.
The block vector for hole-1.c looks:
Blockvector:
no map
block #000, object at 0x555a5d85fb90, 1 symbols in 0x80109..0x80114
int main(void); block object 0x555a5d85faa0, 0x80109..0x80114 section .text
block #001, object at 0x555a5d85faf0 under 0x555a5d85fb90, 1 symbols in 0x80109..0x80114
typedef int int;
block #002, object at 0x555a5d85faa0 under 0x555a5d85faf0, 0 symbols in 0x80109..0x80114, function main
block #000, object at 0x555a5d8603b0, 3 symbols in 0x80008..0xf0001d
int give_me_zero(void); block object 0x555a5d85ff50, 0x80008..0x80016 section .text
int give_me_one(void); block object 0x555a5d860110, 0xf00012..0xf0001d section .text
int baz(void); block object 0x555a5d860280, 0xf00000..0xf0000b section .text
block #001, object at 0x555a5d8602d0 under 0x555a5d8603b0, 1 symbols in 0x80008..0xf0001d
typedef int int;
block #002, object at 0x555a5d85ff50 under 0x555a5d8602d0, 0 symbols in 0x80008..0x80016, function give_me_zero
block #003, object at 0x555a5d860280 under 0x555a5d8602d0, 0 symbols in 0xf00000..0xf0000b, function baz
block #004, object at 0x555a5d860110 under 0x555a5d8602d0, 0 symbols in 0xf00012..0xf0001d, function give_me_one
Note that despite the fact "freestanding" bar belongs to hole-2.c, the
corresponding CU's global and static blocks start at 0x80008! Looking
at DWARF for the second program, it looks like that the compiler (GCC 15)
did not record the presence of "freestanding" code:
Thiago suggested to use minsymbols to tell whether or a CU contains
given address. I do not think this would work reliably as minsymbols do
no know to which CU they belong. In slightly more complicated case of
interleaved CUs it does not seem to be possible to tell for sure to which
one a given minsymbol belongs.
Moreover, Tom suggested that the comment in find_compunit_symtab_for_pc_sect
(which led to cc1fc6af4) may be outdated [2].
Indu Bhagat [Wed, 24 Dec 2025 08:59:07 +0000 (00:59 -0800)]
libsframe: refactor out sframe_fre_grow_tbl
Usage of a global int number_of_entries is likely unnecessary. The same
global is used for growing the FDE tbl too, when adding FDEs. At the
moment, however, carve out a new function to grow the FRE table, and
use a macro instead of 'number_of_entries'.
This refactoring helps provide basis for a later patch where we add
SFrame FREs in bulk instead of one at a time to the SFrame encoder
object.
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
libsframe/
* sframe.c (SFRAME_FRE_ALLOC_LEN): New definition.
(sframe_grow_fre_tbl): New definition.
(sframe_encoder_add_fre): Use the new function.
Indu Bhagat [Wed, 24 Dec 2025 08:51:43 +0000 (00:51 -0800)]
libsframe: refactor sframe_decoder_add_funcdesc for internal use
sframe_encoder_add_funcdesc () was added for SFRAME_VERSION_1. This has
since been obsoleted by introduction of SFRAME_VERSION_2 and its
corresponding sframe_decoder_add_funcdesc_v2 API.
Refactor the functionality into an internal-only API:
sframe_encoder_add_funcdesc_internal (). Ensure it returns the error
code for the caller to take necessary action or pass to user.
Keep only two args for sframe_encoder_add_funcdesc: function size and
function start addr. This simple barebone API will be used in a
subsequent commit to adjust the link-time behaviour of SFrame sections.
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
include/
* sframe-api.h (sframe_encoder_add_funcdesc): Remove args to
create the barebone API.
libsframe/
* sframe.c (sframe_encoder_add_funcdesc): Refactor out into
sframe_encoder_add_funcdesc_internal. Change args.
(sframe_encoder_add_funcdesc_v2): Use the new internal API.
* libsframe.ver: Move sframe_encoder_add_funcdesc to 2.1 node.
Indu Bhagat [Wed, 24 Dec 2025 08:44:37 +0000 (00:44 -0800)]
gas: sframe: refactor out the offsets emission code
Minor refactoring. Carve out the SFrame FRE offsets emission code into
a new output_sframe_row_entry_offsets (). This change helps prepare for
later supporting a new FDE type in SFrame V3.
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
gas/
* gen-sframe.c (output_sframe_row_entry_offsets): New
definition.
(output_sframe_row_entry): Use the new definition.
Indu Bhagat [Wed, 24 Dec 2025 08:41:18 +0000 (00:41 -0800)]
include: sframe: add SFRAME_V2_ prefixed macro names for FDE
Such a change for readability only. SFrame V1 is now obsolete, and with
newer versions like V3 or later, its likely better to have macro names
reflect the applicable version.
Add new macro names for FDE information related macros.
Indu Bhagat [Wed, 24 Dec 2025 08:41:02 +0000 (00:41 -0800)]
libsframe: implement an internal-only SFrame FDE representation
Up until now, libsframe has used the same SFrame FDE representation as
the on-disk representation (sframe_func_desc_entry). The choice made by
the author of the library, back when it was first contributed, perhaps
sufficed the needs then. But looking forward, we need to be able to
allow reading and dumping out of not just sections with version
SFRAME_VERSION_2 but also future supported versions.
Note that libsframe did not (and still does not) expose the SFrame FDE
representation in any public APIs; doing so is not recommended.
For the path forward, create an internal-only SFrame FDE representation
(sframe_func_desc_entry_int). libsframe now keeps all in-memory FDEs of
type sframe_func_desc_entry_int. Doing so means instead of memcpy, we
need to resort to member-by-member mapping. This can be seen in
sframe_fde_tbl_init (read time) and the new function
sframe_encoder_write_fde (write time).
Other than that, replace out the previous direct interaction with
on-disk format when:
- flipping SFrame contents before decoding them in sframe_decode.
- flipping SFrame contents before writing them out in sframe_encode.
Indu Bhagat [Tue, 23 Dec 2025 22:59:59 +0000 (14:59 -0800)]
include: gas: bfd: sframe: clean the abstraction
... between specification and implmentation.
Move to definition in the implementation (gas/ld/libsframe) and not the
specification (include/sframe.h). At this time the implementation in
gas and ld generate the sections in the latest SFrame version only.
Indu Bhagat [Tue, 23 Dec 2025 22:59:09 +0000 (14:59 -0800)]
gas: sframe: ignore .cfi_offset for RA selectively
For ABIs not tracking RA (e.g., AMD64), the return address is expected
to be in a specific location (usually a fixed offset from CFA on stack).
Explicit manourvering to a different offset may be non-representable in
SFrame, and should not be simply ignored.
Although such patterns are not usually seen in the wild, it is more
correct to catch them if at all they manifest.
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
gas/
* gen-sframe.c (sframe_xlate_do_offset): Do not ignore
.cfi_offset for RA all the time.
gas: Don't skip SFrame FDE if .cfi_register specifies RA w/o tracking
Do not skip SFrame FDE if .cfi_register specifies RA register without
RA tracking being actually used. Without RA tracking the register
contents can always be restored from the stack using the fixed
RA offset from CFA.
Even for ABI/arch without RA tracking, there may be instances where user
may specify '.cfi_register RA, reg'. This needs to be caught, skipping
this from SFrame generation may not be correct. This may be done in
certain hand-written asm sequences where the user needs to manipulate
the return to a certain function.
No testcase is being added ATM because in SFrame V3, a new FDE type can
be used to represent such cases (A new test case will be added then).
Matthieu Longo [Mon, 22 Dec 2025 15:50:02 +0000 (15:50 +0000)]
gas: add as_info() for informational diagnostics
This patch adds as_info(), a shortened version of as_info_where(),
for emitting informational diagnostics from Gas.
This new helper provides the same formatting and source location
handling as as_info_where(), while offering a simpler interface
for the common case. It respects the --no-info flag, and supports
indentation in the same way as its sibling.
Andrew Burgess [Wed, 15 Nov 2023 16:36:09 +0000 (16:36 +0000)]
gdb: allow 'set args' and run commands to contain newlines
When starting GDB it is possible to set an inferior argument that
contains a newline, for example:
shell> gdb --args my.app "abc
> def"
...
(gdb) show args
Argument list to give program being debugged when it is started is "abc'
'def".
However, once GDB is started, the only way to install an argument
containing a newline is to use the Python API.
This commit changes that.
After this commit 'set args' as well as 'run', 'start', and 'starti',
will now accept multi-line inferior arguments, e.g.:
(gdb) set args "abc
> def"
(gdb) show args
Argument list to give program being debugged when it is started is ""abc
def"".
And also:
(gdb) run "abc
> def"
... etc ...
Once GDB has presented the secondary prompt to gather the remaining
inferior arguments then it is possible for the user to quit argument
entry by sending SIGINT (usually, Ctrl-c), or sending EOF (usually,
Ctrl-d). For the 'set args' case this will abort the argument change,
leaving the arguments as they were previously. For the run style
commands, this aborts the run command completely, the inferior is not
changed, and the partially collected arguments are not installed.
On Unix hosts, arguments can be wrapped with either single or double
quotes, while on MS-Windows hosts, arguments can only be wrapped with
double quotes. This gives the expected behaviour when native
debugging, but isn't entirely accurate. If a user is cross debugging
between Unix and MS-Windows then the host machine will determine which
set of quotes is valid, which will then be incorrect for the actual
target machine. This should probably be fixed in the future, but
isn't something I plan to fix immediately. If this patch is accepted,
then I can create a bug to track this issue.
Reviewed-By: Eli Zaretskii <eliz@gnu.org> Tested-By: Guinevere Larsen <guinevere@redhat.com>
Matthieu Longo [Mon, 22 Dec 2025 14:25:35 +0000 (14:25 +0000)]
loongarch: add back support for object attributes v1
A previous commit [1] mistakenly removed support for Object Attributes
for LoongArch targets.
This patch adds back the OA feature into Gas for the LoongArch targets
following the new approach which consists in:
- defining TC_OBJ_ATTR to 1 in tc-loongarch.h
- enabling the compilation of obj-elf-attr.c in gas/configure.ac
Tom Tromey [Fri, 5 Dec 2025 21:09:42 +0000 (14:09 -0700)]
Use gdb_bfd_sections in more places
I found a few spots still iterating over sections using "->next", and
thought it would be a little cleaner to use gdb_bfd_sections instead.
In one spot the loop indentation turned out to be wrong as well.
Tom Tromey [Sun, 21 Dec 2025 19:10:36 +0000 (12:10 -0700)]
Remove rust_parser::get_string
Now that struct stoken has been replaced with string_view,
rust_parser::get_string doesn't provide much value. In some places it
can even be replaced with a direct use of the string_view.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Tom Tromey [Fri, 19 Dec 2025 14:33:30 +0000 (07:33 -0700)]
Don't use stoken in rust-parse.c
I wanted to change rust-parse.c to use string_view and not stoken.
This was simple enough, but it seemed good to also change
parser_state::push_dollar to use string_view; and as it turned out,
this simplified the code a little.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Tom Tromey [Fri, 19 Dec 2025 14:40:05 +0000 (07:40 -0700)]
Use string_view in user_reg_map_name_to_regnum
This changes user_reg_map_name_to_regnum to use std::string_view.
This pointed out some dead code in that function: the "len < 0" test
in the loop can never be true, because earlier code changes 'len' in
this case.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Tom Tromey [Mon, 22 Dec 2025 17:55:07 +0000 (10:55 -0700)]
Fix --help output
In commit 9e69a2e127940cc5, which introduced "command" styling, I
accidentally made gdb's --help output mention the "stream" command,
rather than the "help" command.
While doing this I also found a spot where --help output was
incorrectly formatted. This patch fixes this as well.
I'm going to backport this to the gdb-17 branch as well.
Guinevere Larsen [Thu, 23 Oct 2025 19:29:13 +0000 (16:29 -0300)]
gdb/reverse: force direction to forward when stopping record
If a user had set the execution direction to reverse, and then they use
the command "record stop", the execution direction will be cached as
reversed, which will affect some warning messages, and can confuse
users.
This commit fixes this by forcing the execution direction to "forward"
when the command "record stop" is executed.
Hannes Domani [Mon, 22 Dec 2025 11:26:51 +0000 (12:26 +0100)]
Fix crash when breakpoint condition causes inferior exit
When using a breakpoint condition that causes an inferior exit, gdb
crashes with a null pointer access:
(gdb) b main if callexit()
Breakpoint 1 at 0x114b: file callexit.c, line 32.
(gdb) r
Starting program: /home/src/lappy/binutils-gdb.git/gdb/testsuite/gdb.base/callexit
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/../lib/libthread_db.so.1".
[Inferior 1 (process 218586) exited normally]
../../gdb/infcall.c:895:50: runtime error: member call on null pointer of type 'struct thread_fsm'
../../gdb/infcall.c:895:50: runtime error: member access within null pointer of type 'struct thread_fsm'
Fix this by checking the thread_fsm pointer beforehand, now the result
looks like this:
(gdb) b main if callexit()
Breakpoint 1 at 0x114b: file callexit.c, line 32.
(gdb) r
Starting program: /home/src/lappy/binutils-gdb.git/gdb/testsuite/gdb.base/callexit
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/../lib/libthread_db.so.1".
[Inferior 1 (process 220707) exited normally]
❌ Error in testing condition for breakpoint 1:
The program being debugged exited while in a function called from GDB.
Evaluation of the expression containing the function
(callexit) will be abandoned.
❌ No registers.
(gdb)
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16156 Approved-By: Andrew Burgess <aburgess@redhat.com>
Hannes Domani [Mon, 22 Dec 2025 11:06:43 +0000 (12:06 +0100)]
Fix crash if breakpoint commands contain detach or kill
If breakpoint commands contain detach or kill, then gdb tries to access
freed memory:
(gdb) b main
Breakpoint 1 at 0x111d: file main.c, line 21.
(gdb) commands
Type commands for breakpoint(s) 1, one per line.
End with a line saying just "end".
>detach
>end
(gdb) run
Starting program: /home/src/lappy/binutils-gdb.git/gdb/testsuite/gdb.base/main
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/../lib/libthread_db.so.1".
main () at main.c:21
21 return 0;
[Inferior 1 (process 241852) detached]
=================================================================
==241817==ERROR: AddressSanitizer: heap-use-after-free on address 0x7b7a3de0b760 at pc 0x55fcb92613fe bp 0x7ffec2d524f0 sp 0x7ffec2d524e0
READ of size 8 at 0x7b7a3de0b760 thread T0
#0 0x55fcb92613fd in bpstat_do_actions_1 ../../gdb/breakpoint.c:4898
#1 0x55fcb92617da in bpstat_do_actions() ../../gdb/breakpoint.c:5012
#2 0x55fcba3180e7 in inferior_event_handler(inferior_event_type) ../../gdb/inf-loop.c:71
#3 0x55fcba3ba1e1 in fetch_inferior_event() ../../gdb/infrun.c:4769
0x7b7a3de0b760 is located 0 bytes inside of 56-byte region [0x7b7a3de0b760,0x7b7a3de0b798)
freed by thread T0 here:
#0 0x7f1a43522a2d in operator delete(void*, unsigned long) /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_new_delete.cpp:155
#1 0x55fcb925d5cd in bpstat_clear(bpstat**) ../../gdb/breakpoint.c:4646
#2 0x55fcbb69ea6a in clear_thread_inferior_resources ../../gdb/thread.c:185
#3 0x55fcbb69f4cb in set_thread_exited(thread_info*, std::optional<unsigned long>, bool) ../../gdb/thread.c:244
#4 0x55fcba368d64 in operator() ../../gdb/inferior.c:269
#5 0x55fcba375e2b in clear_and_dispose<inferior::clear_thread_list()::<lambda(thread_info*)> > ../../gdb/../gdbsupport/intrusive_list.h:529
#6 0x55fcba368f19 in inferior::clear_thread_list() ../../gdb/inferior.c:265
#7 0x55fcba3694ba in exit_inferior(inferior*) ../../gdb/inferior.c:322
#8 0x55fcba369e35 in detach_inferior(inferior*) ../../gdb/inferior.c:358
#9 0x55fcba319d9f in inf_ptrace_target::detach_success(inferior*) ../../gdb/inf-ptrace.c:214
#10 0x55fcba56a2f6 in linux_nat_target::detach(inferior*, int) ../../gdb/linux-nat.c:1582
#11 0x55fcba62121c in thread_db_target::detach(inferior*, int) ../../gdb/linux-thread-db.c:1381
#12 0x55fcbb5ca49e in target_detach(inferior*, int) ../../gdb/target.c:2557
#13 0x55fcba356ba4 in detach_command(char const*, int) ../../gdb/infcmd.c:2894
#14 0x55fcb9597eea in do_simple_func ../../gdb/cli/cli-decode.c:94
#15 0x55fcb95b10b5 in cmd_func(cmd_list_element*, char const*, int) ../../gdb/cli/cli-decode.c:2831
#16 0x55fcbb6f5282 in execute_command(char const*, int) ../../gdb/top.c:563
#17 0x55fcb95eedb9 in execute_control_command_1 ../../gdb/cli/cli-script.c:526
#18 0x55fcb95f04dd in execute_control_command(command_line*, int) ../../gdb/cli/cli-script.c:702
#19 0x55fcb9261175 in bpstat_do_actions_1 ../../gdb/breakpoint.c:4940
#20 0x55fcb92617da in bpstat_do_actions() ../../gdb/breakpoint.c:5012
#21 0x55fcba3180e7 in inferior_event_handler(inferior_event_type) ../../gdb/inf-loop.c:71
#22 0x55fcba3ba1e1 in fetch_inferior_event() ../../gdb/infrun.c:4769
previously allocated by thread T0 here:
#0 0x7f1a435218cd in operator new(unsigned long) /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_new_delete.cpp:86
#1 0x55fcb927061f in build_bpstat_chain(address_space const*, unsigned long, target_waitstatus const&) ../../gdb/breakpoint.c:5880
#2 0x55fcba3d63b6 in handle_signal_stop ../../gdb/infrun.c:7083
#3 0x55fcba3d01c7 in handle_inferior_event ../../gdb/infrun.c:6574
#4 0x55fcba3b9918 in fetch_inferior_event() ../../gdb/infrun.c:4713
This checks after executing commands of each breakpoint if the bpstat
was deleted already, and stops any further processing immediately.
Now the result looks like this:
(gdb) b main
Breakpoint 1 at 0x111d: file main.c, line 21.
(gdb) commands
Type commands for breakpoint(s) 1, one per line.
End with a line saying just "end".
>detach
>end
(gdb) run
Starting program: /home/src/lappy/binutils-gdb.git/gdb/testsuite/gdb.base/main
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/../lib/libthread_db.so.1".
main () at main.c:21
21 return 0;
[Inferior 1 (process 242940) detached]
(gdb)
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=14354 Approved-By: Andrew Burgess <aburgess@redhat.com>
Jan Beulich [Mon, 22 Dec 2025 10:06:59 +0000 (11:06 +0100)]
gas: stub out sframe-opt.c functions when SFrame is not supported
Much like everything in gen-sframe.c, these functions are supposed to
never be reached when SFrame isn't supported by a target. Adding
respective assertions reduces code size for such targets, while at the
same time adding consistency checking for targets which optionally
support the feature.
Jan Beulich [Mon, 22 Dec 2025 10:06:35 +0000 (11:06 +0100)]
gas/x86: reduce / correct target checks for --64 command line option
First, pei-x86-64 is meaningless for gas; it's a linker output target, not
one object files would use. Next, coff-x86-64 is meaningless for TE_PE
(and really coff-x86-64 isn't currently provided by any libbfd
configuration anyway). Then, of the three ones left exactly one is a
possible candidate for a given gas configuration. Checking others as well
would only lead to (possibly cryptic) errors later. And finally, even for
ELF we want to check for the one target which i386_target_format() would
also use. This last aspect then applies to --x32 handling as well (just
that there it's benign right now, as only one target exists starting
"elf32-x86-64".
Alan Modra [Sat, 20 Dec 2025 03:49:50 +0000 (14:19 +1030)]
Add back non-solaris ELF targets to solaris config
This reverses some of the changes made in config.bfd for PR 27666.
Removing targets for that PR was really just a workaround, and since
the underlying bug is now fixed they can be added back.
I chose to add the non-solaris ELF targets to the linker config using
targ_extra_emuls rather than targ_extra_libpath because someone using
the elf32_sparc emulation probably doesn't want to pick up solaris
libraries by accident.
PR 33374
bfd/
* config.bfd: Remove pr27666 comments. Add back non-solaris
ELF targets to selvecs for solaris targets.
ld/
* configure.tgt: Adjust solaris targets to suit config.bfd
change.