Only native code should use struct user_gcs, so its definition should be
in a native-specific file and not in a file under gdb/arch/.
To fix this problem, create gdb/nat/aarch64-gcs-linux.h and move the
struct user_gcs definition to it, as suggested by Luis.
To fix the use of struct user_gcs in gdb/aarch64-linuxt-dep.c, define a
macro with the size of the GCS regset in gdb/arch/aarch64-gcs-linux.h
and use it in aarch64-linux-tdep.c, as is done for other regsets and
following a suggestion from Simon Marchi.
Also, move the HWCAP_GCS definition to gdb/nat/aarch64-gcs-linux.h and
create an AARCH64_HWCAP_GCS definition in gdb/arch/aarch64-gcs-linux.h
for use by target-dependent code.
Similarly, move the SEGV_CPERR and PR_SHADOW_STACK_{ENABLE,WRITE,PUSH}
definitions, which were added by the GCS patches and are only used by
aarch64-linux target-dependent code, to gdb/arch/aarch64-gcs-linux.h
with an AARCH64_ prefix and adjust users.
Finally, I noticed that gdb/aarch64-linux-nat.c and
gdbserver/linux-aarch64-low.cc don't need anything from the
arch/aarch64-gcs-linux.h header, so make them not include it.
Suggested-by: Luis <luis.machado.foss@gmail.com> Suggested-by: Simon Marchi <simark@simark.ca> Approved-By: Luis Machado <luis.machado.foss@gmail.com>
The HWCAP2_SME, HWCAP2_SME2 and HWCAP2_SME2P1 definitions should be in a
file under gdb/nat/, so move them to aarch64-scalable-linux-ptrace.h.
Also, I noticed that gdb/aarch64-linux-nat.c and
gdbserver/linux-aarch64-low.cc don't need anything from the
arch/aarch64-scalable-linux.h header, so make them not include it.
Approved-By: Luis Machado <luis.machado.foss@gmail.com>
GDB conditionally defines HWCAP2_MTE in gdb/arch/aarch64-mte-linux.h, but
that's not the best place for it since it's a definition that should be
used only in native code so move it to gdb/nat/aarch64-mte-linux-ptrace.h.
Introduce an AARCH64_HWCAP2_MTE in gdb/arch/aarch64-mte-linux.h to be used
by target-dependant code.
Similarly, add AARCH64_ prefix to the SEGV_MTEAERR and SEGV_MTESERR
definitions in gdb/arch/aarch64-mte-linux.h.
I noticed that enum class aarch64_memtag_type is only used in native code,
so move its definition to gdb/nat/aarch64-mte-linux-ptrace.h as well.
I also noticed that gdb/aarch64-linux-tdep.h defines
AARCH64_LINUX_SIZEOF_MTE_REGSET which is redundant with
AARCH64_LINUX_SIZEOF_MTE, already defined in gdb/arch/aarch64-mte-linux.h
so consolidate both definitions.
Finally, the include of arch/aarch64-mte-linux.h isn't used in
gdb/aarch64-linux-nat.c nor in gdb/nat/aarch64-mte-linux-ptrace.c so
remove it from them.
Suggested-by: Luis <luis.machado.foss@gmail.com> Suggested-by: Simon Marchi <simark@simark.ca> Approved-By: Luis Machado <luis.machado.foss@gmail.com>
GDB: Add aarch64-fpmr-linux.h to gdb/arch/ and gdb/nat/
GDB conditionally defines HWCAP2_FPMR in gdb/arch/aarch64.h, but that's
not the best place for it since it's a Linux-specific definition.
Add new Linux- and feature-specific headers to contain it, one for
target-dependent code and the other for native code.
The target-dependant code should use AARCH64_HWCAP2_FPMR in
gdb/arch/aarch64-fpmr-linux.h while native code should use HWCAP2_FPMR,
which will hopefully be defined by the system headers but with a backup
definition in gdb/nat/aarch64-fpmr-linux.h if it isn't.
Suggested-by: Luis <luis.machado.foss@gmail.com> Suggested-by: Simon Marchi <simark@simark.ca> Approved-By: Luis Machado <luis.machado.foss@gmail.com>
GDB: Add aarch64-pauth-linux.h to gdb/arch/ and gdb/nat/
The code supporting Pointer Authentication duplicates the definition of
AARCH64_HWCAP_PACA and of AARCH64_LINUX_SIZEOF_PAUTH between GDB and
gdbserver, so add two new headers to host those definitions.
The target-dependant code should use AARCH64_HWCAP_PACA in
gdb/arch/aarch64-pauth-linux.h while native code should use HWCAP_PACA,
which will hopefully be defined by the system headers but with a backup
definition in gdb/nat/aarch64-pauth-linux.h if it isn't.
Suggested-by: Luis <luis.machado.foss@gmail.com> Suggested-by: Simon Marchi <simark@simark.ca> Approved-By: Luis Machado <luis.machado.foss@gmail.com>
Simon Marchi [Mon, 16 Mar 2026 14:25:23 +0000 (10:25 -0400)]
gdb: remove TYPE_CHAIN
IMO, there is no point in keeping this macro. Remove it and access the
field directly. If we ever want some kind of abstraction in front of
the field, then we'll add a method.
Change-Id: Ia45cc7be5c6d9d09a9d4903f01b1ab282839a9c2 Approved-By: Andrew Burgess <aburgess@redhat.com>
Simon Marchi [Mon, 16 Mar 2026 14:25:22 +0000 (10:25 -0400)]
gdb: remove TYPE_RVALUE_REFERENCE_TYPE
IMO, there is no point in keeping this macro. Remove it and access the
field directly. If we ever want some kind of abstraction in front of
the field, then we'll add a method.
Change-Id: Ic1e6ee65f7fda78a40e935b1e6a8e3b7ab5540fb Approved-By: Andrew Burgess <aburgess@redhat.com>
Simon Marchi [Mon, 16 Mar 2026 14:25:21 +0000 (10:25 -0400)]
gdb: remove TYPE_REFERENCE_TYPE
IMO, there is no point in keeping this macro. Remove it and access the
field directly. If we ever want some kind of abstraction in front of
the field, then we'll add a method.
Change-Id: Iabdb3a3eecd8274ddefc32ad835644bc4a0d2087 Approved-By: Andrew Burgess <aburgess@redhat.com>
Simon Marchi [Mon, 16 Mar 2026 14:25:20 +0000 (10:25 -0400)]
gdb: remove TYPE_POINTER_TYPE
IMO, there is no point in keeping this macro. Remove it and access the
field directly. If we ever want some kind of abstraction in front of
the field, then we'll add a method.
Change-Id: I592789130ad81776c7a8b39c4721ebb4aa7293f7 Approved-By: Andrew Burgess <aburgess@redhat.com>
Simon Marchi [Mon, 16 Mar 2026 14:25:19 +0000 (10:25 -0400)]
gdb: remove TYPE_MAIN_TYPE
IMO, there is no point in keeping this macro. Remove it and access the
field directly. If we ever want some kind of abstraction in front of
the field, then we'll add a method.
Change-Id: I1076b0e07644afdc0c1f3a4916148d3344a9d395 Approved-By: Andrew Burgess <aburgess@redhat.com>
Simon Marchi [Mon, 16 Mar 2026 14:25:18 +0000 (10:25 -0400)]
gdb: remove INIT_NONE_SPECIFIC
This macro seems unnecessary. It is only used right after allocating a
new type, and it only sets some fields to 0, which is the default state
of a struct type anyway.
Change-Id: I9dab6825b07875964505c387daf5f6b1e12c8144 Approved-By: Andrew Burgess <aburgess@redhat.com>
Simon Marchi [Mon, 16 Mar 2026 15:23:19 +0000 (11:23 -0400)]
gdb, gdbserver, gdbsupport: replace many uses of strcmp with streq
Replace all occurrences of:
strcmp (...) == 0
strcmp (...) != 0
!strcmp (...)
0 == strcmp (...)
strcmp (...) directly used as a boolean predicate
with the equivalent expression using streq.
This is for consistency (we already use streq as some places in the
testsuite) but also for clarity. I think that streq is clearer on the
intent than strcmp. It's also a bit shorter.
Change-Id: Ibbf5261b1872c240bc0c982c147f6a5477275a91 Approved-By: Andrew Burgess <aburgess@redhat.com>
Simon Marchi [Mon, 16 Mar 2026 00:12:22 +0000 (20:12 -0400)]
gdb/dwarf: fix build error with older gcc
With gcc 7.5.0, we get:
CXX dwarf2/read.o
/home/simark/src/binutils-gdb/gdb/dwarf2/read.c: In function ‘void decode_line_header_for_cu(die_info*, dwarf2_cu*, const file_and_directory&)’:
/home/simark/src/binutils-gdb/gdb/dwarf2/read.c:5796:25: error: unused variable ‘_’ [-Werror=unused-variable]
auto [_, inserted_]
^
That version of gcc (and earlier) apparently produces unused variable
warnings for unused structured bindings. Fix it by accessing `.second`
directly to get the "inserted" boolean value.
Provided symbols are revised to match those provided by HP ld.
This fixes startup issues caused by defining __FPU_MODEL,
__libdl_jmp_tbl and __systab.
This change adds the emultempl/hppa64elf.em file. We now always
link against /lib/pa20_64/milli.a on HP-UX.
HP-UX shared libraries have some unresolved symbols. So, we also
need to ignore unresolved symbols in shared libraries.
We adjust TEXT_START_ADDR and SHLIB_TEXT_START_ADDR to match the
values used by HP ld.
The .data section is moved to the start of the data segment.
2026-03-15 John David Anglin <danglin@gcc.gnu.org>
ld/ChangeLog:
* emulparams/elf64hppa.sh (TEXT_START_ADDR): Revise value to match
HP ld value.
(SHLIB_TEXT_START_ADDR): Likewise.
(EXTRA_EM_FILE): Define.
(OTHER_SYMBOLS): Revise to match symbols provided by HP ld.
* emultempl/hppa64elf.em: New file.
* scripttempl/elf64hppa.sc: Move .data to start of segment.
Add new command line option to select PRU core revision to assemble for.
This new option is used to limit the available opcodes to what the
selected revision supports.
Simon Marchi [Tue, 10 Mar 2026 17:34:45 +0000 (13:34 -0400)]
gdb/linux-tdep: use builtin integer types
I noticed some spots creating new integer types, where I think we could
use the builtin types created by create_gdbtypes_data instead.
The old code to initialize `short_type` was actually passing the wrong
bit length value, so I think this actually fixes a latent bug, although
it goes away in a subsequent patch.
Change-Id: I8fc71cb75f4450a42f48ba2af5c1163208e58d8c Approved-By: Tom Tromey <tom@tromey.com>
hppa64: Improve HP-UX support and fix some relocation issues
With this patch, gcc-16 test results are now similar to those
using the HP ld.
The change fixes dynamic symbol handling. At the moment, we
only have a single stub section and no support for long pc-relative
calls. So, we only need to redirect pc-relative branches through
the PLT when the call is to a dynamic function.
The change to elf64_hppa_finalize_dynreloc() fixes C++ VTT support.
This fixed many tests in the gcc g++ and libstdc++ testsuites.
The next step is to add support for long pc-relative branches via
the PLT.
2026-03-14 John David Anglin <danglin@gcc.gnu.org>
bfd/ChangeLog:
* elf64-hppa.c (elf64_hppa_check_relocs): Only set NEED_PLT
and NEED_STUB for symbols with function types.
(elf64_hppa_dynamic_symbol_p): Return false for millicode
symbols.
(allocate_global_data_dlt): Only allocate DLT entries for
symbols that are dynamic or defined. Clear hh->want_dlt
if we don't want a DLT entry.
(allocate_global_data_plt): Only allocate PLT entries for
dynamic symbols.
(allocate_global_data_stub): Likewise, Only allocate stubs
for dynamic symbols.
(elf64_hppa_create_dynamic_sections): Fix flags for .dynamic
section and remove duplicated flags for other dynamic
sections.
(allocate_dynrel_entries): Fix DLT and PLT allocations.
(elf64_hppa_late_size_sections): Don't sort relocations.
Tweak code to set section used to set __text_seg.
(elf64_hppa_finish_dynamic_symbol): Use eh->dynindx instead
of hh->eh.dynindx. Don't call elf64_hppa_dynamic_symbol_p
to determine whether PLT entries and stubs need initialization.
(elf64_hppa_finalize_dynreloc): Add rent->addend to value
calculation.
(elf_hppa_remark_useless_dynamic_symbols): Revise symbols
checked.
(elf_hppa_final_link_relocate): Revise code to redirect
pc-relative calls to stubs.
(elf_backend_want_p_paddr_set_to_zero): Define to 1 on HP-UX
target.
Simon Marchi [Tue, 10 Mar 2026 17:30:32 +0000 (13:30 -0400)]
gdb/linux-tdep: check return value of linux_find_memory_region_ftype callback
I noticed that linux_find_memory_regions_full did not check the return
value of the linux_find_memory_region_ftype callback. I think this is a
mistake. When called from linux_find_memory_regions, the
find_memory_region_ftype callback could return false, in which case we
should stop iterating.
This probably didn't matter in practice, as these callbacks generally
don't return false (only in error cases that never happen).
Change-Id: Iafc5a9aae3d955454420d700a23f18de6f0bc267 Approved-By: Tom Tromey <tom@tromey.com>
Matthieu Longo [Fri, 27 Feb 2026 14:13:26 +0000 (14:13 +0000)]
gdb/python: add accessor helpers for __dict__ in Python extension objects
Python extension objects that support __dict__ must inherit from
gdbpy_dict_wrapper, a wrapper class that stores the PyObject
corresponding to the __dict__ attribute. Because this dictionary
is not managed directly by Python, each extension objects must
provide appropriate accessors so that attributes stored in __dict__
are looked up correctly.
Currently, management of this dictionary is not centralized, and
each Python extension object implements its own logic to create,
access, and destroy it.
A previous patch centralized the creation logic; this patch focuses
on centralizing the access to the dictionary. It introduces two new
macros:
- gdbpy_dict_wrapper_cfg_dict_getter, which defines a getter for
__dict__.
- gdbpy_dict_wrapper_getsetattro, which sets tp_getattro and
tp_setattro in PyTypeObject to gdb_py_generic_getattro and
gdb_py_generic_setattro, respectively. These helpers already
centralizes attribute access for Python extension objects having
a __dict__.
Note: this macro will eventually be removed once Python extension
types are migrated to heap-allocated types.
Tom Tromey [Fri, 20 Feb 2026 13:54:36 +0000 (06:54 -0700)]
Remove type::stub_is_supported
I noticed type::stub_is_supported the other day. It is only set in a
single spot in the DWARF reader. And looking at this, the logic seems
backward or confused to me.
That is, a type is opaque if a bunch of conditions are met (earlier in
the method), and then either the type is marked as a stub, or else the
type does not have the stub_is_supported flag set.
However the DWARF reader essentially does this:
if (something)
type->set_is_stub (true);
else
type->set_stub_is_supported (true);
That is, either one flag or the other is going to be true along this
path.
So maybe this was a workaround for some other reader that doesn't set
the flag. Luckily, most of the other readers were removed. Checking
the CTF reader, it seems to correctly set the stub flag for incomplete
types.
So, I think the stub_is_supported machinery can simply be removed now.
Tom Tromey [Fri, 20 Feb 2026 13:54:27 +0000 (06:54 -0700)]
Use dwarf-to-dwarf-assembler.py on dw2-icc-opaque
I ran dwarf-to-dwarf-assembler.py on the output of the dw2-icc-opaque
test. The test was already architecture-independent, but I think it's
a bit easier to read this way.
I made a couple of tiny edits to the output, that I don't think affect
the test:
* I slightly shortened the producer strings (removing the newline and
subsequent text)
* I changed a DW_AT_data_member_location to be a constant rather than
an expression
Tom Tromey [Thu, 19 Feb 2026 19:15:05 +0000 (12:15 -0700)]
Print overload debug messages to gdb_stdlog
I noticed that overload debugging messages go to gdb_stderr. I think
the usual convention is that debug output goes to gdb_stdlog, so this
patch makes this change.
Jan Beulich [Fri, 13 Mar 2026 09:31:58 +0000 (10:31 +0100)]
testsuites: prune checking gas for CFI / SFrame
Both leave the generated assembler file around. Maybe that's okay-ish
when left in tmpdir/, but the main directories really shouldn't be
cluttered. The file actually doesn't even need putting there when not
working with a remote host.
The SFrame test additionally leaves an a.out file in the main directory,
then the assembler output isn't really of interest anyway.
Jan Beulich [Fri, 13 Mar 2026 06:52:46 +0000 (07:52 +0100)]
bfd: avoid elf-vxworks.c for non-VxWorks targets
It is wasteful to build this file when it's not actually used. Limit it to
VxWorks targets and introduce a compiler define (paralleling
OBJ_MAYBE_ELF, as having similar purpose) to guard internals.
By adding more #ifdef-ary, more savings may be possible. For now, besides
those guarding the vector definitions, only ones necessary to avoid the
need for elf_vxworks_*() inline stubs are being added. Somewhat similarly
tighter #ifdef around the definitions of *_elf*_vxworks*_vec (using
HAVE_..._vec) may yield further savings.
Jan Beulich [Fri, 13 Mar 2026 06:52:08 +0000 (07:52 +0100)]
bfd: avoid elf-solaris2.c for non-Solaris targets
Even if small, it is wasteful to build this file when it's not actually
used. Limit it to Solaris targets and introduce a compiler define
(paralleling OBJ_MAYBE_ELF, as having similar purpose) to guard internals.
Jan Beulich [Fri, 13 Mar 2026 06:51:46 +0000 (07:51 +0100)]
bfd: avoid elf-sframe.c for SFrame-unaware targets
It is wasteful to build this file when it's not actually used. Limit it
to targets actually using SFrame and introduce a compiler define
(paralleling OBJ_MAYBE_ELF, as having similar purpose) to guard internal
function decls.
Jan Beulich [Fri, 13 Mar 2026 06:51:24 +0000 (07:51 +0100)]
bfd: avoid elf-attrs.c for ELF-attributes-free targets
It is wasteful to build this file when it's not actually used. Limit it
to targets actually using ELF attributes and introduce a compiler define
(paralleling OBJ_MAYBE_ELF, as having similar purpose) to guard internal
function decls and to provide stubs for exported functions.
Jan Beulich [Fri, 13 Mar 2026 06:50:45 +0000 (07:50 +0100)]
gas: conditionalize body of create_obj_attrs_section()
This way bfd_elf_obj_attr_size() and bfd_elf_set_obj_attr_contents() will
remain unused for targets not supporting object attributes, which allows
libbfd to not provide them.
Also correct the surrounding #if-s: OBJ_MAYBE_ELF really needs taking into
consideration as well.
Alan Modra [Thu, 12 Mar 2026 22:25:04 +0000 (08:55 +1030)]
check sframe version in _bfd_elf_parse_sframe
Currently if you attempt to link an object file with sframe version 2
contents, the linker will complain in _bfd_elf_merge_section_sframe
and fail to produce an output. This affects anyone who has objects
assembled by binutils-2.45 with .sframe sections. A work-around is to
pass --discard-sframe to ld.
Ideally the linker would rewrite version 2 sframe input to version 3,
but in the absence of that support it would be nicer if ld just
ignored version 2 (or 1) sframe sections without needing to pass
--discard-sframe. That is the aim of this patch.
It does so by checking the sframe version in _bfd_elf_parse_sframe
where various failing checks result in an error being printed and the
section not being marked as SEC_INFO_TYPE_SFRAME, but causes no
overall linker failure. In addition, an sframe version failure now
also marks the sframe section with SEC_EXCLUDE. This is also done for
other sframe failures. See the changelog below for other fixes.
bfd/
* elf-sframe.c (_bfd_elf_merge_section_sframe): Don't check
sframe version here.
(_bfd_elf_parse_sframe): Check sframe version here instead.
Do the "already parsed" check first. Reorder various other
checks. Do not bother parsing or print errors when
discard_sframe is set. Free section contents on failure
paths. Set SEC_EXCLUDE for fails. Check for NULL bfd_zalloc
return, and only allocate after successfully parsing sframe.
On errors report that the section will be ignored, not "no
.sframe will be created".
binutils/
* testsuite/lib/binutils-common.exp: Ignore sframe version
errors.
Tom de Vries [Thu, 12 Mar 2026 20:16:59 +0000 (21:16 +0100)]
[gdb/testsuite] Handle debuginfod output in gdb.debuginfod/solib-with-dwz.exp
I ran into a timeout in test-case gdb.debuginfod/solib-with-dwz.exp.
GDB times out like this:
...
Download failed: Timer expired. \
Continuing without source file solib-with-dwz-bar.c.
...
My theory is that the download fails because debuginfod becomes unresponsive,
because it's stuck trying to write output into some buffer that is already
full.
Fix this by regularly draining debuginfod output in the test-case, using a new
proc drain_debuginfod.
Debuginfod is run with "-vvvv", which makes it rather verbose, and dropping
that also fixes the timeouts, but it might be useful for debugging, so I went
with the output draining method, and left the "-vvvv" as is.
Reviewed-By: Keith Seitz <keiths@redhat.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33901
Tom Tromey [Thu, 12 Mar 2026 17:17:31 +0000 (11:17 -0600)]
Fix the --disable-libctf build
If you configure with --disable-libctf, currently gdb will fail to
build. The fix is to rename the stub function elfctf_build_psymtabs
to remove the "p".
Simon Marchi [Wed, 11 Mar 2026 18:05:26 +0000 (14:05 -0400)]
gdb/dwarf: change die_needs_namespace to return bool
Change the return type to bool, and do some other trivial refactoring:
- remove unnecessary `attr` variable, which I don't think helps code
readability
- change an `if (cond) return false; return true` pattern to be just
one return expression.
Change-Id: I647c3ad73af94bb76c4b59f580bbdfd1eef45888 Approved-By: Tom Tromey <tom@tromey.com>
The code sign extending the low 32 bits into the high 32 bits in this
function does not have any address checking as it ignores the result
from bfd_perform_relocation. Even if it did take notice that isn't
sufficient. In little-endian mode a testcase could be crafted with
the low word at the end of a section which would put the high word out
of bounds.
I notice also that mips32_64bit_reloc is called from a rela R_MIPS_64
reloc howto. Using a rel R_MIPS_32 howto for the lower word can't be
correct as it retrieves the addend from section contents rather than
the reloc.
Fix both of these problems by performing the entire normal 64-bit
relocation first rather than trying to be clever doing it by pieces.
Nowadays config.bfd ensures that mips elf targets always have a 64-bit
bfd.
Also, don't trim addends to 32 bits for relocatable linking or gas.
That doesn't seem necessary and in any case wasn't done properly for
the rela case, where the addend is not in section contents but in the
relocation. Note that relocatable linking will usually be done by
elfxx-mips.c:_bfd_mips_elf_relocate_section. The main use of these
howtos is in gas and bfd_simple_get_relocated_section_contents.
Tom Tromey [Wed, 11 Mar 2026 13:46:11 +0000 (07:46 -0600)]
Do not reuse 'attr' in read_array_type
I was looking at dwarf2/read.c:read_array_type and I thought it would
be nicer if the 'attr' wasn't reused. This patch changes it to be
redeclared in every 'if' where it is used, making it clear that its
value is local to just the one block.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
MIPS/BFD: Make `_bfd_mips_elf_sign_extend' static inline
Let the function be inlined from outside elfxx-mips.c as well, avoiding
the call overhead for a simple arithmetic calculation, though we have no
such user at the moment.
Use common branchless code for `_bfd_mips_elf_sign_extend', typically
avoiding the branch penalty and also reducing code size when inlined in
elfxx-mips.c.
Tom Tromey [Tue, 10 Mar 2026 14:49:28 +0000 (08:49 -0600)]
Return void from ada-valprint.c:print_optional_low_bound
This changes ada-valprint.c:print_optional_low_bound to return void.
At first I was going to have it return bool, but then I noticed the
return value is never used.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Tom Tromey [Tue, 10 Mar 2026 13:55:47 +0000 (07:55 -0600)]
Use bool in ada_is_tagged_type
This changes ada_is_tagged_type to use 'bool' for its return and
parameter type, and then also changes ada_lookup_struct_elt_type to
propagate the boolean-ness.
Approved-By: Simon Marchi <simon.marchi@efficios.com>