Commit Graph

124922 Commits

Author SHA1 Message Date
GDB Administrator
9dbb9f9379 Automatic date update in version.in 2026-01-18 00:00:07 +00:00
H.J. Lu
6b5d9284fc gas: Update PR gas/33744 tests
Since .set directive doesn't work on alpha and hpux has a non-standard
common directive, skip the relevant tests on alpha and hpux.  Also allow
2, 4, 8 byte section alignment for 1-byte section since some targets
have a minimum section alignment.

	PR gas/33744
	* testsuite/gas/elf/sh-link-abs-1.d: Skip alpha and allow 1, 2,
	4, 8 byte section alignment.
	* 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-common-1.d: Skip hpux and allow 1,
	2, 4, 8 byte section alignment.
	* 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

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2026-01-18 07:36:47 +08:00
Simon Marchi
adc60fd9ec gdb/i386: remove i386_dbx_reg_to_regnum
Following the removal of gdbarch_sdb_reg_to_regnum,
i386_dbx_reg_to_regnum is only used by i386_svr4_dwarf_reg_to_regnum to
handle SSE and MMX registers.  Remove it and inline the relevant bits in
i386_svr4_dwarf_reg_to_regnum.

Change-Id: Id74fad6ef6798c4cd061905f1c01eadd90e0a118
Approved-By: Andrew Burgess <aburgess@redhat.com>
2026-01-17 09:58:41 -05:00
Simon Marchi
e894e456f0 gdb: remove gdbarch_sdb_reg_to_regnum
Following the removal of the COFF debug info support,
gdbarch_sdb_reg_to_regnum is no longer used, remove it.

Change-Id: I2cb43465f1fdf74863edfa4dd00fd5f28a5a26bd
Approved-By: Andrew Burgess <aburgess@redhat.com>
2026-01-17 09:58:38 -05:00
Simon Marchi
56ae4fea45 gdb: remove stale comments about COFF / stabs
These comments appear to be stale and no longer relevant.

Change-Id: I3470969b0c0f38d809fe074ffab93ac91202de18
Approved-By: Andrew Burgess <aburgess@redhat.com>
2026-01-17 09:57:23 -05:00
Tom de Vries
8fa65585b7 [gdb/tdep] Fix gdb.base/siginfo.exp on s390x-linux
On s390x-linux (SLES 15 SP5), I'm running into:
...
FAIL: gdb.base/siginfo.exp: backtrace for nexti (pattern 2)
FAIL: gdb.base/siginfo.exp: step out of handler
...

The first FAIL is caused by a failure to unwind:
...
 (gdb) bt^M
 #0  handler (sig=26, info=0x3ffffffe428, context=0x3ffffffe4a8) at \
   gdb.base/siginfo.c:31^M
 Backtrace stopped: Cannot access memory at address 0x1a00000088^M
 (gdb)
...

In contrast, on x86_64-linux I get instead:
...
 (gdb) bt^M
 #0  handler (sig=26, info=0x7fffffffc170, context=0x7fffffffc040) at \
   gdb.base/siginfo.c:31^M
 #1  <signal handler called>^M
 #2  0x0000000000401201 in main () at gdb.base/siginfo.c:67^M
 (gdb)
...

The memory access error is triggered here in s390_sigtramp_frame_unwind_cache:
...
  /* Restore the previous frame's SP.  */
  prev_sp = read_memory_unsigned_integer (
			info->saved_regs[S390_SP_REGNUM].addr (),
                        word_size, byte_order);
...
while trying to read an "Old-style RT frame" (for syscall sigreturn).

The problem is that we actually have a "New-style RT frame" (for syscall
rt_sigreturn).

[ See linux kernel source file arch/s390/kernel/signal.c for a detailed
explanation of the two. ]

The choice between the two is made earlier in that same function:
...
  /* New-style RT frame:
	retcode + alignment (8 bytes)
	siginfo (128 bytes)
	ucontext (contains sigregs at offset 5 words).  */
  if (next_ra == next_cfa)
    {
      ...
    }

  /* Old-style RT frame and all non-RT frames:
	old signal mask (8 bytes)
	pointer to sigregs.  */
  else
...

I'm not sure why the check gives the wrong result, but I noticed that
s390_sigtramp_frame_sniffer is able to distinguish between the two, so fix
this by:
- factoring out new function s390_sigtramp_p out of
  s390_sigtramp_frame_sniffer, and
- using s390_sigtramp_p in s390_sigtramp_frame_unwind_cache to distinguish
  between the "Old-style RT frame" and "New-style RT frame".

This fixes the backtrace.

The second failure is:
...
(gdb) step^M
32      } /* handler */^M
1: x/i $pc^M
=> 0x1000772 <handler+50>:      nopr^M
(gdb) step^M
0x000003fffdffe490 in __kernel_rt_sigreturn ()^M
1: x/i $pc^M
=> 0x3fffdffe490 <__kernel_rt_sigreturn>:       svc     173^M
(gdb) FAIL: gdb.base/siginfo.exp: step out of handler
...

There is some code in process_event_stop_test that is supposed to trigger:
...
  if (ecs->event_thread->control.step_range_end != 1
      && (ecs->event_thread->control.step_over_calls == STEP_OVER_UNDEBUGGABLE
	  || ecs->event_thread->control.step_over_calls == STEP_OVER_ALL)
      && get_frame_type (frame) == SIGTRAMP_FRAME)
    {
      infrun_debug_printf ("stepped into signal trampoline");
      /* The inferior, while doing a "step" or "next", has ended up in
	 a signal trampoline (either by a signal being delivered or by
	 the signal handler returning).  Just single-step until the
	 inferior leaves the trampoline (either by calling the handler
	 or returning).  */
      keep_going (ecs);
      return;
    }
...
but it doesn't because frame is a NORMAL_FRAME instead of a SIGTRAMP_FRAME.

This is caused by the "dwarf2" unwinder triggering, which has higher priority
than the "s390 linux sigtramp" unwinder:
...
(gdb) maint info frame-unwinders
Name                        Type                      Class     Enabled
dummy                       DUMMY_FRAME               GDB       Y
dwarf2 tailcall             TAILCALL_FRAME            DEBUGINFO Y
inline                      INLINE_FRAME              GDB       Y
jit                         NORMAL_FRAME              EXTENSION Y
python                      NORMAL_FRAME              EXTENSION Y
dwarf2                      NORMAL_FRAME              DEBUGINFO Y
dwarf2 signal               SIGTRAMP_FRAME            DEBUGINFO Y
s390 linux sigtramp         SIGTRAMP_FRAME            ARCH      Y
s390 stub                   NORMAL_FRAME              ARCH      Y
s390 prologue               NORMAL_FRAME              ARCH      Y
...

I found some code in dwarf2_frame_sniffer:
...
  /* On some targets, signal trampolines may have unwind information.
     We need to recognize them so that we set the frame type
     correctly.  */

  if (fde->cie->signal_frame
      || dwarf2_frame_signal_frame_p (get_frame_arch (this_frame),
				      this_frame))
    return self->type () == SIGTRAMP_FRAME;
...
and an example implementation i386_linux_dwarf_signal_frame_p, and after
copying this approach, indeed the stepping failure was fixed, but the
backtrace broken again.

Instead, fix this by giving the "s390 linux sigtramp" unwinder a higher
priority:
...
(gdb) maint info frame-unwinders
Name                        Type                      Class     Enabled
dummy                       DUMMY_FRAME               GDB       Y
dwarf2 tailcall             TAILCALL_FRAME            DEBUGINFO Y
inline                      INLINE_FRAME              GDB       Y
jit                         NORMAL_FRAME              EXTENSION Y
python                      NORMAL_FRAME              EXTENSION Y
s390 linux sigtramp         SIGTRAMP_FRAME            ARCH      Y
dwarf2                      NORMAL_FRAME              DEBUGINFO Y
dwarf2 signal               SIGTRAMP_FRAME            DEBUGINFO Y
s390 stub                   NORMAL_FRAME              ARCH      Y
s390 prologue               NORMAL_FRAME              ARCH      Y
...

Also fixes test-case gdb.base/sigaltstack.exp and gdb.base/sigbpt.exp.

Tested on s390x-linux.

Reviewed-By: Keith Seitz <keiths@redhat.com>

PR tdep/33708
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33708
2026-01-17 08:44:57 +01:00
Alan Modra
ec2ec78ce0 fix new arm and aarch64 gas test failures
aarch64-pe  +FAIL: gas/aarch64/fix-adj
arm-pe  +FAIL: MVE vmlas instructions
arm-wince-pe  +FAIL: MVE vmlas instructions

These new tests use ELF directives.

	* testsuite/gas/aarch64/fix-adj.d: Only run on ELF targets.
	* testsuite/gas/arm/mve-vmlas.d: Likewise.
2026-01-17 12:54:18 +10:30
Alan Modra
e6357caf75 ld: put wild matching_sections on an obstack
so that the memory can be reclaimed easily when reset_resolved_wilds
throws it all away.

	* ldlang.c (matching_obstack): New static var.
	(add_matching_section): Rewrite to use matching_obstack.
	(lang_init): Init matching_obstack.
	(reset_resolved_wilds): Free matching_obstack.
2026-01-17 11:50:02 +10:30
Alan Modra
1522f86f18 Make some ldlang functions inline
These are small, and making them inline lets me call
lang_statement_append without adding a forward declaration in the
next patch.

	* ldlang.c (lang_for_each_statement, lang_list_init),
	(lang_statement_append): Move to..
	* ldlang.h: ..here making them inline functions.
	(bfd_input_just_syms): Group with other inlines.
2026-01-17 11:50:02 +10:30
GDB Administrator
5afa3ba8c4 Automatic date update in version.in 2026-01-17 00:00:07 +00:00
Richard Ball
7ae2329129 aarch64: Add support for FEAT_MTETC
This patch adds two new DC operations:

   *gbva
   *zgbva
2026-01-16 22:16:48 +00:00
Richard Ball
fcdde313c9 aarch64: Add FEAT_SCR2 System registers
This patch adds the system register "SCR2_EL3"
Defined by FEAT_SCR2.
2026-01-16 22:15:45 +00:00
Simon Marchi
342e858099 gdb/hppa: replace bfd_map_over_sections with gdb_bfd_sections
Replace bfd_map_over_sections with iteration over gdb_bfd_sections.

Change-Id: I92ba6b5ef9e9ab3d2ebe364373aeaf459fd6e34c
Approved-By: Tom Tromey <tom@tromey.com>
2026-01-16 15:46:36 -05:00
Simon Marchi
697db8cba8 gdb/windows: replace bfd_map_over_sections with gdb_bfd_sections
Replace bfd_map_over_sections with iteration over gdb_bfd_sections.
Change core_process_module_section's signature to take a cpms_data
reference instead of a void pointer.

Change-Id: Ic4f9a12c9c1479799ec87658fd88490106b61836
Approved-By: Tom Tromey <tom@tromey.com>
2026-01-16 15:46:36 -05:00
Simon Marchi
17b8c1dddc gdb/compile: replace bfd_map_over_sections with gdb_bfd_sections
Replace bfd_map_over_sections with iteration over gdb_bfd_sections.
Rename copy_sections to copy_section and change its signature to take
explicit parameters instead of the callback-style void pointer.

Change-Id: I30f1c3c051415722f2220b7fba48103101b640e8
Approved-By: Tom Tromey <tom@tromey.com>
2026-01-16 15:46:36 -05:00
Simon Marchi
39c65b019c gdb/mips-sde: replace bfd_map_over_sections with gdb_bfd_sections
Replace bfd_map_over_sections with iteration over gdb_bfd_sections.

Change-Id: If2e1141f2e9345fe50e2a63ce8f8682e82a60f21
Approved-By: Tom Tromey <tom@tromey.com>
2026-01-16 15:46:36 -05:00
Simon Marchi
dce2433aea gdb/mips: replace bfd_map_over_sections with gdb_bfd_sections (2)
Replace bfd_map_over_sections with iteration over gdb_bfd_sections.

Change-Id: I34182a67ee52da479c1868a5880709c401cbf34e
Approved-By: Tom Tromey <tom@tromey.com>
2026-01-16 15:46:36 -05:00
Simon Marchi
6c7c9ad764 gdb/mips: replace bfd_map_over_sections with gdb_bfd_sections (1)
Replace bfd_map_over_sections with iteration over gdb_bfd_sections.

Change-Id: Ib236b364dc81f43cab8d27271d413eb61d6c703e
Approved-By: Tom Tromey <tom@tromey.com>
2026-01-16 15:46:36 -05:00
Tom de Vries
0965cd5b25 [gdb] Handle AT_HWCAP3/AT_HWCAP4 in default_print_auxv_entry
On aarch64-linux, I run into:
...
(gdb) info auxv^M
  ...
26   AT_HWCAP2            Extension of AT_HWCAP          0x181^M
29   ???                                                 0x0^M
31   AT_EXECFN            File name of executable        0xffffffffffb9 ...
  ...
28   AT_RSEQ_ALIGN        rseq allocation alignment      32^M
0    AT_NULL              End of vector                  0x0^M
(gdb) WARNING: Unrecognized tag value: 29 ... ??? ... 0x0^M
FAIL: gdb.base/auxv.exp: info auxv on live process
...

Fix this by handling AT_HWCAP3 in default_print_auxv_entry.  Likewise for
AT_HWCAP4.

Tested on aarch64-linux.

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

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32590
2026-01-16 20:14:51 +01:00
Tom de Vries
0c90306549 [include] Add AT_HWCAP3/AT_HWCAP4 in elf/common.h
Since glibc 2.39, containing commit 3ab9b88 ("powerpc: Add HWCAP3/HWCAP4 data
to TCB for Power Architecture."), glibc's elf/elf.h contains constants
AT_HWCAP3/AT_HWCAP4.

Add these in elf/common.h.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2026-01-16 20:14:51 +01:00
Maximilian Bosch
dac8058441 gdb/testsuite: add testcase for .debug_gdb_scripts being compressed
This is a test-case to make sure that
8eb1701823
("gdb: fix loading compressed scripts from `.debug_gdb_scripts`-section")
doesn't regress.

The test was mostly implemented by Tom Tromey, with the exception of the
check to make sure that the sections are actually compressed and
corrected compiler flags (-Wl,--compress-debug-sections=zlib-gabi was
missing).

This is an individual patch since the actual fix already landed in the
repository.

Approved-By: Tom Tromey <tom@tromey.com>
2026-01-16 12:13:47 -07:00
Simon Marchi
03375540de gdb/buildsym: patch_subfile_names
This doesn't seem used anymore.

Change-Id: I39e04f1f05fee3c6f7747923d5c1c2feef1fa315
Approved-By: Tom Tromey <tom@tromey.com>
2026-01-16 12:35:20 -05:00
Simon Marchi
bed351f20f gdb/buildsym: remove get_last_source_start_addr/set_last_source_start_addr methods
Nothing seems to use this anymore.  However, the private field is still
used internally by buildsym, so keep it.

Change-Id: Ie6fbd96110a3c5603359a483855bbecc4008e5b4
Approved-By: Tom Tromey <tom@tromey.com>
2026-01-16 12:34:46 -05:00
Simon Marchi
becf559f73 gdb/buildsym: remove m_last_source_file
Nothing seems to use this anymore.

Change-Id: I6a767f2251ce9e683c231708466899a3e9ff4cb1
Approved-By: Tom Tromey <tom@tromey.com>
2026-01-16 12:33:30 -05:00
Simon Marchi
7c9cc0adcd gdb: remove buildsym-legacy
With the removal of the COFF debug info support, nothing uses
buildsym-legacy anymore, remove it.

Change-Id: I46612509889b6868f5889a4347ad8d0a28d29127
Approved-By: Tom Tromey <tom@tromey.com>
2026-01-16 12:18:45 -05:00
Simon Marchi
1837ca7053 gdb/coffread: remove debug info support
This patch removes support for reading in the COFF debug info.

I am not a specialist of the COFF format, but my understanding is that
debug info in the COFF format consisted of extra symbol table entries
describing the standard symbol table entries.  For instance, when
compiling without debug info, a function would get a simple symbol
entry, akin to an ELF symbol.  We would create a minimal symbol out of
that.  When compiling with debug info, that symbol table entry would be
followed by special additional entries, describing things like
parameters and local variables (what would now be in DWARF).  We would
create some full symbols out of that.

This patch removes everything that reads this extra information, on the
basis that any target still used today would not use it anymore, having
switched to DWARF instead.  We still read the standard symbol table
entries and create minimal symbols out of that.  This can be seen when
loading a Windows executable (the only COFF executable kind I know how
to produce):

    $ ./gdb -nx -q --data-directory=data-directory -ex "set debug symtab-create 2" -ex "file a.exe"
    ...
    [symtab-create] record_full: recording minsym:  mst_file_bss                  0x140008018     6  argv
    [symtab-create] record_full: recording minsym:  mst_file_bss                  0x140008008     6  managedapp
    [symtab-create] record_full: recording minsym:  mst_text                      0x1400013e0     0  WinMainCRTStartup
    [symtab-create] record_full: recording minsym:  mst_text                      0x140001400     0  mainCRTStartup
    [symtab-create] record_full: recording minsym:  mst_text                      0x140001420     0  atexit
    [symtab-create] record_full: recording minsym:  mst_file_data                 0x140005000     3  __EH_FRAME_BEGIN__
    [symtab-create] record_full: recording minsym:  mst_file_bss                  0x140008060     6  obj
    ...
    [symtab-create] install: installing 299 minimal symbols of objfile /home/smarchi/src/binutils-gdb/gdb/a.exe

I did not and can't easily test more than that.  At least, the remaining
code is understandable enough that I think we would be able to fix any
bug that comes up.

This change should not alter the debugging experience on Windows.

For more info on the COFF symbol table format:

  https://www.delorie.com/djgpp/doc/coff/symtab.html

Change-Id: I83220589b8e5b242a4ac42a842e504a4aa47aada
Approved-By: Tom Tromey <tom@tromey.com>
2026-01-16 12:18:45 -05:00
Simon Marchi
5e880e6a0a gdb/coffread: replace bfd_map_over_sections with iteration
Replace two uses of bfd_map_over_sections with an iteration over
gdb_bfd_sections.

Re-use cs_to_bfd_section in cs_section_address to simplify it.

Change-Id: I2b8f70cc1deba151b7b286affe78a43ac1a26375
Approved-By: Tom Tromey <tom@tromey.com>
2026-01-16 12:18:44 -05:00
Tom Tromey
c02564ad42 Use make_unique_xstrdup in tracepoint
This changes the tracepoint code to use make_unique_xstrdup (and
make_unique_xstrndup).  This meant changing the types of some members
of uploaded_tp -- but it seems to me that using array types there did
not add any value.

Approved-By: Andrew Burgess <aburgess@redhat.com>
2026-01-16 07:44:33 -07:00
Tom Tromey
4f148246ca Use make_unique_xstrdup in more places
This replaces a number of uses of 'ptr.reset (xstrdup ())'
with 'ptr = make_unique_xstrdup ()'.

The main motivation for this is that, IMO, it's better to avoid the
reset method when possible.

Approved-By: Andrew Burgess <aburgess@redhat.com>
2026-01-16 07:44:32 -07:00
Richard Ball
19ffb6d2d7 aarch64: Add support for FEAT_CMH
This patch adds the new instructions from FEAT_CMH
These new instructions are hints, STCPH and SHUH.
SHUH can have an operand PH or no operand.
2026-01-16 12:35:41 +00:00
Richard Ball
542ed77ff7 arm: Fix MVE vmlas encoding
Continuation of fix to VMLA

Bit 12 of the first halfword in the VMLAS instruction is listed as (0)
in the ARMARM (document DDI0553B.w, version ID07072023).
This means that the instruction does not discriminate between signed
and unsigned types and processing elements do not use the bit.
The encoding used by gas was based on an older version
of the document that made the sign important.
This change makes it possible to use vmlas.i8 (16,32) in addition to
vmlas.u8 and vmlas.s8 mnemonics, with the i8, i16 and i32 aliases becoming
the default when disassembling.
The generated encoding sets bit 12 to 0, compatibly with other
assembler implementations.
2026-01-16 12:19:11 +00:00
Richard Ball
d8e004f124 aarch64: Add support for MLBI system instructions
This patch adds support for MLB invalidate (MLBI) instruction.

Syntax: MLBI <mlbi_op>{, <Xt>}

This instruction is an alias to "SYS #4, C7, C0, #<op2>{, <Xt>}"
and MLBI being the preferred disassembly.

The following list of MLBI operations are supported in this patch for the
MLBI instructions enabled by "+mpamv2"

   * alle1
   * vmalle1
   * vpide1
   * vpmge1
2026-01-16 12:16:17 +00:00
Richard Ball
5fc6b09c07 aarch64: Add FEAT_MPAMv2_VID system registers
This patch adds the system registers defined by
FEAT_MPAMv2_VID. These registers are:

   *mpamvidcr_el2
   *mpamvidsr_el2
   *mpamvidsr_el3
2026-01-16 12:16:03 +00:00
Ezra Sitorus
c810cfe842 aarch64: Add FEAT_MPAMv2 system registers 2026-01-16 10:23:07 +00:00
Jens Remus
c4b575f3b5 s390: gas: sframe: do not reject .cfi_register REG_SP, REG
On s390 64-bit (s390x) compilers may save the SP, FP, and RA registers,
which are of interest in SFrame, in other registers, such as floating-
point registers, for instance when in a leaf function.

SFrame does not explicitly track the SP.  Instead SFrame relies on the
architecture-specific CFA definition to recover the SP.  The s390x ELF
ABI [1] defines the CFA as SP at call site + 160, which results in the
implicit SP recovery rule SP = CFA - 160.

Assuming that CFI on s390 64-bit (s390x) adheres to the CFA definition,
it is safe to ignore any CFI directives, that specify the SP register at
entry to be saved either on the stack or in another register, as the SP
can then always be recovered using the implicit SP recovery rule.

[1]: s390x ELF ABI, https://github.com/IBM/s390x-abi/releases

Committed-by: Indu Bhagat <indu.bhagat@oracle.com>

gas/
	* gen-sframe.c (sframe_xlate_do_register): Ignore .cfi_register SP
	on s390x.

gas/testsuite/
	* gas/cfi-sframe/cfi-sframe.exp (cfi-sframe-s390x-err-4): Rename
	test to cfi-sframe-s390x-sp-register.
	* gas/cfi-sframe/cfi-sframe-s390x-err-4.d: Rename to ...
	* gas/cfi-sframe/cfi-sframe-s390x-err-4.s: Likewise.
	* gas/cfi-sframe/cfi-sframe-s390x-sp-register.d: This.  Test
	that .cfi_register SP is ignored.
	* gas/cfi-sframe/cfi-sframe-s390x-sp-register.s: Likewise.  Add
	minimal assembler sample.
2026-01-15 17:02:28 -08:00
Indu Bhagat
55575b6058 [SFrame-V3] libsframe: testsuite: add new testcases for SFRAME_FDE_TYPE_FLEX
This patch adds two new tests for SFrame V3 changes, focusing on the
newly added flexible FDE TYPE SFRAME_FDE_TYPE_FLEX.

Following tests are added:
  - be-flipping-v3.c: Validates that big-endian SFrame V3 data is
    correctly endian flipped when run on little-endian hosts.  It
    verifies the decoding of CFA offsets and the new V3 register/offset
    metadata bitfields using the SFRAME_V3_FLEX_FDE_OFFSET_REG_* macros.
  - findfre-flex-1.c: Tests a variety of sframe_find_fre lookup
    scenarios, apart from checking the basic encoder/decoder APIs.

Documentation for the binary test data DATA-BE-V3 is provided in
README-be-flipping-v3 to ensure reproducibility.

libsframe/
	* Makefile.in: Regenerate.
	* testsuite/libsframe.decode/DATA-BE-V3: New test data.
	* testsuite/libsframe.decode/README-be-flipping-v3: New file.
	* testsuite/libsframe.decode/be-flipping-v3.c: New test.
	* testsuite/libsframe.decode/decode.exp: Run be-flipping-v3.
	* testsuite/libsframe.decode/local.mk: Add be-flipping-v3.
	* testsuite/libsframe.find/find.exp: Run findfre-flex-1.
	* testsuite/libsframe.find/findfre-flex-1.c: New test.
	* testsuite/libsframe.find/local.mk: Add findfre-flex-1.
2026-01-15 17:02:28 -08:00
Indu Bhagat
c1929fda66 [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.
2026-01-15 17:02:28 -08:00
Indu Bhagat
4553b29a0e [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.
2026-01-15 17:02:28 -08:00
Indu Bhagat
2a99ed6340 [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.
2026-01-15 17:02:27 -08:00
Indu Bhagat
530d779e2b [SFrame-V3] gas: binutils: ld: NEWS: add SFrame v3 related announcements
Add NEWS entries related to the SFrame version 3 release.
2026-01-15 17:02:27 -08:00
Indu Bhagat
c7c86abf8c [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.
2026-01-15 17:02:27 -08:00
Indu Bhagat
832ca9ef67 [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.
2026-01-15 17:02:27 -08:00
Indu Bhagat
dc49e2f284 [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.
2026-01-15 17:02:27 -08:00
Indu Bhagat
8ab6e4c72a [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.
2026-01-15 17:02:27 -08:00
Indu Bhagat
9d1500135a [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.
2026-01-15 17:02:26 -08:00
Indu Bhagat
77a0bf4928 [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.
2026-01-15 17:02:26 -08:00
Indu Bhagat
72cd17f0be [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.
2026-01-15 17:02:26 -08:00
Indu Bhagat
7e11620c67 [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.
2026-01-15 17:02:26 -08:00
Indu Bhagat
3b409a1504 [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.
2026-01-15 17:02:26 -08:00
Indu Bhagat
bedf3b4b0e [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.
2026-01-15 17:02:26 -08:00