]> git.feebdaed.xyz Git - 0xmirror/binutils-gdb.git/log
0xmirror/binutils-gdb.git
9 days agogdb, btrace: fix assert with gcc-15
Markus Metzger [Wed, 17 Dec 2025 05:34:09 +0000 (05:34 +0000)]
gdb, btrace: fix assert with gcc-15

This fixes

/usr/include/c++/15/optional:1186: constexpr _Tp& std::optional<_Tp>::operator*() & [with _Tp = std::__cxx11::basic_string<char>]: Assertion 'this->_M_is_engaged()' failed.

encountered in gdb.btrace/ptwrite.exp.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
9 days agoAutomatic date update in version.in
GDB Administrator [Thu, 18 Dec 2025 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

10 days agogdb: replace msym_bunch with deque
Simon Marchi [Wed, 17 Dec 2025 04:31:39 +0000 (23:31 -0500)]
gdb: replace msym_bunch with deque

This patch replaces the msym_bunch implementation with an std::deque.

I initially tried to replace it with a vector.  However, that doesn't
work, because minimal_symbol references need to stay valid across calls
to minimal_symbol_reader::record_full in at least one spot.
elf_symtab_read calls minimal_symbol_reader::record_full (through
function record_minimal_symbol) to record a minimal symbol for a PLT
entry and then uses a previously added minimal symbol to set the size of
the PLT minimal symbol.  If we used a vector, a re-allocation could
happen which would invalidate the reference to the previous minimal
symbol (luckily this was caught by ASan).

An std::deque implementation typically uses a sequence of fixed-sized
arrays, much like our current msym_bunch implementation.  So adding an
item at the end will not invalidate existing references.  But unlike our
msym_bunch, we don't have to worry about memory management.

I was a bit puzzled about this code in
minimal_symbol_reader::record_full:

  /* If we already read minimal symbols for this objfile, then don't
     ever allocate a new one.  */
  if (!m_objfile->per_bfd->minsyms_read)
    {
      m_msym_bunch_index++;
      m_objfile->per_bfd->n_minsyms++;
    }

From what I understand, this "feature" gets used when you have
ECOFF debug info in an ELF executable.  We first parse the ELF minimal
symbols in elf_symfile_read, then go into elfmdebug_build_psymtabs.
elfmdebug_build_psymtabs has the capability to generate minimal symbols
(useful when you use ECOFF debug info in an ECOFF executable I guess),
but in this case we already have the ELF ones, so we don't want to
record the ECOFF minimal symbols.  Hence this mechanism to suppress new
minimal symbols.

The consequence of this patch, I believe, is that
minimal_symbol_reader::record_full will unnecessarily allocate minimal
symbols in this case.  These minimal symbols won't be installed, because
of the check in minimal_symbol_reader::install.  The minimal symbols
will be freed when the minimal_symbol_reader gets destroyed.  That means
a higher temporary memory usage when reading an ECOFF-in-ELF file, but
no change in behavior.  See discussion at [1].

[1] https://inbox.sourceware.org/gdb-patches/85958fad-17e1-4593-b842-d60a6610f149@polymtl.ca/T/#meaf9b53da296e7f6872b441ec97038d172ca907f

Change-Id: I7d10c6aca42cc9dcf80b483394e1e56351a9465f
Approved-By: Tom Tromey <tom@tromey.com>
10 days ago[gdb/contrib] Add tcllint->tclint in codespell-dictionary.txt
Tom de Vries [Wed, 17 Dec 2025 16:27:00 +0000 (17:27 +0100)]
[gdb/contrib] Add tcllint->tclint in codespell-dictionary.txt

Confusingly, the Tcl linter we're using is called tclint instead of tcllint.

Add a corresponding entry in gdb/contrib/codespell-dictionary.txt.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
10 days agogdb: improve line number lookup around inline functions
Andrew Burgess [Fri, 26 Jul 2024 15:32:33 +0000 (16:32 +0100)]
gdb: improve line number lookup around inline functions

This commit aims to fix an issue where GDB would report the wrong line
for frames other than #0 if a previous frame had just left an inline
function.

Consider this example which is compiled at -Og:

  volatile int global = 0;

  static inline int bar (void) { asm (""); return 1; }

  static void foo (int count)
  { global += count; }

  int main (void)
  {
    foo (bar ());
    return 0;
  }

Used in this GDB session:

  (gdb) break foo
  Breakpoint 1 at 0x401106: file test.c, line 6.
  (gdb) run
  Starting program: /tmp/inline-bt/test.x

  Breakpoint 1, foo (count=count@entry=1) at test.c:6
  6 { global += count; }
  (gdb) frame 1
  #1  0x0000000000401121 in main () at test.c:3
  3 static inline int bar (void) { asm (""); return 1; }

Notice that GDB incorrectly reports frame #1 as being at line 3 when
it should really be reporting this line:

  foo (bar ());

The cause of this problem is in find_pc_sect_line (symtab.c).  This
function is passed a PC for which GDB must find the symtab_and_line
information.  The function can be called in two modes based on the
NOTCURRENT argument.

When NOTCURRENT is false then we are looking for information about the
current PC, i.e. the PC at which the inferior is currently stopped
at.

When NOTCURRENT is true we are looking for information about a PC that
it not the current PC, but is instead the PC for a previous frame.
The interesting thing in this case is that the PC passed in will be
the address after the address we actually want to lookup information
for, this is because as we unwind the program counter from frame #0
what we get is the return address in frame #1.  The return address is
often (or sometimes) on the line after the calling line, and so in
find_pc_sect_line, when NOTCURRENT is true, we subtract 1 from PC and
then proceed as normal looking for information about this new PC
value.

Now lets look at the x86-64 disassembly for 'main' from the above
example.  The location marker (=>) represents the return address in
'main' after calling 'foo':

  (gdb) run
  Starting program: /tmp/inline-bt/test.x

  Breakpoint 1, foo (count=count@entry=1) at test.c:6
  6 { global += count; }
  #0  foo (count=count@entry=1) at test.c:6
  #1  0x000000000040111f in main () at test.c:3
  (gdb) up
  #1  0x000000000040111f in main () at test.c:3
  3 static inline int bar (void) { asm (""); return 1; }
  (gdb) disassemble
  Dump of assembler code for function main:
     0x0000000000401115 <+0>: mov    $0x1,%edi
     0x000000000040111a <+5>: call   0x401106 <foo>
  => 0x000000000040111f <+10>: mov    $0x0,%eax
     0x0000000000401124 <+15>: ret
  End of assembler dump.

And the corresponding line table:

  (gdb) maintenance info line-table
  objfile: /tmp/inline-bt/test.x ((struct objfile *) 0x59405a0)
  compunit_symtab: test.c ((struct compunit_symtab *) 0x53ad320)
  symtab: /tmp/inline-bt/test.c ((struct symtab *) 0x53ad3a0)
  linetable: ((struct linetable *) 0x53adc90):
  INDEX  LINE   REL-ADDRESS        UNREL-ADDRESS      IS-STMT PROLOGUE-END EPILOGUE-BEGIN
  0      6      0x0000000000401106 0x0000000000401106 Y
  1      6      0x0000000000401106 0x0000000000401106 Y
  2      6      0x0000000000401106 0x0000000000401106
  3      6      0x0000000000401114 0x0000000000401114
  4      9      0x0000000000401115 0x0000000000401115 Y
  5      10     0x0000000000401115 0x0000000000401115 Y
  6      3      0x0000000000401115 0x0000000000401115 Y
  7      3      0x0000000000401115 0x0000000000401115 Y
  8      3      0x0000000000401115 0x0000000000401115 Y
  9      10     0x0000000000401115 0x0000000000401115
  10     11     0x000000000040111f 0x000000000040111f Y
  11     12     0x000000000040111f 0x000000000040111f
  12     END    0x0000000000401125 0x0000000000401125 Y

When looking for the line information of frame #1 we start with the
return address 0x40111f, however, as this is not the current program
counter value we subtract one and look for line information for
0x40111e.

We will find the entry at index 9, this is the last entry with an
address less than the address we're looking for, the next entry has an
address greater than the one we're looking for.  The entry at index 9
is for line 10 which is the correct line, but GDB reports line 3, so
what's going on?

Having found a matching entry GDB checks to see if the entry is marked
as is-stmt (is statement).  In our case index 9 (line 10) is not a
statement, and so GDB looks backwards for entries at the same address,
if any of these are marked is-stmt then GDB will use the last of these
instead.  In our case the previous entry at index 8 is marked is-stmt,
and so GDB uses that.  The entry at index 8 is for line 3, and that is
why GDB reports the wrong line.  So why perform the backward is-stmt
check?

When NOTCURRENT is false (not our case) the backward scan makes
sense.  If the inferior has just stopped at some new location, and we
want to report that location to the user, then it is better (I think)
to select an is-stmt entry.  In this way we will report a line number
for a line which the inferior is just about to start executing, and
non of the side effects of that line have yet taken place.  The line
GDB prints will correspond with the reported line, and if the user
queries the inferior state, the inferior should (assuming the compiler
emitted correct is-stmt markers) correspond to the line in question
having not yet been started.

However, in our case NOTCURRENT is true.  We're looking back to
previous frames that are currently in-progress.  If upon return to the
previous frame we are about to execute the next line then (it seems to
me) that this indicates we must be performing the very last action
from the previous line.  As such, looking back through the line table
in order to report a line that has not yet started is the wrong thing
to do.  We really want to report the very last line table entry for
the previous address as this is (I think) most likely to represent the
previous line that is just about to complete.

Further, in the NOTCURRENT case, we should care less about reporting
an is-stmt line.  When a user looks back to a previous frame I don't
think they expect the line being reported to have not yet started.  In
fact I think the expectation is the reverse ... after all, the
previous line must have executed enough to call the current frame.

So my proposal is that the backward scan of the line table looking for
an is-stmt entry should not be performed when NOTCURRENT is true.  In
the case above this means we will report the entry at index 9, which
is for line 10, which is correct.

For testing this commit I have:

 1. Extended the existing gdb.opt/inline-bt.exp test.  I've extended
 the source code to include a test similar to the example above.  I
 have also extended the script so that the test is compiled at a
 variety of optimisation levels (O0, Og, O1, O2).

 2. Added a new DWARF assembler test which hard codes a line table
 similar to the example given above.  My hope is that even if test
 case (1) changes (due to compiler changes) this test will continue to
 test the specific case I'm interested in.

I have tested the gdb.opt/inline-bt.exp test with gcc versions 8.4.0,
9.3.1, 10.5.0, 11.5.0, 12.2.0, and 14.2.0, in each case the test will
fail (with the expected error) without this patch applied, and will
pass with this patch applied.

I was inspired to write this patch while reviewing these patches:

  https://inbox.sourceware.org/gdb-patches/AS8P193MB1285C58F6F09502252CEC16FE4DF2@AS8P193MB1285.EURP193.PROD.OUTLOOK.COM
  https://inbox.sourceware.org/gdb-patches/AS8P193MB12855708DFF59A5309F5B19EE4DF2@AS8P193MB1285.EURP193.PROD.OUTLOOK.COM

though this patch only covers one of the issues addressed by these
patches, and the approach taken is quite different.  Still, those
patches are worth reading for the history of this fix.

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

Approved-By: Tom Tromey <tom@tromey.com>
10 days agoMinor test fix for gnat-llvm
Tom Tromey [Tue, 16 Dec 2025 21:34:30 +0000 (14:34 -0700)]
Minor test fix for gnat-llvm

This patch fixes a spot in the gdb test suite where gnat-llvm seems to
emit slightly better DWARF than GNAT.

10 days agobfd/ELF: Handle prstatus of 156 bytes in elf32_arm_nabi_grok_prstatus
Tom de Vries [Wed, 17 Dec 2025 14:04:21 +0000 (15:04 +0100)]
bfd/ELF: Handle prstatus of 156 bytes in elf32_arm_nabi_grok_prstatus

For a corefile generated on openSUSE Leap 15.2 armv7l with linux version
5.3.18, we get:
...
$ gdb -q --core core
  ...
Core was generated by `/usr/bin/rs_scope -d'.

⚠️ warning: Couldn't find general-purpose registers in core file.
(gdb)
...

The warning is emitted because the pseudo-section .reg is missing, because
elf32_arm_nabi_grok_prstatus expects the PRSTATUS note to have size 148, but
instead we have:
...
$ eu-readelf -n core | grep -i prstatus
  CORE                 156  PRSTATUS
  CORE                 156  PRSTATUS
  CORE                 156  PRSTATUS
  CORE                 156  PRSTATUS
...

This is a bug for CONFIG_BINFMT_ELF_FDPIC=y configurations, fixed
by v5.9 linux kernel commit 16aead81018c ("take fdpic-related parts of
elf_prstatus out").

The bug causes the FDPIC-specific unsigned long fields pr_exec_fdpic_loadmap
and pr_interp_fdpic_loadmap to be added to struct elf_prstatus in case the
FDPIC ABI is not used.

Work around this bug in elf32_arm_nabi_grok_prstatus, by ignoring the extra
fields, which gets us instead:
...
Core was generated by `/usr/bin/rs_scope -d'.
Program terminated with signal SIGSEGV, Segmentation fault.
[Current thread is 1 (LWP 30047)]
(gdb)
...

Tested gdb, gas, binutils and ld on x86_64-linux and arm-linux with
--enable-targets=all.

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

10 days ago[gdb] Fix style.indent in tclint.toml
Tom de Vries [Wed, 17 Dec 2025 13:57:42 +0000 (14:57 +0100)]
[gdb] Fix style.indent in tclint.toml

The style.indent setting in gdb/tclint.toml is set to 4 spaces, which is an
approximation.

Starting with v0.6.2, tclfmt supports setting style.indent to mixed,<s>,<t>,
which allows us to specify the actual indentation scheme.

Set style.indent to mixed,4,8.

PR testsuite/33724
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33724

10 days agogdb: remove unused includes from valops.c
Simon Marchi [Wed, 17 Dec 2025 04:14:48 +0000 (23:14 -0500)]
gdb: remove unused includes from valops.c

clangd says they are unused.

Change-Id: I17362d38eabf7b93a311265ba7497560592faa94

10 days agogdb: remove unused include from gdbtypes.c
Simon Marchi [Wed, 17 Dec 2025 01:43:19 +0000 (20:43 -0500)]
gdb: remove unused include from gdbtypes.c

clangd says it's not used.

Change-Id: I49ae57264599b490c3fe4c61c05a11e7c0891056

10 days agoAutomatic date update in version.in
GDB Administrator [Wed, 17 Dec 2025 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

11 days agoPR 33721 load/store of misaligned address
Alan Modra [Tue, 16 Dec 2025 21:30:24 +0000 (08:00 +1030)]
PR 33721 load/store of misaligned address

This fixes PR33721 by a common technique of declaring a packed struct
to access unaligned integer fields.  (See eg. linux kernel
include/vdso/unaligned.h)  I've tidied the PR29856 fix for a similar
bug too (not that there was anything wrong with that fix).

PR 33721
PR 29856
* sframe.c (flip_fre_start_address): Use a packed struct to
access 2-byte and 4-byte unaligned fields.  Make addr a void*.
(sframe_decode_fre_start_address): Similarly, and remove
unnecessary casts.  Always set *fre_start_addr.

11 days agomore solaris tidies
Alan Modra [Tue, 16 Dec 2025 21:22:06 +0000 (07:52 +1030)]
more solaris tidies

Don't overspecify the obsolete solaris targets: match solaris* rather
than solaris2.[0-9]*.  Move the sparc-*-solaris2.[0-6]* match later,
and make it sparc*-*-solaris* so that it catches sparcv9 and sparc64.
This change is necessary for internal binutils consistency so that
selecting --target=sparc-sun-solaris2 gets an error that the target is
obsolete, and furthermore that the same target with --enable-obsolete
does not result in runtime errors.

bfd/
* config.bfd: Don't overspecify obsolete solaris targets.
ld/
* configure.tgt: Don't overspecify obsolete solaris targets.
* po/BLD-POTFILES.in: Regenerate.

11 days ago[gdb/testsuite] Fix gdb.cp/typeid.exp with m32 PIE
Tom de Vries [Tue, 16 Dec 2025 20:10:11 +0000 (21:10 +0100)]
[gdb/testsuite] Fix gdb.cp/typeid.exp with m32 PIE

On x86_64-linux, if I run test-case gdb.cp/typeid.exp with target boards:
- unix/-m64
- unix/-m32
- unix/-fPIE/-pie/-m64
- unix/-fPIE/-pie/-m32
for only target board unix/-fPIE/-pie/-m32 I get:
...
(gdb) print &typeid(i)^M
could not find typeinfo symbol for 'int'^M
(gdb) FAIL: gdb.cp/typeid.exp: before starting: print &typeid(i)
print &typeid(i) == &typeid(typeof(i))^M
could not find typeinfo symbol for 'int'^M
(gdb) FAIL: gdb.cp/typeid.exp: before starting: print &typeid(i) == &typeid(typeof(i))
print &typeid(cp)^M
could not find typeinfo symbol for 'char*'^M
(gdb) FAIL: gdb.cp/typeid.exp: before starting: print &typeid(cp)
print &typeid(cp) == &typeid(typeof(cp))^M
could not find typeinfo symbol for 'char*'^M
(gdb) FAIL: gdb.cp/typeid.exp: before starting: print &typeid(cp) == &typeid(typeof(cp))
print &typeid(ccp)^M
could not find typeinfo symbol for 'char const*'^M
(gdb) FAIL: gdb.cp/typeid.exp: before starting: print &typeid(ccp)
print &typeid(ccp) == &typeid(typeof(ccp))^M
could not find typeinfo symbol for 'char const*'^M
(gdb) FAIL: gdb.cp/typeid.exp: before starting: print &typeid(ccp) == &typeid(typeof(ccp))
...

This is yet another configuration for which these tests don't work.

We're already allowing this for clang and istarget "powerpc*-*-*".

I don't think there is value in trying to detect yet another configuration.

Instead, just allow it in general.

Tested on x86_64-linux.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
11 days agogas: sframe: fix memory leak of remember_fre
Indu Bhagat [Tue, 16 Dec 2025 19:54:07 +0000 (11:54 -0800)]
gas: sframe: fix memory leak of remember_fre

While at it, use the same pattern for cleaning up memory in
sframe_xlate_ctx_cleanup.

gas/
* gen-sframe.c (sframe_xlate_ctx_cleanup): Use the same pattern
for free'ing memory consistently.
(sframe_xlate_ctx_finalize): Free up remember_fre.

11 days agogdb: trivial cleanups in minimal_symbol_is_less_than
Simon Marchi [Tue, 1 Apr 2025 02:58:47 +0000 (22:58 -0400)]
gdb: trivial cleanups in minimal_symbol_is_less_than

Remove unnecessary braces.

Replace `&` + `->` with `.`.

Remove the trivial comments that just explain how the comparison
operators work in C.

Change-Id: Id77ae534c90219e2c02332ff5606c54d00286eca

11 days agoUntabify gdb 'help' output
Tom Tromey [Fri, 12 Dec 2025 19:09:56 +0000 (12:09 -0700)]
Untabify gdb 'help' output

This changes the gdb 'help' command to untabify its output.  This lets
us fix the last couple of warnings from the whitespace checker.

Regression tested on x86-64 Fedora 41.

Approved-By: Andrew Burgess <aburgess@redhat.com>
11 days agogdb: shortcut 'list LINENO'
Andrew Burgess [Sat, 15 Nov 2025 14:55:19 +0000 (14:55 +0000)]
gdb: shortcut 'list LINENO'

While working on a test for a weird interaction between the DWARF
parser, debuginfod, and the 'list' command, I noticed that performing
'list LINENO' can incur a significant amount of work trying to figure
out which symtab the source should be listed from.  This seems a
little weird as a plain 'list' just uses the default symtab with no
searching through all of the symtabs.

The symtab lookup is all hidden behind the decode_line_1 call, which
is made from list_command (cli/cli-cmds.c).

The thing is, in list_command we already have code which (basically)
checks if the argument to 'list' is a line number, here's the code:

  for (p = arg; p != arg1 && *p >= '0' && *p <= '9'; p++);
  linenum_beg = (p == arg1);

And we already have code within list_command which depends on the
default symtab, look at how 'list .', 'list +', and 'list -' are
handled.

I think that 'list LINENO' is such a common use case that is makes
sense to optimise this case in order to avoid the need to perform
symtab lookup.  I think this can be achieved without any significant
changes to the list_command function; we'll just move the existing
line number check (see above code) a little earlier in the function
and change it to a strtol call so that the actual line number is
recorded.  Then there's a little error checking, before finally we can
skip straight to listing the source code using the default symtab.

For anything other than 'list LINENO' we will handle the command just
as we've always done.

I think there's actually scope for list_command to handle more cases
internally, without calling out to decode_line_1, but I thought I'd
see how happy people were with this smaller change first before I
tried anything larger.

There should be no user visible changes after this commit, other than
'list LINENO' might be a little faster.

Reviewed-By: Keith Seitz <keiths@redhat.com>
11 days agogdb: minor code cleanups in list_command
Andrew Burgess [Sat, 15 Nov 2025 14:17:01 +0000 (14:17 +0000)]
gdb: minor code cleanups in list_command

There should be no functional change after this commit, this is mostly
just a code cleanup in the list_command function.

I have inlined local variables into the function body, changing 'int'
to 'bool' where appropriate, and updating 'if' conditions to avoid
treating non-bools as a bool.

I also make more use of list_around_line towards the end of the
list_command function, which avoids some code duplication, but
shouldn't be a functional change.

Reviewed-By: Keith Seitz <keiths@redhat.com>
11 days ago[gdb] Fix "the the"
Tom de Vries [Tue, 16 Dec 2025 15:20:22 +0000 (16:20 +0100)]
[gdb] Fix "the the"

Replace "the the" with "the".

Result of running:
...
$ find gdb* -type f | egrep -v ChangeLog | xargs sed -i 's/the the /the /'
$ find gdb* -type f | egrep -v ChangeLog | xargs sed -i 's/the the$/the/'
...

The only change I have doubts about, is this comment in queue_comp_unit in
gdb/dwarf2/read.c:
...
    ... .  If the CU gets enqueued by this function but its DIEs
-   are not yet loaded, the the caller must load the CU's DIEs to ensure the
+   are not yet loaded, the caller must load the CU's DIEs to ensure the
    invariant is respected.
...
where I think "the the" -> "then the" also make sense.  But for now, I'm going
with "the the" -> "the".

Tested by building gdb on x86_64-linux.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
11 days agogdb: fix crash from 'shell' when GDB has no terminal
Andrew Burgess [Fri, 12 Dec 2025 11:27:53 +0000 (11:27 +0000)]
gdb: fix crash from 'shell' when GDB has no terminal

Bug PR gdb/33716 identifies a problem where GDB will crash when using
the 'shell' command if GDB is not attached to a terminal.  E.g.:

  $ gdb -nw -nh -q -batch -ex 'shell echo hello' </dev/null
  hello

  Fatal signal: Segmentation fault
  ----- Backtrace -----
  ... etc ...

This problem was introduced with commit:

  commit 3a7f7d0be3a2953fd110f084b34586ce9c649d66
  Date:   Fri Jul 25 19:07:59 2025 +0200

      [gdb/tui] Fix shell command terminal settings

This commit introduces 'class scoped_gdb_ttystate', a RAII class which
backs up and restores the current terminal state.  Unfortunately, the
implementation tries to backup and restore the state even when GDB is
not attached to a terminal.

If GDB is not attached to a terminal then serial_get_tty_state
will (on a Unix like system) return a NULL pointer.  Calling
serial_set_tty_state with a NULL state object will trigger the crash
seen above.

Elsewhere in GDB, calling serial_set_tty_state is guarded by calling
gdb_has_a_terminal().  I propose that we only try to backup the
terminal state if GDB is actually connected to a terminal.  The call
to serial_set_tty_state will only be made if the backed up tty state
is not NULL.

With this change in place the crash is resolved.  There's a new test
to cover this case.

While I'm here I added a gdb_assert in ser-unix.c which would have
triggered in this case before we saw the crash.  And I've extended the
comment in serial.h to document that serial_get_tty_state can return
NULL.

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

Approved-By: Simon Marchi <simon.marchi@efficios.com>
11 days agogdb: rename scoped_gdb_tty_state, and make it non-copyable
Andrew Burgess [Sat, 13 Dec 2025 08:36:01 +0000 (08:36 +0000)]
gdb: rename scoped_gdb_tty_state, and make it non-copyable

The scoped_gdb_tty_state class seems misnamed.  For save/restore type
classes the pattern in GDB is usually scoped_restore_<whatever>, so
lets rename this to scoped_restore_tty_state.  I dropped the 'gdb' part
of the name as the underlying functions being called are
serial_get_tty_state and serial_set_tty_state, so the new name
matches (I think) what's actually being called.

I've also made the class non-copyable like other scoped_restore_
classes.

There should be no user visible changes after this commit.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
11 days agogdb/doc: fix incorrect use of @value
Andrew Burgess [Tue, 16 Dec 2025 10:00:38 +0000 (10:00 +0000)]
gdb/doc: fix incorrect use of @value

In commit:

  commit 255a9c42709958d0925d1d0d1d39d262972fd2a6
  Date:   Fri Dec 5 11:33:29 2025 +0000

      gdb: new setting to disable progress bars

I incorrectly used @value{on} and @value{off} to reference the on/off
settings of a new flag.  This caused the following warnings when
building the docs:

  gdb.texinfo:51356: warning: undefined flag: off
  gdb.texinfo:51357: warning: undefined flag: on

Looking through the docs there seems to be a split, in some cases we
use @code and in others we use @samp.  I'm not sure @code is correct,
so I've switched to use @samp.  The warnings are gone after this
patch.

11 days agoRe: LoongArch: Add linker relaxation support for R_LARCH_CALL30
Alan Modra [Tue, 16 Dec 2025 08:43:15 +0000 (19:13 +1030)]
Re: LoongArch: Add linker relaxation support for R_LARCH_CALL30

clang catches this error and another like it on line 6320.
elfnn-loongarch.c:6357:35: error: overlapping comparisons always evaluate to true [-Werror,-Wtautological-overlap-compare]
 6357 |                    && (r_type != R_LARCH_CALL36 || r_type != R_LARCH_CALL30))
      |                        ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~

* elfnn-loongarch.c (loongarch_elf_relax_section): Correct tests
for R_LARCH_CALL36 and_LARCH_CALL30.

11 days agoAutomatic date update in version.in
GDB Administrator [Tue, 16 Dec 2025 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

12 days agogdb/testsuite: fix tcllint errors in gdb.base/startup-hints.exp
Simon Marchi [Mon, 15 Dec 2025 21:27:18 +0000 (16:27 -0500)]
gdb/testsuite: fix tcllint errors in gdb.base/startup-hints.exp

Fix:

    gdb/testsuite/gdb.base/startup-hints.exp:61:44: expression with substitutions should be enclosed by braces [unbraced-expr]
    gdb/testsuite/gdb.base/startup-hints.exp:64:28: expression with substitutions should be enclosed by braces [unbraced-expr]

Change-Id: Id21ff11ced82b11c11d0eb0d186fe6fc5c4c06c5

12 days agoLD/testsuite: Expand archive verification to group feature
Maciej W. Rozycki [Mon, 15 Dec 2025 19:04:30 +0000 (19:04 +0000)]
LD/testsuite: Expand archive verification to group feature

Expand archive verification to cover the group feature.  Linker error
messages for unsatisfied symbol references vary between targets a bit,
in particular `arc-*-*' produce duplicate messages and `alpha*-*-osf*'
and `alpha*-*-linux*ecoff*' add a "final link failed" message.  Factor
this in with the error pattern list to match.  Usual XFAIL annotations
apply.

12 days agoCRIS/LD/testsuite: Add tests for emulation switching
Maciej W. Rozycki [Mon, 15 Dec 2025 19:04:30 +0000 (19:04 +0000)]
CRIS/LD/testsuite: Add tests for emulation switching

Add tests matching generic ones from ld-archive/archive.exp for explicit
link emulation switching, verifying that correct output is produced from
a link including an archive the format of which is not the default one.

This covers generic BFD code using `cris-aout' and `cris-elf' targets as
ones that permit switching between dissimilar emulations from assembly
through the link.

Only tests for link emulation explicitly specified are included at this
stage, as bugs in BFD currently prevent links from successful completion
that use the default emulation while involving archives in a non-default
format.  Additional tests will be included with a subsequent change that
addresses said bugs.

12 days agoLD/testsuite: Expand archive verification to `--whole-archive' feature
Maciej W. Rozycki [Mon, 15 Dec 2025 19:04:30 +0000 (19:04 +0000)]
LD/testsuite: Expand archive verification to `--whole-archive' feature

Expand archive verification to cover the `--whole-archive' feature,
adding link map and verbose output matching to verify the correct
archive members are added and the unwanted ones omitted.

Adjust the linker flags accordingly for XCOFF targets, by switching from
the `-bexpall' option to `-unix' (`-bexpfull' would do too, but has some
test coverage already, unlike `-unix', which is a superset of the former
option), so that additional symbols pulled with `--whole-archive' aren't
discarded by linker garbage collection.

This test expansion has revealed the lack of thin archive support in AR
for Alpha/VMS and XCOFF targets, despite apparent presence of relevant
code in the respective BFD backends.  With `ar rcT' invocation a regular
archive is silently produced instead.

Rather than making the relevant tests overly permissive, XFAIL them for
the affected targets, referring PR binutils/33600.

12 days agoVMS/BFD: Fix a sign extension issue with archive symbol lookup
Maciej W. Rozycki [Mon, 15 Dec 2025 19:04:30 +0000 (19:04 +0000)]
VMS/BFD: Fix a sign extension issue with archive symbol lookup

Symbol binary search code for VMS archive files uses plain `char' data
type to cast a difference between characters to data of the `int' type.
Consequently the difference is consider unsigned in the range between 0
and 255 on hosts where plain `char' data type is unsigned, resulting in
symbol lookup failures, such as with the test expansion included with
this change causing regressions as follows:

FAIL: Regular archive link
FAIL: Thin archive link
FAIL: Regular archive plus regular link
FAIL: Regular archive plus thin link
FAIL: Thin archive plus regular link
FAIL: Thin archive plus thin link

owing to link failures such as:

.../ld/ld-new: tmpdir/abc.o:($DATA$+0x0): undefined reference to `aa'
.../ld/ld-new: tmpdir/ab.a(b.obj):($DATA$+0x10): undefined reference to `aa'
.../ld/ld-new: tmpdir/abc.o:($DATA$+0x0): undefined reference to `aa'
.../ld/ld-new: tmpdir/ab.a(b.obj):($DATA$+0x10): undefined reference to `aa'

with the `alpha-dec-vms' target on the `powerpc64le-linux-gnu' host.

Use explicit `signed char' data type for the cast then, removing the
failures.

12 days agoLD/testsuite: Fix archive verification for Alpha/VMS
Maciej W. Rozycki [Mon, 15 Dec 2025 19:04:30 +0000 (19:04 +0000)]
LD/testsuite: Fix archive verification for Alpha/VMS

As from commit a2298f23f2e2 ("PR 33385 vms archives") the handling of
Alpha/VMS archives has been recently unbroken, after 7 years, revealing
issues with archive tests added with commit 435223a9ae70 ("LD/testsuite:
Add tests for archive handling"), the change of the failure mode of
which went unnoticed.

In particular there is no NM support for executables and archives always
have an index by the nature of the format; cf. `_bfd_vms_lib_archive_p':
"The map is always present."

Address these peculiarities by excluding NM tests for the executables
produced and by omitting mapless archive rejection tests just as with
XCOFF targets, removing all the test failures:

alpha-dec-vms  -FAIL: Regular archive link
alpha-dec-vms  -FAIL: Thin archive link
alpha-dec-vms  -FAIL: Regular archive plus regular link
alpha-dec-vms  -FAIL: Regular archive plus thin link
alpha-dec-vms  -FAIL: Thin archive plus regular link
alpha-dec-vms  -FAIL: Thin archive plus thin link
alpha-dec-vms  -FAIL: Regular archive w/o index link
alpha-dec-vms  -FAIL: Thin archive w/o index link

Factor out code to filter out unwanted tests to a procedure for a better
structure of the code.

12 days agoPR binutils/33485: LD/testsuite: Also XFAIL `ns32k-*-*' targets
Maciej W. Rozycki [Mon, 15 Dec 2025 19:04:30 +0000 (19:04 +0000)]
PR binutils/33485: LD/testsuite: Also XFAIL `ns32k-*-*' targets

NS32k targets also use the a.out archive format, which suffers from PR
binutils/33485 where symbol indexes in a.out thin archives are missing
symbols for subsequent members.  This affects `ns32k-pc532-lites*',
`ns32k-pc532-mach*', and `ns32k-pc532-ux*' targets in particular; other
NS32k targets appear defunct.  Add suitable XFAIL annotation, removing
failures such as:

ns32k-pc532-lites  -FAIL: Thin archive link
ns32k-pc532-lites  -FAIL: Regular archive plus thin link
ns32k-pc532-lites  -FAIL: Thin archive plus regular link
ns32k-pc532-lites  -FAIL: Thin archive plus thin link

12 days ago[pre-commit] Move codespell-log to post-commit
Tom de Vries [Mon, 15 Dec 2025 16:19:26 +0000 (17:19 +0100)]
[pre-commit] Move codespell-log to post-commit

The current pre-commit hook codespell-log works with script
gdb/contrib/codespell-log.sh.

During the commit-msg phase of a commit, the following happens:
- git calls pre-commit
- pre-commit calls gdb/contrib/codespell-log.sh,
- gdb/contrib/codespell-log.sh calls pre-commit, and
- precommit calls codespell.

This purpose of this indirection is to:
- ignore the exit status of codespell (to make sure that the commit is not
  aborted), and
- control the version of codespell.

However, if the check fails, the output is a bit messy due to the indirection:
...
$ touch gdb/bla.c
$ git add gdb/bla.c
$ git commit -m "Usuable"
  ...
codespell-log............................................................Passed
- hook id: codespell-log
- duration: 0.43s

codespell-log-internal...................................................Failed
- hook id: codespell
- exit code: 65

.git/COMMIT_EDITMSG:1: Usuable ==> Usable

[detached HEAD 18ec133830f] Usuable
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 gdb/bla.c
...

And if the check passes, the output is still verbose due to the verbose=true
setting.

I found a simpler way to implement this.

Given that we don't want to abort the commit, the post-commit stage is a more
natural place for this check.  Moving it there solves two problems:
- we no longer need to ignore the exit status of codespell
- we no longer need the verbose=true setting

The only issue is that we need to generate the file containing the commit
message ourselves, something that is provided by git in the commit-msg stage.
So we still need a wrapper script.

However, it seems that specifying a shell script as entry point of a codespell
hook is fine, so we no longer need to call pre-commit from codespell-log.sh.

Having simplified codespell-log.sh, we can downgrade it to a /bin/sh script,
instead of requiring bash.

Checked with shellcheck.

12 days agogdb: new setting to disable progress bars
Andrew Burgess [Fri, 5 Dec 2025 11:33:29 +0000 (11:33 +0000)]
gdb: new setting to disable progress bars

Two commits ago, in the commit titled:

    gdb: make get_chars_per_line return an unsigned value

A bodge was added in cli-out.c so that progress bars (as seen when
debuginfod downloads a file) would be disabled when the output
terminal had unlimited width.

The hack was added because this previous commit fixed a bug such that
progress bars could now be displayed in very wide, or even on
unlimited width output terminals.  By fixing this bug, progress bars
were now being displayed when running the testsuite, as the testsuite
sets the output terminal to unlimited width.

To avoid breaking the tests, this previous commit added a bodge such
that on unlimited width output terminals, progress bars would always
be disabled.  This got the tests passing again, but isn't an ideal
solution.

This commit cleans things up.  We now have a new setting:

  set progress-bars enabled on|off
  show progress-bars enabled

This setting allows progress bars to be turned off.  The tests are
then updated to explicitly turn off progress bars.  The bodge from the
earlier commit is then removed.

Now, progress bars should display correctly on any width of output
terminal over 50 characters, the minimum required.  And the debuginfod
tests should all pass as they turn off progress bars.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
12 days agogdb: fix crashes and weird output from new boxed hint text
Andrew Burgess [Thu, 4 Dec 2025 10:38:23 +0000 (10:38 +0000)]
gdb: fix crashes and weird output from new boxed hint text

After the commit:

  commit f6df8aa48f120b78f0670b429f8a3363020a47dc
  Date:   Mon Sep 15 11:56:17 2025 -0300

      gdb: Make startup message more user friendly

I noticed, that when I start GDB with a file on the command line, I
was seeing some stray '..'.  Like this:

  $ gdb -nw -nh /tmp/hello.x
  GNU gdb (GDB) 18.0.50.20251202-git
  Copyright (C) 2025 Free Software Foundation, Inc.
  License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
  This is free software: you are free to change and redistribute it.
  There is NO WARRANTY, to the extent permitted by law.
  Type "show copying" and "show warranty" for details.
  This GDB was configured as "x86_64-pc-linux-gnu".
  Type "show configuration" for configuration details.
  For bug reporting instructions, please see:
  <https://www.gnu.org/software/gdb/bugs/>.

  ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
  ┃ Find the GDB manual online at:                                               ┃
  ┃ http://www.gnu.org/software/gdb/documentation/.                              ┃
  ┃ For help, type "help".                                                       ┃
  ┃ Type "apropos <word>" to search for commands related to <word>               ┃
  ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
  ..
  Reading symbols from /tmp/hello.x...

Notice the '..' after the boxed hint text, that's what I'm complaining
about.  Also, notice that the last line within the box is missing its
period.

Before the above commit the last line would appear like this when no
file was loaded:

  Type "apropos <word>" to search for commands related to <word>.

And like this when a file was being loaded:

  Type "apropos <word>" to search for commands related to <word>...

The extra '..' are added to show that a file is being loaded, and that
this might take some time.  But we have the 'Reading symbols from ...'
text to indicate this now, so I think the extra '..' are redundant.
Lets just drop them.  This will leave just a single period at the end
of the sentence.

The above commit unfortunately, didn't include any tests, so I thought
I'd write some to cover this fix.... and that uncovered a bug where
the box around the startup hints could be corrupted:

  $ gdb -eiex 'set width 50' -nw -nh
  GNU gdb (GDB) 18.0.50.20251202-git
  Copyright (C) 2025 Free Software Foundation, Inc.
  License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
  This is free software: you are free to change and redistribute it.
  There is NO WARRANTY, to the extent permitted by law.
  Type "show copying" and "show warranty" for details.
  This GDB was configured as "x86_64-pc-linux-gnu".
  Type "show configuration" for configuration details.
  For bug reporting instructions, please see:
  <https://www.gnu.org/software/gdb/bugs/>.

  ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
  ┃ Find the GDB manual online at:                 ┃
  ┃ http://www.gnu.org/software/gdb/documentation/. ┃
  ┃ For help, type "help".                         ┃
  ┃ Type "apropos <word>" to                       ┃
  ┃  search for commands related to <word>         ┃
  ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

  (gdb)

This was caused by a mistake on the line where we choose whether to
box or not.  The line is currently:

  if (width - 3 <= docs_url.length ())

There are two problems here, the '3' should be '4'.  The box adds 4
characters '| ' and ' |'.  But also, the WIDTH can be very small, less
than 4 even, which means that the subtraction can underflow, wrapping
around and giving a very large value.  I plan to rewrite the line to:

  if (width < docs_url.length () + 1 + 4)

The '+ 1' accounts for the period at the end of the URL line (which
was previously handled by the '<=', and the '+ 4' accounts for the box
borders.  By making it a '+ 4' on the URL, rather than '- 4' from the
width, we avoid underflow.  This is fine so long as the URL to our
documentation doesn't approach UINT_MAX in length.  Which I hope it
never does.

I've added a couple of asserts to print_gdb_hints to reflect things
that must be true.  The first is that get_chars_per_line never returns
0.  And later on, I assert that 'width > 4' in a place where we are
about to do 'width - 4'.  If the assert triggers then underflow would
have occurred.

Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
Approved-By: Tom Tromey <tom@tromey.com>
12 days agogdb: make get_chars_per_line return an unsigned value
Andrew Burgess [Thu, 4 Dec 2025 15:19:37 +0000 (15:19 +0000)]
gdb: make get_chars_per_line return an unsigned value

I noticed that get_chars_per_line currently returns an 'int', but the
value it is returning, from utils.c, is an 'unsigned int'.  In some
cases this can cause weird behaviour as an unlimited width terminal
will have UINT_MAX characters per line, which will appear as negative
when returned from get_chars_per_line.

This has been the case since get_chars_per_line was added in commit:

  commit 2f2287318b33ddf855a692fcc191f6b25caf4644
  Date:   Wed Dec 16 18:18:40 2020 +0100

      [gdb/cli] Add a progress meter

Lets make get_chars_per_line return an unsigned value, and update all
the uses of this function to hold the result in an unsigned variable.

I ran into this issue when looking at print_gdb_hints (from top.c)
where a very large get_chars_per_line() value would appear negative,
and so the startup hints would be printed without a box when really
they should have been boxed.  Someone else noticed this problem while
I was building this patch, and pushed commit:

  commit 06e470d8fc0ae0e83fe0977fdf8c011998980891
  Date:   Sat Nov 29 15:48:55 2025 +0100

      gdb: handle unlimited screen width case in print_gdb_hints

This commit works around the signed / unsigned confusion entirely
within print_gdb_hints by adding a case to 'int' in one place.  The
change I present here reverts parts of 06e470d8fc0a in favour of
fixing the type of WIDTH within print_gdb_hints.

It is worth nothing that there are other bugs in print_gdb_hints
relating to how WIDTH is handled, but these are fixed in the next
commit.

By updating the return type of get_chars_per_line, I ran into some
issues in cli-out.c relating to how progress bars are handled.  The
existing code includes code like:

   if (!stream->isatty ()
       || !current_ui->input_interactive_p ()
       || chars_per_line < MIN_CHARS_PER_LINE)
     return;

The early return here triggers when progress bars should not be
printed.  Notice that when the terminal width is unlimited,
CHARS_PER_LINE will appear negative, and so the early return will
trigger.

It turns out that our testsuite depends on this; the debuginfod tests
don't expect to see a progress bar, and they don't because within the
tests we set the width to unlimited.

By "fixing" the type of CHARS_PER_LINE to 'unsigned int', an unlimited
width terminal no longer triggers the early return, and GDB starts
trying to print a progress bar in our debuginfod tests, which cause
the tests to fail.

I think the real fix is to add a new flag to allow progress bars to be
disabled, the tests can then use this.  I will add just such a flag at
the end of this series.

For now though, I propose adding a bodge.  If CHARS_PER_LINE is
UINT_MAX, then we should act as if progress bars are disabled.  The
above code now becomes:

   if (!stream->isatty ()
       || !current_ui->input_interactive_p ()
       || chars_per_line < MIN_CHARS_PER_LINE
       || chars_per_line == UINT_MAX)
     return;

This change is in cli_ui_out::clear_progress_notify.  There is a
similar change in cli_ui_out::do_progress_notify.  With these two
changes, the debuginfod tests are working again.  This bodge will be
removed by the last patch in this series.

There's no tests with this commit yet as print_gdb_hints has other
bugs which will be fixed in the next commit.  At this point I'll add
some tests.

Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
Approved-By: Tom Tromey <tom@tromey.com>
12 days agoMinor DAP test cleanups
Tom Tromey [Wed, 3 Dec 2025 20:39:22 +0000 (13:39 -0700)]
Minor DAP test cleanups

This patch removes the "-1" from returns in the DAP tests, and also
reindents one of those lines at the same time.

12 days agoDAP: accept requests with '"arguments": null'
Ronan Desplanques [Mon, 1 Dec 2025 14:27:37 +0000 (15:27 +0100)]
DAP: accept requests with '"arguments": null'

Some Debug Adapter Protocol clients like Helix set the optional
"arguments" field of the ConfigurationDone request to null, which is a
bit odd but seems to be allowed by the protocol specification. Before
this patch, Python exceptions would be raised on such requests. This
patch makes it so these requests are treated as if the "arguments"
field was absent.

12 days agoUse skip_spaces in more places
Tom Tromey [Fri, 12 Dec 2025 18:45:42 +0000 (11:45 -0700)]
Use skip_spaces in more places

I looked through gdb for instance of:

      while (*p == ' ' || *p == '\t')
p++;

... and replaced these with a call to skip_spaces.

In some cases this might slightly change the semantics, as now other
whitespace (like \r or \f) will be considered.  However I don't think
this matters.

Regression tested on x86-64 Fedora 41.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
12 days agoaarch64: Add support for new BTI <target> "r"
Srinath Parvathaneni [Mon, 15 Dec 2025 11:01:49 +0000 (11:01 +0000)]
aarch64: Add support for new BTI <target> "r"

This patch adds support for new BTI <target> "r" (instruction: bti r),
which is an alias to "bti" (with no target), for both "bti" and "bti r"
the preferred disassembly is "bti r". This "bti r" instruction is by
default available from Armv8-A architecture.

The HINT_OPD_F_NOPRINT macro has become redundant with these changes
and has been removed.

12 days agobfd/s12z: put relocations next to each other
Jan Beulich [Mon, 15 Dec 2025 10:29:54 +0000 (11:29 +0100)]
bfd/s12z: put relocations next to each other

It's not helpful to have two separate "sections", each with a single
relocation.

12 days agobfd/ELF: fold BFD_RELOC_<arch>_RELATIVE
Jan Beulich [Mon, 15 Dec 2025 10:29:33 +0000 (11:29 +0100)]
bfd/ELF: fold BFD_RELOC_<arch>_RELATIVE

There's no need to have a separate reloc per arch; just like for other
more or less generic ones a single one will (mostly) do. Arm64, C-Sky,
and KVX - sadly - are exceptions.

12 days agobfd/ELF: fold BFD_RELOC_<arch>_J{,U}MP_SLOT
Jan Beulich [Mon, 15 Dec 2025 10:29:19 +0000 (11:29 +0100)]
bfd/ELF: fold BFD_RELOC_<arch>_J{,U}MP_SLOT

There's no need to have a separate reloc per arch; just like for other
more or less generic ones a single one will (mostly) do. Arm64, C-Sky,
and KVX - sadly - are exceptions.

12 days agobfd/ELF: fold BFD_RELOC_<arch>_GLOB_DAT
Jan Beulich [Mon, 15 Dec 2025 10:28:50 +0000 (11:28 +0100)]
bfd/ELF: fold BFD_RELOC_<arch>_GLOB_DAT

There's no need to have a separate reloc per arch; just like for other
more or less generic ones a single one will (mostly) do. Arm64, C-Sky,
and KVX - sadly - are exceptions.

12 days agobfd/ELF: fold BFD_RELOC_<arch>_COPY
Jan Beulich [Mon, 15 Dec 2025 10:28:14 +0000 (11:28 +0100)]
bfd/ELF: fold BFD_RELOC_<arch>_COPY

There's no need to have a separate reloc per arch; just like for other
more or less generic ones a single one will (mostly) do. Arm64, C-Sky,
and KVX - sadly - are exceptions.

12 days agobfd/ELF: fold BFD_RELOC_<arch>_IRELATIVE
Jan Beulich [Mon, 15 Dec 2025 10:27:56 +0000 (11:27 +0100)]
bfd/ELF: fold BFD_RELOC_<arch>_IRELATIVE

There's no need to have a separate reloc per arch; just like for other
more or less generic ones a single one will (mostly) do. Arm64, C-Sky, and
KVX - sadly - are exceptions.

12 days agoS/390: use BFD_RELOC_<n>_PLT_PCREL in favor of custom types
Jan Beulich [Mon, 15 Dec 2025 09:49:07 +0000 (10:49 +0100)]
S/390: use BFD_RELOC_<n>_PLT_PCREL in favor of custom types

No reason to have separate types when the generic ones have no (other)
meaning for this target.

12 days agoSparc: use BFD_RELOC_<n>_PLT_PCREL in favor of custom types
Jan Beulich [Mon, 15 Dec 2025 09:48:47 +0000 (10:48 +0100)]
Sparc: use BFD_RELOC_<n>_PLT_PCREL in favor of custom types

No reason to have separate types when the generic ones have no (other)
meaning for this target.

12 days agoArc: use generic BFD_RELOC_... in favor of custom types
Jan Beulich [Mon, 15 Dec 2025 09:48:26 +0000 (10:48 +0100)]
Arc: use generic BFD_RELOC_... in favor of custom types

No reason to have separate types when the generic ones have no (other)
meaning for this target.

12 days agoArm: use BFD_RELOC_32_PLT_PCREL in favor of custom type
Jan Beulich [Mon, 15 Dec 2025 09:48:10 +0000 (10:48 +0100)]
Arm: use BFD_RELOC_32_PLT_PCREL in favor of custom type

No reason to have a separate type when the generic one has no (other)
meaning for this target.

Doing the adjustments makes obvious that elf32_arm_reloc_map[] had two
identical entries; that duplicate is being removed.

12 days agoAutomatic date update in version.in
GDB Administrator [Mon, 15 Dec 2025 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

13 days agoFix configure rebuild
John David Anglin [Sun, 14 Dec 2025 21:57:28 +0000 (16:57 -0500)]
Fix configure rebuild

2025-12-14  John David Anglin  <danglin@gcc.gnu.org>

bfd/ChangeLog:

* configure: Regenerate.

ld/ChangeLog:

* configure: Regenerate.

13 days agoFix binutils build on hppa64-hpux with gcc-16 (v3)
John David Anglin [Sun, 14 Dec 2025 21:11:19 +0000 (16:11 -0500)]
Fix binutils build on hppa64-hpux with gcc-16 (v3)

With recent gcc versions, implicit function declarations are errors.
We need to ensure that ffs() and strtoull() are declared and correctly
checked for by configure.

strtoull() is not declared on hpux but it's provided by libiberty.

An unnecessary include of strings.h in elf32-xtensa.c is removed.

Approved-By: Jan Beulich <jbeulich@suse.com>
2025-12-14  John David Anglin  <danglin@gcc.gnu.org>

bfd/ChangeLog:

* configure.ac: Check for strtoull declaration.
* elf32-xtensa.c: Remove strings.h include.
* configure: Regenerate.
* config.in: Regenerate.
* sysdep.h: Include strings.h and declare strtoull()
if a declaration for it isn't found by configure.

ld/ChangeLog:

* configure.ac: Check for strtoull declaration.
* configure: Regenerate.
* config.in: Regenerate.
* sysdep.h: Declare strtoull() if a declaration for it
isn't found by configure.

13 days agoAutomatic date update in version.in
GDB Administrator [Sun, 14 Dec 2025 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

2 weeks agogdb: use the pid from inferior in setup_inferior
Tankut Baris Aktemur [Sat, 13 Dec 2025 11:50:47 +0000 (12:50 +0100)]
gdb: use the pid from inferior in setup_inferior

This is a step to reduce the dependency on the global inferior_ptid
variable.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2 weeks agoLoongArch: Set the default ABI of loongarch*-elf targets to double-float
Lulu Cai [Thu, 11 Dec 2025 07:40:58 +0000 (15:40 +0800)]
LoongArch: Set the default ABI of loongarch*-elf targets to double-float

The ABI setting for the elf target was ommitted in commit "db614f37cab".
Set the default ABI for elf to double-float.

In addition, test case failures caused by the loongarch*-elf linker not
supporting relevant options have also been skipped.

gas/

        * config/tc-loongarch.c (loongarch_after_parse_args): Set
  default ABI to double-float for other targets.

ld/

        * testsuite/ld-loongarch-elf/la32.d: Skip tests when not
  supported.
        * testsuite/ld-loongarch-elf/ld-loongarch-elf.exp: Likewise.
        * testsuite/ld-loongarch-elf/relax.exp: Likewise.

2 weeks agoRe: ld: testsuite: Add sframe test for PR 33401
Alan Modra [Fri, 12 Dec 2025 23:00:46 +0000 (09:30 +1030)]
Re: ld: testsuite: Add sframe test for PR 33401

If user CXXFLAGS include -fno-inline the test fails with
FAIL: PR ld/33401 (Step 1: Create relocatable object and check R_*_NONE)
This should not be a FAIL.  If the compiler does not generate R_*_NONE
(a good thing!) then it should be UNTESTED, which means the readelf
check can't be done by run_cc_link_tests.  I haven't made that change
in this patch, just worked around a user -fno-inline.

2 weeks agoAutomatic date update in version.in
GDB Administrator [Sat, 13 Dec 2025 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

2 weeks agogdb/breakpoint.c: fix style issues in get_sal_arch
Lancelot SIX [Fri, 8 Nov 2024 19:52:55 +0000 (19:52 +0000)]
gdb/breakpoint.c: fix style issues in get_sal_arch

Fix coding standard related issues in get_sal_arch.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I62b059e0bf060f368c9895c97d8b162d73ff61ce

2 weeks agold: testsuite: Add sframe test for PR 33401
Claudiu Zissulescu [Fri, 12 Dec 2025 15:02:32 +0000 (17:02 +0200)]
ld: testsuite: Add sframe test for PR 33401

When linking for a relocable output file (-r), one or more R_*_NONE
relocations may be generated for .sframe section. Two new tcl
procedures are added to sframe.exp file. 'check-dump' is checking if
an input bin file has the same relocation as specified in the second
input argument. 'check_pr33401' is the main checking function for
PR33401 which calls twice the ld tool to produce an relocable output
file.

ld:

PR33401
* testsuite/ld-sframe/StateClient.cpp: New file.
* testsuite/ld-sframe/StatePlaying.cpp: Likewise.
* testsuite/ld-sframe/pr33401.rd: Likewise.
* testsuite/ld-sframe/sframe.exp (check_pr33401): New procedure.

Co-authored-by: Indu Bhagat <indu.bhagat@oracle.com>
Reviewed-by: Indu Bhagat <indu.bhagat@oracle.com>
2 weeks agobfd: ld: sframe: skip R_*_NONE relocations from input bfds
Indu Bhagat [Fri, 12 Dec 2025 15:02:32 +0000 (17:02 +0200)]
bfd: ld: sframe: skip R_*_NONE relocations from input bfds

Fix PR ld/33401 - SFrame assertion when linking gav-0.9.1

As the issue demonstrates, R_*_NONE relocations are not necessarily
at the end of .sframe section (previously thought so with PR ld/33127).
Skip over R_*_NONE relocs when they are strewn intermittently inside the
.rela.sframe section.

bfd/
PR ld/33401
* elf-sframe.c (sframe_decoder_init_func_bfdinfo):  Skip over
R_*_NONE relocations.

2 weeks agogas/gen-sframe: avoid gcc extension using __VA_ARGS__
Jan Beulich [Fri, 12 Dec 2025 14:00:41 +0000 (15:00 +0100)]
gas/gen-sframe: avoid gcc extension using __VA_ARGS__

We shouldn't be using extensions when we don't have a suitable fallback in
place. Introducing a format-argument-less counterpart macro would feel a
little odd here. Instead make the sole use site have a (fake) argument
(the non-translatable part of the string).

2 weeks agold/pe-dll: Don't auto-export symbols from .tls section
LIU Hao [Fri, 12 Dec 2025 14:00:15 +0000 (15:00 +0100)]
ld/pe-dll: Don't auto-export symbols from .tls section

The .tls section of an image contains template data that will be duplicated
for each new thread to be created. Accessing thread-local data involves an
image-specific global variable, _tls_used, for calculation. Therefore, it is
impossible to export thread-local variables from a DLL.

The only symbol that exists in the .tls input section is _tls_start, but it's
a CRT symbol and is never auto-exported. It's only necessary to check for
user symbols, which are always generated in the subsection .tls$ by default,
or in subsections like .tls$$<symbol> when -fdata-sections is specified.

Reference: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80881
Signed-off-by: LIU Hao <lh_mouse@126.com>
2 weeks agobfd: Add minimal support to handle note that describes xsave layout
Vignesh Balasubramanian [Fri, 12 Dec 2025 13:59:49 +0000 (14:59 +0100)]
bfd: Add minimal support to handle note that describes xsave layout

This note section is already supported by Linux kernel.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/arch/x86/kernel/fpu/xstate.c?id=ba386777a30b38dabcc7fb8a89ec2869a09915f7

Co-Authored-By: Jini Susan George <jinisusan.george@amd.com>
2 weeks agogas/d30v: make use of tc_symbol_chars[]
Jan Beulich [Fri, 12 Dec 2025 13:59:20 +0000 (14:59 +0100)]
gas/d30v: make use of tc_symbol_chars[]

... instead of having arch-specific code in app.c.

2 weeks ago[gdb/testsuite] Fix timeout in gdb.base/async-shell.exp
Tom de Vries [Fri, 12 Dec 2025 08:35:23 +0000 (09:35 +0100)]
[gdb/testsuite] Fix timeout in gdb.base/async-shell.exp

For test-case gdb.base/async-shell.exp, I usually get:
...
(gdb) run &^M
Starting program: async-shell ^M
(gdb) PASS: $exp: run &
[Thread debugging using libthread_db enabled]^M
Using host libthread_db library "/lib64/libthread_db.so.1".^M
shell echo foo^M
foo^M
(gdb) PASS: $exp: shell echo foo
...

And with taskset -c 11, I get instead:
...
(gdb) run &^M
Starting program: async-shell ^M
(gdb) PASS: $exp: run &
shell echo foo^M
foo^M
(gdb) PASS: $exp: shell echo foo
[Thread debugging using libthread_db enabled]^M
Using host libthread_db library "/lib64/libthread_db.so.1".^M
...

With a gdb 16.3 based package I ran into:
...
(gdb) run &
Starting program: async-shell
(gdb) PASS: $exp: run &
shell echo foo
foo
(gdb) [Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
FAIL: $exp: shell echo foo (timeout)
...

I have tried to reproduce this using various timing tricks, but haven't
managed.  Nevertheless, I believe this can reproduced with trunk, so fix this
using -no-prompt-anchor.

PR testsuite/33667
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33667

2 weeks agoRISC-V: avoid ld crashes due to bogus use by testcases
Jan Beulich [Fri, 12 Dec 2025 07:06:41 +0000 (08:06 +0100)]
RISC-V: avoid ld crashes due to bogus use by testcases

Specifying a little-endian emulation isn't very helpful when the target is
big-endian (and hence gas defaults to that). Surely the linker better
wouldn't crash when invoked like this, but making sure of this isn't the
purpose of any of these tests (afaict). Make assembly output match linker
options.

With this the ld testsuite completes successfully for me. binutils and gas
testsuites still have issues.

2 weeks agox86: replace XFAILs in "GOTX default" tests
Jan Beulich [Fri, 12 Dec 2025 07:05:11 +0000 (08:05 +0100)]
x86: replace XFAILs in "GOTX default" tests

The use of XFAIL was wrong here. XFAIL marks tests which in principle
should work, but where making them work requires extra effort.

2 weeks agogas/macro: drop ISSEP()
Jan Beulich [Fri, 12 Dec 2025 07:04:41 +0000 (08:04 +0100)]
gas/macro: drop ISSEP()

I've been irritated by it more than once: It very obviously doesn't cover
all separators, hence resulting in inconsistent behavior. Nor do both use
sites look to really want the same set of separators. In macro_expand() we
really can pull the get_token() call ahead. If we don't find the expected
'=' we can simply continue parsing from the original position.

The use in get_any_string() is dead code afaict, inherited from gasp. The
sole leftover thereof is handled in the scrubber (see H_TICK_HEX,
LEX_IS_H, and alike there). With that dropped, ISBASE() also can be.

2 weeks agold/ELF: correct tidying of sec64k object files
Jan Beulich [Fri, 12 Dec 2025 07:02:33 +0000 (08:02 +0100)]
ld/ELF: correct tidying of sec64k object files

These consume quite a bit of space (especially noticeable during batch
testing), but are rather mechanical to (re)create. In 2.28, when the
object file names used were changed (from dump<N>.o to names derived from
source file names), the tidying code wasn't updated (and hence lost its
effect).

2 weeks agold/ELF: leave note sections alone for relocatable linking
Jan Beulich [Fri, 12 Dec 2025 07:02:12 +0000 (08:02 +0100)]
ld/ELF: leave note sections alone for relocatable linking

Commit 023e60ced0c8 ("ld: Move note sections after .rodata section") had a
rather undesirable effect for relocatable links (which typically wouldn't
use a custom linker script): .note.GNU-stack, which isn't even a proper
notes sections (it's SHT_PROGBITS instead, which likely will want
correcting independently), would be moved immediately past .text and
.rodata (and alike), ahead of any custom notes sections. A later final
link, possibly simply combining all .note and .note.* sections, would then
find .note.GNU-stack first, resulting in the output section to also become
SHT_PROGBITS. This way consumers looking for SHT_NOTE wouldn't find the
data they're after.

The goal of mentioning some known .note.* in the linker scripts is to
avoid orphan section diagnostics. That's not typically of interest for
relocatable links, though (people caring about this will want to have
custom scripts anyway, much like they may need to if they had any custom
.note.* sections). Therefore suppress that part of the linker script for
relocatable links.

2 weeks agold/Linux: determine program name in a more reliable manner
Jan Beulich [Fri, 12 Dec 2025 07:01:53 +0000 (08:01 +0100)]
ld/Linux: determine program name in a more reliable manner

What argv[0] holds can be pretty arbitrary. As long as it's used for just
diagnostics, that may be pretty okay to go from, but ld also uses it to
find linker scripts. For that we want to be sure we start from the real
executable name. Which on Linux we can determine from the /proc/self/exe
symbolic link target (provided of course procfs is mounted).

While there constify program_name as well.

2 weeks agoAutomatic date update in version.in
GDB Administrator [Fri, 12 Dec 2025 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

2 weeks agoUse -wrap in two test cases
Tom Tromey [Thu, 11 Dec 2025 21:10:18 +0000 (14:10 -0700)]
Use -wrap in two test cases

Both Baris and Tom pointed out spots in recent patches where -wrap
could have been used.  This patch changes both the relevant tests to
use it.

2 weeks ago[pre-commit] Add pre-commit setup check
Tom de Vries [Thu, 11 Dec 2025 21:38:30 +0000 (22:38 +0100)]
[pre-commit] Add pre-commit setup check

I wrote a patch and accidentally introduced a typo in the commit message.

This didn't get detected because codespell-log didn't run.

I installed pre-commit on that setup a while back, before codespell-log was
around and consequently only the .git/hooks/pre-commit script was installed.

This is a bit hard to notice given that all other hooks do run.

Add a pre-commit check that checks for this situation:
...
$ rm .git/hooks/commit-msg
$ git commit --amend
  ...
pre-commit-setup........................................................Failed
- hook id: pre-commit-setup
- exit code: 1

missing hook: .git/hooks/commit-msg (please run pre-commit install)
  ...
$
...

This is a bit niche, but worthwhile if you're using a dozen build and test
installations.

2 weeks ago[gdb/testsuite] Add tclint-plugin.py
Tom de Vries [Thu, 11 Dec 2025 21:31:49 +0000 (22:31 +0100)]
[gdb/testsuite] Add tclint-plugin.py

Tclint v0.6.2 adds the possibility to specify a dynamic plugin using:
...
$ tclint --commands tclint-plugin.py
...

Update the pre-commit tclint version to v0.6.2, and add a plugin
gdb/testsuite/tclint-plugin.py.

The new plugin informs tclint about procs like proc_with_prefix which have a
script-type parameter, making tclint check the body of proc foo:
...
proc_with_prefix foo {} {
    ...
}
...

Declaring proc_with_prefix a builtin command makes tclint issue a
redefined-builtin for the definition of proc_with_prefix.  Fix this by adding
"tclint-disable redefined-builtin" at the start of each file containing such
procs.

The plugin is not complete.  Most entries were found by grepping for something
like "proc.*body".

The hope is that eventually we get to a situation where we can drop the
plugin and instead annotate like this [1]:
...
 # tclint-args: name: any, arguments: any, body: script
 proc proc_with_prefix { name arguments body } {
     ...
 }
...

One fix in the testsuite, in test-case gdb.python/py-missing-objfile.exp.

[1] https://github.com/nmoroze/tclint/issues/121#issuecomment-3319368338

2 weeks agogdb/testsuite: use with_timeout_factor in huge.exp testcases
Jan Vrany [Thu, 11 Dec 2025 16:21:51 +0000 (16:21 +0000)]
gdb/testsuite: use with_timeout_factor in huge.exp testcases

I occasionally run GDB testsuite on sluggish targets that need higher
timeout. The usual remedy I use is to set timeout to higher value in
site.exp.

This does not help with gdb.fortran/huge.exp, gdb.base/huge.exp and
gdb.ada/huge.exp, which set the timeout to fixed value of 30,
regardless of whether the timeout has been increased or not, causing
them to fail on some of my machines.

This commit fixes the problem by using with_timeout_factor.

Approved-By: Tom Tromey <tom@tromey.com>
2 weeks agold: Remove elf_i386_ldso reference
Rainer Orth [Thu, 11 Dec 2025 15:27:14 +0000 (16:27 +0100)]
ld: Remove elf_i386_ldso reference

There's still a reference to the removed elf_i386_ldso emulation, breaking
the build with --enable-targets=all.

Tested on x86_64-pc-linux-gnu.

2025-12-11  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

ld:
* Makefile.am (ALL_EMULATION_SOURCES): Remove eelf_i386_ldso.c.
* Makefile.in: Regenerate.

2 weeks agoaarch64: Update parse_vector_reg_list comment
Alice Carlotti [Wed, 10 Dec 2025 21:17:24 +0000 (21:17 +0000)]
aarch64: Update parse_vector_reg_list comment

The information about indexes was wrong.  I've also adjusted the
formatting and improved other parts of the comment.

2 weeks agoaarch64: Add support for FEAT_LSCP
Richard Ball [Thu, 11 Dec 2025 14:10:24 +0000 (14:10 +0000)]
aarch64: Add support for FEAT_LSCP

This patch adds the new instructions from FEAT_LSCP.
These instructions are LDAP, LDAPP and STLP.

2 weeks agoCleanup bfd target vectors and ld emulations on Solaris (missed part)
Rainer Orth [Thu, 11 Dec 2025 14:02:37 +0000 (15:02 +0100)]
Cleanup bfd target vectors and ld emulations on Solaris (missed part)

This reordering of the x86_64-*-solaris2.1[01] entry in config.bfd was
missed in the original commit.

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

bfd:
* config.bfd [BFD64] <x86_64-*-solaris2.1[01]*>: Move down.

2 weeks agoFix "unset local-environment" when clearenv not available
Tom Tromey [Wed, 10 Dec 2025 14:23:37 +0000 (07:23 -0700)]
Fix "unset local-environment" when clearenv not available

Tom de Vries pointed out that clearenv isn't available on all hosts.
Since this seems like a niche command at best, it seemed fine to
disable this command on such platforms.

Reviewed-By: Tom de Vries <tdevries@suse.de>
2 weeks agoCleanup bfd target vectors and ld emulations on Solaris
Rainer Orth [Thu, 11 Dec 2025 13:43:16 +0000 (14:43 +0100)]
Cleanup bfd target vectors and ld emulations on Solaris

This patch is a major cleanup of the Solaris configurations of both bfd and ld.

The Solaris cases in both bfd/config.bfd and ld/configure.tgt have seen a
major cleanup, making the support for various Solaris versions explicit,
correcting several inconsistencies, and making it easier to remove support
for some versions in the future.

* All 32-bit-only configurations (Solaris < 7 on SPARC, Solaris < 10 on
  x86) only include the 32-bit target vectors and linker emulations.

* For 32-bit-default targets on 64-bit systems (Solaris >= 7 on SPARC,
  Solaris >= 10 on x86), the 32-bit target vectors and linker emulations
  are the default while supporting the 64-bit ones.

* For 64-bit-default targets on 64-bit systems, it's the other way round.
  They default to 64-bit target vectors etc. while also supporting the
  32-bit ones.

* Added a warning to all Solaris cases in config.bfd not to include the
  non-*_sol2 vectors to avoid the ambiguity reported in PR binutils/27666.

* On x86, the iamcu target vectors and linker emulations have been
  removed: Solaris never supported the Intel MCU.

* On x86, the PE and PEI target vectors have been removed: they were only
  supported in binutils proper.  Their only use would be on EFI files
  e.g. in GRUB, which doesn't justify their inclusion.

* With iamcu support gone, a few gas tests had to be disabled as on
  VxWorks.

* The 32-bit Solaris/x86 ld configuration currently includes the
  elf_i386_ldso emulation, which was never a emulation in its own right but
  just an implementation detail of the elf_i386_sol2 emulation.  Instead,
  the settings that are not already provided by sourced .sh files are moved
  into elf_i386_sol2.sh.  Many settings became superfluous by just sourcing
  elf_i386.sh as is already done in elf_x86_64_sol2.sh, massively
  simplifying the emulation.

* Solaris-specific settings in generic emulparams scripts have been moved
  to the *_sol2.sh files.

* NATIVE_LIB_DIRS in ld/configure.tgt now uses the default setting:
  /usr/ccs/lib contains just a bunch of symlinks into /usr/lib at least
  since Solaris 8.

* ld/emulparams/solaris2.sh now sets ELF_INTERPRETER_NAME to
  /usr/lib/amd64/ld.so.1, matching both the native linker and
  elf_i386_sol2.sh.

* The SEARCH_DIR statements in linker scripts on 64-bit targets contained
  both the native (64-bit) and non-default (32-bit) directies.  The latter
  are completely pointless and are omitted using a new
  LIBPATH_SKIP_NONNATIVE setting.

Tested on {amd64,i386}-pc-solaris2.11 and {sparcv9,sparc}-sun-solaris2.11,
and {x86_64,i686}-pc-linux-gnu as well as with gcc trunk bootstraps on the
Solaris targets.  On those, I've compared the gas/ld and gas/gld 2.45.50
testresults with 2.45 ones.

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

bfd:
* config.bfd <i[3-7]86-*-solaris2*>: Split into ...
<i[3-7]86-*-solaris2.1[01]*> ... this.
(targ_selvecs): Remove iamcu_elf32_vec, i386_coff_vec, i386_pei_vec.
(targ64_selvecs): Remove x86_64_pe_vec, x86_64_pei_vec.
<i[3-7]86-*-solaris2.[0-9]*>: ... and this.
[BFD64] <x86_64-*-solaris2*>: Change into x86_64-*-solaris2.1[01]*.
(targ_defvecs): Change to x86_64_elf64_sol2_vec.
(targ_selvecs): Remove iamcu_elf32_vec, i386_coff_vec,
i386_pei_vec, x86_64_pe_vec, x86_64_pei_vec.
<sparc-*-solaris2.[0-6] | sparc-*-solaris2.[0-6].*>: Split into ...
<sparc-*-solaris2.[7-9]* | sparc-*-solaris2.1[01]*>: ... this.
<sparc-*-solaris2.[0-6]*>: ... this.
[BFD64] <sparc-*-solaris2* | sparcv9-*-solaris2* |
sparc64-*-solaris2*>: Omit sparc-*-solaris2*.
(targ_defvec): Swap with targ_selvecs.

* testsuite/gas/i386/i386.exp: Disable iamcu tests on Solaris.

ld:
* configure.tgt <i[3-7]86-*-solaris2>: Split into ...
<i[3-7]86-*-solaris2.1[01]*>: .. this.
(targ_extra_emuls): Remove elf_i386_ldso and elf_iamcu.
<i[3-7]86-*-solaris2.[0-9]*>: ... and this.
<sparc64-*-solaris2*, sparcv9-*-solaris2*>: Change into ...
<sparc64-*-solaris2.[7-9]* | sparc64-*-solaris2.1[01]* |
sparcv9-*-solaris2.[7-9]* | sparcv9-*-solaris2.1[01]*>: ... this
(targ_extra_emuls): Reorder.
(tdir_elf32_sparc): Remove.
<sparc-*-solaris2.[7-9]* | sparc-*-solaris2.1[01]*>: New case.
<sparc-*-solaris2.[0-6]*, sparc-*-solaris2.[0-6].*>: Change into ...
<sparc-*-solaris2.[0-6]*>: ... this.
<sparc-*-solaris2*>: Remove.
<x86_64-*-solaris2*>: Change into ...
<x86_64-*-solaris2.1[01]*>: ... this.
(targ_extra_emuls): Reorder.  Remove elf_i386_ldso, elf_iamcu.
(tdir_elf_i386): Remove.
(NATIVE_LIB_DIRS): Remove Solaris handling.

* emulparams/elf32_sparc_sol2.sh (ELF_INTERPRETER_NAME): New
variable.
* emulparams/elf64_sparc.sh <sparc*-solaris*> (LIBPATH_SUFFIX):
Move ...
* emulparams/elf64_sparc_sol2.sh: ... here.
(LIBPATH_SKIP_NONNATIVE): New variable.
(ELF_INTERPRETER_NAME): Likewise.
* emulparams/elf_i386_ldso.sh: Merge into ...
* emulparams/elf_i386_sol2.sh: ... this.
Remove duplicate variables.
Source elf_i386.sh instead of elf_i386_ldso.sh.
* emulparams/elf_x86_64.sh <*-*-solaris2*> (ELF_INTERPRETER_NAME):
Move ...
* emulparams/elf_x86_64_sol2.sh: ... here.
Use /usr/lib/amd64/ld.so.1.
(LIBPATH_SKIP_NONNATIVE): New variable.
* emulparams/solaris2.sh: Fix comment.

* genscripts.sh: Fix typos.
Heed LIBPATH_SKIP_NONNATIVE.

2 weeks agolto: Compile LTO 15 test with -fno-fat-lto-objects
H.J. Lu [Thu, 11 Dec 2025 00:33:05 +0000 (08:33 +0800)]
lto: Compile LTO 15 test with -fno-fat-lto-objects

When -ffat-lto-objects is used to compile binutils, LTO 15 test fails on
32-bit targets the same way as -fno-lto, where the builtin function is
used to divide unsigned 64-bit integers.  Compile LTO 15 test with
-fno-fat-lto-objects so that it passes on both 32-bit and 64-bit targets.

PR ld/33709
* testsuite/ld-plugin/lto.exp (lto_link_tests): Compile lto-15a.c
and lto-15b.c with -fno-fat-lto-objects.

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

2 weeks agoLoongArch32: Fix and add testcases
Lulu Cai [Thu, 6 Nov 2025 11:32:53 +0000 (19:32 +0800)]
LoongArch32: Fix and add testcases

Fixed several test failures caused by the LoongArch32 assembler adding
labels during assembly. Additionally, skipped tests specific to LoongArch64.

Add test for new relocations.
Add test for tls type transition, got relaxation and call30 relaxation.

2 weeks agoLoongArch: Add linker relaxation for got_pcadd_hi20 and got_pcadd_lo12
mengqinggang [Mon, 22 Sep 2025 03:43:41 +0000 (11:43 +0800)]
LoongArch: Add linker relaxation for got_pcadd_hi20 and got_pcadd_lo12

.L1:
pcaddu12i $t0, %got_pcadd_hi20(a)     -> pcaddu12i $t0, %pcadd_hi20(a)
ld.w/d $t0, $t0, %got_pcadd_lo12(.L1) -> addi.w/d $t0, $t0, %pcadd_lo12(.L1)

2 weeks agoLoongArch: Add support for tls type transition on LA32
mengqinggang [Sun, 21 Sep 2025 06:43:49 +0000 (14:43 +0800)]
LoongArch: Add support for tls type transition on LA32

desc -> le
ie -> le
desc -> ie

For desc/ie -> le, need to change the symbol of le_lo12 to the symbol of
[desc|ie]_pcadd_hi20.

2 weeks agoLoongArch: Add linker relaxation support for R_LARCH_CALL30
mengqinggang [Tue, 9 Sep 2025 07:39:38 +0000 (15:39 +0800)]
LoongArch: Add linker relaxation support for R_LARCH_CALL30

Relax call30 to bl, relax tail30 to b.

2 weeks agoLoongArch: LA32R macros expand
mengqinggang [Mon, 8 Sep 2025 09:01:46 +0000 (17:01 +0800)]
LoongArch: LA32R macros expand

Define a symbol .Lpcadd_hi* at R_LARCH_*_PCADD_HI20
if the instruction expand from macro.
Change the symbol of R_LARCH_PCADD_LO12 to .Lpcadd_hi*
if the instruction expand from macro.

2 weeks agoLoongArch: LA32 macros support
mengqinggang [Wed, 8 Oct 2025 05:25:06 +0000 (13:25 +0800)]
LoongArch: LA32 macros support

Change pcalau12i to pcaddu12i for LA32 macros.
Add call/tail and call30/tail30 macros, call/tail can expand to
call36/tail36 or call30/tail30 by mabi option.

2 weeks agoLoongArch: Add processing for LA32/LA32R relocations
mengqinggang [Sun, 7 Sep 2025 09:43:56 +0000 (17:43 +0800)]
LoongArch: Add processing for LA32/LA32R relocations

R_LARCH_CALL30:
  pcaddu12i $ra, %call30(func)
  jirl     $ra, $ra, 0
Similar with R_LARCH_CALL36, pcaddu12i and jirl must be adjacent.

R_LARCH_PCADD_HI20, R_LARCH_PCADD_LO12:
.Lpcadd_hi0:
  pcaddu12i $t0, %pcadd_hi20(sym)
  addi.w    $t0, $t0, %pcadd_lo12(.Lpcadd_hi0)
Similar with RISCV PCREL_HI20, PCREL_LO12, R_LARCH_PCADD_LO12 reference to the
symbol at R_LARCH_PCADD_HI20.

2 weeks agoLoongArch: Add LA32 and LA32R relocations
mengqinggang [Sun, 7 Sep 2025 07:47:56 +0000 (15:47 +0800)]
LoongArch: Add LA32 and LA32R relocations

LA32 and LA32R do not have pcaddu18i.
LA32R does not have pcalau12i.

Add R_LARCH_CALL30 for pcaddu12i + jirl used in LA32 and LA32R.
Add R_LARCH_*_PCADD_HI20 for pcaddu12i used in LA32R.
Add R_LARCH_*_PCADD_LO12 for addi.w/ld.w used in LA32R.

2 weeks agoLoongArch: Enable all instructions by default on LA32 like LA64
mengqinggang [Sun, 7 Sep 2025 07:24:55 +0000 (15:24 +0800)]
LoongArch: Enable all instructions by default on LA32 like LA64

Glibc checks LSX/LASX support when configure.
Kernel has float instructions but with -msoft-float option.

2 weeks agoLoongArch: Add R_LARCH_TLS_LE_ADD_R relocation support for add.w
mengqinggang [Mon, 5 May 2025 03:29:52 +0000 (11:29 +0800)]
LoongArch: Add R_LARCH_TLS_LE_ADD_R relocation support for add.w

Fix compiler error for "add.w $r12,$r12,$r2,%le_add_r(a)".

2 weeks agoLoongArch: Change DWARF2_CIE_DATA_ALIGNMENT to -4 for loongarch32
Jiajie Chen [Mon, 16 Dec 2024 07:27:36 +0000 (15:27 +0800)]
LoongArch: Change DWARF2_CIE_DATA_ALIGNMENT to -4 for loongarch32

2 weeks agoLoongArch: Enable loongarch_elf64_vec loongarch64_pei_vec on LA32 target
mengqinggang [Mon, 8 Sep 2025 08:43:05 +0000 (16:43 +0800)]
LoongArch: Enable loongarch_elf64_vec loongarch64_pei_vec on LA32 target

Fix -march=loongarch64 error on LA32 target.

2 weeks agoRevert "[gdb/guile] Use SCM_DEBUG_TYPING_STRICTNESS 0"
Thiago Jung Bauermann [Wed, 3 Dec 2025 23:15:13 +0000 (20:15 -0300)]
Revert "[gdb/guile] Use SCM_DEBUG_TYPING_STRICTNESS 0"

This reverts commit 852cbc7ffadf9daf173e13ea56caff49d52733af.

It fixed the build with libguile v2.0.9, but now GDB only supports
Guile >= 2.2.

I was able to build GDB using -std=c++20 with both Guile 2.2 and
Guile 3.0 (tested with GCC 14.3) without any error or warning.

Approved-By: Tom Tromey <tom@tromey.com>
2 weeks agoGDB: Guile: Remove procedures ineffectual since Guile 2.2
Thiago Jung Bauermann [Fri, 5 Dec 2025 04:05:49 +0000 (01:05 -0300)]
GDB: Guile: Remove procedures ineffectual since Guile 2.2

The manual mentions since GDB 10 that the functions for getting and setting
the size of memory port buffers are deprecated, and don't work when using
Guile 2.2 or later.  Since now GDB only supports Guile 2.2 and newer,
perform the promised removal.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
2 weeks agoGDB: Guile: Remove code meant for Guile < 2.2
Thiago Jung Bauermann [Thu, 4 Dec 2025 22:30:50 +0000 (19:30 -0300)]
GDB: Guile: Remove code meant for Guile < 2.2

Approved-By: Tom Tromey <tom@tromey.com>