]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
4 weeks ago[SFrame-V3] sframe: s390: gas: testsuite: enable flex FDE for s390x
Indu Bhagat [Fri, 16 Jan 2026 00:43:58 +0000 (16:43 -0800)] 
[SFrame-V3] sframe: s390: gas: testsuite: enable flex FDE for s390x

This commit amalgamates a patch set proposed by Jens Remus to enable the
SFrame Version 3 Flexible FDE Type (SFRAME_FDE_TYPE_FLEX) generation for
the s390x ABI.

Previously, s390x relied on architecture-specific encoding (shifting register
numbers into offset fields) to represent register recovery rules.  This limited
the complexity of CFI that could be supported.  With Flex FDE enabled:
  - s390x can now represent .cfi_def_cfa using non-SP/FP registers.
  - The architecture-specific function s390_sframe_xlate_do_register () in GAS
    is replaced by the generic Flex FDE generation path.
  - The SFrame V3 specific macros for s390x register encoding are removed
    from libsframe/include, as the generic Flex FDE format handles explicit
    register columns natively.

The testsuite is updated to replace negative tests (which asserted
warnings or empty SFrame generation for these patterns) with positive
tests verifying valid Flex FDE generation.

Co-authored-by: Jens Remus <jremus@linux.ibm.com>
gas/
* config/tc-s390.c (s390_support_flex_fde_p): Return true to
enable Flex FDE generation.
* gen-sframe.c (s390_sframe_xlate_do_register): Disable s390x
specific implementation.
(sframe_xlate_do_register): Invoke generic Flex FDE path now
that flex FDE generation is supported.
gas/testsuite/
* gas/cfi-sframe/cfi-sframe-s390x-err-1.d: Removed.
* gas/cfi-sframe/cfi-sframe-s390x-err-1.s: Moved to...
* gas/cfi-sframe/cfi-sframe-s390x-non-spfp-cfa-1.s: ...here.
* gas/cfi-sframe/cfi-sframe-s390x-err-2.d: Removed.
* gas/cfi-sframe/cfi-sframe-s390x-err-2.s: Moved to...
* gas/cfi-sframe/cfi-sframe-s390x-non-spfp-cfa-2.s: ...here.
* gas/cfi-sframe/cfi-sframe-s390x-fpra-register-1.d: Update to
expect Flex FDE output.
* gas/cfi-sframe/cfi-sframe-s390x-fpra-register-2.d: Likewise.
* gas/cfi-sframe/cfi-sframe.exp: Run renamed tests.
include/
* sframe.h (SFRAME_V3_S390X_OFFSET_IS_REGNUM): Remove.
(SFRAME_V3_S390X_OFFSET_ENCODE_REGNUM): Remove.
(SFRAME_V3_S390X_OFFSET_DECODE_REGNUM): Remove.
libsframe/
* sframe-dump.c (sframe_s390x_offset_regnum_p): Return false
for SFrame V3.
(sframe_s390x_offset_decode_regnum): Remove V3 support.

4 weeks ago[SFrame-V3] sframe: doc: specification changes for SFrame version 3
Indu Bhagat [Fri, 16 Jan 2026 00:43:53 +0000 (16:43 -0800)] 
[SFrame-V3] sframe: doc: specification changes for SFrame version 3

Update the SFrame specification to document Version 3. This version
introduces fundamental changes to support additional scenarios (e.g.,
s390x register-based recovery, x86_64 DRAP) using a 'Flexible FDE'
definition while maintaining compactness for standard frames.

Key changes documented include:
  - The SFrame Function Descriptor Entry (FDE) is split into two
    distinct structures:
      [sframe_func_desc_idx] Fixed-size index for binary search.
      [sframe_func_desc_attr] Variable-location attributes including new
      info bytes.
  - Flexible FDEs (SFRAME_FDE_TYPE_FLEX)
    A new FDE type that interprets FRE bytes not as simple stack
    offsets, but as pairs of "Control Data" and "Offset". This
    allows encoding complex recovery rules (e.g., "CFA = *(RBP - 8)")
    without bloating the format for standard cases.
  - Provision for defining new FDE types in future.  A total of 5 bits
    are reserved for this purpose.
  - Make explicit distinction between FDE Types vs. PC Type
      [FDE Type] Defines how to interpret stack trace data (Default vs. Flex).
      [PC Type] Defines how PCs are advanced for an FDE (Increment vs. Mask).
  - Other renames like sfde_func_start_address is renamed to
    sfdi_func_start_offset to accurately reflect that it is a relative
    offset, not an absolute address.
  - Remove SFRAME_F_FRAME_POINTER from SFrame V3.  The corresponding bit
    is now unused in SFrame V3.

libsframe/doc/
* sframe-spec.texi: Update text for SFrame Version 3.
(Changes from Version 2 to Version 3): New section.
(The SFrame FDE Index): New section documenting sframe_func_desc_idx.
(The SFrame FDE Attribute): New section documenting
sframe_func_desc_attr.
(The SFrame FDE Info Bytes): Expanded to document sfda_func_info and
sfda_func_info2 split.
(The SFrame FDE PC Types): Document SFRAME_V3_FDE_PCTYPE_INC and
SFRAME_V3_FDE_PCTYPE_MASK.
(The SFrame FDE Types): Document SFRAME_FDE_TYPE_DEFAULT and
SFRAME_FDE_TYPE_FLEX.
(Interpretation of SFrame FREs): Split into Default and Flexible
interpretation.
(Flexible FDE Type Interpretation): Document the Control
Data/Offset pair encoding.

4 weeks ago[SFrame-V3] include: libsframe: remove SFRAME_F_FRAME_POINTER flag
Indu Bhagat [Fri, 16 Jan 2026 00:43:49 +0000 (16:43 -0800)] 
[SFrame-V3] include: libsframe: remove SFRAME_F_FRAME_POINTER flag

SFrame V3 has 8 precious flag bits, two of which are being used.  More
flag byte (s) can be added to the auxiliary header when it comes to
that.  But for now, it may be worthwhile to use the 8-bits frugally.

SFRAME_F_FRAME_POINTER flag bit was added with the intention of marking
binaries built with frame-pointer preserved.  A stack tracer could then
use this information, to unambiguously ascertain whether frame-pointer
based stack traces will be precise.  But such a marking of binary will
ideally be done by the linker, and at the moment adding such a framework
is not justified for such small gain.  The outcome of this is that
SFRAME_F_FRAME_POINTER is never set in SFrame V2 binaries.

Remove the definition SFRAME_F_FRAME_POINTER for SFrame V3.  The
relinquished bit can be used (in future format incarnations) when
reading/dumping SFrame V2 sections are no longer supported by consumers.
Changing the values of existing flags, e.g.,
SFRAME_F_FDE_FUNC_START_PCREL, is not being done for V3, to avoid
version-specific flag bit reading (albeit doable) in consumers.

Related changes to the specification are done in a subsequent commit.

include/
* sframe.h (SFRAME_V3_F_ALL_FLAGS): Remove
SFRAME_F_FRAME_POINTER from the set of V3 flags.
libsframe/
* sframe-dump.c (dump_sframe_header_flags): Add a comment for
clarity.

4 weeks ago[SFrame-V3] gas: binutils: ld: NEWS: add SFrame v3 related announcements
Indu Bhagat [Fri, 16 Jan 2026 00:43:46 +0000 (16:43 -0800)] 
[SFrame-V3] gas: binutils: ld: NEWS: add SFrame v3 related announcements

Add NEWS entries related to the SFrame version 3 release.

4 weeks ago[SFrame-V3] ld: testsuite: x86: sframe: check link of signal frame and outermost...
Indu Bhagat [Fri, 16 Jan 2026 00:43:41 +0000 (16:43 -0800)] 
[SFrame-V3] ld: testsuite: x86: sframe: check link of signal frame and outermost frames

In this test, two "special" case FDEs are linked:
  - Signal frame where the SFrame stack trace data is not
    representable.
  - _start like outermost frame function.

This is useful test for sframe_encoder's merge input sections
functionality and its associated write code-paths (sframe_encoder_write)
too.

ld/testsuite/
* ld-x86-64/sframe-link-1.d: New test.
* ld-x86-64/sframe-signal.s: New input file.
* ld-x86-64/sframe-start.s: Likewise.
* ld-x86-64/x86-64.exp: Add new test.

4 weeks ago[SFrame-V3] ld: add --discard-sframe command line option
Indu Bhagat [Fri, 16 Jan 2026 00:43:35 +0000 (16:43 -0800)] 
[SFrame-V3] ld: add --discard-sframe command line option

Add a new command line option --discard-sframe to the linker.
This option allows users to prevent the linker from generating an output
.sframe section.

The rationale for this option is: Consider the case when say, the distro
is shipped with SFrame sections in the installed binaries/libraries. A
user application using these installed libraries, but not enabling
.sframe for itself just yet, will see an output .sframe corresponding to
the pulled in libraries.  This is "partial" .sframe information for the
application.  Adding such an option to the linker, gives user a way to
turn off the .sframe section completely without relying on a linker
script.

Previously, the existing --no-ld-generated-unwind-info option
controlled whether (not just .eh_frame for PLT entries, but also) SFrame
for PLT entries. The new command line option,
--discard-sframe now decouples SFrame from other unwind
formats (like .eh_frame), allowing for more control over the output
binary's SFrame data.

The option is added for architectures that currently support SFrame:
AArch64, s390x, and x86_64.

bfd/
* elf-sframe.c (_bfd_elf_parse_sframe): Mark with SEC_EXCLUDE if
--discard-sframe is in effect.
* elf64-s390.c (elf_s390_create_dynamic_sections): Use
discard_sframe to guard .sframe section creation.
* elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Likewise.
include/
* bfdlink.h (struct bfd_link_info): Add discard_sframe bitfield.
ld/
* ldlex.h (enum option_values): Add OPTION_NO_LD_SFRAME_INFO.
* lexsup.c (elf_sframe_list_options): New function.
(ld_list_options): Add sframe_info argument. Update callers.
* ld.texi: Update documentation.
* emulparams/sframe-info.sh: New file.
* emultempl/aarch64elf.em: Add --discard-sframe option
listing and handling.
* emulparams/elf64_s390.sh: Likewise.
* emulparams/elf_x86_64.sh: Likewise.
* Makefile.am: Update to handle sframe-info.sh and new list options.
* configure.ac: Handle SFRAME_INFO target variable.
* Makefile.in: Regenerate.
* configure: Regenerate.
ld/testsuite/
* ld-x86-64/x86-64.exp: New test.
* ld-x86-64/sframe-command-line-1.d: New test.
* ld-aarch64/aarch64-elf.exp: New test.
* ld-s390/s390.exp: New test.
* ld-x86-64/x86-64.exp: New test.
* ld-aarch64/sframe-command-line-1.d: New test.
* ld-s390/sframe-command-line-1.d: New test.
* ld-x86-64/sframe-command-line-1.d: New test.

4 weeks ago[SFrame-V3] gas: sframe: doc: testsuite: add new command line option --gsframe-3
Indu Bhagat [Fri, 16 Jan 2026 00:43:29 +0000 (16:43 -0800)] 
[SFrame-V3] gas: sframe: doc: testsuite: add new command line option --gsframe-3

This option will allow users to select emission of SFrame stack trace
information as per the SFrame version 3 specification.  Currenly, SFrame
version 3 is also the default.

In future, as SFrame evolves, similar command line args may be added for
future versions.

gas/
* as.c (enum gen_sframe_version): New definition.
(parse_args): Add option processing for --gsframe-3.
* as.h (enum gen_sframe_version): New declaration.
* doc/as.texi: Document the new option.
* gen-sframe.c (sframe_set_version): Use enum gen_sframe_version
as version.
(output_sframe): Likewise.
gas/testsuite/
* gas/cfi-sframe/cfi-sframe.exp: New test.
* gas/cfi-sframe/cfi-sframe-common-1d.d: Test new command line
option --gsframe-3.
* gas/cfi-sframe/cfi-sframe-common-1d.s: Likewise.

4 weeks ago[SFrame-V3] include: gas: libsframe: split FDE into idx and attr
Indu Bhagat [Fri, 16 Jan 2026 00:43:23 +0000 (16:43 -0800)] 
[SFrame-V3] include: gas: libsframe: split FDE into idx and attr

This patch introduces a structural change to the SFrame V3 format. It
shifts the SFrame Function Descriptor Entry (FDE) (a physical entity in
SFrame V2) into a conceptual one in SFrame V3, such that an FDE is now
split into two distinct parts to optimize the binary search table and
data organization:
 - FDE Index (sframe_func_desc_idx_v3): This structure contains the
   essential indexing information: the function start address offset,
   function size in bytes, and the offset to the SFrame FDE
   attribute/Frame Row Entries (FREs) area for the function.
 - FDE Attributes (sframe_func_desc_attr_v3): The metadata regarding the
   function (number and size of FREs, FDE type, and repetition block
   size etc.) is moved to a new structure.

On-Disk Layout: In V3, the "Attributes" are now stored immediately
preceding the SFrame FREs for that function. The sfde_func_start_fre_off
now points to the attr structure, and the actual FREs follow immediately
after.  IOW, the "Attributes" are now moved to the FRE sub-section,
located immediately preceding the FREs for the respective function.

The above layout has the advantage that:
  a) its cleaner with separation between the index elements vs other data
  b) the index has better cache locality (by virtue of it being smaller
     than the layout in SFrame V2).
  c) As the format evolves, the guarantees of alignment for FDE index
     are easier to maintain.  FDE attr, being in the SFrame FRE
     sub-section, carry no guarantees of alignment.

This had been previously suggested and communicated in an earlier
discussion on binutils mailling list
https://inbox.sourceware.org/binutils/29b1f7b0-61ea-410c-8aca-d5dd6115e668@oracle.com/

The read/write paths in sframe.c are updated to account for this split.

sframe_fde_tbl_init now requires access to the FRE buffer to populate
the internal FDE table, as the attributes are no longer resident in the
FDE section.

flip_sframe is refactored into version-specific handlers (_v2 and _v3)
because the endian-swapping logic now differs significantly. In V3, the
iterator must jump from the FDE table to the FRE section to swap the
attributes.

Lastly, the two entities generating SFrame sections (GAS and GNU ld)
both now must _not_ set the sfde_func_start_fre_off to zero, when the
number of FREs is zero.  This is because now there will be some valid
attr data at that location.

Backward Compatibility: Due to the need to support readelf/objdump for
SFrame V2 sections, the patch explicitly maintains V2 support via
separate code paths (e.g., flip_sframe_fdes_with_fres_v2)

Note about alignment: Now that the sframe_func_desc_idx_v3 is refactored
out of the conceptual SFrame FDE, SFrame FDE index member elements are
at aligned boundaries again.  The alignment property for SFrame FDE was
broken from an ealier patch "[08/36] sframe: gas: libsframe: use
uint16_t for num_fres of FDE" up until this one.

include/
* sframe.h (sframe_func_desc_entry_v3): Remove sfde_func_num_fres,
sfde_func_info, sfde_func_info2, and sfde_func_rep_size.  Rename
to sframe_func_desc_idx_v3.
(sframe_func_desc_attr_v3): New SFrame FDE attribute structure.
libsframe/
* sframe.c (sframe_fde_tbl_init): Add argument for FRE buffer.
Read attributes from the FRE section for V3.
(flip_fde_desc): Rename from flip_fde. Check size against
sframe_func_desc_entry_v3.
(flip_fde_attr_v3): New function.
(sframe_decode_fde_desc_v2): New function extracted from
sframe_decode_fde.
(sframe_decode_fde_desc_v3): New function.
(sframe_decode_fde_attr_v3): New function.
(flip_sframe_fdes_with_fres_v2): New function for V2 flipping.
(flip_sframe_fdes_with_fres_v3): New function for V3 flipping.
(flip_sframe): Dispatch to version-specific flip functions.
(sframe_decode): Pass FRE buffer to sframe_fde_tbl_init.
(sframe_decoder_get_offsetof_fde_start_addr): Adjust for subset
of sframe_func_desc_entry_v3 restructured into
sframe_func_desc_idx_v3.
(sframe_encoder_get_offsetof_fde_start_addr): Likewise.
(sframe_find_fre): Skip attribute size to find FREs in V3.
(sframe_decoder_get_fre): Likewise.
(sframe_decoder_get_fres_buf): Likewise.
(sframe_encoder_add_fre): Add attribute size to byte count.
(sframe_encoder_add_fres_buf): Read attributes from buffer.
(sframe_encoder_write_fde): Write only FDE index fields.
(sframe_encoder_write_func_attr): New function.
(sframe_encoder_write_sframe): Write FDE attributes before FREs.
gas/
* gen-sframe.c (output_sframe_funcdesc): Do not reset
sfde_func_start_fre_off to zero when zero num FREs.
(output_sframe_func_desc_attr): New refactored out function.
(output_sframe_internal): Invoke output_sframe_func_desc_attr.
libsframe/testsuite/
* libsframe.decode/DATA2: Regenerate data file.

4 weeks ago[SFrame-V3] bfd: ld: sframe: avoid unnecessary decoding of SFrame FREs at link time
Indu Bhagat [Fri, 16 Jan 2026 00:43:20 +0000 (16:43 -0800)] 
[SFrame-V3] bfd: ld: sframe: avoid unnecessary decoding of SFrame FREs at link time

At link time, in _bfd_elf_merge_section_sframe (), it suffices to bring
over the all per-function stack trace metadata (all FREs) as a blob into
the SFrame encoder object.  There is no need to "decode" each SFrame
FRE, only to add them in a serial fashion.

This is an optimization, and not directly related to any SFrame V3
related changes to the specification.  This should also bring us a step
closer to supporting SFrame for targets which use linker relaxations.
Removing the need to decode the input FREs can allow the linker to
simply use the available set of FREs from (relocated) contents.  To
support targets using linker relaxations in SFrame, other changes in the
SFrame parse functionality time may also be necessary, but this brings
us just a step closer.

Add two new APIs to accomplish this:
 - sframe_decoder_get_fres_buf, and
 - sframe_encoder_add_fres_buf

bfd/
* elf-sframe.c (_bfd_elf_merge_section_sframe): Get all FRE data
and add it all in bulk.
libsframe/
* libsframe.ver: Add new APIs.
* sframe.c (sframe_buf_fre_entry_size): New internal API to get
size of one SFrame FRE at the indicated buffer location, without
fully "decoding" the SFrame FRE.
(sframe_decoder_get_fres_buf): New definition.
(sframe_encoder_add_fres_buf): New definition.
include/
* sframe-api.h (sframe_decoder_get_fres_buf): New declaration.
(sframe_encoder_add_fres_buf): New declaration.

4 weeks ago[SFrame-V3] gas: sframe: testsuite: handle .cfi_offset for RA
Indu Bhagat [Fri, 16 Jan 2026 00:43:16 +0000 (16:43 -0800)] 
[SFrame-V3] gas: sframe: testsuite: handle .cfi_offset for RA

With the introduction of flex FDE type, handling .cfi_offset for
RA needs adjustment.

On architectures like x86_64, the return address (RA) is typically saved
at a fixed offset from the CFA. Previous versions of the SFrame format
assumed this fixed offset was invariant for the entire function on such
architectures. Consequently, GAS would warn and suppress SFrame
generation if it encountered a .cfi_offset directive for the RA
register that deviated from this fixed default.

SFrame V3 introduces "Flex FDEs" which allows tracking the RA location
explicitly even on architectures where it is usually fixed.

This patch updates sframe_xlate_do_offset () to leverage Flex FDEs. When
processing a .cfi_offset for the RA register:
  - The check for non-representable RA offsets is relaxed. If the ABI
    supports Flex FDEs (SFrame V3), GAS proceeds instead of issuing a
    warning.
  - For ABIs without explicit RA tracking (like AMD64), if the RA
    offset differs from the default fixed offset, the FDE is marked as a
    Flex FDE, and the new stack location is recorded.
  - Logic is added to detect when the RA is restored to its standard
    fixed offset. In this case, the tracking state is reset (ra_loc set
    to SFRAME_FRE_ELEM_LOC_NONE), deferring to the ABI's default fixed RA
    offset behavior.

gas/
* gen-sframe.c (sframe_xlate_do_offset): Support .cfi_offset for RA
by switching to Flex FDEs when necessary.
gas/testsuite/
* gas/cfi-sframe/cfi-sframe-x86_64-6.d: New test.
* gas/cfi-sframe/cfi-sframe-x86_64-6.s: New test to check
transition of location of REG_RA from register to CFA-8 (default
location on AMD64).  Flex FDE in effect.
* gas/cfi-sframe/cfi-sframe.exp: Add new test.

4 weeks ago[SFrame-V3] gas: sframe: testsuite: skip SFrame FDE if .cfi_register SP, reg
Indu Bhagat [Fri, 16 Jan 2026 00:43:12 +0000 (16:43 -0800)] 
[SFrame-V3] gas: sframe: testsuite: skip SFrame FDE if .cfi_register SP, reg

SFrame does not track the SP.  For recovery of the SP, SFrame relies on
the architecture/ABI's CFA definition:

  CFA = SP [+ offset   // on s390x]

Which results in the following implicit CFA value offset rule for SP:

  SP = CFA [- offset   // on s390x]

Where offset is zero for most architectures/ABIs, except s390x.

Therefore .cfi_register SP, reg directives must be rejected, as such
semantics cannot be represented in SFrame yet.

gas/
* gas/gen-sframe.c (s390_sframe_xlate_do_register): Check for
REG_SP and reject while generating a warning.
(sframe_xlate_do_register): Likewise.
gas/testsuite/
* gas/cfi-sframe/cfi-sframe-s390x-err-4.d: New test.
* gas/cfi-sframe/cfi-sframe-s390x-err-4.s: Likewise.
* gas/cfi-sframe/cfi-sframe-x86_64-empty-5.d: Likewise.
* gas/cfi-sframe/cfi-sframe-x86_64-empty-5.s: Likewise.
* gas/cfi-sframe/cfi-sframe.exp: Add new tests.

4 weeks ago[SFrame-V3] gas: sframe: testsuite: handle .cfi_register FP/RA for flex FDE
Indu Bhagat [Fri, 16 Jan 2026 00:43:07 +0000 (16:43 -0800)] 
[SFrame-V3] gas: sframe: testsuite: handle .cfi_register FP/RA for flex FDE

Use SFrame FDE of type SFRAME_FDE_TYPE_FLEX_TOPMOST_FRAME.

When FP, RA were moved to a general-purpose register, the SFrame
generation previously warned and skipped the FDE (except on s390x).
This patch updates the translator to detect .cfi_register for RA (and
FP), tracks the destination register in the SFrame row entry,
and emits the register in the relevant FRE offsets in SFrame FDE type
SFRAME_FDE_TYPE_FLEX.

gas/
* gen-sframe.c (sframe_row_entry_initialize): Propagate ra_reg
and ra_deref_p.
(sframe_xlate_do_register): Handle .cfi_register for RA/FP on
AMD64 by setting flex_p and recording the register.
gas/testsuite/gas/
* cfi-sframe/cfi-sframe.exp: Run new test.
* cfi-sframe/cfi-sframe-x86_64-5.d: New test.
* cfi-sframe/cfi-sframe-x86_64-5.s: Simple test for checking
FLEX FDE generation for `.cfi_register REG_RA, XX`.
* cfi-sframe/cfi-sframe-x86_64-esc-expr-3.d: New test.
* cfi-sframe/cfi-sframe-x86_64-esc-expr-3.s: New test with DWARF
expression for REG_FP, followed by .cfi_register and .cfi_offset
for REG_FP.
* cfi-sframe/cfi-sframe-x86_64-ra-undefined-flex-1.d: New test.
* cfi-sframe/cfi-sframe-x86_64-ra-undefined-flex-1.s: New test
for FLEX FDE with undefined RA.

4 weeks ago[SFrame-V3] gas: x86: testsuite: add new testcases for SFRAME_FDE_TYPE_FLEX
Indu Bhagat [Fri, 16 Jan 2026 00:43:00 +0000 (16:43 -0800)] 
[SFrame-V3] gas: x86: testsuite: add new testcases for SFRAME_FDE_TYPE_FLEX

gas/testsuite/
* gas/cfi-sframe/cfi-sframe-x86_64-4.d: New test.
* gas/cfi-sframe/cfi-sframe-x86_64-4.s: Non SP/FP based CFA.
* gas/cfi-sframe/cfi-sframe-x86_64-esc-expr-1.d: New test.
* gas/cfi-sframe/cfi-sframe-x86_64-esc-expr-1.s: DRAP pattern
with both CFA expression and FP expression.
* gas/cfi-sframe/cfi-sframe-x86_64-esc-expr-2.d: New test.
* gas/cfi-sframe/cfi-sframe-x86_64-esc-expr-2.s: Test CFA
expression with sleb128.
* gas/cfi-sframe/cfi-sframe.exp: Add new tests.

4 weeks ago[SFrame-V3] sframe: gas: translate specific CFI directives for SFRAME_FDE_TYPE_FLEX
Indu Bhagat [Fri, 16 Jan 2026 00:42:50 +0000 (16:42 -0800)] 
[SFrame-V3] sframe: gas: translate specific CFI directives for SFRAME_FDE_TYPE_FLEX

This patch updates the SFrame generation in GAS to translate specific
.cfi_escape directives into the new SFrame V3 FDE type
SFRAME_FDE_TYPE_FLEX.

The primary goal is to support code patterns where:
  - the Canonical Frame Address (CFA) is not defined by a simple offset
    from the Stack Pointer (SP) or Frame Pointer (FP), or where the CFA
    rule involves a dereference. Such patterns are generated by compilers
    for stack realignment (e.g., DRAP on x86_64, or when mixing legacy
    codes that keep 4-byte stack alignment with modern codes that keep
    16-byte stack alignment for SSE compatibility).
  - the Frame Pointer is not defined by a simple offset from the CFA,
    but may even involve another register and/or dereferencing.
  - the Return Address is not defined by a simple offset from the CFA,
    but may even involve another register and/or dereferencing.

Support for non-SP/FP based CFA: Update sframe_xlate_do_def_cfa () and
sframe_xlate_do_def_cfa_register () to detect when a non-SP/FP register
is used for the CFA.

Support for CFA expressions: A vital part of supporting the
above-mentioned cases on AMD64 is support for CFA expressions.  Add
sframe_xlate_do_escape_cfa_expr () to parse simple
DW_CFA_def_cfa_expression sequence in .cfi_escape.

Support for FP expressions: Update sframe_xlate_do_escape_expr () to
handle DW_CFA_expression involving DW_OP_breg6 (rbp) on AMD64,
allowing for tracking of the Frame Pointer when it is saved with a
dereference rule in the DRAP pattern.

The "support" for both CFA expressions and FP expressions is quite
minimal, and is tailored to the most commonly seen occurrences generated
by GCC for AMD64.

gas/
* gas/gen-sframe.c (output_sframe_row_entry_offsets):
(sframe_xlate_do_def_cfa): Handle non-SP/FP CFA registers by setting
flex_p for AMD64.
(sframe_xlate_do_def_cfa_register): Likewise.
(sframe_xlate_escape_sleb128_to_int64): New definition.
(sframe_xlate_do_escape_cfa_expr): New function to handle
DW_CFA_def_cfa_expression of specific shapes.
(sframe_xlate_do_escape_expr): Update to handle dereferenced FP rules.
(sframe_xlate_do_cfi_escape): Invoke sframe_xlate_do_escape_cfa_expr ().
(create_sframe_all): In case of error, but when signal frame is
also true, there cannot be a flex FDE.

4 weeks ago[SFrame-V3] gas: sframe: add new backend hook sframe_support_flex_fde_p for FLEX...
Indu Bhagat [Fri, 16 Jan 2026 00:42:46 +0000 (16:42 -0800)] 
[SFrame-V3] gas: sframe: add new backend hook sframe_support_flex_fde_p for FLEX FDEs

For the newly added SFrame FDE type SFRAME_FDE_TYPE_FLEX, add a new
backend hook so that the respective ABI/arch can opt out of the
generation of SFRAME_FDE_TYPE_FLEX in GAS.

AArch64 is an example of an ABI for which SFrame is supported, but one
that does not need the flexible FDE representation for any of the
current usecases currently.

Reviewed-by: Jens Remus <jremus@linux.ibm.com>
gas/
* config/tc-aarch64.c (aarch64_support_flex_fde_p): New
definition.
* config/tc-aarch64.h (aarch64_support_flex_fde_p): New
declaration.
(sframe_support_flex_fde_p): Define.
* config/tc-i386.c (x86_support_flex_fde_p): New definition.
* config/tc-i386.h (x86_support_flex_fde_p): New declaration.
(sframe_support_flex_fde_p): Define.
* config/tc-s390.c (s390_support_flex_fde_p): New definition.
* config/tc-s390.h (s390_support_flex_fde_p): New declaration.
(sframe_support_flex_fde_p): Define.

4 weeks ago[SFrame-V3] libsframe: textual dump of fde type SFRAME_FDE_TYPE_FLEX
Indu Bhagat [Fri, 16 Jan 2026 00:42:41 +0000 (16:42 -0800)] 
[SFrame-V3] libsframe: textual dump of fde type SFRAME_FDE_TYPE_FLEX

Refactor the SFrame textual dumper in sframe-dump.c to properly handle
the new FDE type.

In SFrame V2, the textual dumper could afford to be oblivious to the
exact DWARF register number for stack-pointer and frame-pointer
registers in each ABI.  This is because a single bit was used to
differentiate between the two (irrespective of the ABI), and the dumper
could easily just use a:
    const char *base_reg_str[] = {"fp", "sp"};
to get the register name.

With the introduction of new SFrame FDE type SFRAME_FDE_TYPE_FLEX, which
carry DWARF register numbers if applicable, this needs to change.  E.g.,
for some patterns on AMD64, one may see CFA is the value at 'r10+0'; or
FP is the value at 'rbp+8'.  This means that for textual dump, we now
need a mapping from:
  - the ABI-specific frame-pointer to string "fp"
  - the ABI-specific stack-pointer to string "sp"
This is done via the SFRAME_ABI_REG_MAP helper macros and the new
sframe_get_reg_name () API.

For registers other than stack-pointer and frame-pointer, the SFrame
textual dump does not print the register name (say, "rax"), but just the
number (i.e., "r0").

Check the func_info2 byte and dispatch the stack frame row entry (FRE)
dumping to the correct function: either dump_sframe_func_fre_simple or
dump_sframe_func_fre_flex.

Ensure the display is consistent to previous semantics.  When flex FDE
is in effect, there may not always be an RA offset (after the CFA
offsets).  A padding offset for RA is present if FP offsets follow.  So
if a padding offset for RA is seen, we will display "U".  If no RA
offset is seen, however, we will display a "u" unless its an ABI where
RA offset is fixed (in the latter case we display "f").

libsframe/
* sframe-dump.c (SFRAME_SP): Define mapping from stack-pointer
register number to "sp".
(SFRAME_FP): Define mapping from frame-pointer register number
to "fp".
(SFRAME_ABI_REG_MAP): Helper macro to define per-ABI-arch
mappings.
(sframe_get_reg_name): Helper API to get register name.
(dump_sframe_func_with_fres): Refactor a bit...
(dump_sframe_func_fre_simple): ..into this.
(sframe_format_fre_disp): New definition.
(dump_sframe_func_fre_flex): Likewise.
(dump_sframe): Allow both SFrame version 2 and version 3.

4 weeks ago[SFrame-V3] libsframe: testsuite: add new argument to offset access APIs
Indu Bhagat [Fri, 16 Jan 2026 00:42:37 +0000 (16:42 -0800)] 
[SFrame-V3] libsframe: testsuite: add new argument to offset access APIs

For FDE type SFRAME_FDE_TYPE_FLEX, the offsets are not only laid out
differently, they also have different encoding:
  - first data item is of unsigned type, it indicates the "Control Word"
  - second data item is of signed  type, it indicates the "Offset Word"
(The usage of "Word" above is colloquial, does not indicate a machine word of
a specific size.)

Adjust the APIs in libsframe to get stack frame offsets by adding a new
argument type.  Also add a new API to read the data items as unsigned
types of the specified size: sframe_get_fre_udata.

At the moment, like the generation routines in GAS, the textual dump
routines in sframe-dump.c are also unaware of the FDE type
SFRAME_FDE_TYPE_FLEX.  In the next commits, these capabilities will be
added.

include/
* sframe-api.h (MAX_NUM_STACK_OFFSETS): Increase the number of
stack offsets to 6 to accommodate the FDE type
SFRAME_FDE_TYPE_FLEX.
(sframe_get_fre_udata): New declaration.
(sframe_fre_get_cfa_offset): Add new arg.
(sframe_fre_get_fp_offset): Likewise.
(sframe_fre_get_ra_offset): Likewise.
libsframe/
* libsframe/sframe-dump.c (dump_sframe_func_with_fres): Pass
SFRAME_FDE_TYPE_DEFAULT for FDE type.
* sframe.c (sframe_fre_get_cfa_offset): Handle FDE type.
(sframe_fre_get_fp_offset): Likewise.
(sframe_fre_get_ra_offset): Likewise.
* libsframe/libsframe.ver: Add new API sframe_get_fre_udata.
libsframe/testsuite/
* libsframe.find/findfre-1.c: Pass SFRAME_FDE_TYPE_DEFAULT for
FDE type.
* libsframe.find/findfunc-1.c: Likewise.
* libsframe.find/plt-findfre-1.c: Likewise.
* libsframe.find/plt-findfre-2.c: Likewise.

4 weeks ago[SFrame-V3] gas: sframe: output new FDE type SFRAME_FDE_TYPE_FLEX
Indu Bhagat [Fri, 16 Jan 2026 00:42:32 +0000 (16:42 -0800)] 
[SFrame-V3] gas: sframe: output new FDE type SFRAME_FDE_TYPE_FLEX

This patch updates the routines for emission of the new FDE type
SFRAME_FDE_TYPE_FLEX in the SFrame output section.  The support for
generating these flex FDEs themselves is added in a subsequent commit.

Update struct sframe_row_entry to track additional state for CFA,
FP, and RA.  Modify output_sframe_row_entry_offsets () to emit
metadata/offset pairs for flexible FDEs or padding where applicable,
ensuring the usual ordering (CFA, RA, FP).  The padding data, a.k.a.
SFRAME_FRE_RA_OFFSET_INVALID is emitted in flexible FDEs when RA is
untracked but FP offsets follow.  Trailing padding offsets should not
occur.  Add a new function get_udata_size_in_bytes () to account for
sizing of unsigned register metadata.

gas/
* gen-sframe.c (get_udata_size_in_bytes): Get size of unsigned
int data in bytes.
(get_fre_num_offsets): Handle SFRAME_FDE_TYPE_FLEX.
(sframe_get_fre_offset_size): Account for register metadata
in flexible FDEs.
(output_sframe_row_entry_offsets): Add logic for flexible
FDE offset pairs.
(output_sframe_row_entry): Reset base register for flex FDEs.
(output_sframe_funcdesc): Emit FDE type in func_info2.
(sframe_xlate_ctx_init): Initialize flex_p.
(sframe_xlate_ctx_finalize): Finalize flex_p status.
(sframe_row_entry_initialize): Copy new deref tracking bits.
(sframe_xlate_do_offset): Set deref bits during translation.
* gen-sframe.h (struct sframe_row_entry): Add cfa_deref_p,
fp_deref_p, and ra_deref_p.
(struct sframe_func_entry): Add fde_flex_p.
(struct sframe_xlate_ctx): Add flex_p.

4 weeks ago[SFrame-V3] gas: sframe: use three states for location tracking
Indu Bhagat [Fri, 16 Jan 2026 00:42:29 +0000 (16:42 -0800)] 
[SFrame-V3] gas: sframe: use three states for location tracking

Up until now, for SFrame stack trace data generation (for default FDE
type), keeping two states sufficed to distinguish between the following
cases:
  - the tracked entity is saved on a location on stack (identified by
    SFRAME_FRE_ELEM_LOC_STACK)
  - the tracked entity is in its designated register (identified by
    SFRAME_FRE_ELEM_LOC_REG).

Soon though, we will start to generate a new FDE type
SFRAME_FDE_TYPE_FLEX, where in addition to above:
  - the tracked entity may be saved in a temporary register
  - the tracked entity may be saved at a "non-standard" location, e.g.,
    not a simple CFA+offset based location
  - and other cases

To effectively distinguish between the various states (necessary to
track for flex FDEs), define three states to track the location of each
tracked entity:
  - SFRAME_FRE_ELEM_LOC_NONE: the entity is in its desginated location
    (e.g., in case of AMD64 where the RA is at fixed offset from CFA)
  - SFRAME_FRE_ELEM_LOC_REG: the entity is in a location based off a
    register
  - SFRAME_FRE_ELEM_LOC_STACK: the entity is in a location based off the
    CFA

While at it, rather than asserting in sframe_xlate_do_offset (), reset
the fp_reg state to SFRAME_FRE_REG_INVALID.  This is in preparation for
upcoming flex FDE generation patches.

Co-Authored-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
gas/
* gen-sframe.c (sframe_xlate_do_offset): Reset other state.
(sframe_xlate_do_same_value): Reset to SFRAME_FRE_ELEM_LOC_NONE.
* gen-sframe.h (SFRAME_FRE_ELEM_LOC_REG): New definition.
(SFRAME_FRE_ELEM_LOC_STACK): Likewise.
(SFRAME_FRE_ELEM_LOC_NONE): Likewise.

4 weeks ago[SFrame-V3] gas: bfd: include: libsframe: fixup terminology 'PC Type' vs 'FDE Type'
Indu Bhagat [Fri, 16 Jan 2026 00:42:25 +0000 (16:42 -0800)] 
[SFrame-V3] gas: bfd: include: libsframe: fixup terminology 'PC Type' vs 'FDE Type'

In SFrame V2, we did use the the term 'FDE Type' for the two designated
'PC Type' for the SFrame FDEs (SFRAME_FDE_TYPE_PCINC,
SFRAME_FDE_TYPE_PCMASK).  In hindsight, 'FDE Type' was an inappropriate
term for the said intent.  Fix this terminology by defining two new
constants:
 - SFRAME_V3_FDE_PCTYPE_MASK
 - SFRAME_V3_FDE_PCTYPE_INC

The old constants from V2 (SFRAME_FDE_TYPE_PCINC,
SFRAME_FDE_TYPE_PCMASK) remain, but are now unused in the codebase.

The term 'FDE Type' should be used for the actual FDE Types.  In a
subsequent commit, we will add SFRAME_FDE_TYPE_FLEX FDE Type for SFrame
V3.

bfd/
* elf64-s390.c (_bfd_s390_elf_create_sframe_plt): Rename
inappropriate SFRAME_FDE_TYPE_PCINC to SFRAME_V3_FDE_PCTYPE_INC.
* elfxx-x86.c (_bfd_x86_elf_create_sframe_plt): Likewise.  Also
rename inappropriate SFRAME_FDE_TYPE_PCMASK to
SFRAME_V3_FDE_PCTYPE_MASK.
gas/
* gen-sframe.c (output_sframe_funcdesc): Likewise.
* sframe-opt.c (sframe_convert_frag): Likewise.
libsframe/
* sframe-dump.c (dump_sframe_func_with_fres): Likewise.
* sframe.c (sframe_fre_check_range_p): Likewise.
(sframe_fde_create_func_info): Likewise.
libsframe/testsuite/
* libsframe.encode/encode-1.c: Likewise.
* libsframe.find/findfre-1.c: Likewise.
* libsframe.find/findfunc-1.c: Likewise.
* libsframe.find/plt-findfre-1.c: Likewise.
* libsframe.find/plt-findfre-2.c: Likewise.

4 weeks ago[SFrame-V3] include: sframe: reserve 5 bits for new FDE types
Indu Bhagat [Fri, 16 Jan 2026 00:42:21 +0000 (16:42 -0800)] 
[SFrame-V3] include: sframe: reserve 5 bits for new FDE types

In SFrame V2, the FDE representation caters to the most common cases of
stack trace metadata:
  - CFA is SP/FP based,
  - FP/RA offsets, if present are CFA based (except some cases in s390x
    where reg can be encoded).

Introduce an additional FDE type SFRAME_FDE_TYPE_FLEX, which can encode
a more flexible set of CFA, FP and RA recovery rules.  Some of the
patterns supported include:
  - CFA may be non-SP/FP based.
  - CFA, FP may encode dereferencing of register after offset adjustment
  - RA may be in a non-default register.

The important bit here is that since SFrame does not track all
callee-saved registers, the above-mentioned recovery rules must only be
done for topmost frames (by the stack tracer).

Adding a new FDE type does have implications for a stack tracer in that
it needs to:
  - Check the FDE type before interpreting the variable length bytes
    trailing the SFrame FRE header as stack offsets.
  - If the FDE type is SFRAME_FDE_TYPE_FLEX, and the
    recovery rules employ the use of any non-SP/FP based register, the
    stack tracer must proceed only if it is the topmost frame on stack.

For CFA, RA, and FP, up to two "offsets" may be used.  The two offsets
represent the information as follows:
  - (minimum 8-bit) offset1 to encode register like:
    (regnum << 3) | unused << 2 | deref << 1 | reg_p (=1)
  - offset2 to encode offset: offset

reg_p = 1 indicates a register, reg_p = 0 indicates CFA.

The offsets are in the usual order:  CFA, RA, FP if present.

For example, for FP/RA tracking,

a) If the reg is REG1 for FP/RA tracking,
   - Encoding:
     + offset1 to encode register: (REG1 << 3) | unused << 2 | deref << 1 | reg_p (=1)
     + offset2 to encode offset: offset
   - Action:
     + if deref, FP/RA = \*(REG1 + offset) (e.g., seen for FP recovery
       with certain DRAP patterns on x86_64)
     + if no deref, FP/RA = REG1 + offset

b) If the reg is CFA for FP/RA tracking,
   - Encoding:
     + [=Effectively Padding] offset1 to encode register:
        (( 0 << 3 ) | unused << 2 | 0 << 1 | reg_p (=0))
     + offset2 to encode offset: offset
   - Action:
     + if deref, FP/RA = *(CFA + offset)
     + if no deref, FP/RA = CFA + offset (pattern shouldnt be seen for
       RA)

Next for CFA tracking,
   - Action:
     + if deref, CFA = *(reg + offset) (e.g., seen for CFA recovery in
       some stack realignment patterns on AMD64)
     + if no deref, CFA = reg + offset (e.g., for .cfi_def_cfa 2, 8, or
       .cfi_def_cfa 10, 0)

Expected usage of this FDE type is quite low (DRAP on x86_64).

NB: In SFrame V2, we did use the the term 'FDE Type' for the two
designated 'PC Type' for the SFrame FDEs (SFRAME_FDE_TYPE_PCINC,
SFRAME_FDE_TYPE_PCMASK).  In hindsight, 'FDE Type' was inappropriate
term.  In a subsequent commit, we will fix this terminology for SFrame
V3.

include/
* sframe.h (SFRAME_FDE_TYPE_FLEX): New SFrame FDE type.
(SFRAME_V3_FDE_TYPE_MASK): New constant definition.
(SFRAME_V3_FDE_TYPE): New macro definition.
(SFRAME_V3_SET_FDE_TYPE): Likewise.
(SFRAME_V3_FLEX_FDE_REG_ENCODE): Macro to encode register in the
SFrame offset data.
(SFRAME_V3_FLEX_FDE_OFFSET_REG_NUM): New definition.
(SFRAME_V3_FLEX_FDE_OFFSET_REG_DEREF_P): Likewise.
(SFRAME_V3_FLEX_FDE_OFFSET_REG_P): Likewise.

4 weeks ago[SFrame-V3] include: gas: libsframe: add 8-bits of func_info2 for extensibility in FDE
Indu Bhagat [Fri, 16 Jan 2026 00:42:17 +0000 (16:42 -0800)] 
[SFrame-V3] include: gas: libsframe: add 8-bits of func_info2 for extensibility in FDE

The existing field func_info (in the SFrame FDE) is used to convey important
information around the encoding and interpretation of the rest of the
stack trace data for the respective SFrame FDE: the SFrame FRE type,
SFrame FDE PC type, etc.

Currently there is 1 bit left for AArch64, and 2 bits for AMD64, s390x
(and other future ABIs to be supported).  Provision some additional
space now (specifically an additional 8-bits) for future needs for V3
and beyond.

Compared to V2, this now increases the size of SFrame FDE by 1 byte in
V3.  In this patch, the additional func_info2 byte is not used
functionally yet.  Hence, rather mechanical changes in libsframe, bfd
and libsframe/testsuite accompany.  We will put func_info2 into use in a
later patch by reserving 5 of these bits for SFrame FDE types.

With the addition of a new byte for additional func info (func_info2),
add a new arg to allow usecases like textual dumper to get all data
members in one API: sframe_decoder_get_funcdesc_v3.  To keep the APIs
symmetric looking, add new arg to sframe_encoder_add_funcdesc_v3 too.

Since bfd uses these APIs, carry out the mechanical change in the
respective APIs too.  And of course, the testsuite which exercises these
APIs.

bfd/
* elf-sframe.c (_bfd_elf_merge_section_sframe): Get and set
func_info2.
* elf64-s390.c (_bfd_s390_elf_create_sframe_plt): Pass 0 for
func_info2 for SFrame FDE for PLT.
* elfxx-x86.c (_bfd_x86_elf_create_sframe_plt): Likewise.
gas/
* gen-sframe.c (output_sframe_funcdesc): Emit the uint8_t for
func_info2.
libsframe/
* sframe-dump.c (dump_sframe_func_with_fres):
* sframe.c (sframe_fde_tbl_init): Handle the new additional
member.
(sframe_encoder_write_fde): Likewise.
* sframe.c (sframe_decoder_get_funcdesc_v3): Update func_info2.
libsframe/testsuite/
* libsframe.decode/DATA2: Update data file with SFrame section
data.
* libsframe.encode/encode-1.c: Pass 0 for func_info2 arg.
* libsframe.find/findfre-1.c: Likewise.
* libsframe.find/findfunc-1.c: Likewise.
* libsframe.find/plt-findfre-1.c: Likewise.
* libsframe.find/plt-findfre-2.c: Likewise.
include/
* sframe.h: Add new uint8_t sfde_func_info2 to
sframe_func_desc_entry_v3.
* sframe-api.h (sframe_decoder_get_funcdesc_v3): New arg.
(sframe_encoder_add_funcdesc_v3): Likewise.

4 weeks ago[SFrame-V3] gas: sframe: allow SFrame FDEs with 0 FREs for signal frames
Indu Bhagat [Fri, 16 Jan 2026 00:42:13 +0000 (16:42 -0800)] 
[SFrame-V3] gas: sframe: allow SFrame FDEs with 0 FREs for signal frames

Update the SFrame generation logic in GAS to emit Function Descriptor Entries
(FDEs) for signal frames even when no Frame Row Entries (FREs) could be
generated.

Previously, create_sframe_all () would discard any FDE that failed
translation or resulted in zero FREs. However, for signal frames (marked
with .cfi_signal_frame), preserving the FDE may be valuable even without
stack offsets. The presence of the SFrame FDE with the 'Signal'
attribute may allow stack tracers to identify the frame as a signal
trampoline and potentially apply fallback handling, rather than treating
the PC range as having no stack trace info at all.

The patch modifies create_sframe_all () to detect translation errors for
signal frames, effectively allowing the generation of an empty FDE (0 FREs)
marked with the 'S' attribute.

gas/
* gen-sframe.c (sframe_fde_free): Add NULL check for safety.
(create_sframe_all): Allow FDEs for signal frames even if translation
encountered errors or produced no FREs.
gas/testsuite/
* gas/cfi-sframe/cfi-sframe.exp: New test.
* gas/cfi-sframe/cfi-sframe-x86_64-signal-1.d: New test ensuring
signal frame FDE is emitted with 0 FREs.
* gas/cfi-sframe/cfi-sframe-x86_64-signal-1.s: New test.

4 weeks ago[SFrame-V3] sframe: gas: bfd: add support for signal frames
Indu Bhagat [Fri, 16 Jan 2026 00:42:09 +0000 (16:42 -0800)] 
[SFrame-V3] sframe: gas: bfd: add support for signal frames

Reserve a bit in function info byte in the SFrame FDE to designate
signal frames.

Also update the SFrame opt code in GAS and dumping routines in libsframe
to handle signal frame bit.

include/
* sframe.h (SFRAME_V3_FDE_SIGNAL_P): Extract signal frame bit.
(SFRAME_V3_FDE_UPDATE_SIGNAL_P): Set signal frame bit.
gas/
* gen-sframe.c (get_dw_fde_signal_p): New function to retrieve signal
frame state from DWARF FDE.
(sframe_v3_set_func_info): Renamed from sframe_v1_set_func_info.
Accept signal_p argument and encode it.
(sframe_set_version): Update ops to use sframe_v3_set_func_info.
(sframe_set_func_info): Pass signal_p to the ops hook.
(output_sframe_funcdesc): Retrieve signal frame marker and pass to
sframe_set_func_info.
* gen-sframe.h (struct sframe_version_ops): Update set_func_info
signature.
* sframe-opt.c (sframe_convert_frag): Preserve signal_p bit during
fragment conversion.  While at it, use SFRAME_V3_* macros where
applicable.
libsframe/testsuite/
* gas/cfi-sframe/cfi-sframe-common-13.d: New test.
* gas/cfi-sframe/cfi-sframe-common-13.s: New test.
* gas/cfi-sframe/cfi-sframe.exp: Run new test.
libsframe/
* sframe-dump.c (dump_sframe_func_with_fres): Decode signal frame bit
and print "S" attribute in the dump output.

4 weeks ago[SFrame-V3] include: libsframe: bfd: gas: testsuite: support for signed 64-bit offset...
Indu Bhagat [Fri, 16 Jan 2026 00:42:03 +0000 (16:42 -0800)] 
[SFrame-V3] include: libsframe: bfd: gas: testsuite: support for signed 64-bit offset in SFrame FDE

This change enables support text > 2 GiB in SFrame format.

Each SFrame FDE needs to hold information about the start PC of the
function it pertains to.  Currently, the field 'sfde_func_start_address'
in SFrame FDE is encoded as a 32-bit offset to the start PC of the
function from the field itself.

In SFrame V2, this offset was a signed 32-bit offset.  The signedness
gives the flexibility of having .sframe ELF section before or after the
.text* sections.  But the size of 32-bit puts the limitation that
.sframe togther with the .text* sections must fit the 2 GiB range.

Currently, if the linker sees the offset not representable as 32-bit
signed offset, it issues an error (not seen in the wild, simulated by
forcing a function to align via an '.align  2147483648' directive):

  test.o:(.sframe+0x1c): relocation truncated to fit: R_X86_64_PC32 against `.text'
  make: *** [Makefile:7: all] Error 1

ATM, EH Frame also suffers with the same issue.

Moving forward, some cloud applications have been shown to be nearing
1.5 GiB threshold.  Extending the offset to int64_t now seems to be good
choice to make now for future-proof'ing the sections.

The use of int64_t offset is done for all SFrame V3 sections.  This
bump from int32_t to int64_t should not lead to an increase in the size
of SFrame sections, because of the following additional changes to the
SFrame FDE specification:
  - Reduce the type of sfde_func_num_fres (from uint32_t to uint16_t)
  - Remove the 2 bytes of padding (sfde_func_padding2). These served the
    two-fold purpose of keeping FDE data aligned _and_ unused space for
    future needs.

Now that the offset is int64_t, start using the
sframe_decoder_get_funcdesc_v3 () instead of
sframe_decoder_get_funcdesc_v2 () in GNU ld.

This patch changes the offset type in the SFrame FDE definition to an
int64_t.  No further changes in gas are necessary because the code
already accounts for writing out as per the size of the member of the
struct:

  emit_expr (&exp, sizeof_member (sframe_func_desc_entry,
                                  sfde_func_start_offset));

bfd/
* elf-sframe.c (sframe_read_value): Signed offset for start PC
is 8-bytes now.
(_bfd_elf_merge_section_sframe): Likewise.
* elf64-s390.c (_bfd_s390_elf_create_sframe_plt): Use V3 API.
(elf_s390_finish_dynamic_sections): Signed offset for start PC
is 8-bytes now.
* elfxx-x86.c (_bfd_x86_elf_create_sframe_plt): Use V3 API.
(_bfd_x86_elf_finish_dynamic_sections): Signed offset for start
PC is 8-bytes now.
gas/
* sframe.c (output_sframe_funcdesc): Rename to
sfde_func_start_offset.
libsframe/
* libsframe/sframe.c (sframe_fde_tbl_init): Rename to
sfde_func_start_offset.
(flip_fde): Likewise.
(sframe_decoder_get_secrel_func_start_addr): Use int64_t.
(sframe_fre_check_range_p): Likewise.
(sframe_decoder_get_offsetof_fde_start_addr): Rename to
sfde_func_start_offset.
(sframe_get_funcdesc_with_addr_internal): Use int64_t.
(sframe_find_fre): Likewise.
(sframe_encoder_get_offsetof_fde_start_addr): Rename to
sfde_func_start_offset.
(sframe_encoder_add_funcdesc_internal): Use int64_t.
(sframe_encoder_add_funcdesc): Likewise.  And rename to
sfde_func_start_offset.
(sframe_encoder_write_fde): Rename to sfde_func_start_offset.
libsframe/testsuite/
* libsframe.decode/DATA2: Regenerate the data file.
* libsframe.encode/encode-1.c: Use int64_t for start pc offset.
* libsframe.find/findfre-1.c: Likewise.
* libsframe.find/findfunc-1.c: Likewise.
* libsframe.find/plt-findfre-1.c: Likewise.
* libsframe.find/plt-findfre-2.c: Likewise.
include/
* sframe-api.h (sframe_find_fre): Update arg type to int64_t.
(sframe_encoder_add_funcdesc): Likewise.
* sframe.h: Change data type to int64_t.

4 weeks ago[SFrame-V3] sframe: gas: libsframe: remove padding field from FDE
Indu Bhagat [Fri, 16 Jan 2026 00:41:59 +0000 (16:41 -0800)] 
[SFrame-V3] sframe: gas: libsframe: remove padding field from FDE

Remove the unused sfde_func_padding2 member from the
sframe_func_desc_entry_v3 structure.

A later patch in this series reorganizes the members of the FDE
structure in a way explicit padding is no longer necessary to keep
natural alignment.  So remove the explicit padding now.

Reviewed-by: Jens Remus <jremus@linux.ibm.com>
include/
* sframe.h: Remove sfde_func_padding2 from
sframe_func_desc_entry_v3.
gas/
* gen-sframe.c (output_sframe_funcdesc): Stop writing
sfde_func_padding2.
libsframe/
* sframe.c (sframe_encoder_write_fde): Stop writing
sfde_func_padding2.
* testsuite/libsframe.decode/DATA2: Regenerate binary test data.

4 weeks ago[SFrame-V3] sframe: gas: libsframe: use uint16_t for num_fres of FDE
Indu Bhagat [Fri, 16 Jan 2026 00:41:55 +0000 (16:41 -0800)] 
[SFrame-V3] sframe: gas: libsframe: use uint16_t for num_fres of FDE

Reduce the size of the num_fres field in the Function Descriptor Entry
(FDE) from 32 bits to 16 bits.

The number of Frame Row Entries (FREs) for a single function is extremely
unlikely to exceed 65,535 in real-world scenarios. Reducing this field
saves 2 bytes per FDE, contributing to a smaller overall SFrame section size.

(BTW, these savings will be eaten up by a later commit which adds
support for text > 2 GiB by increasing an offset from int32_t to
int64_t).

Safety checks are added to the assembler to warn and skip SFrame FDE
generation if a function's FRE count exceeds UINT16_MAX.

Note regarding alignment: With the current patch, the members of
sframe_func_desc_entry_v3 are not at aligned boundaries anymore.  Recall
that all sframe_func_desc_entry_v3 entries are stored together in the
"SFrame FDE sub-section" forming an index.  Only after a later patch in
the series "[29/36] [SFrame-V3] include: gas: libsframe: split FDE into
desc and attr" will the alignment properties of SFrame index will be
restored.

include/
* sframe.h (sframe_func_desc_entry_v3): Change sfde_func_num_fres
type to uint16_t.
gas/
* gen-sframe.c (output_sframe_funcdesc): Write 2 bytes for num_fres
and assert it fits in uint16_t.
(sframe_do_fde): Add check to skip FDE emission if num_fres exceeds
UINT16_MAX.
libsframe/
* sframe.c (sframe_encoder_write_fde): Cast num_fres to uint16_t
to ensure correctly written out data.
* testsuite/libsframe.decode/DATA2: Update binary test data.

4 weeks ago[SFrame-V3] libsframe: add V3 APIs for adding and getting SFrame FDE
Indu Bhagat [Fri, 16 Jan 2026 00:41:50 +0000 (16:41 -0800)] 
[SFrame-V3] libsframe: add V3 APIs for adding and getting SFrame FDE

(Similar to V2) Add two new APIs for adding and getting SFrame FDE:
 - sframe_encoder_add_funcdesc_v3
 - sframe_decoder_get_funcdesc_v3

Note the argument for the function start address is int64_t instead of
int32_t (the latter is used in sframe_encoder_add_funcdesc_v2 and
sframe_encoder_get_funcdesc_v2).  The new V3 APIs will be used in a
subsequent commit to extend SFrame V3 to support text > 2 GiB by
allowing int64_t offsets by default.

Similar to the analogous V2 APIs, they return 0 on success and
SFRAME_ERR (in case of sframe_decoder_get_funcdesc_v3) or error code (in
case of sframe_encoder_add_funcdesc_v3) on failure.

Reviewed-by: Jens Remus <jremus@linux.ibm.com>
include/
* sframe-api.h (sframe_decoder_get_funcdesc_v3): New
declaration.
(sframe_encoder_add_funcdesc_v3): Likewise.
libsframe/
* libsframe.ver: Add the new APIs.
* sframe.c (sframe_decoder_get_funcdesc_v3): New definition.
(sframe_encoder_add_funcdesc_v3): Likewise.

4 weeks ago[SFrame-V3] libsframe: bump so version to libsframe.so.3.0.0
Indu Bhagat [Fri, 16 Jan 2026 00:41:45 +0000 (16:41 -0800)] 
[SFrame-V3] libsframe: bump so version to libsframe.so.3.0.0

Consolidate the 2.0 and 2.1 nodes into a new 3.0 node.

In subsequent patches for releasing SFrame V3, libsframe APIs will be
affected.  A non-exhaustive list of noteworthy changes are mentioned
next.

Some existing APIs (breaking binary compatibility) by adding an
additional arg to these:
  - sframe_fre_get_ra_offset
  - sframe_fre_get_fp_offset
  - sframe_fre_get_cfa_offset

Change of argument type:
  - sframe_find_fre

The behaviour of some APIs will change:
 - sframe_encoder_write now writes out V3.

And lastly removal of two APIs:
  - sframe_decoder_get_funcdesc
  - sframe_encoder_add_funcdesc

Above make this release of the library binary incompatible with previous
release, hence a version bump and new version node 3.0.

Reviewed-by: Jens Remus <jremus@linux.ibm.com>
libsframe/
* libsframe.ver: Create a new 3.0 node.  Remove the 2.0 node.
* libtool-version: Bump the so version.

4 weeks ago[SFrame-V3] sframe: gas: bfd: ld: format bump to version 3
Indu Bhagat [Fri, 16 Jan 2026 00:41:07 +0000 (16:41 -0800)] 
[SFrame-V3] sframe: gas: bfd: ld: format bump to version 3

Bump version to SFRAME_VERSION_3.  Introduce a new definition of SFrame
FDE for version 3, which is a duplicate of SFrame FDE in V2, for now.
In other words, no changes to the format specification yet.

GNU as emits SFrame V3 by default.  SFrame encoder (ld) emits SFrame V3
sections.  In a later commit, we will add a new command line option to
gas: --gsframe-3 which will bind the implementation in gas to emit
SFrame V3.

Also, adjust the testcases for the new version string
"SFRAME_VERSION_3".

bfd/
* elf-sframe.c (_bfd_elf_merge_section_sframe): Linker emits
the latest version by default.
* elf64-s390.c (_bfd_s390_elf_create_sframe_plt): Linker emitted
PLT sections are also SFRAME_VERSION_3.
* elfxx-x86.c (_bfd_x86_elf_create_sframe_plt): Likewise.
gas/
* gen-sframe.c (sframe_set_version): GAS emits SFrame V3 by
default.
(output_sframe): Likewise.
libsframe/
* sframe-dump.c (dump_sframe): Enable dumping for both
SFRAME_VERSION_2 and SFRAME_VERSION_3.
include/ChangeLog:
* sframe.h (SFRAME_VERSION_3): New definition.
(SFRAME_VERSION): Current version is now SFRAME_VERSION_3.
(SFRAME_V3_FDE_FUNC_INFO): New definition.
(SFRAME_V3_FDE_FRE_TYPE): Likewise.
(SFRAME_V3_FDE_PC_TYPE): Likewise.
(SFRAME_V3_AARCH64_FDE_PAUTH_KEY): Likewise.
(SFRAME_V3_FDE_UPDATE_PAUTH_KEY): Likewise.
binutils/testsuite/
* all affected tests: Replace SFRAME_VERSION_2 with
SFRAME_VERSION_3.
gas/testsuite/
* all affected tests: Likewise.
ld/testsuite/
* all affected tests: Likewise.
libsframe/testsuite/
* all affected tests: Likewise.

4 weeks ago[SFrame-V3] sframe: use const for sframe_decoder_ctx object arg
Indu Bhagat [Fri, 16 Jan 2026 00:41:03 +0000 (16:41 -0800)] 
[SFrame-V3] sframe: use const for sframe_decoder_ctx object arg

As the library version will be bumped soon, include this change now.
Note the arg names in sframe-dump.c APIs have 'sfd_ctx' instead of the
usual 'dctx'.  We can address this cosmetic change at a later time.
Other cosmetic changes, e.g. to make fixing function-level comments more
consistent, are left out of the patch for now.

Additionally, constify the return type of static function
sframe_decoder_get_header, now that the call sites consistently use a
const object.

Reviewed-by: Jens Remus <jremus@linux.ibm.com>
4 weeks ago[SFrame-V3] libsframe: remove old sframe_decoder_get_funcdesc API
Indu Bhagat [Fri, 16 Jan 2026 00:40:58 +0000 (16:40 -0800)] 
[SFrame-V3] libsframe: remove old sframe_decoder_get_funcdesc API

sframe_decoder_get_funcdesc () was added for SFRAME_VERSION_1.  This has
since been obsoleted by introduction of SFRAME_VERSION_2 and its
corresponding sframe_decoder_get_funcdesc_v2 API.

Remove from the version script file as well.  We will bump the version
of the library to 3.0.0 in a subsequent patch (closer to release) and
consolidate the entries into a new LIBSFRAME_3.0 node.

Reviewed-by: Jens Remus <jremus@linux.ibm.com>
include/
* sframe-api.h (sframe_decoder_get_funcdesc): Remove.
libsframe/
* libsframe.ver: Likewise.
* sframe.c (sframe_decoder_get_funcdesc): Remove definition.

4 weeks ago[SFrame-V3] libsframe: testsuite: add a new test for SFrame V2
Indu Bhagat [Fri, 16 Jan 2026 00:40:54 +0000 (16:40 -0800)] 
[SFrame-V3] libsframe: testsuite: add a new test for SFrame V2

The existing frecnt-2.c testcase reads the SFrame section from the
provided DATA2 buffer.  It exercises the sframe_decode (),
sframe_decoder_get_num_fidx (), and sframe_decoder_get_funcdesc_v2 ()
APIs.  Currently DATA2 file is the SFrame section created from the test
input (mentioned in the comments in the file) in SFrame version 2
format.

Moving forward, creating SFrame V2 section via GNU assembler and GNU ld
will not be supported.  But textual dump of SFrame V2 sections via
readelf/objdump will need to be supported.  Add a test similar to
frecnt-2.c using SFrame version 2 binary data to the libsframe
testsuite.  Such a test will help ensure that sframe_decode () and
related APIs remain tested for multiple supported arches till the
support for dumping V2 sections is to be maintained.

Duplicate frecnt-2.c to create a frecnt-v2.c, the latter will test with
a SFrame V2 input section always.

Reviewed-by: Jens Remus <jremus@linux.ibm.com>
libsframe/
* Makefile.in: Regenerated.
libsframe/testsuite/
* libsframe.decode/decode.exp: Add new test.
* libsframe.decode/local.mk: Likewise
* libsframe.decode/DATA-V2: New SFrame V2 test data file.
* libsframe.decode/frecnt-v2.c: New test.

4 weeks ago[SFrame-V3] readelf: testsuite: sframe: add new SFrame V2 test
Indu Bhagat [Fri, 16 Jan 2026 00:40:46 +0000 (16:40 -0800)] 
[SFrame-V3] readelf: testsuite: sframe: add new SFrame V2 test

In subsequent commits, we will add support for SFrame V3.  In the next
GNU Binutils release, GNU as and ld will only generate SFrame V3; SFrame
V2 will not be supported for generation nor linking.

For readelf/objdump, however, continue to support textual dump of SFrame
V2 sections.  Add a binary file (with no debug data) with SFrame V2
section to keep the dumping tested.

Add ET_REL And ET_EXEC binary file based tests for x86_64 and s390x.
Check that both readelf and objdump works on the SFrame V2 sections.

binutils/testsuite/
* binutils-all/s390/README-sframe-tests: New test.
* binutils-all/s390/sframe.exp: New test.
* binutils-all/s390/test-v2-ET_EXEC.sframe.bz2: New test.
* binutils-all/s390/test-v2-ET_EXEC.sframe.dump: New test.
* binutils-all/s390/test-v2-ET_REL.sframe.bz2: New test.
* binutils-all/s390/test-v2-ET_REL.sframe.dump: New test.
* binutils-all/x86-64/README-sframe-tests: New test.
* binutils-all/x86-64/sframe.exp: New test.
* binutils-all/x86-64/test-v2-ET_EXEC.sframe.bz2: New test.
* binutils-all/x86-64/test-v2-ET_EXEC.sframe.dump: New test.
* binutils-all/x86-64/test-v2-ET_REL.sframe.bz2: New test.
* binutils-all/x86-64/test-v2-ET_REL.sframe.dump: New test.

4 weeks agoAutomatic date update in version.in
GDB Administrator [Fri, 16 Jan 2026 00:00:06 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 weeks agogdb/NEWS: mention DWP v1 support removal
Simon Marchi [Thu, 15 Jan 2026 16:24:58 +0000 (11:24 -0500)] 
gdb/NEWS: mention DWP v1 support removal

Support for DWP v1 was removed in commit 92a222b648d ("gdb/dwarf: remove
support for DWP v1").

Change-Id: I6ce341bb6a2238b434fb458b3e2aa81db74cd8ae
Approved-By: Eli Zaretskii <eliz@gnu.org>
4 weeks agogdb/NEWS: add missing newline
Simon Marchi [Thu, 15 Jan 2026 16:24:57 +0000 (11:24 -0500)] 
gdb/NEWS: add missing newline

Change-Id: Ib3714d1b75d42580460f5e4183d7801314aa4b9a

4 weeks agoApply [noreturn] in more places
Tom Tromey [Thu, 15 Jan 2026 17:38:02 +0000 (10:38 -0700)] 
Apply [noreturn] in more places

I looked at adding -Wmissing-noreturn to the warning flags.  This
resulted in too many false reports, IMO, so I am not planning to
submit it.

However, it did point out a few spots that legitimately should have
[[noreturn]].

In making this patch, my criterion was to mark up a function whose
contract is that it always throws an exception.  I did not include
functions that just happen to always throw (e.g.,
default_infcall_mmap).  That is, this patch uses the attribute as a
form of documentation and not really for its code-generation
application.

Tested by rebuilding.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
4 weeks agogdb/dwarf: fix mis-indented lines in dwarf2/read.c
Simon Marchi [Thu, 15 Jan 2026 19:14:02 +0000 (14:14 -0500)] 
gdb/dwarf: fix mis-indented lines in dwarf2/read.c

Change-Id: I4070a60531d396237afa298bbaf6482004f3ab39

4 weeks agogdb, gdbsupport, gdbserver: add support for printf 't' length modifier
Simon Marchi [Mon, 12 Jan 2026 18:24:02 +0000 (13:24 -0500)] 
gdb, gdbsupport, gdbserver: add support for printf 't' length modifier

Tom de Vries reported [1] that a use of the `t` printf length modifier
(used for ptrdiff_t) breaks "set debug dwarf-die 1":

    +break -qualified main
    Reading Reading compcomp unit at offset  unit at offset 0x00x39

    Reading comp unit at offset 0x1a8
    Reading comp unit at offset 0x1e9
    Reading comp unit at offset 0x2c5
    Reading comp unit at offset 0x2a2
    Reading comp unit at offset 0x904
    Unrecognized format specifier 't' in printf

This use is in dwarf2/read.c:

      gdb_printf (gdb_stdlog, "Read die from %s@0x%tx of %s:\n",
  m_die_section->get_name (),
  (begin_info_ptr - m_die_section->buffer),
  bfd_get_filename (m_abfd));

Add support for the `t` length modifier in format_pieces, which
gdb_printf ultimately uses (through ui_out::vmessage).  Modify the three
users of format_pieces: gdb's printf command, gdb's ui_out::vmessage
function and gdbserver's ax_printf function.

The implementation is mostly copied from what we do for size_t.

Since format_pieces is also used to implement the printf command, this
patch brings user-visible changes.  Before:

    (gdb) printf "%td\n", -123
    ❌️ Unrecognized format specifier 't' in printf

After:

    (gdb) printf "%td\n", -123
    -123

[1] https://inbox.sourceware.org/gdb-patches/d4ccce34-aad5-4e3d-8fc9-efb2fc11275c@suse.de/

Change-Id: Ie9fce78f5f48082d8f8a9ca2847b5ae26acaa60d
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb/Makefile: update HFILES_NO_SRCDIR
Andrew Burgess [Thu, 15 Jan 2026 15:59:41 +0000 (15:59 +0000)] 
gdb/Makefile: update HFILES_NO_SRCDIR

The HFILES_NO_SRCDIR in our Makefile has gotten a little out of date.
The files: expanded-symbol.h, finish-thread-state.h, and
nat/amd64-linux.h are missing, and there are a few files that are in
the list twice.

This commit adds the missing files and removes the duplicates.

There should be no changes to a built GDB after this commit.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: fix handling of raw ANSI escape sequences printed from Python
Andrew Burgess [Thu, 15 Jan 2026 10:28:45 +0000 (10:28 +0000)] 
gdb: fix handling of raw ANSI escape sequences printed from Python

Bug PR gdb/33748 reports a regression with print styled output from
Python when using ANSI escape sequences to apply the styling.  This
regression was introduced by commit:

  commit 3825c972a636852600b47c242826313f4b9963b8
  Date:   Wed Jun 18 15:02:29 2025 +0100

      gdb: allow gdb.Color to work correctly with pagination

Prior to this commit GDB would always forward any ANSI escape
sequences directly to the output stream, but this meant that GDB
didn't know which style was currently in effect.

The above commit changed GDB so that we would parse the ANSI escape
sequence, and then apply it to the output stream, this allowed GDB to
track which style was in use, which in turn meant that GDB could
correctly suspend the style and reapply it when the pager was
activated.

The problem though is that ANSI escape sequences can be built up in
parts.  For example, a user can emit the sequence to change the
foreground blue, and then later emit the sequence to change the text
to bold.  The result is output that is both blue and bold.

In the above commit, when parsing an incoming ANSI sequence, GDB was
always starting from the default styling state.  The result of parsing
the ANSI sequence was then being applied.  In our above example, this
meant that when parsing the sequence for bold text we would "forget"
that the current style had a blue foreground color.

This can be easily fixed by starting from the current style, rather
than the default style.

This fix was suggested by Patryk Sondej who originally reported the
bug.

Co-Authored-By: Patryk Sondej <patryk.sondej@gmail.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33748

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoRemove extraneous 'return'
Tom Tromey [Thu, 15 Jan 2026 17:35:19 +0000 (10:35 -0700)] 
Remove extraneous 'return'

This 'return' comes after a call to a 'noreturn' function, and can be
removed.

I am not sure exactly what is up with the comment, but perhaps there
was a time when 'error' was not marked this way.

4 weeks agogdb/dwarf: merge create_dwo_unit_in_dwp_{v2,v5}
Simon Marchi [Thu, 15 Jan 2026 03:55:29 +0000 (22:55 -0500)] 
gdb/dwarf: merge create_dwo_unit_in_dwp_{v2,v5}

create_dwo_unit_in_dwp_v2 and create_dwo_unit_in_dwp_v5 are very
similar.  Merge them into a common create_dwo_unit_in_dwp function, with
a few conditionals for what differs.  This makes it easier to spot the
differences between the two paths, and it's less code to maintain.

Change-Id: I71c44b827fff3d4c8214a075a397a852a38d1cf9
Reviewed-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb/dwarf: remove v2 and v5 section pool structures variants
Simon Marchi [Thu, 15 Jan 2026 03:55:28 +0000 (22:55 -0500)] 
gdb/dwarf: remove v2 and v5 section pool structures variants

The two variants of section_pool are identical, except the size of the
section_ids array.  We can have only one, we just need to ensure that it
is large enough for v5.  And then I think that the "section_pool" struct
is unnecessary, we can have the fields directly in dwp_hash_table.

Change-Id: I70167a95ff61ff668c09c7e19568ced2798fa6f3
Reviewed-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb/dwarf: cleanup dwarf2_locate_v{2,5}_dwp_sections parameters
Simon Marchi [Thu, 15 Jan 2026 03:55:27 +0000 (22:55 -0500)] 
gdb/dwarf: cleanup dwarf2_locate_v{2,5}_dwp_sections parameters

Change the `void *` parameter to `dwp_file *`.  Remove the unused `abfd`
parameter.  These were probably missed when converting the caller from
bfd_map_over_sections to gdb_bfd_sections.

Change-Id: I0420c83ba35ae304901b9e140584ebaba31f2330
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb/dwarf: remove support for DWP v1
Simon Marchi [Thu, 15 Jan 2026 03:55:26 +0000 (22:55 -0500)] 
gdb/dwarf: remove support for DWP v1

The GCC wiki [1] says that version 1 of the DWP format "was an
experimental version that is no longer supported".  That comment was
written in 2013.  From what I understand, DWP version 1 was not widely
adopted.  Unlike version 2 and version 5 (which is part of DWARF 5).

I propose to get rid of v1 support, which allows removing a bit of code,
making things a bit easier when reasoning about DWARF code.

[1] https://gcc.gnu.org/wiki/DebugFissionDWP

Change-Id: Ie46b55662e63b7f341b7827330154ec4ab5af9e5
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb/dwarf: initialize fields of virtual_v2_or_v5_dwo_sections
Simon Marchi [Thu, 15 Jan 2026 03:55:25 +0000 (22:55 -0500)] 
gdb/dwarf: initialize fields of virtual_v2_or_v5_dwo_sections

I noticed that create_dwo_unit_in_dwp_v2 and create_dwo_unit_in_dwp_v5
initialized structure virtual_v2_or_v5_dwo_sections differently, one
with a memset and one with default initialization.  Make that consistent
by moving the initialization in the struct itself, which is less
error-prone anyway.

Change-Id: I48a21a871601d076bbeeb19befd0ad62e9ba7f2a
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoRISC-V: Add second-pass relaxation for JAL to C.J/C.JAL
Kito Cheng [Mon, 12 Jan 2026 08:26:32 +0000 (16:26 +0800)] 
RISC-V: Add second-pass relaxation for JAL to C.J/C.JAL

When linker relaxation converts CALL (auipc+jalr, 8 bytes) to JAL
(4 bytes), further relaxation to C.J or C.JAL (2 bytes) may become
possible as code shrinks and jump distances decrease.

This patch adds _bfd_riscv_relax_jal to perform this second-pass
relaxation.  To enable this, we introduce R_RISCV_DELETE_AND_RELAX,
a new internal relocation that combines piecewise deletion with
preservation of relaxation capability.  When _bfd_riscv_relax_call
relaxes CALL to JAL, it marks the deletion as R_RISCV_DELETE_AND_RELAX
instead of R_RISCV_DELETE.  After the piecewise deletion is resolved,
R_RISCV_DELETE_AND_RELAX is converted back to R_RISCV_RELAX at the
JAL instruction offset, allowing _bfd_riscv_relax_jal to further
relax JAL to C.J/C.JAL.

C.JAL is only available on RV32 (rd=ra), while C.J is available on
both RV32 and RV64 (rd=x0).

Changes since v1:
- Use R_RISCV_DELETE_AND_RELAX with piecewise deletion instead of
  calling _riscv_relax_delete_immediate directly, to maintain
  relaxation performance.
- Add preserve_relax parameter to riscv_relax_delete_bytes to
  simplify the logic in _bfd_riscv_relax_call.

4 weeks agoMIPS/BFD: Initialize `error_message' in `_bfd_mips_elf_orphan_shr16_reloc'
Maciej W. Rozycki [Thu, 15 Jan 2026 00:37:35 +0000 (00:37 +0000)] 
MIPS/BFD: Initialize `error_message' in `_bfd_mips_elf_orphan_shr16_reloc'

There is no value assigned in `_bfd_mips_elf_generic_reloc' via the
`error_message' parameter and consequently the original `error_message'
variable in `_bfd_mips_elf_orphan_shr16_reloc' remains uninitialized in
the error case, which newer versions of GCC can correctly diagnose:

In function '_bfd_mips_elf_orphan_shr16_reloc',
    inlined from 'mips_elf_free_hi16_list' at ../../binutils-gdb/bfd/elfxx-mips.c:13309:12:
../../binutils-gdb/bfd/elfxx-mips.c:13281:5: error: 'error_message' may be used uninitialized [-Werror=maybe-uninitialized]
13281 |     _bfd_link_reloc_status_error (abfd, info, hi->input_section,
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13282 |                                   &hi->rel, error_message, r);
      |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../binutils-gdb/bfd/elfxx-mips.c: In function 'mips_elf_free_hi16_list':
../../binutils-gdb/bfd/elfxx-mips.c:13255:9: note: 'error_message' declared here
13255 |   char *error_message;
      |         ^~~~~~~~~~~~~
cc1: all warnings being treated as errors

Fix the problem by preinitializing the variable to NULL as at other
places.

4 weeks agoAutomatic date update in version.in
GDB Administrator [Thu, 15 Jan 2026 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 weeks agoMove mips_hi16_list to mips_elf_section_data
Alan Modra [Wed, 14 Jan 2026 22:28:44 +0000 (22:28 +0000)] 
Move mips_hi16_list to mips_elf_section_data

This patch is in response to fuzzing testcases that manage to cause
segfaults due to stale references to freed memory via mips_hi16.data.

A number of the error/warning handlers in ldmain.c use %C.  This can
cause debug info to be parsed for the first time in order to print
file/function/line.  If one of those warnings is triggered after some
hi16 relocs have been processed but before the matching lo16 reloc is
handled, *and* the debug info is corrupted with a lo16 reloc, then the
mips_hi16_list will be flushed with the result that printing a warning
changes linker output.  It is also possible that corrupted debug info
adds to the hi16 list, with the result that when the linker handles a
later lo16 reloc in a text section, ld will segfault accessing
mips_hi16.data after the debug buffers have be freed.  Both of these
problems are fixed by keeping a per-section mips_hi16_list rather than
a per-file list.

* elfxx-mips.c (struct mips_hi16): Move earlier, deleting
input_section field.
(struct _mips_elf_section_data): Add mips_hi16_list.
(struct mips_elf_obj_tdata): Delete mips_hi16_list.
(_bfd_mips_elf_free_cached_info): Adjust to suit new location
of mips_hi16_list.
(_bfd_mips_elf_hi16_reloc, _bfd_mips_elf_lo16_reloc): Likewise.
(_bfd_mips_elf_orphan_shr16_reloc): Likewise.
(mips_elf_free_hi16_list): Likewise.
(_bfd_mips_elf_finalize_section_relocs): Likewise.
(_bfd_elf_mips_get_relocated_section_contents): Likewise.

4 weeks agoMIPS: Add tests for orphan REL HI16 relocation addend processing
Maciej W. Rozycki [Wed, 14 Jan 2026 22:28:44 +0000 (22:28 +0000)] 
MIPS: Add tests for orphan REL HI16 relocation addend processing

Add GAS and LD test cases for orphan REL HI16 relocation processing,
including verification of the addends produced as well as the warning
messages expected.

Due to the ordering used for the list of oustanding cached HI16 reloc
entries warnings for non-ELF links are issued in the reverse order
compared to one for ELF links.  This is not considered a defect as all
the required warnings are produced in both cases, however separate
warning lists are required and included here for ELF and srec output.

4 weeks agoMIPS/BFD: Fix howto orphan REL HI16 relocation addend processing
Maciej W. Rozycki [Wed, 14 Jan 2026 22:28:44 +0000 (22:28 +0000)] 
MIPS/BFD: Fix howto orphan REL HI16 relocation addend processing

Correct the addend being ignored for orphan REL HI16 relocations.

For assembly and non-ELF links `_bfd_mips_elf_hi16_reloc' is called from
`bfd_install_relocation' and `bfd_perform_relocation' respectively via
the respective howtos.  It caches the relocation for later processing as
`_bfd_mips_elf_lo16_reloc' is called via the corresponding LO16 reloc's
howto, at which point both the HI16 and the LO16 parts are calculated
and installed.

If no matching LO16 relocation has been later encountered, then the
cached entry is never processed, with the outstanding cached entries
silently dropped at the conclusion of processing, resulting in zero
addend being used for the field relocated.

Dropping of the entries only happens in `_bfd_mips_elf_free_cached_info'
at the time the BFD is being successfully closed and section contents
long written to output.  For non-ELF links dropping will also execute in
`_bfd_elf_mips_get_relocated_section_contents' via a separate piece of
code if the function has encountered an error.

Address the issues first by factoring out code to process outstanding
cached entries to `mips_elf_free_hi16_list' and then by making the
function actually install the relocations cached as required.  This has
to happen before section contents have been written and therefore the
success path wires the function call to `bfd_finalize_section_relocs',
for assembly and `_bfd_elf_mips_get_relocated_section_contents' for
non-ELF links.

For housekeeping purposes the latter call will just drop cached entries
as it happens now in the case of an error, and likewise the call from
`_bfd_mips_elf_free_cached_info' is retained in case a fatal error in
the assembler prevents `bfd_finalize_section_relocs' from being called.

This also results in a warning being issued now about orphan REL HI16
relocations encountered in non-ELF links.  Previously no such warning
was produced since the cached entries were dropped.  For assembly we
expect the tool to have issued its own warning, so we process orphan
relocations silently if successful, but still issue a warning if an
error is returned.

We are careful in `mips_elf_free_hi16_list' to retain any incoming BFD
error as the function may be called under an error condition and if
there's another failure in processing at this stage we don't want to
clobber the original error.

Test cases will be added with a separate change.

4 weeks agoMIPS/BFD: Fix ELF link orphan REL HI16 relocation addend processing
Maciej W. Rozycki [Wed, 14 Jan 2026 22:28:44 +0000 (22:28 +0000)] 
MIPS/BFD: Fix ELF link orphan REL HI16 relocation addend processing

Correct the addend being ignored for orphan REL HI16 relocations.

For ELF links `_bfd_mips_elf_relocate_section' handles relocation and
uses `mips_elf_add_lo16_rel_addend' to shift the incoming HI16 in-place
addend into its intended [31:16] bit positions and combine it with the
LO16 part.  If no matching LO16 reloc has been found, then the function
returns early and consequently the incoming HI16 addend is not shifted
and remains in bits [0:15].  For final links any value of the symbol
referred is then added.  Then the final value is shifted back into bits
[0:15] for installation into the field relocated.  It is obviously wrong
as the original HI16 in-place addend has now been lost.

Fix the issue by shifting the incoming HI16 in-place addend before using
`mips_elf_next_relocation' to find the matching LO16 relocation.  Then
upon early return from `mips_elf_add_lo16_rel_addend' the addend is in
the intended [31:16] bit positions already.

Test cases will be added with a separate change.

4 weeks agoMIPS/BFD: Standardize orphan REL HI16 relocation warning
Maciej W. Rozycki [Wed, 14 Jan 2026 22:28:44 +0000 (22:28 +0000)] 
MIPS/BFD: Standardize orphan REL HI16 relocation warning

Use the warning callback for the orphan REL HI16 relocation warning just
as with any other linker relocation processing warnings, standardizing
the message format and providing source location where available.

Test cases will be added with a separate change.

4 weeks agoMIPS/GAS: Warn about unmatched REL HI16 relocations
Maciej W. Rozycki [Wed, 14 Jan 2026 22:28:44 +0000 (22:28 +0000)] 
MIPS/GAS: Warn about unmatched REL HI16 relocations

Ever since commit 749b8d9d455c ("PATCH: ld/4208: `final link failed: Bad
value' when building Linux MIPS kernels."), which went in back in 2007,
<https://inbox.sourceware.org/binutils/20070320043504.GA7735@lucon.org/>,
we've been warning about unmatched HI16 REL relocations in the linker,
as it has been concluded in the discussion on PR ld/4208 that we have no
need to be forgiving about compiler bugs that lead to object files to be
made that are not compliant with the psABI.

However no corresponding update has ever been made to GAS, despite that
it's always helpful to issue a warning as early as possible in the build
process.  In this particular case GAS also has more information to hand
as it always has the full original addend available that has been used
for both the high-part and the low-part relocation, while the linker has
to rely on the in-place value stored in the relocatable field by earlier
processing, which has necessarily been truncated.  Therefore the linker
may miss cases where unrelated high-part and low-part relocations have
been put next to each other that had significantly different addends at
assembly time (small differences are deliberately permitted where they
are known not to affect any borrow from the high part).

Additionally GAS is able to point at the exact place in sources where
any offending orphan relocations have been used.

Update GAS to issue the warning then where applicable and remove an old
comment referring to GCC producing orphan HI16 relocations.

Test cases will be added with a separate change.

4 weeks agoBFD: Make `bfd_finalize_section_relocs' return status
Maciej W. Rozycki [Wed, 14 Jan 2026 22:28:43 +0000 (22:28 +0000)] 
BFD: Make `bfd_finalize_section_relocs' return status

Update `bfd_finalize_section_relocs' to return status so that backends
can fail in this interface and propagate that to the respective callers.
Add suitable error reporting there.  No failure cases in the existing
handlers though.

4 weeks agoBFD: Rename `*_set_reloc' to `*_finalize_section_relocs'
Maciej W. Rozycki [Wed, 14 Jan 2026 22:28:43 +0000 (22:28 +0000)] 
BFD: Rename `*_set_reloc' to `*_finalize_section_relocs'

The `*_set_reloc' interface is to be called at the conclusion of section
relocation processing, however its name reflects a particular action to
take rather than the context of invocation.  Implementation is already
backend-specific.

Rename the interface such as not to make its name artificially limit the
intended purpose.  Update the callers and documentation accordingly.  No
functional change.

4 weeks agoGAS: Unify code for SET_SECTION_RELOCS call
Maciej W. Rozycki [Wed, 14 Jan 2026 22:28:43 +0000 (22:28 +0000)] 
GAS: Unify code for SET_SECTION_RELOCS call

Fold a separate call to `bfd_set_reloc' into SET_SECTION_RELOCS itself,
so that the GAS interface to this facility is contained in a single
invocation.

Currently both `write_relocs' and `obj_mach_o_reorder_section_relocs'
call `bfd_set_reloc', causing the function to be called twice by Mach-O
targets, such as `i386-darwin', once before target-specific processing
and again afterwards, which is at the very least fragile in terms of
assuming that any actions made by the function on the first invocation
won't interfere with the final intended result.

Set the macro by default to a plain call to `bfd_set_reloc', letting
backends override the macro, with the requirement now to factor in a
call to said function at the appropriate time.  Backends can choose
whether to call `bfd_set_reloc' first (such as COFF), or last (such as
Mach-O), or at any other point in relation to their own additional
actions.

Update the COFF variant accordingly, moving it to a new function for a
better code structure, retaining functionality.

This is in preparation for `bfd_set_reloc' to return an error status.

4 weeks ago[gdb/testsuite] Speed up gdb.base/tls-dlobj.exp
Tom de Vries [Wed, 14 Jan 2026 20:41:45 +0000 (21:41 +0100)] 
[gdb/testsuite] Speed up gdb.base/tls-dlobj.exp

In test-case gdb.base/tls-dlobj.exp we use breakpoints to step through the
executable.  The breakpoints are used only once, but they are permanent, so we
end up with 11 breakpoints, 10 of which of the form $srcfile:$n.

The executable loads and unloads shared libraries, triggering solib events in
gdb, which will re-set the breakpoints.

Setting a breakpoint of the form $srcfile:$n triggers a filename search that
iterates over all CUs in all objfiles for which we have debuginfo.

In case glibc debuginfo is installed, and in case we have a slow gdb, for
instance because of building with -O0 and Address Sanitizer, this might become
noticeable.

While it's a good idea to try to speed up this search (see for instance
PR33781), measuring this speed is not the point of this test-case, so fix this
by making the breakpoints temporary.

Tested on x86_64-linux.

Approved-by: Kevin Buettner <kevinb@redhat.com>
4 weeks agogdb/jit: add function symbols to global block
Jan Vrany [Wed, 14 Jan 2026 14:31:36 +0000 (14:31 +0000)] 
gdb/jit: add function symbols to global block

While playing with JIT reader I realized that it is not possible to set
a breakpoint on jitted function:

    (gdb) b jit_function_stack_mangle
    Function "jit_function_stack_mangle" not defined.
    Make breakpoint pending on future shared library load? (y or [n])

The problem is that symbols for jitted functions (jit_function_stack_mangle
in the above example) are not added to jitted compunit's global block:

    (gdb) maint print symtabs
    ...
    Symtab for file  at 0x55d6f8c186c0
    Read from object file << JIT compiled code at 0x5555555592a0 >> (0x55d6f8cd4090)
    Language: unknown

    Line table:

     line 1 at 0x7ffff7fbc000 (stmt)
     line 0 at 0x7ffff7fbc001 (stmt)

    Blockvector:

    block #000, object at 0x55d6f8c188b0, 0 symbols in 0x7ffff7fbc000..0x7ffff7fbc011
      block #001, object at 0x55d6f8c18910 under 0x55d6f8c188b0, 0 symbols in 0x7ffff7fbc000..0x7ffff7fbc011
        block #002, object at 0x55d6f8c18730 under 0x55d6f8c18910, 0 symbols in 0x7ffff7fbc000..0x7ffff7fbc00a, function jit_function_stack_mangle
        block #003, object at 0x55d6f8c187f0 under 0x55d6f8c18910, 0 symbols in 0x7ffff7fbc00a..0x7ffff7fbc011, function jit_function_add

This commit changes JIT reader to add jitted functions to the global
block:

    ...
    Blockvector:

    block #000, object at 0x55ed6665b180, 2 symbols in 0x7ffff7fbc000..0x7ffff7fbc011
     void jit_function_stack_mangle(); block object 0x55ed6665b000, 0x7ffff7fbc000..0x7ffff7fbc00a
     void jit_function_add(); block object 0x55ed6665b0c0, 0x7ffff7fbc00a..0x7ffff7fbc011
      block #001, object at 0x55ed6665b230 under 0x55ed6665b180, 0 symbols in 0x7ffff7fbc000..0x7ffff7fbc011
        block #002, object at 0x55ed6665b000 under 0x55ed6665b230, 0 symbols in 0x7ffff7fbc000..0x7ffff7fbc00a, function jit_function_stack_mangle
        block #003, object at 0x55ed6665b0c0 under 0x55ed6665b230, 0 symbols in 0x7ffff7fbc00a..0x7ffff7fbc011, function jit_function_add

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogas: sframe: simplify get_offset_size_in_bytes
Jens Remus [Wed, 14 Jan 2026 12:25:21 +0000 (13:25 +0100)] 
gas: sframe: simplify get_offset_size_in_bytes

Type offsetT is either defined as signed 32-bit or 64-bit integer
depending on whether BFD64 is defined.  Do not test for whether an
offsetT value exceeds INT32_MIN..INT32_MAX for !BFD64 32-bit offsetT
(or INT64_MIN..INT64_MAX for BFD64 64-bit offsetT).  This is always
true and may result in a compile error when using compiler option
-Werror=type-limits, such as the one resolved with commit
6b8fb74a9403 ("gas: sframe: do not test whether offsetT exceeds
INT64_MIN..INT64_MAX") for BFD64 64-bit offsetT:

../../binutils-gdb/gas/gen-sframe.c: In function ‘get_offset_size_in_bytes’:
../../binutils-gdb/gas/gen-sframe.c:213:45: error: comparison is always true due to limited range of data type [-Werror=type-limits]
  213 |   else if ((sizeof (offsetT) > 4) && (value <= INT64_MAX && value >= INT64_MIN))
      |                                             ^~
../../binutils-gdb/gas/gen-sframe.c:213:67: error: comparison is always true due to limited range of data type [-Werror=type-limits]
  213 |   else if ((sizeof (offsetT) > 4) && (value <= INT64_MAX && value >= INT64_MIN))
      |                                                                   ^~

Instead of testing for whether the value is in range of
INT8_MIN..INT8_MAX, INT16_MIN..INT16_MAX, or INT32_MIN..INT32_MAX,
test whether the value is unchanged when casted to int8_t, int16_t,
or int32_t.  This also improves readability.

gas/
* gen-sframe.c (get_offset_size_in_bytes): Simplify.  Do not
test whether !BFD64 32-bit offsetT exceeds INT32_MIN..INT32_MAX.

Fixes: 58008ed4e6af ("gas: sframe: use standard min/max integer constants")
Suggested-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
4 weeks agopy-gdb-readline: replace deprecated interfaces in GdbRemoveReadlineFinder
Matthieu Longo [Fri, 25 Jul 2025 10:58:56 +0000 (11:58 +0100)] 
py-gdb-readline: replace deprecated interfaces in GdbRemoveReadlineFinder

A previous patch [1] enabled readline in Python in a GDB-specific way
and blocked the standard Python readline module to prevent conflicts
with GDB by adding a custom importer raising an exception for the readline
module.

This custom importer was written back in 2012 for old Python versions,
and does not seem to work anymore with Python 3.x. find_module() and
load_module() have been deprecated since Python 3.4, and the first one
has been removed since 3.12, and the second will be removed in 3.15.
The GDB testsuite does not cover this use case, and the removal of
find_module() was not detected by the testsuite. This issue is tracked
in bug 32473.

importlib.abc.MetaPathFinder:
  find_module(fullname, path)
    Deprecated since version 3.4: Use find_spec() instead.
    Changed in version 3.10: Use of find_module() by the import
    system now raises ImportWarning.
    Changed in version 3.12: find_module() has been removed. Use
    find_spec() instead.

  find_spec(fullname, path, target=None)
    New in version 3.4, as a replacement for find_module.

importlib.abc.Loader:
  load_module(fullname):
    Deprecated since version 3.4, will be removed in version 3.15
    The recommended API for loading a module is exec_module()
    (and create_module()).

This patch uses Patryk Sondej's approach detailed in bug 32473, but with
a slight variation regarding the finder insertion in sys.meta_path.
It also adds a new test to prevent future regression.

[1]: 037bbc8eeaf8e6f3a5e185e78268aa71a1159ae7

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

4 weeks agoMAINTAINERS: Update my email address
Nelson Chu [Wed, 14 Jan 2026 03:20:49 +0000 (11:20 +0800)] 
MAINTAINERS: Update my email address

5 weeks agoAutomatic date update in version.in
GDB Administrator [Wed, 14 Jan 2026 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 weeks agoelf: Handle the section flag 'o' linked to special sections
H.J. Lu [Sun, 11 Jan 2026 03:43:40 +0000 (11:43 +0800)] 
elf: Handle the section flag 'o' linked to special sections

Call _bfd_elf_section_from_bfd_section to get the sh_link value from
the section flag 'o' directive, which may point to special sections,
like SHN_ABS or SHN_COMM.  Update readelf to print the special section
names in the sh_link field and replace "internal->sh_link > num" with
"internal->sh_link >= num".

bfd/

PR gas/33744
* elf.c (assign_section_numbers): Call
_bfd_elf_section_from_bfd_section to get the sh_link value.

binutils/

PR gas/33744
* readelf.c (special_defined_section_index): New.
(get_32bit_section_headers): Don't warn special section indexes
in the sh_link field.
(get_64bit_section_headers): Likewise.
(process_section_headers): Print special defined section names.

gas/

PR gas/33744
* testsuite/gas/elf/elf.exp: Run PR gas/33744 tests.
* testsuite/gas/elf/sh-link-abs-1.d: New file.
* testsuite/gas/elf/sh-link-abs-2.d: Likewise.
* testsuite/gas/elf/sh-link-abs-3-32.d: Likewise.
* testsuite/gas/elf/sh-link-abs-3-64.d: Likewise.
* testsuite/gas/elf/sh-link-abs-4-32.d: Likewise.
* testsuite/gas/elf/sh-link-abs-4-64.d: Likewise.
* testsuite/gas/elf/sh-link-abs.s: Likewise.
* testsuite/gas/elf/sh-link-common-1.d: Likewise.
* testsuite/gas/elf/sh-link-common-2.d: Likewise.
* testsuite/gas/elf/sh-link-common-3-32.d: Likewise.
* testsuite/gas/elf/sh-link-common-3-64.d: Likewise.
* testsuite/gas/elf/sh-link-common-4-32.d: Likewise.
* testsuite/gas/elf/sh-link-common-4-64.d: Likewise.
* testsuite/gas/elf/sh-link-common.s: Likewise.
* testsuite/gas/elf/sh-link-large-common-1.d: Likewise.
* testsuite/gas/elf/sh-link-large-common-2.d: Likewise.
* testsuite/gas/elf/sh-link-large-common-3.d: Likewise.
* testsuite/gas/elf/sh-link-large-common-4.d: Likewise.
* testsuite/gas/elf/sh-link-large-common.s: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
5 weeks agogas: sframe: do not test whether offsetT exceeds INT64_MIN..INT64_MAX
Jens Remus [Tue, 13 Jan 2026 13:14:43 +0000 (14:14 +0100)] 
gas: sframe: do not test whether offsetT exceeds INT64_MIN..INT64_MAX

A value of type offsetT, which is either a signed 32-bit or 64-bit
integer, cannot exceed the range of INT64_MIN..INT64_MAX.  This
resolves the following compile error:

../../binutils-gdb/gas/gen-sframe.c: In function ‘get_offset_size_in_bytes’:
../../binutils-gdb/gas/gen-sframe.c:213:45: error: comparison is always true due to limited range of data type [-Werror=type-limits]
  213 |   else if ((sizeof (offsetT) > 4) && (value <= INT64_MAX && value >= INT64_MIN))
      |                                             ^~
../../binutils-gdb/gas/gen-sframe.c:213:67: error: comparison is always true due to limited range of data type [-Werror=type-limits]
  213 |   else if ((sizeof (offsetT) > 4) && (value <= INT64_MAX && value >= INT64_MIN))
      |                                                                   ^~

Fixes: 58008ed4e6af ("gas: sframe: use standard min/max integer constants")
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
5 weeks agogas: sframe: use standard min/max integer constants
Jens Remus [Tue, 13 Jan 2026 12:17:49 +0000 (13:17 +0100)] 
gas: sframe: use standard min/max integer constants

Replace the use of custom VALUE_{8|16|32|64}BIT constant definitions
with the standard INT{8|16|32|64}_{MIN|MAX} ones from stdint.h.

Besides improving readability this also fixes the issue that the
smallest representable signed 8/16/32-bit integer value was
erroneously sized as the next larger integer type.  For example
get_offset_size_in_bytes (INT8_MIN) returned 2 instead of 1, due
to INT8_MIN (= -128) != -VALUE_8BIT (= -127):

  (gdb) call get_offset_size_in_bytes (-127)
  $1 = 1
  (gdb) call get_offset_size_in_bytes (-128)
  $2 = 2

gas/
* gen-sframe.c (VALUE_8BIT, VALUE_16BIT, VALUE_32BIT,
VALUE_64BIT): Remove.
(get_offset_size_in_bytes): Use standard min/max integer
constants.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
5 weeks agogdb: yet more miscellaneous styling fixes
Andrew Burgess [Sat, 10 Jan 2026 18:37:05 +0000 (18:37 +0000)] 
gdb: yet more miscellaneous styling fixes

The previous patch was all about address styling, but I spotted some
non-address styling that was missing.  This patch covers those cases.

There's function name styling for the 'jump' command, and line number,
and function name styling for 'maint print symbols'.

Other than the extra styling, there should be no user visible changes
after this commit.

Approved-By: Tom Tromey <tom@tromey.com>
5 weeks agogdb: more address styling throughout
Andrew Burgess [Fri, 9 Jan 2026 15:03:40 +0000 (15:03 +0000)] 
gdb: more address styling throughout

I looked for the pattern 'gdb_puts (paddress (', these are places in
GDB where we are printing a target address without styling.  I changed
most of what I found to print the address as styled.

I did leave a few unchanged in psymtab.c, these are all in maintenance
commands 'maint print psymbols', 'maint info psymtabs', and 'maint
check psymtabs'.  None of these commands appear to print anything for
me (do we even use partial symtabs these days?  I thought not) so I
didn't want to mess with commands that I couldn't test.

Other than the additional styling, there should be no user visible
changes after this commit.

Approved-By: Tom Tromey <tom@tromey.com>
5 weeks agogdb: output styling, and GDB code style fixes, for 'info frame'
Andrew Burgess [Fri, 9 Jan 2026 14:03:04 +0000 (14:03 +0000)] 
gdb: output styling, and GDB code style fixes, for 'info frame'

I noticed that the output of 'info frame' was not styled much; the
frame's filename is styled, as are the names of any frame local
variables.  But there's lots of address and line number styling
missing.

When I started looking at the info_frame_command_core function though,
there were lots of coding standard changes that could be made too, so
while I was in the area I thought I'd make some coding standard
changes to the function:

  + Inlined local variable declarations.

  + Removed the 'caller_pc_p' local, and made 'caller_pc' a
    std::optional<CORE_ADDR> instead.

  + Converted a local from 'int' to 'bool'.

  + Replaced NULL with nullptr.

  + Replaced calls to gdb_printf with gdb_puts when the thing to print
    is a constant string.

  + Added { ... } around if/else bodies that are a single statement
    AND a comment inline with GDB coding style.

  + Avoid treating pointers and integers as booleans in 'if'
    conditions.  Compare to nullptr and/or zero instead.

Other than the new styling, there should be no user visible changes
after this commit.

Approved-By: Tom Tromey <tom@tromey.com>
5 weeks agogas/riscv: Fix grammar in error messages
Andreas Schwab [Mon, 30 Dec 2024 17:55:46 +0000 (18:55 +0100)] 
gas/riscv: Fix grammar in error messages

5 weeks agoobjcopy: Set bfd_error_system_call before reporting error from make_tempname
Andreas Schwab [Tue, 21 Feb 2023 21:32:11 +0000 (22:32 +0100)] 
objcopy: Set bfd_error_system_call before reporting error from make_tempname

5 weeks agoreadelf: Handle R_RISCV_SET32
Andreas Schwab [Mon, 12 Jan 2026 21:54:38 +0000 (22:54 +0100)] 
readelf: Handle R_RISCV_SET32

5 weeks agoRegenerate libiberty/aclocal.m4 and ld/config.in using the correct versions of the...
Nick Clifton [Tue, 13 Jan 2026 10:04:05 +0000 (10:04 +0000)] 
Regenerate libiberty/aclocal.m4 and ld/config.in using the correct versions of the autotools

5 weeks agogdb: Update comment of c_type_print_template_args.
Christina Schimpe [Mon, 29 Dec 2025 15:15:14 +0000 (15:15 +0000)] 
gdb: Update comment of c_type_print_template_args.

Remove function description for TABLE.  This function does not take a
parameter "table".

Approved-By: Tom Tromey <tom@tromey.com>
5 weeks agoPowerPC: Support for eTCE (RFC02662)
Abhay Kandpal [Tue, 13 Jan 2026 05:28:45 +0000 (00:28 -0500)] 
PowerPC: Support for eTCE (RFC02662)

opcodes/
        * ppc-opc.c (XTLBIE_MASK, XTLBIEIO_MASK): New macros.
        (powerpc_opcodes): Add tlbiep, tlbieio, tlbsyncio,
        ptesyncio.

gas/
        * testsuite/gas/ppc/future.s: New test.
        * testsuite/gas/ppc/future.d: Likewise.

5 weeks agoPowerPC: Support for Additional Performance Monitor Counters (RFC02666)
Abhay Kandpal [Tue, 13 Jan 2026 04:44:52 +0000 (23:44 -0500)] 
PowerPC: Support for Additional Performance Monitor Counters (RFC02666)

opcodes/
        * ppc-opc.c (powerpc_opcodes): Add mtummcrae, mtummcr2e,
        mtmmcr2e, mtmmcrae, mtmmcr1e, mtmmcr3e, mtupmc7, mtupmc8,
        mtpmc7, mtpmc8, mfummcrae, mfmmcrae, mfummcr1e, mfmmcr1e,
        mfummcr2e, mfmmcr2e, mfummcr3e, mfmmcr3e, mfupmc7, mfpmc7,
        mfupmc8, mfpmc8.

gas/
        * testsuite/gas/ppc/future.s: New test.
        * testsuite/gas/ppc/future.d: Likewise.

5 weeks agolibiberty: sync with gcc
Maciej W. Rozycki [Tue, 13 Jan 2026 00:48:28 +0000 (00:48 +0000)] 
libiberty: sync with gcc

Import the following commits from GCC as of r16-6728-g7c3584be8c8806:
07df546fb90 libiberty/testsuite: make test-pexecute's -t option a little more useful
0c775dcf3e7 libiberty: Make `objalloc_free' `free'-like WRT null pointer

5 weeks agoAutomatic date update in version.in
GDB Administrator [Tue, 13 Jan 2026 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 weeks agogas: Check @@@ before renaming the versioned symbol
H.J. Lu [Sun, 11 Jan 2026 22:55:34 +0000 (06:55 +0800)] 
gas: Check @@@ before renaming the versioned symbol

The versioned symbol with the @@@ syntax is a special case. If the symbol
is not defined, 2 `@'s will be removed from the versioned_name. Otherwise,
1 `@' will be removed.  But for malformed versioned symbols may not have
@@@:

.symver foo,foo@@@version1
.symver foo,foo@version2

Check @@@ before renaming the versioned symbol.

PR gas/33745
* config/obj-elf.c (elf_frob_file_before_adjust): Check @@@ before
renaming the versioned symbol.
* testsuite/gas/symver/symver.exp: Run symver17.
* testsuite/gas/symver/symver17.l: New file.
* testsuite/gas/symver/symver17.s: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
5 weeks agogdb/testsuite: fix DUPLICATE in call-sc.exp
Jan Vrany [Mon, 12 Jan 2026 19:55:03 +0000 (19:55 +0000)] 
gdb/testsuite: fix DUPLICATE in call-sc.exp

With test-case gdb.base/call-sc.exp I get:

    DUPLICATE: gdb.base/call-sc.exp: tc: ptype; call-sc-tc (char)
    DUPLICATE: gdb.base/call-sc.exp: ts: ptype; call-sc-ts (short)
    DUPLICATE: gdb.base/call-sc.exp: ti: ptype; call-sc-ti (int)
    ...

Fix this by changing test name in testcase added in commit be90f3e2.

Tested on x86_64-linux.

Approved-By: Tom de Vries <tdevries@suse.de>
5 weeks agogdb/dwarf: make dwarf2_per_cu size fields atomic
Simon Marchi [Sun, 11 Jan 2026 03:40:30 +0000 (22:40 -0500)] 
gdb/dwarf: make dwarf2_per_cu size fields atomic

Make m_addr_size, m_offset_size, and m_ref_addr_size use std::atomic.
Multiple indexer threads may set these values concurrently, which
currently causes a TSan failure:

     WARNING: ThreadSanitizer: data race (pid=1535364)
       Write of size 1 at 0xfffed1813515 by thread T1:
         #0 dwarf2_per_cu::set_addr_size(unsigned char) /home/vries/gdb/src/gdb/dwarf2/read.h:291 (gdb+0x98af68) (BuildId: cce1d3c72972f5759cd1746e1a001e90d7498301)
         #1 cutu_reader::cutu_reader(dwarf2_per_cu&, dwarf2_per_objfile&, abbrev_table const*, dwarf2_cu*, bool, language, abbrev_table_cache const*) /home/vries/gdb/src/gdb/dwarf2/read.c:3114 (gdb+0x9472b4) (BuildId: cce1d3c72972f5759cd1746e1a001e90d7498301)
         #2 std::__detail::_MakeUniq<cutu_reader>::__single_object std::make_unique<cutu_reader, dwarf2_per_cu&, dwarf2_per_objfile&, decltype(nullptr), decltype(nullptr), bool, language, abbrev_table_cache const*>(dwarf2_per_cu&, dwarf2_per_objfile&, decltype(nullptr)&&, decltype(nullptr)&&, bool&&, language&&, abbrev_table_cache const*&&) /usr/include/c++/15/bits/unique_ptr.h:1084 (gdb+0x891f98) (BuildId: cce1d3c72972f5759cd1746e1a001e90d7498301)
         #3 cooked_indexer::ensure_cu_exists(cutu_reader*, section_and_offset const&, bool) /home/vries/gdb/src/gdb/dwarf2/cooked-indexer.c:118 (gdb+0x88e1e8) (BuildId: cce1d3c72972f5759cd1746e1a001e90d7498301)
         #4 cooked_indexer::scan_attributes(dwarf2_per_cu*, cutu_reader*, unsigned char const*, unsigned char const*, abbrev_info const*, char const**, char const**, enum_flags<cooked_index_flag_enum>*, sect_offset*, cooked_index_entry const**, parent_map::addr_type*, bool*, bool) /home/vries/gdb/src/gdb/dwarf2/cooked-indexer.c:316 (gdb+0x88ed1c) (BuildId: cce1d3c72972f5759cd1746e1a001e90d7498301)
         #5 cooked_indexer::index_dies(cutu_reader*, unsigned char const*, std::variant<cooked_index_entry const*, parent_map::addr_type>, bool) /home/vries/gdb/src/gdb/dwarf2/cooked-indexer.c:539 (gdb+0x88fa50) (BuildId: cce1d3c72972f5759cd1746e1a001e90d7498301)
         #6 cooked_indexer::make_index(cutu_reader*) /home/vries/gdb/src/gdb/dwarf2/cooked-indexer.c:718 (gdb+0x890430) (BuildId: cce1d3c72972f5759cd1746e1a001e90d7498301)
 ...

      Previous write of size 1 at 0xfffed1813515 by thread T4:
        #0 dwarf2_per_cu::set_addr_size(unsigned char) /home/vries/gdb/src/gdb/dwarf2/read.h:291 (gdb+0x98af68) (BuildId: cce1d3c72972f5759cd1746e1a001e90d7498301)
        #1 cutu_reader::cutu_reader(dwarf2_per_cu&, dwarf2_per_objfile&, abbrev_table const*, dwarf2_cu*, bool, language, abbrev_table_cache const*) /home/vries/gdb/src/gdb/dwarf2/read.c:3114 (gdb+0x9472b4) (BuildId: cce1d3c72972f5759cd1746e1a001e90d7498301)
        #2 std::__detail::_MakeUniq<cutu_reader>::__single_object std::make_unique<cutu_reader, dwarf2_per_cu&, dwarf2_per_objfile&, decltype(nullptr), decltype(nullptr), bool, language, abbrev_table_cache const*>(dwarf2_per_cu&, dwarf2_per_objfile&, decltype(nullptr)&&, decltype(nullptr)&&, bool&&, language&&, abbrev_table_cache const*&&) /usr/include/c++/15/bits/unique_ptr.h:1084 (gdb+0x891f98) (BuildId: cce1d3c72972f5759cd1746e1a001e90d7498301)
        #3 cooked_indexer::ensure_cu_exists(cutu_reader*, section_and_offset const&, bool) /home/vries/gdb/src/gdb/dwarf2/cooked-indexer.c:118 (gdb+0x88e1e8) (BuildId: cce1d3c72972f5759cd1746e1a001e90d7498301)
        #4 cooked_indexer::index_imported_unit(cutu_reader*, unsigned char const*, abbrev_info const*) /home/vries/gdb/src/gdb/dwarf2/cooked-indexer.c:431 (gdb+0x88f454) (BuildId: cce1d3c72972f5759cd1746e1a001e90d7498301)
        #5 cooked_indexer::index_dies(cutu_reader*, unsigned char const*, std::variant<cooked_index_entry const*, parent_map::addr_type>, bool) /home/vries/gdb/src/gdb/dwarf2/cooked-indexer.c:498 (gdb+0x88f770) (BuildId: cce1d3c72972f5759cd1746e1a001e90d7498301)
        #6 cooked_indexer::index_imported_unit(cutu_reader*, unsigned char const*, abbrev_info const*) /home/vries/gdb/src/gdb/dwarf2/cooked-indexer.c:434 (gdb+0x88f4ac) (BuildId: cce1d3c72972f5759cd1746e1a001e90d7498301)
        #7 cooked_indexer::index_dies(cutu_reader*, unsigned char const*, std::variant<cooked_index_entry const*, parent_map::addr_type>, bool) /home/vries/gdb/src/gdb/dwarf2/cooked-indexer.c:498 (gdb+0x88f770) (BuildId: cce1d3c72972f5759cd1746e1a001e90d7498301)
        #8 cooked_indexer::make_index(cutu_reader*) /home/vries/gdb/src/gdb/dwarf2/cooked-indexer.c:718 (gdb+0x890430) (BuildId: cce1d3c72972f5759cd1746e1a001e90d7498301)
...

It's fine for multiple threads to try to set these values concurrently.
The only condition is that either the previous value was 0 (unset) or
equals the new value being set.

Change-Id: Ib13218707cefdf33a51b3246ba5773a7800463b9
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33775
Reviewed-By: Tom de Vries <tdevries@suse.de>
5 weeks agogas: Explicitly code void parameter list
Jens Remus [Mon, 12 Jan 2026 15:09:23 +0000 (16:09 +0100)] 
gas: Explicitly code void parameter list

This fixes the following compile errors reported by Clang:

  CC       config/obj-elf-attr.o
../../gas/config/obj-elf-attr.c:64:21: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
   64 | oav1_attr_info_init ()
      |                     ^
      |                      void
../../gas/config/obj-elf-attr.c:74:21: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
   74 | oav1_attr_info_exit ()
      |                     ^
      |                      void

gas/
* config/obj-elf-attr.c (oav1_attr_info_init,
oav1_attr_info_exit): Explicitly code void parameter list.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
5 weeks agoUse a map for symfile.c:symtab_fns
Tom Tromey [Fri, 7 Nov 2025 16:41:23 +0000 (09:41 -0700)] 
Use a map for symfile.c:symtab_fns

This changes symfile.c:symtab_fns to use a map rather than a vector,
letting us remove an otherwise extraneous type.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
5 weeks agoaarch64: Don't relax relocations to static function symbols
Richard Earnshaw [Fri, 9 Jan 2026 17:59:45 +0000 (17:59 +0000)] 
aarch64: Don't relax relocations to static function symbols

The aarch64 ABI states that long branch veneers may be added to
facilitate linking code that is beyond the range of a 26-bit call or
branch; but it requires that the target symbol be a function symbol.

Ensure that this latter condition is maintained by rejecting
relaxation of a static function symbol to it's section symbol.

Note that there should probably be a fix to the linker to enforce this
during link time.  I've not done this for now because that might break
some existing object code that has been built with older versions of
gas.  At some point we should revisit this.

This change also causes a small change in the LD testsuite: instead of
generating some veneers with the section name we now (correctly)
generate them using the name of the called function.

5 weeks agoAutomatic date update in version.in
GDB Administrator [Mon, 12 Jan 2026 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 weeks agogas: Update testsuite/gas/symver/symver15.l
H.J. Lu [Sun, 11 Jan 2026 22:48:17 +0000 (06:48 +0800)] 
gas: Update testsuite/gas/symver/symver15.l

Update testsuite/gas/symver/symver15.l to expect:

Error: multiple versions [`foo@version2'|`foo@version1'] for symbol `foo'

* testsuite/gas/symver/symver15.l: Expect '|'.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
5 weeks ago[gdbsupport] Regenerate Makefile.in
Tom de Vries [Sun, 11 Jan 2026 09:53:26 +0000 (10:53 +0100)] 
[gdbsupport] Regenerate Makefile.in

The buildbot complains about an out-of-date Makefile.in.  Fix this by
regenerating it from Makefile.am using automake.

5 weeks agoor1k: Mark undefined TLS symbol as STT_TLS
H.J. Lu [Tue, 18 Nov 2025 04:09:54 +0000 (12:09 +0800)] 
or1k: Mark undefined TLS symbol as STT_TLS

Update or1k_apply_fix to handle all TLS relocations.

PR gas/33426
* config/tc-or1k.c (or1k_apply_fix): Handle all TLS relocations.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
5 weeks agox86: Cache the symbol table when packing relative relocations
H.J. Lu [Fri, 9 Jan 2026 00:54:42 +0000 (08:54 +0800)] 
x86: Cache the symbol table when packing relative relocations

When packing relative relocations, x86 linker may load the same symbol
table repeatedly, which can take a long time.  On Intel Core i7-1195G7
with 32GB RAM, it takes more than 45 minutes to create an output with
-pie -z pack-relative-relocs from an input with 208025 code sections.
Cache the symbol table to reduce the link time to less than 2 seconds.

On the same machine, creating 3.1GB clang executable in LLVM 21.1.3 debug
build:

user            55.39 seconds
system          6.71 seconds
total           65.80 seconds
maximum set(GB) 10.43
page faults     2406941

PR ld/33765
* elfxx-x86.c (elf_x86_relative_reloc_record_add): Remove
keep_symbuf_p.
(_bfd_x86_elf_link_relax_section): Updated.  Cache the symbol
table to avoid loading it again.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
5 weeks agoAutomatic date update in version.in
GDB Administrator [Sun, 11 Jan 2026 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 weeks ago[gdb/testsuite] Add missing wait in gdb.multi/sched-multi-add-inferior.exp
Tom de Vries [Sat, 10 Jan 2026 06:36:39 +0000 (07:36 +0100)] 
[gdb/testsuite] Add missing wait in gdb.multi/sched-multi-add-inferior.exp

With a gdb build with -O0 and Address Sanitizer and test-case
gdb.multi/sched-multi-add-inferior.exp, I get:
...
FAIL: $exp: target_type_1=extended-remote: target_type_2=extended-remote: \
  continue to function1
FAIL: $exp: target_type_1=extended-remote: target_type_2=extended-remote: \
  continue to function2
FAIL: $exp: target_type_1=native: target_type_2=extended-remote: \
  continue to function1
FAIL: $exp: target_type_1=native: target_type_2=extended-remote: \
  continue to function2
FAIL: $exp: target_type_1=native: target_type_2=native: continue to function1
FAIL: $exp: target_type_1=native: target_type_2=native: continue to function2
...

In more detail, for the target_type_1 == target_type_2 == native configuration,
we have:
...
(gdb) continue^M
Continuing.^M
[Switching to Thread 0x7ffff7cc02c0 (LWP 2514714)]^M
^M
Thread 2.1 "sched-multi-add" hit Breakpoint 4, main (...) at multi-target.c:94^M
94            function2 (); /* set break 2 here */^M
(gdb) FAIL: $exp: target_type_1=native: target_type_2=native: \
  continue to function1
thread apply 2.1 set wait_for_gdb = 0^M
^M
Thread 2.1 (Thread 0x7ffff7cc02c0 (LWP 2514714) "sched-multi-add"):^M
(gdb) PASS: $exp: target_type_1=native: target_type_2=native: \
  thread apply 2.1 set wait_for_gdb = 0
continue^M
Continuing.^M
[Switching to Thread 0x7ffff7cc02c0 (LWP 2514718)]^M
^M
Thread 3.1 "sched-multi-add" hit Breakpoint 3, main (...) at multi-target.c:93^M
93            function1 (); /* set break 1 here */^M
(gdb) FAIL: $exp: target_type_1=native: target_type_2=native: \
  continue to function2
...

The situation is as follows:
- there are two inferiors
- due to "set schedule-multiple on", continue continues both inferiors
- after the first continue, the test-case expects the breakpoint on thread 3.1
  to trigger
- instead, the breakpoint in thread 2.1 triggers

The mechanism by which this order is supposed to be guaranteed, is that thread
2.1 is blocked, and only unblocked after thread 3.1 hits its breakpoint:
...
    # Unblock thread 2.1 and continue again.  This time, thread 2.1
    # will hit a breakpoint.
    gdb_test "thread apply 2.1 set wait_for_gdb = 0" ".*"
...

However, thread 2.1 is never blocked.

Fix this by adding the missing:
...
    gdb_test "thread apply 2.1 set wait_for_gdb = 1" ".*"
...

Tested on x86_64-linux.

Approved-by: Kevin Buettner <kevinb@redhat.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33540

5 weeks agoAutomatic date update in version.in
GDB Administrator [Sat, 10 Jan 2026 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 weeks agogdb/coffread: simplify stab section detection
Simon Marchi [Fri, 9 Jan 2026 19:41:24 +0000 (14:41 -0500)] 
gdb/coffread: simplify stab section detection

We look for stab sections for the sole purpose of emitting a warning if
we see one.  Simplify this by using a boolean to indicate if we saw a
stab section or not.  Simplify the search to just look for sections
starting with ".stab", it should be enough for this purpose.

Also, remove the make_scoped_restore that would overwrite the stab
section vector, I'm not sure why it's there.  It seems to me like it
would cause the warning to never be shown.

Change-Id: I56323189ffdaa2d06a96d457cdd999b23efa5979
Approved-By: Tom Tromey <tom@tromey.com>
5 weeks agogdb: update shared libraries when inferior is created, even if no bfd exists
Sébastien Darche [Tue, 30 Sep 2025 18:54:30 +0000 (14:54 -0400)] 
gdb: update shared libraries when inferior is created, even if no bfd exists

I noticed an unexpected behaviour difference when loading a core file
in GDB depending on whether the main executable can be accessed or not.
If GDB knows about the main executable, then symbols for unrelated
libraries (such as libc) are loaded. If GDB cannot find the main
executable, then they are not.

Here is a reproducer using the artifacts from
gdb.python/py-missing-objfile.exp.  This test is ideal to reproduce the
problem, because it hides from GDB the executable and library used to
generate the core file.

In the "good" case, where we give an executable to GDB (in addition to
the core), we get a complete backtrace (assuming GDB can find debug symbols
for glibc):

    $ ./gdb -nx -q --data-directory=data-directory testsuite/outputs/gdb.python/py-missing-objfile/hidden/py-missing-objfile  -c testsuite/outputs/gdb.python/py-missing-objfile/py-missing-objfile.core -ex bt -batch
    ...
    #0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
    #1  0x00007fcbd0c98a13 in __pthread_kill_internal (threadid=<optimized out>, signo=6) at pthread_kill.c:89
    #2  0x00007fcbd0c3e410 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
    #3  0x00007fcbd0c2557a in __GI_abort () at abort.c:77
    #4  0x000055561659d152 in dump_core () at /home/sdarche/binutils-gdb/gdb/testsuite/gdb.python/py-missing-objfile.c:34
    #5  0x000055561659d182 in main () at /home/sdarche/binutils-gdb/gdb/testsuite/gdb.python/py-missing-objfile.c:46

Or, if debug symbols for glibc aren't available, GDB at least tells us
from which .so each frame comes from:

    #0  0x00007fcbd0c9894c in ?? () from /usr/lib/libc.so.6
    #1  0x00007fcbd0c3e410 in raise () from /usr/lib/libc.so.6
    #2  0x00007fcbd0c2557a in abort () from /usr/lib/libc.so.6
    #3  0x000055561659d152 in dump_core () at /home/sdarche/binutils-gdb/gdb/testsuite/gdb.python/py-missing-objfile.c:34
    #4  0x000055561659d182 in main () at /home/sdarche/binutils-gdb/gdb/testsuite/gdb.python/py-missing-objfile.c:46

If we omit passing the main executable to GDB (and GDB has no way to
find it, because the test moved it on purpose), we get:

    $ ./gdb -nx -q --data-directory=data-directory -c testsuite/outputs/gdb.python/py-missing-objfile/py-missing-objfile.core -ex bt -batch
    #0  0x00007fcbd0c9894c in ?? ()
    #1  0x0000000000000000 in ?? ()

Upon investigating, the "normal" path to load associated sos is through
the post_create_inferior function in infcmd.c, which calls
solib_create_inferior_hook.  The solib_ops in turn loads the symbols by
calling solib_add.

When loading a core file, the list of loaded shared libraries can be
found (and as we can see with `info sharedlibraries`, this is done
properly).  However, the current control flow handling in
post_create_inferior does not ask the solib to load the symbols through
solib_create_inferior_hook if a main exec_bfd is not present.

The proposed change eliminates the if statement in the
post_create_inferior function.

This change may have side-effects on some solib_ops which may not check
if the current inferior has a valid exec_bfd().

This commit also modifies the gdb.python/py-missing-objfile.exp test,
providing a test case in which the main exec file is missing, but not
the shared library.  This is a good way to confirm this fix works, as
the symbols from the shared library should be found even though the main
exec file is missing.  The test cases also ask GDB to clean_restart to
ensure there is no leftover bfd or symbols.

Furthermore, the total number of calls to the missing objfiles handler
is 4 in the "all objfiles missing" test case instead of the
previous 3 :
- 2 for the mapped files (exec and so), in
  core_target_build_file_mappings
- 1 for the core file exec, in locate_exec_from_corefile_build_id
- 1 for the missing so, in solib_map_sections

The changes in check_loaded_debug handle the case where no symbol exist
at all, and also when a symbol table exists (but the symbol cannot be
found)

Note: Some comments in some solib_ops (frv, dbst) seem to indicate that
solib_add should be called before solib_create_inferior_hook by
post_create_inferior, but this does not seem to be the case anymore.
Those comments might need to be updated.

Change-Id: I517ff85813c941215b19fa8540c77f755a0aca28
Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Tested-By: Guinevere Larsen <guinevere@redhat.com>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
5 weeks agogdb/solib-svr4: update solib when an inferior is not being executed (e.g. core files)
Sébastien Darche [Tue, 30 Sep 2025 18:54:29 +0000 (14:54 -0400)] 
gdb/solib-svr4: update solib when an inferior is not being executed (e.g. core files)

Loading a core file currently generates a warning when enabling `set
verbose on`:

    $ ./gdb -nx -q --data-directory=data-directory a.out -ex "set verbose on" -ex "core core.151894" -batch
    ...
    warning: platform-specific solib_create_inferior_hook did not load initial shared libraries.

The warning comes from infcmd.c:post_create_inferior() which initializes
the solib_ops.  The latter is in charge of calling solib_add() in its
implementation of solib_ops::create_inferior_hook.  The svr4_solib_ops
class, however, does not call solib_add (through enable_break) if the
inferior is not being executed.

This patch moves the call to solib_add() outside of the conditional
nested call.  No user-visible change should be expected, except for fact
that the warning will no longer be shown.

Change-Id: I5488dc166fdc985669422a0f1c0c2f43158cd8c4
Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
5 weeks agogdb/testsuite: fix typo in gdb.python/py-missing-objfile.exp
Sébastien Darche [Tue, 30 Sep 2025 18:54:28 +0000 (14:54 -0400)] 
gdb/testsuite: fix typo in gdb.python/py-missing-objfile.exp

The py-missing-objfile.exp test attempts to load a core file with
missing debug info and counts the number of times a python missing
objfile handler is called.

In one test case, the number of expected calls to the missing objfile
handler is two, but the test case misleadingly says three. This commit
fixes this typo.

Change-Id: I421143ebed392227f14918ea529eb0e9cbd98dda
Approved-By: Simon Marchi <simon.marchi@efficios.com>
5 weeks agogdb/coffread: remove unused fields of coff_symfile_info
Simon Marchi [Fri, 9 Jan 2026 19:14:36 +0000 (14:14 -0500)] 
gdb/coffread: remove unused fields of coff_symfile_info

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