]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
27 hours agolibsframe: use const qualifier for sframe_header object
Indu Bhagat [Mon, 20 Oct 2025 04:11:54 +0000 (21:11 -0700)] 
libsframe: use const qualifier for sframe_header object

...where applicable.

For the static functions that do not modify the sframe_header object,
use const.  Ditto for local vars.

Reviewed-by: Jens Remus <jremus@linux.ibm.com>
libsframe/
        * sframe.c (sframe_get_hdr_size): Use const qualifier.
        (sframe_header_sanity_check_p): Likewise.
        (flip_sframe): Use const for local var.
        (sframe_decode): Likewise.  While at it, use similar looking var
name.
        (sframe_decoder_get_hdr_size): Use const for local var.
        (sframe_decoder_get_abi_arch): Likewise.
        (sframe_decoder_get_version): Likewise.
        (sframe_decoder_get_fixed_fp_offset): Likewise.
        (sframe_decoder_get_fixed_ra_offset): Likewise.
        (sframe_get_funcdesc_with_addr_internal): Likewise.
        (sframe_decoder_get_num_fidx): Likewise.
        (sframe_encoder_get_hdr_size): Likewise.
        (sframe_encoder_get_abi_arch): Likewise.
        (sframe_encoder_get_version): Likewise.
        (sframe_encoder_get_num_fidx): Likewise.

27 hours agoinclude: sframe: rename sframe_func_desc_entry to use an explicit v2
Indu Bhagat [Mon, 20 Oct 2025 04:03:27 +0000 (21:03 -0700)] 
include: sframe: rename sframe_func_desc_entry to use an explicit v2

As SFrame format evolves, this will be useful to refer to v2 on-disk
layout directly as the format evolves.

Reviewed-by: Jens Remus <jremus@linux.ibm.com>
include/
        * sframe.h (struct sframe_func_desc_entry): Rename to tag v2.

31 hours agoAutomatic date update in version.in
GDB Administrator [Mon, 20 Oct 2025 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

43 hours ago[gdb/testsuite] Add gdb.src/pre-commit.exp
Tom de Vries [Sun, 19 Oct 2025 12:21:00 +0000 (14:21 +0200)] 
[gdb/testsuite] Add gdb.src/pre-commit.exp

Add a test-case running the pre-commit hooks, as suggested here [1].

[1] https://sourceware.org/pipermail/gdb-patches/2025-October/221441.html

2 days agoAutomatic date update in version.in
GDB Administrator [Sun, 19 Oct 2025 00:00:18 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 days agoAutomatic date update in version.in
GDB Administrator [Sat, 18 Oct 2025 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 days ago[gdb/python] Use PyConfig for python 3.9
Tom de Vries [Fri, 17 Oct 2025 18:27:40 +0000 (20:27 +0200)] 
[gdb/python] Use PyConfig for python 3.9

On ppc64le-linux (AlmaLinux 9.6) with python 3.9 and test-case
gdb.python/py-failed-init.exp I run into:
...
builtin_spawn $gdb -nw -nx -q -iex set height 0 -iex set width 0 \
  -data-directory $build/gdb/data-directory -iex set interactive-mode on^M
Python path configuration:^M
  PYTHONHOME = 'foo'^M
  PYTHONPATH = (not set)^M
  program name = '/usr/bin/python'^M
  isolated = 0^M
  environment = 1^M
  user site = 1^M
  import site = 1^M
  sys._base_executable = '/usr/bin/python'^M
  sys.base_prefix = 'foo'^M
  sys.base_exec_prefix = 'foo'^M
  sys.platlibdir = 'lib64'^M
  sys.executable = '/usr/bin/python'^M
  sys.prefix = 'foo'^M
  sys.exec_prefix = 'foo'^M
  sys.path = [^M
    'foo/lib64/python39.zip',^M
    'foo/lib64/python3.9',^M
    'foo/lib64/python3.9/lib-dynload',^M
  ]^M
Fatal Python error: init_fs_encoding: failed to get the Python codec of the \
  filesystem encoding^M
Python runtime state: core initialized^M
ModuleNotFoundError: No module named 'encodings'^M
^M
Current thread 0x00007fffabe18480 (most recent call first):^M
<no Python frame>^M
ERROR: (eof) GDB never initialized.
Couldn't send python print (1) to GDB.
UNRESOLVED: gdb.python/py-failed-init.exp: gdb-command<python print (1)>
Couldn't send quit to GDB.
UNRESOLVED: gdb.python/py-failed-init.exp: quit
...

The test-case expects gdb to present a prompt, but instead gdb calls exit
with this back trace:
...
(gdb) bt
 #0  0x00007ffff6e4bfbc in exit () from /lib64/glibc-hwcaps/power10/libc.so.6
 #1  0x00007ffff7873fc4 in fatal_error.lto_priv () from /lib64/libpython3.9.so.1.0
 #2  0x00007ffff78aae60 in Py_ExitStatusException () from /lib64/libpython3.9.so.1.0
 #3  0x00007ffff78c0e58 in Py_InitializeEx () from /lib64/libpython3.9.so.1.0
 #4  0x0000000010b6cab4 in py_initialize_catch_abort () at gdb/python/python.c:2456
 #5  0x0000000010b6cfac in py_initialize () at gdb/python/python.c:2540
 #6  0x0000000010b6d104 in do_start_initialization () at gdb/python/python.c:2595
 #7  0x0000000010b6eaac in gdbpy_initialize (extlang=0x11b7baf0 <extension_language_python>)
     at gdb/python/python.c:2968
 #8  0x000000001069d508 in ext_lang_initialization () at gdb/extension.c:319
 #9  0x00000000108f9280 in captured_main_1 (context=0x7fffffffe870)
     at gdb/main.c:1100
 #10 0x00000000108fa3cc in captured_main (context=0x7fffffffe870)
     at gdb/main.c:1372
 #11 0x00000000108fa4d8 in gdb_main (args=0x7fffffffe870) at gdb/main.c:1401
 #12 0x000000001001d1d8 in main (argc=3, argv=0x7fffffffece8) at gdb/gdb.c:38
...

This may be a python issue [1].

The problem doesn't happen if we use the PyConfig approach instead of the
py_initialize_catch_abort approach.

Fix this by using the PyConfig approach starting 3.9 (previously, starting
3.10 to avoid Py_SetProgramName deprecation in 3.11).

It's possible that we have the same problem and need the same fix for 3.8, but
I don't have a setup to check that.  Add a todo in a comment.

Tested on ppc64le-linux.

Approved-By: Tom Tromey <tom@tromey.com>
[1] https://github.com/python/cpython/issues/107827

3 days agogdb: restore warning when core file and executable don't match
Andrew Burgess [Fri, 17 Oct 2025 13:19:54 +0000 (14:19 +0100)] 
gdb: restore warning when core file and executable don't match

Consider the following GDB session:

  (gdb) file /path/to/program
  (gdb) core /path/to/corefile
  warning: core file may not match specified executable file.
  ... etc ...
  (gdb)

Notice the warning.  GDB produces this warning when one of the
following conditions is true:

  + The build-id for the core file doesn't match the build-id of the
    executable, or

  + The filename of the executable doesn't match the partial filename
    stored in the PRPSINFO note from the core file.

Unfortunately, this warning was broken by the following two commits:

  commit c97e57bc9d2e081b7c842742933b7262f1d7ce39
  Date:   Wed Oct 8 11:18:07 2025 +0100

      gdb: move core file bfd from program_space into core_target

  commit 84f8be0d9c8ce30bf56eb9e14ce6fe012125fa53
  Date:   Wed Sep 10 11:04:45 2025 +0100

      gdb: remove program_space::core_bfd member function

These commits changed how the validate_files function (in corefile.c),
which is where the warning is emitted, find the core file BFD object.
Prior to the above commits, the core file BFD was stored in the
program_space, and was set by the time validate_files was called.

After the above commits the core file BFD is stored in the inferior's
core_target, and can only be accessed if the core_target has been
pushed onto the inferior's target stack.

Unfortunately, validate_files is called just before core_target is
pushed.  As a result, in validate_files it appears as if there is no
core file loaded, and so no validation is performed.

This commit fixes that by moving the call to validate_files to after
the core_target is pushed.  The warning is now restored.

I was surprised that this wasn't caught in testing.  I was sure we had
a test for that warning.  But, when I look now, I cannot find any such
test, so this commit adds one.

While I'm adding the test, validate_files also has a warning that it
can emit if the core file is older than the executable.  I've made
sure that the test covers this warning too.

Approved-By: Tom Tromey <tom@tromey.com>
3 days agodoc/python.texi : Adapt to Python 3 print syntax
Jeremy Bryant [Tue, 14 Oct 2025 21:55:39 +0000 (22:55 +0100)] 
doc/python.texi : Adapt to Python 3 print syntax

This change adapts the print syntax to Python 3.
The documentation examples will then work on current installations.
Python 2 was sunsetted in January 2020.

Approved-By: Tom Tromey <tom@tromey.com>
4 days ago[gdb/tdep] Fix inferior call return of small char array for ppc64 v1 abi some more
Tom de Vries [Fri, 17 Oct 2025 06:02:02 +0000 (08:02 +0200)] 
[gdb/tdep] Fix inferior call return of small char array for ppc64 v1 abi some more

PR tdep/33534 reports a regression due to commit 13f1820106c ("[gdb/tdep] Fix
inferior call return of small char array for ppc64 v1 abi").

The regression can be reproduced with the test-case introduced in the commit:
gdb.ada/return-small-char-array.exp, on a ppc64-linux setup with v1 elf abi
(cfarm121).

The commit contains two changes to a piece of code in
ppc64_sysv_abi_return_value:
...
   /* Small character arrays are returned, right justified, in r3.  */
-  if (valtype->code () == TYPE_CODE_ARRAY
+  if (tdep->elf_abi == POWERPC_ELF_V1
+      && valtype->code () == TYPE_CODE_ARRAY
       && !valtype->is_vector ()
       && valtype->length () <= 8
-      && valtype->target_type ()->code () == TYPE_CODE_INT
+      && (valtype->target_type ()->code () == TYPE_CODE_INT
+   || valtype->target_type ()->code () == TYPE_CODE_CHAR)
       && valtype->target_type ()->length () == 1)
...

The first change limits the effect of the if clause to the v1 elf abi.  This
change doesn't affect the regression, since it's on a ppc64-linux setup with
v1 elf abi.  Furthermore, it's correct in the sense that the v2 elf abi
doesn't have this kind of special treatment of small character arrays.

The second change is the part that causes the regression.  The code itself
seems correct, in the sense that it enables gdb to recognize small char arrays
in ada.

The regression stems from the following discrepancy.

The comment in gdb states that "small character arrays are returned, right
justified, in r3".  This matches the v1 ABI [1].

OTOH, gcc produces code that is not in agreement with this.  Instead, it
passes the small character arrays in memory, in a caller-allocated storage
buffer pointed at by r3.  This turns out to be an gcc bug [2].

Fix this by treating this as an abi spec bug, and replacing the code handling
the "Small character arrays" case with a comment.

Doing so reveals that there are two problems in the test-case:
- missing fvar-tracking, and
- the "step 2" command doesn't land at the intended line.

Fix these by:
- adding fvar-tracking, and
- setting a breakpoint at the intended line, and continuing to it.

Tested on ppc64-linux (v1 abi), ppc64le-linux (v2 abi), and x86_64-linux.

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

[1] https://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi-1.9.html.
[2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122282

4 days agoDon't build libctf tests in source dir
Alan Modra [Fri, 17 Oct 2025 00:34:40 +0000 (11:04 +1030)] 
Don't build libctf tests in source dir

Running the libctf testsuite currently leaves big-struct-ctf.o in
libctf/testsuite/libctf-lookup/.

It ought to be possible to make the binutils source dir read-only,
and putting compiler output in the source dir leads to interesting
effects when testing multiple binutils targets in parallel.

* lib/ctf-lib.exp (run_lookup_test): For "link: objects" compile
objects in tmpdir.

4 days agoAutomatic date update in version.in
GDB Administrator [Fri, 17 Oct 2025 00:00:10 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 days agolibsframe: fix warning about argument of sframe_fre_sanity_check_p
Indu Bhagat [Thu, 16 Oct 2025 18:20:21 +0000 (11:20 -0700)] 
libsframe: fix warning about argument of sframe_fre_sanity_check_p

Recent commit (6ca8915c) added a new API sframe_fre_get_ra_undefined_p
(). It has a 'const sframe_frame_row_entry *fre' argument, causing a
warning in function ‘sframe_fre_get_ra_undefined_p’:

libsframe/sframe.c:794:50: warning: passing argument 1 of
‘sframe_fre_sanity_check_p’ discards ‘const’ qualifier from pointer
target type [-Wdiscarded-qualifiers]
  794 |   if (fre == NULL || !sframe_fre_sanity_check_p (fre))
      |                                                  ^~~
libsframe/sframe.c:293:52: note: expected ‘sframe_frame_row_entry *’ but
argument is of type ‘const sframe_frame_row_entry *’
  293 | sframe_fre_sanity_check_p (sframe_frame_row_entry *frep)
      |                            ~~~~~~~~~~~~~~~~~~~~~~~~^~~~

Fix it by using const qualifier.

libsframe/
* sframe.c (sframe_fre_sanity_check_p): Use const.

4 days agoBump 'isort' version for pre-commit
Simon Marchi [Thu, 16 Oct 2025 17:01:13 +0000 (13:01 -0400)] 
Bump 'isort' version for pre-commit

I ran `pre-commit autoupdate` and this showed up.  No changes in the
formatting.

Change-Id: If06cec2ab902d3174caf6d5b13885f4b66b66c61

4 days ago[pre-commit] Add check-gnu-style
Tom de Vries [Thu, 16 Oct 2025 10:09:57 +0000 (12:09 +0200)] 
[pre-commit] Add check-gnu-style

I got a review comment [1] because I forgot to do "space before paren".

I realized I forgot to run check_GNU_style.py, a script from the GCC repo,
which warns about things like this.

[ The python script has been around since 2017 (and an earlier version written
in shell script since 2010). ]

So for this change in gdb/gdb.c:
...
-  return gdb_main (&args);
+  return gdb_main(&args);
...
we get:
...
$ ./contrib/check_GNU_style.py <(git diff)
=== ERROR type #1: there should be exactly one space between function name \
  and parenthesis (1 error(s)) ===
gdb/gdb.c:38:17:  return gdb_main(&args);
...

Add a pre-commit hook to do this automatically.

This copies two files from the GCC repo to root-level contrib, and adds a
wrapper script gdb/contrib/check-gnu-style-pre-commit.sh (checked with
shellcheck).

The wrapper script is setup to not fail on violations, so the messages are
informational at this point.  I'm not sure all checks are 100% applicable to
our coding style.

The python script check_GNU_style.py has two dependencies: unidiff and
termcolor, which users need to install themselves.

The check is added at the pre-commit stage.  I also considered post-commit,
and I'm still not sure what is the better choice.

As with all pre-commit checks, if the check is not to your liking, you can
use SKIP=check-gnu-style to skip it.

In summary, with the new pre-commit check we get:
...
$ git commit -a -m "style error"
black...............................................(no files to check)Skipped
flake8..............................................(no files to check)Skipped
isort...............................................(no files to check)Skipped
codespell...........................................(no files to check)Skipped
check-include-guards................................(no files to check)Skipped
check-gnu-style.........................................................Passed
- hook id: check-gnu-style
- duration: 0.04s

=== ERROR type #1: there should be exactly one space between function name \
  and parenthesis (1 error(s)) ===
gdb/gdb.c:38:17:  return gdb_main(&args);

tclint..............................................(no files to check)Skipped
black...............................................(no files to check)Skipped
flake8..............................................(no files to check)Skipped
codespell...........................................(no files to check)Skipped
check-include-guards................................(no files to check)Skipped
codespell-log...........................................................Passed
- hook id: codespell-log
- duration: 0.19s
tclint...............................................(no files to check)Skipped
[master $hex] style error
...

Approved-By: Simon Marchi <simon.marchi@efficios.com>
[1] https://sourceware.org/pipermail/gdb-patches/2025-September/220983.html

4 days ago[gdb/c++] Fix hang on whatis std::string::npos
Tom de Vries [Thu, 16 Oct 2025 09:38:53 +0000 (11:38 +0200)] 
[gdb/c++] Fix hang on whatis std::string::npos

Consider the following scenario, exercising "whatis std::string::npos":
...
$ cat test.cc
int main (void) {
  std::string foo = "bar";
  return foo.size ();
}
$ g++ test.cc -g
$ gdb -q -batch -iex "set trace-commands on" a.out -x gdb.in
+start
Temporary breakpoint 1 at 0x4021c7: file test.cc, line 3.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Temporary breakpoint 1, main () at test.cc:3
3   std::string foo = "bar";
+info auto-load python-scripts
No auto-load scripts.
+whatis std::string
type = std::__cxx11::basic_string<char, std::char_traits<char>, \
  std::allocator<char> >
+whatis std::string::npos
type = const std::__cxx11::basic_string<char, std::char_traits<char>, \
  std::allocator<char> >::size_type
...

After installing the package containing the pretty-printers:
...
$ zypper install libstdc++6-pp
...
and adding some commands to use them, we get instead:
...
$ gdb -q -batch -iex "set trace-commands on" a.out -x gdb.in
+add-auto-load-safe-path /usr/share/gdb/auto-load
+add-auto-load-scripts-directory /usr/share/gdb/auto-load
+start
  ...
+info auto-load python-scripts
Loaded  Script
Yes     /usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.34-gdb.py
+whatis std::string
type = std::string
+whatis std::string::npos
type = const std::__cxx11::basic_string<char, std::char_traits<char>, \
  std::allocator<char> >::size_type
...

Note that "whatis std::string" now prints "std::string", but that
"whatis std::string::npos" still uses the longer name for std::string.

This is when compiling gdb with -O0.  With -O2 -fstack-protector-strong, we
have a hang instead:
...
+whatis std::string
type = std::string
+whatis std::string::npos
<HANG>
...

Valgrind complains about an uninitialized field
demangle_component::d_counting, which is fixed by using
cplus_demangle_fill_name in replace_typedefs_qualified_name.

After fixing that, the hang is also reproducible at -O0.

The hang happens because we're stuck in the while loop in
replace_typedefs_qualified_name, replacing "std::string::size_type" with
"std::string::size_type".

Fix this in inspect_type by checking for this situation, getting us instead:
...
+whatis std::string
type = std::string
+whatis std::string::npos
type = const std::string::size_type
$
...

The test-case is a bit unusual:
- pretty-print.cc is a preprocessed c++ source, reduced using cvise [1], then
  hand-edited to fix warnings with gcc and clang.
- the pretty-printer .py file is a reduced version of
  /usr/share/gcc-15/python/libstdcxx/v6/printers.py.

Using the test-case (and the cplus_demangle_fill_name fix), I managed to
reproduce the hang on both:
- openSUSE Leap 15.6 with gcc 7, and
- openSUSE Tumbleweed with gcc 15.

The test-case compiles with clang, but the hang didn't reproduce.

Tested on x86_64-linux.

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

[1] https://github.com/marxin/cvise

4 days agos390: Do not rewrite insns and their relocs in linker if --no-relax
Jens Remus [Thu, 16 Oct 2025 09:09:06 +0000 (11:09 +0200)] 
s390: Do not rewrite insns and their relocs in linker if --no-relax

Under certain conditions the linker rewrites:
- GOT access using lgrl to larl, changing the GOTENT to a PC32DBL reloc
- GOT access using lg to larl, changing the GOT20 to a PC32DBL reloc
- Relative long addressing instructions of weak symbols, which
  definitively resolve to zero to either (1) load address of zero,
  (2) a NOP, or (3) a trapping instruction, changing the relocation to
  a NONE reloc.

Suppress rewriting of non-TLS instructions and related relocations in
linker if option --no-relax is specified.  This aligns with LLVM linker
behavior on s390.

Like x86-64 do not actually enable the linker relaxation option by
default, as other targets would do using ENABLE_RELAXATION or
TARGET_ENABLE_RELAXATION in their linker emulation scripts.  Instead
perform linker instruction/relocation rewrites by default unless linker
option --no-relax is explicitly specified by the user.  This ensures no
functional change unless --no-relax is used.

bfd/
* elf64-s390.c (elf_s390_relocate_section): Do not rewrite
non-TLS instructions and related relocations if --no-relax.
* elf32-s390.c (elf_s390_relocate_section): Likewise.

ld/testsuite/
* ld-s390/s390.exp: New tests.  Same as gotreloc_*-1a and
weakundef-*a, but with linker option --no-relax, to verify
suppression of linker non-TLS insn and reloc rewrites.
* ld-s390/gotreloc_31-1b.dd: Likewise.
* ld-s390/gotreloc_31-no-pie-1b.dd: Likewise.
* ld-s390/gotreloc_64-no-pie-1b.dd: Likewise.
* ld-s390/gotreloc_64-norelro-1b.dd: Likewise.
* ld-s390/gotreloc_64-relro-1b.dd: Likewise.
* ld-s390/weakundef-1b.d: Likewise.  Check for expected reloc
overflows.
* ld-s390/weakundef-2b.d: Likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
4 days agos390: Rename linker tests gotreloc_*-1 and weakundef-*
Jens Remus [Thu, 16 Oct 2025 09:09:06 +0000 (11:09 +0200)] 
s390: Rename linker tests gotreloc_*-1 and weakundef-*

This enables a subsequent patch to introduce a variation of those tests
with linker option --no-relax added.

ld/testsuite/
* ld-s390/gotreloc_31-1.dd: Rename to ...
* ld-s390/gotreloc_31-1a.dd: ... this.
* ld-s390/gotreloc_31-no-pie-1.dd: Likewise.
* ld-s390/gotreloc_31-no-pie-1a.dd: Likewise.
* ld-s390/gotreloc_64-no-pie-1.dd: Likewise.
* ld-s390/gotreloc_64-no-pie-1a.dd: Likewise.
* ld-s390/gotreloc_64-norelro-1.dd: Likewise.
* ld-s390/gotreloc_64-norelro-1a.dd Likewise.
* ld-s390/weakundef-1.dd: Likewise.
* ld-s390/weakundef-1a.dd: Likewise.
* ld-s390/weakundef-2.dd: Likewise.
* ld-s390/weakundef-2a.dd: Likewise.
* ld-s390/s390.exp: Rename tests likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
4 days agos390: Rewrite emitted relocations when rewriting instructions
Jens Remus [Thu, 16 Oct 2025 09:06:17 +0000 (11:06 +0200)] 
s390: Rewrite emitted relocations when rewriting instructions

When the linker rewrites instructions it may need to rewrite the
associated relocations, so that when emitted with option --emit-relocs,
they make sense with the rewritten instructions.  Otherwise post link
analysis and optimization tools may not be able to perform correct
modifications of executables.

Under certain conditions the linker rewrites:
- GOT access using lgrl to larl, changing the GOTENT to a PC32DBL reloc
- GOT access using lg to larl, changing the GOT20 to a PC32DBL reloc
- Relative long addressing instructions of weak symbols, which
  definitively resolve to zero, to either (1) load address of zero,
  (2) a NOP, or (3) a trapping instruction.

In case of a rewrite of GOT access using lgrl/lg to larl emit the
PC32DBL relocation.  In case of a rewrite of relative long addressing
instructions of weak symbols, which definitively resolve to zero, emit
a NONE relocation and reset the symbol table index and addend.  Update
the gotreloc* and weakundef* tests to check for the respective
relocations.

This aligns with how GNU linker behaves on x86-64, when rewriting
instructions/relocations in elf_x86_64_convert_load_reloc().

bfd/
* elf64-s390.c (elf_s390_relocate_section): Rewrite emitted
relocations when rewriting instructions.
* elf32-s390.c (elf_s390_relocate_section): Likewise.

ld/testsuite/
* ld-s390/s390.exp: Link gotreloc* and weakundef* tests with
option --emit-relocs.
* ld-s390/gotreloc_31-1.dd: Expect rewritten instructions to be
accompanied by a PC32DBL or NONE relocation respectively.
* ld-s390/gotreloc_31-no-pie-1.dd: Likewise.
* ld-s390/gotreloc_64-no-pie-1.dd: Likewise.
* ld-s390/gotreloc_64-norelro-1.dd: Likewise.
* ld-s390/gotreloc_64-relro-1.dd: Likewise.
* ld-s390/weakundef-1.dd: Likewise.
* ld-s390/weakundef-2.dd: Likewise.

Fixes: a63cc5f70ca6 ("Rewrite GOT accesses using larl if possible")
Fixes: 896a639babe2 ("s390: Avoid reloc overflows on undefined weak symbols")
Fixes: 6f8b365b653d ("s390: Avoid reloc overflows on undefined weak symbols (cont)")
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
5 days agoAutomatic date update in version.in
GDB Administrator [Thu, 16 Oct 2025 00:00:22 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 days agohppa64: Remove a couple of unnecessary NULL pointer checks
John David Anglin [Wed, 15 Oct 2025 21:07:22 +0000 (17:07 -0400)] 
hppa64: Remove a couple of unnecessary NULL pointer checks

2025-10-15  John David Anglin  <danglin@gcc.gnu.org>

bfd/ChangeLog:

* elf64-hppa.c (allocate_global_data_opd): Remove hh check.
(elf64_hppa_finalize_dlt): Likewise.

5 days agogdb/testsuite: remove incorrect global variable accesses
Andrew Burgess [Mon, 13 Oct 2025 13:44:56 +0000 (14:44 +0100)] 
gdb/testsuite: remove incorrect global variable accesses

I noticed in gdb.replay/missing-thread.exp a reference to $testfile in
a location where 'testfile' had not been made available via a use of
'global'.  The uses looked like this:

  unsupported "$testfile (couldn't start gdbreplay)"

I think there are three problems here, the $testfile is invalid
because there's no 'global testfile' making the variable available.
The use of $testfile is redundant anyway as 'unsupported' already adds
the script name to the output line.  The final text within parenthesis
is bad style that's an important part of the output, but GDB test name
style is that text in parenthesis is additional text that could be
ignored, e.g. "(timeout)".

Replace the above with just:

  unsupported "couldn't start gdbreplay"

This same construct has been copied into multiple gdb.replay/ tests,
so fix them all.

There's no change to what is actually tested after this commit.

5 days agohppa64: Fix addition of symbols to local dynamic table
John David Anglin [Wed, 15 Oct 2025 18:29:51 +0000 (14:29 -0400)] 
hppa64: Fix addition of symbols to local dynamic table

This fixes lookup failure in elf64_hppa_finalize_dynreloc.

2025-10-15  John David Anglin  <danglin@gcc.gnu.org>

bfd/ChangeLog:

* elf64-hppa.c (elf64_hppa_check_relocs): Record local
dynamic symbol if a dynamic relocation is needed.
(allocate_global_data_dlt) Fix typo.
(allocate_dynrel_entries): Don't record symbol.
(elf64_hppa_finalize_dynreloc): Assert dynindx is not -1.

5 days agos390: Add tests for readelf --got-contents option
Jens Remus [Wed, 15 Oct 2025 16:24:04 +0000 (18:24 +0200)] 
s390: Add tests for readelf --got-contents option

Port tests from x86 commit 81e90cf63a10 ("readelf: Add --got-contents
option") to s390 64-bit (s390x).

ld/testsuite/
* ld-s390/binutils.exp: New file.
* ld-s390/got-1.s: Likewise.
* ld-s390/libgot_64-1a.rd: Likewise.
* ld-s390/libgot_64-1b.rd: Likewise.
* ld-s390/libgot_64-1c.rd: Likewise.
* ld-s390/libgot_64-1d.rd: Likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
5 days agogas: sframe: Represent .cfi_undefined RA as FRE without offsets
Jens Remus [Wed, 15 Oct 2025 15:45:48 +0000 (17:45 +0200)] 
gas: sframe: Represent .cfi_undefined RA as FRE without offsets

In DWARF CFI an "undefined" register rule for the return address (RA)
register indicates that there is no return address and the stack trace
is complete.

Represent DW_CFA_undefined as SFrame FRE without any offsets, so that a
stack tracer implementation can use this as indication that an outermost
frame has been reached and the stack trace is complete.

This representation is backward compatible, as existing stack tracers
should already deal with the case, that an SFrame FRE a so far invalid
offset count of zero and stop the trace.

include/
* sframe.h (SFRAME_V2_FRE_RA_UNDEFINED_P): New macro to test
FRE info word for RA undefined (FRE without any offsets).

binutils/
* NEWS: Mention SFrame can represent an undefined RA as FRE
without any offsets.

gas/
* gen-sframe.h (struct sframe_row_entry): Add ra_undefined_p
flag.
* gen-sframe.c (sframe_row_entry_new): Initialize ra_undefined_p
flag to not set.
(sframe_row_entry_initialize): Treat ra_undefined_p flag as
sticky.
(sframe_fre_set_ra_track): Reset ra_undefined_p flag.
(sframe_xlate_do_restore): Reset ra_undefined_p flag to saved
state.
(sframe_xlate_do_same_value): Reset ra_undefined_p flag.
(sframe_xlate_do_cfi_undefined): For RA set ra_undefined_p flag.
(output_sframe_row_entry): Represent RA undefined as SFrame FRE
without any offsets and FRE info word fields zeroed.
* NEWS: Mention assembler represents .cfi_undefined RA in SFrame
as FRE without any offsets.

libsframe/
* doc/sframe-spec.texi (Changes from Version 1 to Version 2):
Mention that a SFrame FRE without any offsets flag indicates an
outermost frame with an undefined RA.
(fre_offset_count): Document that a FRE offset count of zero
indicates an outermost frame with an undefined RA.
* sframe.c (sframe_get_fre_ra_undefined_p): Use macro
SFRAME_V2_FRE_RA_UNDEFINED_P.
(sframe_fre_get_fp_offset, sframe_fre_get_ra_offset): Do not
return fixed FP/RA offset if RA undefined.
* sframe-dump.c (dump_sframe_func_with_fres): Show FRE without
any offsets as "RA undefined".

gas/testsuite/
* gas/cfi-sframe/cfi-sframe.exp: Run tests for .cfi_undefined RA
on AArch64, s390x, and x86-64.
* gas/cfi-sframe/cfi-sframe-aarch64-ra-undefined-1.d: Add test
for .cfi_undefined RA on AArch64.
* gas/cfi-sframe/cfi-sframe-aarch64-ra-undefined-1.s: Likewise.
* as/cfi-sframe/cfi-sframe-s390x-ra-undefined-1.d: Add test
for .cfi_undefined RA on s390x.
* gas/cfi-sframe/cfi-sframe-s390x-ra-undefined-1.s: Likewise.
* gas/cfi-sframe/cfi-sframe-x86_64-ra-undefined-1.d: Add test
for .cfi_undefined RA on x86-64.
* gas/cfi-sframe/cfi-sframe-x86_64-ra-undefined-1.s: Likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
5 days agoinclude: libsframe: Add API to get RA undefined
Jens Remus [Wed, 15 Oct 2025 15:45:48 +0000 (17:45 +0200)] 
include: libsframe: Add API to get RA undefined

SFrame FREs without any offsets will later be used to represent an
undefined return address (RA) in SFrame.  This API can then be used,
for instance by libsframe when dumping SFrame stack trace information
(e.g. in objdump and readelf), to test for RA undefined.  Other users
of libsframe need the same capability.

include/
* sframe-api.h (sframe_fre_get_ra_undefined_p): New declaration.

libsframe/
* libsframe.ver (sframe_fre_get_ra_undefined_p): List new API.
* sframe.c (sframe_fre_get_ra_undefined_p): New definition.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
5 days agolibsframe: s390: No further decode if sframe_get_fre_offset returns err
Jens Remus [Wed, 15 Oct 2025 15:45:48 +0000 (17:45 +0200)] 
libsframe: s390: No further decode if sframe_get_fre_offset returns err

SFrame FREs without any offsets will later be used to represent
.cfi_undefined RA in SFrame.

As a result the API to get the CFA offset can return an error value, if
there are no offsets.  Do not apply the s390x-specific decoding of CFA
offset on the error return value.

libsframe/
* sframe.c (sframe_fre_get_cfa_offset): Do not apply s390x-
specific decoding to error return value.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
5 days agogas: ld: libsframe: Support for SFrame FDEs without any FREs
Jens Remus [Wed, 15 Oct 2025 15:45:48 +0000 (17:45 +0200)] 
gas: ld: libsframe: Support for SFrame FDEs without any FREs

Allow SFrame sections without any FREs, that can occur if they solely
contain FDEs without any FREs.  For FDEs without and FREs set the
offset to the first FRE to zero.

libsframe/
* sframe.c (sframe_encoder_write_sframe): Allow SFrame sections
without any FREs.  For FDEs without any FREs set the offset to
the first FRE to zero.

gas/
* gen-sframe.c (output_sframe_funcdesc): For FDEs without any
FREs set the offset to the first FRE to zero.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
5 days agogdb: add experimental option --enable-py-limited-api
Matthieu Longo [Fri, 11 Jul 2025 16:39:41 +0000 (17:39 +0100)] 
gdb: add experimental option --enable-py-limited-api

Today, GDB links against the Python library using the unstable API. This
approach causes portability issues of the generated GDB artifact. Indeed
the built artifact is tighly coupled with the specific version of Python
that it was compiled with. Using a slighly minor version of Python can
cause unpredictable crashes at runtime due to ABI instability between
the Python versions, even minor ones.

The solution would consist in restricting the usage of Python functions
to the limited C API controlled via Py_LIMITED_API that must be defined
before the inclusion of <Python.h>.

This patch does not aim at porting the whole GDB codebase to the Python
limited C API, but rather enabling a development mode where developers
can experiment with the Python limited C API, and fix issues.
This development mode is accessible with the configure option
--enable-py-limited-api which is set by default to 'no'.

Note: the version of the Python limited API is currently set to 3.11
because of PyBuffer_FillInfo and PyBuffer_Release. This choice is not
frozen, and could be reviewed later on depending on newly discovered
issues during the migration.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=23830
Approved-By: Tom Tromey <tom@tromey.com>
5 days agogdb: make Python conftest compatible with Python limited C API
Matthieu Longo [Wed, 16 Jul 2025 16:17:36 +0000 (17:17 +0100)] 
gdb: make Python conftest compatible with Python limited C API

The current test to check the support of '--dynamic-list' linker flag
uses PyRun_SimpleString (), which is part of the unstable API. As it is
now, the test will systematically fail due to the undefined symbol
rather than testing the import of ctypes.
This patch replaces PyRun_SimpleString () by an equivalent code relying
on the limited C API, and compatible with Python 3.4.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=23830
Approved-By: Tom Tromey <tom@tromey.com>
6 days agoAutomatic date update in version.in
GDB Administrator [Wed, 15 Oct 2025 00:00:31 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 days agogdb/linespec: make symbol_to_sal return an optional
Simon Marchi [Sat, 11 Oct 2025 04:08:50 +0000 (00:08 -0400)] 
gdb/linespec: make symbol_to_sal return an optional

Return an optional, instead of a bool + the actual value by parameter.
I think this makes it a bit easier to understand what's going on.

Change-Id: Idf65f4a026cab6eebfb81c4efda406aeb65d0813
Approved-By: Tom Tromey <tom@tromey.com>
6 days agogdb/linespec: take some parameters by reference
Simon Marchi [Sat, 11 Oct 2025 04:08:49 +0000 (00:08 -0400)] 
gdb/linespec: take some parameters by reference

Change the `sal` parameter of add_sal_to_sals to be a reference.  This
will make things a bit cleaner in a following patch (and it would be a
good change on its own anyway).

Change the `sals` parameter to a reference as well, while at it, which
trickles up to minsym_found.

Change-Id: I348414308940c14fa6030bc41c52f507aa6d1c12
Approved-By: Tom Tromey <tom@tromey.com>
6 days agogdb: remove unnecessary use of symtab_and_line in create_sals_line_offset
Simon Marchi [Sat, 11 Oct 2025 04:06:20 +0000 (00:06 -0400)] 
gdb: remove unnecessary use of symtab_and_line in create_sals_line_offset

create_sals_line_offset uses a symtab_and_line essentially just to hold
a line number and pass it down to decode_digits_list_mode.  Change the
local variable to be an int, and change decode_digits_list_mode to
accept an int, instead of a symtab_and_line.  I think this makes the
code a bit simpler.

Change-Id: I445d2473f042693c3a4f2693877408f85100cd1f
Approved-By: Tom Tromey <tom@tromey.com>
6 days agogdb/symtab: declare variables on first use in skip_prologue_sal
Simon Marchi [Sat, 11 Oct 2025 04:02:44 +0000 (00:02 -0400)] 
gdb/symtab: declare variables on first use in skip_prologue_sal

I'm currently looking at this function, and think it makes it easier to
process if the variables are declared when actually used.

I turned one while loop into a for, in order to be able to declare the
loop variable in the for loop.

Change-Id: I70258a94f39acb3d56e5b8e85cdfadc2f7687bc4
Approved-By: Tom Tromey <tom@tromey.com>
6 days agogdb/symtab: declare variables on first use in find_pc_sect_line
Simon Marchi [Sat, 11 Oct 2025 04:02:43 +0000 (00:02 -0400)] 
gdb/symtab: declare variables on first use in find_pc_sect_line

I'm currently looking at this function, and think it makes it easier to
process if the variables are declared when actually used.

Change-Id: Ie950fc3a7241e55e66ae96a578f79df3a9b45c69
Approved-By: Tom Tromey <tom@tromey.com>
6 days agoFix use of "main" marker in gdb index
Tom Tromey [Mon, 22 Sep 2025 15:08:46 +0000 (09:08 -0600)] 
Fix use of "main" marker in gdb index

Tom de Vries noticed that with .gdb_index, the "main" marker would
sometimes seemingly be ignored.

I tracked this down to an interaction between the rewritten reader and
the "main"-finding code in cooked_index.  With the ordinary DWARF
scanner, a C "main" won't be marked as IS_MAIN; whereas with
.gdb_index this can happen.  In this case, the code thinks that C
requires canonicalization (which is only true for types), and skips
using the symbol.

This patch fixes the problem and adds some comments explaining what is
going on.

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

6 days agoFix gdb.ada/extended-access.exp on riscv64-linux
Tom de Vries [Tue, 14 Oct 2025 16:09:36 +0000 (18:09 +0200)] 
Fix gdb.ada/extended-access.exp on riscv64-linux

On riscv64-linux, I ran into:
...
(gdb) print the_array.all^M
Cannot access memory at address 0x0^M
(gdb) FAIL: gdb.ada/extended-access.exp: print the_array.all
...

The problem is that the_array.p_array is set by a dynamic relocation:
...
0000000000002010 <array_data>:
        ...

0000000000002028 <the_array>:
        ...
                        2028: R_RISCV_RELATIVE  *ABS*+0x2010
...
which doesn't seem to get its value until we arrive in main.

Fix this by running to main before trying to print the_array.

Tested on riscv64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
6 days ago[gdb/testsuite] Fix xfail in gdb.ada/variant_record_field.exp
Tom de Vries [Tue, 14 Oct 2025 16:00:48 +0000 (18:00 +0200)] 
[gdb/testsuite] Fix xfail in gdb.ada/variant_record_field.exp

On ppc64-linux (debian 14) I run into:
...
(gdb) print p_record^M
$1 = (kind => five, i => <error reading variable: \
  access outside bounds of object>^M
(gdb) gdb_do_cache: get_compiler_info_1 ( c )
get_compiler_info: gcc-15-2-0
gdb_do_cache: get_compiler_info_1 ( c )
FAIL: gdb.ada/variant_record_field.exp: print p_record
...

The test-case contains an xfail for "[gcc_major_version] <= 14", which doesn't
trigger because gcc has version 15.2.0, while gnatmake does have version
14.3.0:
...
$ gcc --version
gcc (Debian 15.2.0-4) 15.2.0
  ...
$ gnatmake --version
GNATMAKE 14.3.0
...

Fix this by using "[gnat_version_compare < 15]" instead.

Tested on ppc64-linux and x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
6 days agogdb/corelow: Fix use-after-free in gdb_read_core_file_mappings
Lancelot SIX [Mon, 13 Oct 2025 14:11:09 +0000 (15:11 +0100)] 
gdb/corelow: Fix use-after-free in gdb_read_core_file_mappings

A recent refactor (fc8e5a565b3 -- gdb: make structured core file
mappings processing global) in gdb/corelow.c:gdb_read_core_file_mappings
introduced a use-after-free bug detected by address sanitizer.

In this change, a cache is built which holds addresses to elements of a
std::vector.  However, as elements as inserted in the vector, the
addresses in the cache should be invalidated, but are not, leading to
the use-after-free issue.

This patch proposes to store the index in the vector in the cache
instead of the address of the element, solving the invalidation issue.
An alternative approach could be to use a std::list which does not need
invalidation of addresses/references/iterators as the container is
grown.

Change-Id: Ib57d87c5d0405ffa3b7d38557fb33f7283c5d063
Approved-By: Andrew Burgess <aburgess@redhat.com>
6 days ago[gdb/build] Fix buildbreaker on x86_64-freebsd in gdb/fbsd-nat.c
Tom de Vries [Tue, 14 Oct 2025 09:51:50 +0000 (11:51 +0200)] 
[gdb/build] Fix buildbreaker on x86_64-freebsd in gdb/fbsd-nat.c

Following commit 1ad8737b3c5 ("gdb: change inf_threads_iterator to yield
references"), we're running into a build breaker on x86_64-freebsd, in
gdb/fbsd-nat.c.

Fix this.

Tested by completing a build on x86_64-freebsd and running the TUI test-cases.

6 days ago[gdb/testsuite] Fix ERROR in gdb.tui/corefile-run.exp
Tom de Vries [Tue, 14 Oct 2025 09:34:51 +0000 (11:34 +0200)] 
[gdb/testsuite] Fix ERROR in gdb.tui/corefile-run.exp

When running test-case gdb.tui/corefile-run.exp on x86_64-freebsd, we run into
PR tdep/33176:
...
PASS: gdb.tui/corefile-run.exp: load corefile
run<SNIP>gdb/fbsd-nat.c:1381: internal-error: wait_1: \
  Assertion `fbsd_inf != nullptr || pl.pl_flags & PL_FLAG_CHILD' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
----- Backtrace -----
ERROR: FIXME scroll
...

Skip the ERROR by:
- running the test-case twice, once with CLI and once with TUI, and
- only running the TUI variant if the CLI one succeeds.

While we're at it, add a KFAIL for the PR.

Tested on x86_64-freebsd and x86_64-linux.

7 days agogcore: Remove bashisms and use POSIX sh
Natanael Copa [Thu, 9 Oct 2025 11:15:34 +0000 (13:15 +0200)] 
gcore: Remove bashisms and use POSIX sh

- Switch script shebang to /bin/sh
- Remove unnecessary `function` keywords
- Replace bash arrays with simple scalar variables
- Use $(uname -s) instead of bash specific $OSINFO

Approved-By: Simon Marchi <simon.marchi@efficios.com>
7 days agoFix use-after-free when destroying objfile
Tom Tromey [Tue, 14 Oct 2025 03:36:56 +0000 (21:36 -0600)] 
Fix use-after-free when destroying objfile

The recent patch to heap-allocate compunit_symtabs introduced a
use-after-free that can occur when destroying an objfile.  The bug
here is that the objfile obstack is destroyed before compunit_symtabs;
but the compunit_symtabs destructor refers to the symtabs, which are
allocated on the obstack.

This patch fixes the problem.  This was reported using ASAN, but I
reproduced it with valgrind and verified that this fixes the problem.

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

7 days agoAutomatic date update in version.in
GDB Administrator [Tue, 14 Oct 2025 00:00:22 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 days agoLD/PE: Remove remains of MIPS target support
Maciej W. Rozycki [Mon, 13 Oct 2025 21:02:30 +0000 (22:02 +0100)] 
LD/PE: Remove remains of MIPS target support

Support for ECOFF MIPS targets, including `mips*-*-pe*' among others,
has been removed from GAS and LD with commit e8044f355dc9 ("Remove gas
and ld support for MIPS ECOFF"),
<https://inbox.sourceware.org/binutils/8761x65bzx.fsf@talisman.default/>.
However bits in PEI-format DLL support code have been left behind.

Remove the relevant pieces then, originally from commit 344a211f9995
("Add support for WinCE based toolchains."), including MIPS architecture
parts and HIGHADJ relocation support in particular.  Retain code for LOW
relocation however, even though included with said commit, as it remains
usable by ARM, i386 and x86-64 targets.

Add test cases for LOW, HIGHLOW, and DIR64 relocations handled by code
being modified.  The MCore target currently fails to produce a .reloc
image section owing to missing support, so XFAIL the HIGHLOW test.

7 days agoLD/PE: Make arch identifiers enumeration constants
Maciej W. Rozycki [Mon, 13 Oct 2025 21:02:30 +0000 (22:02 +0100)] 
LD/PE: Make arch identifiers enumeration constants

Convert internal PE architecture identifiers from macros to enumeration
constants so as to make any further updates less disruptive to code.

Add a PE_ARCH_none dummy placeholder so as to start the numbering of
actual architectures from 1 without the need to specify the numeric
value for any of the constants.

No functional change.  Suggested by Richard Earnshaw.

7 days ago[gdb/testsuite] Use expect_build_id_in_core_file a bit more
Tom de Vries [Mon, 13 Oct 2025 18:54:43 +0000 (20:54 +0200)] 
[gdb/testsuite] Use expect_build_id_in_core_file a bit more

Recent commit c1950dcc04c ("gdb/testsuite: fix failure from
gdb.python/py-corefile.exp") introduced proc expect_build_id_in_core_file,
which detects the problem that:
...
    ... some versions of the linker didn't place the build-id within the first
    page of an ELF.  As a result, the Linux kernel would not include the
    build-id in the generated core file, ...
...

Use this proc in a few more test-cases, to deal with the same problem.

Tested on x86_64-linux, openSUSE Tumbleweed with ld 2.43.1.

Approved-By: Andrew Burgess <aburgess@redhat.com>
PR testsuite/33528
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33528

7 days agoAdd a position statement about LLM generated content
Nick Clifton [Mon, 13 Oct 2025 14:16:12 +0000 (15:16 +0100)] 
Add a position statement about LLM generated content

7 days agoAdd note about how to obtain permission to upload new releases
Nick Clifton [Mon, 13 Oct 2025 14:14:42 +0000 (15:14 +0100)] 
Add note about how to obtain permission to upload new releases

8 days agoAutomatic date update in version.in
GDB Administrator [Mon, 13 Oct 2025 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 days agogdb/remote: replace use of std::pair with an actual struct
Andrew Burgess [Sat, 11 Oct 2025 13:03:39 +0000 (14:03 +0100)] 
gdb/remote: replace use of std::pair with an actual struct

Commit:

  commit 5edcbe2277db05b77ebf53f9c30b6c889a8729bc
  Date:   Mon Jul 24 17:35:54 2023 +0100

      gdb: detect when gdbserver has no default executable set

Introduced a use of std::pair as a data structure to hold some per
program space information within the program space registry.

It was pointed out during review of a later patch[1][2] that the code
would be easier to understand if the std::pair was replaced with a
struct with named fields.

That is what this commit does.  Replace the std::pair with a struct,
and update all accesses to use the named fields.

There should be no user visible changes after this commit.

[1] https://inbox.sourceware.org/gdb-patches/69681489-d556-4496-9e3b-8273cab3d8f5@simark.ca
[2] https://inbox.sourceware.org/gdb-patches/469655a7-2bcc-4f27-b2d7-3fa8808ca5b5@simark.ca

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

9 days agoReturn references from compunit_symtab iterator
Tom Tromey [Wed, 8 Oct 2025 23:29:34 +0000 (17:29 -0600)] 
Return references from compunit_symtab iterator

This changes the compunit_symtab iterator to return references rather
than pointers, following the style of some other recent changes.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
9 days agoUse std::unique_ptr in compunit_symtab
Tom Tromey [Wed, 17 Sep 2025 20:31:09 +0000 (14:31 -0600)] 
Use std::unique_ptr in compunit_symtab

Now that compunit_symtab can have a destructor, it can use
std::unique_ptr rather than an explicit 'delete'.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
9 days agoAllocate compunit_symtab on heap
Tom Tromey [Mon, 15 Sep 2025 22:46:25 +0000 (16:46 -0600)] 
Allocate compunit_symtab on heap

This patch changes compunit_symtab to be allocated on the heap, using
'new'.  It also changes the container that holds these in the objfile.
I chose to use an intrusive_list to store compunit_symtab because I
think pointer stability is needed here.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33435
Approved-By: Simon Marchi <simon.marchi@efficios.com>
10 days agogdb/symtab: remove section parameter from find_function_start_sal
Simon Marchi [Thu, 9 Oct 2025 19:14:24 +0000 (15:14 -0400)] 
gdb/symtab: remove section parameter from find_function_start_sal

All 2 callers of this overload pass NULL.  Remove the parameter and pass
nullptr explicitly to find_function_start_sal_1.

Change-Id: Ie20e7c8ad980cd7af99b6ba9c23f4da19febc1bc

10 days agoAutomatic date update in version.in
GDB Administrator [Sat, 11 Oct 2025 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

10 days agogdb: introduce new function create_function_type
Jan Vrany [Fri, 10 Oct 2025 20:38:44 +0000 (21:38 +0100)] 
gdb: introduce new function create_function_type

While working on new Python API to create new function types I realized
that there's no easy way to create a new function type and control where
it is going to be allocated (whether in gdbarch's obstack or objfile's).
Functions lookup_function_type and lookup_function_type_with_arguments
always allocate at the same obstack as its return type.

This is not sufficient for the new Python API - the user may use any
type it can get hold of. For example, one may want to create a function
returning arch-owned type and taking one argument of objfile-owned type.
In that case we need to allocate the new type on that very objfile's
obstack.

This commit introduces new function - create_function_type - that takes
type_allocator as first parameter, allowing caller to control the
allocation. Existing functions (lookup_function_type and
lookup_function_type_with_arguments) are reimplemented by means of new
create_function_type.

Approved-By: Tom Tromey <tom@tromey.com>
10 days agobfd/PE: make local array in _bfd_XXi_swap_scnhdr_out() static
Jan Beulich [Fri, 10 Oct 2025 14:03:15 +0000 (16:03 +0200)] 
bfd/PE: make local array in _bfd_XXi_swap_scnhdr_out() static

... and const. There's no reason to have the compiler copy an anonymous
.rodata object onto the stack. And there's also no reason to allow the
array to be modifiable.

10 days agobfd/PE: respect SEC_ALLOC when deciding whether to force IMAGE_SCN_MEM_DISCARDABLE
Jan Beulich [Fri, 10 Oct 2025 14:02:50 +0000 (16:02 +0200)] 
bfd/PE: respect SEC_ALLOC when deciding whether to force IMAGE_SCN_MEM_DISCARDABLE

While in the common case sections like .reloc don't need to be accessed
by a binary (that's the job of the loader), there are rare cases where
the situation is different. Unconditionally forcing the discardable flag
is therefore unhelpful. Avoid doing so when SEC_ALLOC is set, which
would in particular be the case when .reloc isn't (solely) linker-
generated.

While adjusting the comment, drop the wrong (stale?) following sentence:
.rsrc, as per its table entry, doesn't need to be writable. And
commenting on it wanting to be readable would then need to be repeated
for all other sections as well.

10 days agobfd / PE/COFF: permit SEC_READONLY and consolidate
Jan Beulich [Fri, 10 Oct 2025 14:01:16 +0000 (16:01 +0200)] 
bfd / PE/COFF: permit SEC_READONLY and consolidate

Without SEC_READONLY, even the default .text section would end up with
the IMAGE_SCN_MEM_WRITE flag, which is clearly wrong. (Afaict the flag,
oddly enough, doesn't affect the final linked binary, so there likely
are more anomalies.)

However, as suggested by Richard Earnshaw, PE's requirements are really
target independent. Consolidate SEC_CODE, SEC_DATA, SEC_READONLY,
SEC_LINK_ONCE, and SEC_LINK_DUPLICATES into target-independent code. Yet
of course targets not using CREATE_*_COFF_TARGET_VEC() won't benefit.

Note that in coff-arm.c the EXTRA_S_FLAGS conditional was also stale
(leftover from EPOC removal), and hence can go away.

10 days agogas/SH: respect --no-pad-sections
Jan Beulich [Fri, 10 Oct 2025 14:00:44 +0000 (16:00 +0200)] 
gas/SH: respect --no-pad-sections

This is once again just so the target won't need excluding in a
forthcoming new testcase, which requires no padding at the end of at
least some of the sections.

10 days agogas/SH: support BFD_RELOC_RVA in the PE/COFF case
Jan Beulich [Fri, 10 Oct 2025 14:00:30 +0000 (16:00 +0200)] 
gas/SH: support BFD_RELOC_RVA in the PE/COFF case

This is just so the target won't need excluding in a forthcoming new
testcase, which uses the .rva directive.

10 days agold/PE: respect --enable-reloc-section even when .reloc isn't created by default
Jan Beulich [Fri, 10 Oct 2025 14:00:04 +0000 (16:00 +0200)] 
ld/PE: respect --enable-reloc-section even when .reloc isn't created by default

Even when !DLL_SUPPORT, an executable may still want to have base
relocations created. Avoid doing so by default, though, to not alter
prior behavior.

With this, an xfail can (and actually should) go away (or else we end up
with an XPASS).

10 days agold/PE: adjust pe_detail_list[]
Jan Beulich [Fri, 10 Oct 2025 13:59:44 +0000 (15:59 +0200)] 
ld/PE: adjust pe_detail_list[]

M*Core uses pe-dll.c, but has no entry in the table. Add both big and
little endian ones. Many of the entries aren't relevant when targeting
PE+; move the #endif accordingly. The MIPS entry is actually
questionable altogether: No mips*-*-* target uses pe-dll.c or pep-dll.c.

As I lack sufficient knowledge of the target, introduction of
jmp_mcore_bytes[] will need to be handled by someone else.

10 days agoobjdump: enable PE support for Interix
Jan Beulich [Fri, 10 Oct 2025 13:59:18 +0000 (15:59 +0200)] 
objdump: enable PE support for Interix

This is just so the target won't need excluding in a forthcoming new
testcase. Without doing so objdump would fail saying "option -P/--private
not supported by this file".

10 days agobfd/COFF: optionally pass BFD section into swap_scnhdr_out() hook
Jan Beulich [Fri, 10 Oct 2025 13:58:55 +0000 (15:58 +0200)] 
bfd/COFF: optionally pass BFD section into swap_scnhdr_out() hook

_bfd_XXi_swap_scnhdr_out() will want to use the section's flags. Some
call sites don't have a BFD section available, and hence pass NULL. Code
using the parameter will therefore need to apply appropriate care.

10 days agobfd / PE/COFF: avoid setting SEC_ALLOC when finding IMAGE_SCN_MEM_DISCARDABLE
Jan Beulich [Fri, 10 Oct 2025 13:58:30 +0000 (15:58 +0200)] 
bfd / PE/COFF: avoid setting SEC_ALLOC when finding IMAGE_SCN_MEM_DISCARDABLE

Before teaching _bfd_XXi_swap_scnhdr_out() to respect SEC_ALLOC when
considering whether to force IMAGE_SCN_MEM_DISCARDABLE for a section,
make sure we won't "invert" present wrong behavior when transforming an
incoming object's section attributes to an outgoing one's (objcopy or
"ld -r"): Right now, IMAGE_SCN_MEM_DISCARDABLE would appear out of the
blue for certain sections. We don't want the opposite, though, i.e. we
want avoid silently dropping IMAGE_SCN_MEM_DISCARDABLE when it's present
for an incoming object's section.

10 days agogas/COFF: extend use of SEC_ALLOC
Jan Beulich [Fri, 10 Oct 2025 13:58:03 +0000 (15:58 +0200)] 
gas/COFF: extend use of SEC_ALLOC

In line with bfd's styp_to_sec_flags(), set SEC_ALLOC for code/data
sections. Tie the setting to SEC_LOAD, not avoid inadvertently producing
a .bss-like section.

10 days agold/PE: adjust .reloc and .edata section flags
Jan Beulich [Fri, 10 Oct 2025 13:57:36 +0000 (15:57 +0200)] 
ld/PE: adjust .reloc and .edata section flags

Both really want to be SEC_DATA, even if _bfd_XXi_swap_scnhdr_out()
makes sure that IMAGE_SCN_CNT_INITIALIZED_DATA is set in the final
section header. Otoh, .reloc - being IMAGE_SCN_MEM_DISCARDABLE at least
by default - shouldn't have SEC_ALLOC set.

In an early form of the patch I also dropped SEC_ALLOC for .reloc. While
I've undone that, I think the then necessary testsuite adjustments still
want retaining:

1) I can't explain why the removal of _both_ SEC_ALLOC and SEC_LOAD for
.reloc causes ld-scripts/provide-8 to XPASS on PE targets. Placing a
symbol outside of the image isn't well-defined in PE anyway though, so
convert the xfail-s to notarget-s.

2) The ld-pe/pe-aarch64 fragility is now dealt with in a separate patch.

10 days agoFix AIX CI build break.
Aditya Vidyadhar Kamath [Fri, 10 Oct 2025 11:31:06 +0000 (06:31 -0500)] 
Fix AIX CI build break.

Recently AIX internal CI is broken.

The error is as follows:
--------------------------------
aix-thread.c: In function 'void sync_threadlists(pid_t)':
aix-thread.c:857:53: error: cannot convert 'thread_info' to 'thread_info*' in initialization
  857 |     for (struct thread_info *it : all_threads_safe ())
      |                                                     ^
aix-thread.c: In lambda function:
aix-thread.c:899:61: warning: declaration of 'thread' shadows a previous local [-Wshadow=compatible-local]
  899 |     thread = iterate_over_threads ([&] (struct thread_info *thread)

----------------------------------

This patch is similar to the commit https://urldefense.proofpoint.com/v2/url?u=https-3A__sourceware.org_git_-3Fp-3Dbinutils-2Dgdb.git-3Ba-3Dcommitdiff-3Bh-3D675a17a8a5cde1d8be86536df2ae6366ef0ec759&d=DwIDAg&c=BSDicqBQBDjDI9RkVyTcHQ&r=f-oUQ8ByG1nZ71OI9p76qywCPh7mxzU69hBYnkP9Nis&m=qpgW6gyN_lC_b0fBRhcWkqlvNDmUtHBTvyqGcCZxnuN6vnvJaehZ2WVuFVicJ9oD&s=UtdzAKmXnBH1ZTFOUTmFC9vTwxxralJIDjbYWsCsLYA&e=

all_threads_safe() returns an all_threads_safe_range which is like an iterator to iterate for loops.

AIX is adjusting its code in aix-thread.c for the same.

After applying this patch,
Sample test case output:

------------
gmake check RUNTESTFLAGS='gdb.threads/thread_events.exp  CC_FOR_TARGET="/opt/freeware/bin/gcc" CXX_FOR_TARGET="/opt/freeware/bin/g++" CXXFLAGS_FOR_TARGET="-O0 -w -g -gdwarf -maix64" CFLAGS_FOR_TARGET="-O0 -w -g -gdwarf -maix64"'
gmake check-single
gmake[1]: Entering directory '/upstream_gdb/binutils-gdb/gdb/testsuite'
rm -f *core* gdb.sum gdb.log
   === gdb tests ===

Schedule of variations:
    unix

Running target unix
Using /opt/freeware/share/dejagnu/baseboards/unix.exp as board description file for target.
Using /opt/freeware/share/dejagnu/config/unix.exp as generic interface file for target.
Using /upstream_gdb/binutils-gdb/gdb/testsuite/config/unix.exp as tool-and-target-specific interface file.
Running /upstream_gdb/binutils-gdb/gdb/testsuite/gdb.threads/thread_events.exp ...

                === gdb Summary ===

/upstream_gdb/binutils-gdb/gdb/gdb version  18.0.50.20251010-git -nw -nx -q -iex "set height 0" -iex "set width 0" -data-directory /upstream_gdb/binutils-gdb/gdb/data-directory -iex "set interactive-mode on"

                === gdb Summary ===

/upstream_gdb/binutils-gdb/gdb/gdb version  18.0.50.20251010-git -nw -nx -q -iex "set height 0" -iex "set width 0" -data-directory /upstream_gdb/binutils-gdb/gdb/data-directory -iex "set interactive-mode on"

gmake[1]: Leaving directory '/upstream_gdb/binutils-gdb/gdb/testsuite'

Approved By: Ulrich Weigand <ulrich.weigand@de.ibm.com>

11 days agox86: introduce PadLock predicate
Jan Beulich [Fri, 10 Oct 2025 07:26:44 +0000 (09:26 +0200)] 
x86: introduce PadLock predicate

By, at least for now, (ab)using the PrefixRepe attribute, the other two
PadLock checks can be simplified.

11 days agox86: PadLock adjustments
Jan Beulich [Fri, 10 Oct 2025 07:26:24 +0000 (09:26 +0200)] 
x86: PadLock adjustments

For one, all PadLock insns depend on CR4.FXSR to be enabled, which means
they ought to be taking FXSR as a prereq.

Furthermore none of them permits a REPNE prefix; such forms are documented
to cause #UD. (This is mainly relevant for XSTORE, which doesn't include a
REP prefix in its base encoding. For the others this merely is a change in
what diagnostic is issued.)

Finally it is documented that an operand size prefix also causes #UD.

11 days agobfd/ELF: don't lose trailing globals from SHF_MERGE sections
Jan Beulich [Fri, 10 Oct 2025 07:25:31 +0000 (09:25 +0200)] 
bfd/ELF: don't lose trailing globals from SHF_MERGE sections

_bfd_merged_section_offset() treats trailing symbols specially: That of
the retained section will be assigned the section size, while all ones in
replaced sections will be set to zero (which will then have output offset
added, i.e. generally the size of the retained section). However, in
neither case will the function change the section. Hence such trailing
symbols, when not originating from the retained section, will appear to
live in excluded sections, when they really belong to the sole retained
one.

Replace the section in all cases, and uniformly return section size.

11 days agoaarch64: Add support for FEAT_SSVE_BITPERM
Alice Carlotti [Tue, 7 Oct 2025 22:54:52 +0000 (23:54 +0100)] 
aarch64: Add support for FEAT_SSVE_BITPERM

11 days agoaarch64: Add support for FEAT_SSVE_FEXPA
Alice Carlotti [Tue, 7 Oct 2025 22:50:07 +0000 (23:50 +0100)] 
aarch64: Add support for FEAT_SSVE_FEXPA

11 days agoaarch64: Add support for FEAT_SME_MOP4
Alice Carlotti [Tue, 7 Oct 2025 22:40:26 +0000 (23:40 +0100)] 
aarch64: Add support for FEAT_SME_MOP4

11 days agoaarch64: Add support for FEAT_SME_TMOP
Alice Carlotti [Tue, 7 Oct 2025 22:38:01 +0000 (23:38 +0100)] 
aarch64: Add support for FEAT_SME_TMOP

11 days agoaarch64: Remove incorrect disassembly constraint
Alice Carlotti [Tue, 7 Oct 2025 04:02:11 +0000 (05:02 +0100)] 
aarch64: Remove incorrect disassembly constraint

A check in print_insn_aarch64_word asserted that part of the encoding
space couldn't contain any valid encodings, and then returned ERR_NYI
("Not Yet Implemented", perhaps?) for these values.  However, some of
the new FEAT_MOP4 instructions will trigger the assert.  The check seems
to be outdated, and is clearly no longer valid, so it can just be
deleted.

Additionally, there are no other assignments of ERR_NYI, so delete all
remaining references to this error type.

11 days agoaarch64: Use constant fields in simple_index operands
Alice Carlotti [Fri, 3 Oct 2025 04:50:44 +0000 (05:50 +0100)] 
aarch64: Use constant fields in simple_index operands

Update aarch64_{ins|ext}_simple_index to use constant fields, and swap
the order of the index and regno fields, so that the regno occupies the
last five bits.  (Splitting/combining a variable length value and a
fixed length value is easiest if the fixed length value occupies the
least significant bits.)

11 days agoaarch64: Allow multiple fields for sve_aligned_reglist
Alice Carlotti [Fri, 3 Oct 2025 03:35:36 +0000 (04:35 +0100)] 
aarch64: Allow multiple fields for sve_aligned_reglist

Update aarch64_{ins|ext}_sve_aligned_reglist to use constant fields
instead of operand specific data for zero-extension/truncation.

11 days agoaarch64: Allow multiple fields in {ins|ext}_regno
Alice Carlotti [Thu, 2 Oct 2025 19:45:33 +0000 (20:45 +0100)] 
aarch64: Allow multiple fields in {ins|ext}_regno

Adjust SME_PNd3/SME_PNg3 to use explicit FLD_CONST_1 bits.  This allows
the use of operand specific data to be eliminated here.

11 days agoaarch64: Extend aarch64_field to support constants
Alice Carlotti [Thu, 2 Oct 2025 17:57:58 +0000 (18:57 +0100)] 
aarch64: Extend aarch64_field to support constants

Many instructions have constraints on the range of registers they can
use.  This means that some bits in the register number are fixed, and
therefore aren't mapped to a field in the instruction encoding.
Currently we use various adhoc rules to handle these fixed bits, but
this doesn't handle all cases and we often have to write new code to
support new combinations of permitted registers.

This patch allows these constant bits to instead be specified in the
same structure used to represent instruction fields.  Uses of the new
constant fields will be introduced in subsequent patches.

11 days agoAutomatic date update in version.in
GDB Administrator [Fri, 10 Oct 2025 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

11 days agoRemove linespec.c:symtab_collector class
Tom Tromey [Mon, 29 Sep 2025 15:31:59 +0000 (09:31 -0600)] 
Remove linespec.c:symtab_collector class

linespec.c has a symtab_collector class that is readily replaced by a
lambda.  I think the result is more clear.

I considered using the unordered_dense 'extract' method as well, to
make the code a bit more efficient -- but it wasn't clear to me if the
ordering of the vector mattered, and so I've just added a comment.

Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
11 days agoClean up iterate_over_symtabs
Tom Tromey [Sun, 28 Sep 2025 04:29:24 +0000 (22:29 -0600)] 
Clean up iterate_over_symtabs

After the "search via psyms" series, there's no need for
iterate_over_symtabs to first check the expanded symtabs -- the
callback will now be called for every relevant symtab, including ones
that were already expanded before the search.

Cleaning this up enables some other cleanups.  In particular,
iterate_over_some_symtabs is not needed in its current form, so here
I've renamed it, made it static, and made it search just a single
compunit symtab.

While there I cleaned up the "invert" logic in
objfile::map_symtabs_matching_filename.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30738
Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
11 days agoRemove an extraneous 'return' from void method
Tom Tromey [Sat, 27 Sep 2025 21:12:34 +0000 (15:12 -0600)] 
Remove an extraneous 'return' from void method

cooked_index_functions::map_symbol_filenames returns 'void' but also
does "return ... expression".  While valid, this seems strange.  This
patch removes the unnecessary 'return'.

Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
11 days agoConvert map_symbol_filenames to method
Tom Tromey [Sat, 27 Sep 2025 21:11:13 +0000 (15:11 -0600)] 
Convert map_symbol_filenames to method

This patch changes the free function map_symbol_filenames to be a
method of program_space.  This seems a bit cleaner, and also lets us
hoist a use of the global into the callers.

Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
11 days agodoc/gdb.texinfo: Add EIO and ENOSYS errno values
Yodel Eldar [Wed, 8 Oct 2025 16:34:55 +0000 (11:34 -0500)] 
doc/gdb.texinfo: Add EIO and ENOSYS errno values

This patch adds the EIO and ENOSYS errno values supported by GDB's
File-I/O to section E.14.9: Errno Values of the GDB manual [1] that were
presumably inadvertently omitted; both can be seen in the enum
fileio_error:gdbsupport/fileio.h and corresponding function
host_to_fileio_error:gdbsupport/fileio.cc as FILEIO_{EIO,ENOSYS}.

FILEIO_SUCCESS remains excluded from the manual, because its stated
purpose (commit b872057a6) is to internally represent the absence of an
error value from the remote, and it's not actually an error number.

[1] https://sourceware.org/gdb/current/onlinedocs/gdb.html/Errno-Values.html

Approved-By: Simon Marchi <simon.marchi@efficios.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
12 days agogas/macro.c getstring
Alan Modra [Thu, 9 Oct 2025 04:16:39 +0000 (14:46 +1030)] 
gas/macro.c getstring

This code:
      if (in->ptr[idx] == '!')
{
  idx++;
  sb_add_char (acc, in->ptr[idx++]);
}
and similar code in the other loop, blindly accessed the next element
of the string buffer without first checking idx against in->len,
leading to uninitialised accesses or buffer overruns.  Fix that, and
tidy the loops so that the function always returns the index one past
the last char consumed.  (It could return idx == in->len + 1).

* macro.c (getstring): Don't access past end of input string
buffer.  Tidy loops.  Don't return an index past in->len.

12 days agogdb/testsuite: make gdb.tui/gdb.sh work with dash
Simon Marchi [Thu, 9 Oct 2025 01:49:50 +0000 (21:49 -0400)] 
gdb/testsuite: make gdb.tui/gdb.sh work with dash

gdb.tui/gdb.sh (used by test gdb.tui/tuiterm-2.exp) doesn't run well
when /bin/sh is dash:

    $ bash testsuite/gdb.tui/gdb.sh
    foo^C
    $ dash testsuite/gdb.tui/gdb.sh
    footestsuite/gdb.tui/gdb.sh: 20: read: arg count

shellcheck actually points it out:

    In testsuite/gdb.tui/gdb.sh line 20:
    read
    ^--^ SC3061 (warning): In POSIX sh, read without a variable is undefined.
    ^--^ SC2162 (info): read without -r will mangle backslashes.

Fix the issue by passing the `_` dummy variable.  Using that particular
variable will not cause shellcheck to whine about it being unused.  Also
add `-r` to make it happy.

Change-Id: Ida3eddbfa3473487743fc96615baf735b4773738

12 days agoAutomatic date update in version.in
GDB Administrator [Thu, 9 Oct 2025 00:00:53 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 days agohppa64: Fix relocation handling for global data and a couple of thinkos
John David Anglin [Wed, 8 Oct 2025 21:04:02 +0000 (17:04 -0400)] 
hppa64: Fix relocation handling for global data and a couple of thinkos

This fixes relocation handling in situations where hh->owner and
hh->sym_indx were not initialized.

2025-10-08  John David Anglin  <danglin@gcc.gnu.org>

bfd/ChangeLog:

PR binutils/6511
* elf64-hppa.c (global_sym_index): New from ia64.
(elf64_hppa_check_relocs): Only set hh->eh.ref_regular if we
have a regular definition.
(elf64_hppa_check_relocs): Add missing NEED_DYNREL to need_entry
assignment.
(elf64_hppa_check_relocs): Stash symbol index and section
earlier.
(allocate_global_data_dlt): Initialize hh->owner and hh->sym_indx
if not initialized.
(allocate_global_data_opd): Likewise.  Remove redundant checks
for NULL hh.
(allocate_dynrel_entries): Check for discarded
hppa_info->other_rel_sec section.  Add assert rent->sec->owner
== hh->owner.
(elf64_hppa_finalize_dynreloc): Check for discarded
hppa_info->other_rel_sec section.
(elf_hppa_final_link_relocate): Return bfd_reloc_ok if we
have R_PARISC_NONE relocation.

12 days ago[gdb/testsuite] Fix bp loc in gdb.server/fetch-exec-and-args.exp
Tom de Vries [Wed, 8 Oct 2025 20:32:00 +0000 (22:32 +0200)] 
[gdb/testsuite] Fix bp loc in gdb.server/fetch-exec-and-args.exp

With test-case gdb.server/fetch-exec-and-args.exp, on aarch64-linux I run into:
...
(gdb) break 28^M
Breakpoint 1 at 0xfffff7fd7b8c: file ../sysdeps/aarch64/dl-start.S, line 30.^M
(gdb) continue^M
Continuing.^M
^M
Breakpoint 1, _start () at ../sysdeps/aarch64/dl-start.S:30^M
30              mov     x0, sp^M
(gdb) PASS: $exp: packet=on: test_exec_and_arg_fetch: \
  continue to breakpoint: run to breakpoint
print argc^M
No symbol "argc" in current context.^M
(gdb) FAIL: $exp: packet=on: test_exec_and_arg_fetch: print argc
...

The problem is that the "break 28" is not specific about the file.

Fix this by setting the breakpoint on fetch-exec-and-args.c:28.

Tested on aarch64-linux.

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

12 days ago[gdb/testsuite] Fix ERROR in expect_build_id_in_core_file
Tom de Vries [Wed, 8 Oct 2025 20:08:49 +0000 (22:08 +0200)] 
[gdb/testsuite] Fix ERROR in expect_build_id_in_core_file

With test-case gdb.python/py-corefile.exp I run into:
...
PASS: $exp: test mapped files data: show-build-ids
ERROR: tcl error sourcing gdb.python/py-corefile.exp.
ERROR: bad option "0x1fa178": \
  must be -nobackslashes, -nocommands, or -novariables
    while executing
"subst 0x$offset + 0"
...

Fix this using "[subst 0x$offset]" instead.

Tested on x86_64-linux.

12 days agogdb: add tests for per-inferior settings
Sébastien Darche [Mon, 29 Sep 2025 15:01:03 +0000 (11:01 -0400)] 
gdb: add tests for per-inferior settings

I am currently upstreaming some patches from ROCgdb that were made a few
years ago. This series cleans up how the CLI and MI access parameters
for multiple inferiors.

A preceding patch (702991711a91 ("gdb: Have setter and getter callbacks
for settings")) allowed for per-inferior getter/setter functions of some
inferior-specific settings. Over the years a few changes were accepted
upstream (cc09d372f664 ("gdb: make set/show args work with
$_gdb_setting_str")) that implemented those capabilities.

This patch adds a few tests to verify that those settings are properly
set and accessed from the CLI, MI as well as the python interface.

Co-Authored-By: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I7a5eab210c84d6a6782a32125f68bde34d9a2339
Approved-By: Andrew Burgess <aburgess@redhat.com>
12 days agogdb: make deprecated_show_value_hack use its ui_file parameter
Sébastien Darche [Mon, 29 Sep 2025 14:50:48 +0000 (10:50 -0400)] 
gdb: make deprecated_show_value_hack use its ui_file parameter

If a setting does not provide a "show" function, we fall back to the
deprecated_show_value_hack function to print the value in a generic
way. The current version ignores the `file` parameter specifying the
output file in favor of always using gdb_stdout.

To make things consistent with how the values are printed using a
regular show command, the proposed change makes the function use the
ui_file parameter it receives (even though do_show_command passes
gdb_stdout).

Co-Authored-By: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I54028ed654a1fa4d955e6e46f979472c8d98ace9
Approved-By: Andrew Burgess <aburgess@redhat.com>
12 days agogdb: do not recompute values for inferior parameters when showing them
Sébastien Darche [Mon, 29 Sep 2025 14:22:49 +0000 (10:22 -0400)] 
gdb: do not recompute values for inferior parameters when showing them

When calling the `show` command on a few inferior-specific settings
(inferior-tty, args, cwd), GDB will recompute the values despite them
being provided by a getter.

For instance, When `show cwd` is called, `do_show_command` will query
the value of the `cwd` through `get_inferior_cwd`, which already gets
the per-inferior value. The current version seems to be a workaround
from when settings could not provide a getter function and per-inferior
settings could thus not be implemented properly, forcing the `show`
implementation to recompute the value itself.

The changes clean up the code and makes the show command trust the
values it is being forwarded, as they will always be computed by the
getter function.

Co-Authored-By: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I3b25f61f9101d98a6df7d50cee50131aec7e25c9
Approved-By: Andrew Burgess <aburgess@redhat.com>
12 days agogdb: use getter/setter command styles for "set tdesc filename"
Sébastien Darche [Mon, 29 Sep 2025 13:47:59 +0000 (09:47 -0400)] 
gdb: use getter/setter command styles for "set tdesc filename"

The target description filename command pair ("(set|get) tdesc
filename") uses a rather indirect way to set the variable for the
inferior, using a scratch variable to pass the value. While most other
inferior-specific parameters were updated to the more direct
getter/setter style functions, I believe this parameter was an
oversight.

This patch removes the intermediate string and directly accesses the
tdesc filename for the current inferior.

Co-Authored-By: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I2a87c65c9931ec91d15f854b32ac8279fe7077be
Approved-By: Andrew Burgess <aburgess@redhat.com>