[binutils-gdb] s390: gas: sframe: do not reject .cfi_register REG_SP, REG
Indu Bhagat
ibhagat@sourceware.org
Fri Jan 16 01:06:18 GMT 2026
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c4b575f3b54a0a88778f3da034a5790892c8ed8e
commit c4b575f3b54a0a88778f3da034a5790892c8ed8e
Author: Jens Remus <jremus@linux.ibm.com>
Date: Thu Jan 15 16:44:12 2026 -0800
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.
Diff:
---
gas/gen-sframe.c | 3 ++-
gas/testsuite/gas/cfi-sframe/cfi-sframe-s390x-err-4.s | 5 -----
...i-sframe-s390x-err-4.d => cfi-sframe-s390x-sp-register.d} | 12 +++++++++---
gas/testsuite/gas/cfi-sframe/cfi-sframe-s390x-sp-register.s | 11 +++++++++++
gas/testsuite/gas/cfi-sframe/cfi-sframe.exp | 2 +-
5 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c
index 931c14c4b02..0241d4424b6 100644
--- a/gas/gen-sframe.c
+++ b/gas/gen-sframe.c
@@ -1536,7 +1536,8 @@ sframe_xlate_do_register (struct sframe_xlate_ctx *xlate_ctx,
if (cfi_insn->u.rr.reg1 == SFRAME_CFA_RA_REG
/* SFrame does not track SP explicitly. */
- || cfi_insn->u.rr.reg1 == SFRAME_CFA_SP_REG
+ || (cfi_insn->u.rr.reg1 == SFRAME_CFA_SP_REG
+ && sframe_get_abi_arch () != SFRAME_ABI_S390X_ENDIAN_BIG)
|| cfi_insn->u.rr.reg1 == SFRAME_CFA_FP_REG)
{
as_warn (_("no SFrame FDE emitted; %s register %u in .cfi_register"),
diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe-s390x-err-4.s b/gas/testsuite/gas/cfi-sframe/cfi-sframe-s390x-err-4.s
deleted file mode 100644
index 7c0bedab9f2..00000000000
--- a/gas/testsuite/gas/cfi-sframe/cfi-sframe-s390x-err-4.s
+++ /dev/null
@@ -1,5 +0,0 @@
- .cfi_sections .sframe
- .cfi_startproc
- .cfi_register r15, r5
- br %r7
- .cfi_endproc
diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe-s390x-err-4.d b/gas/testsuite/gas/cfi-sframe/cfi-sframe-s390x-sp-register.d
similarity index 53%
rename from gas/testsuite/gas/cfi-sframe/cfi-sframe-s390x-err-4.d
rename to gas/testsuite/gas/cfi-sframe/cfi-sframe-s390x-sp-register.d
index 1703d817ea9..5203f6dc653 100644
--- a/gas/testsuite/gas/cfi-sframe/cfi-sframe-s390x-err-4.d
+++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe-s390x-sp-register.d
@@ -1,6 +1,5 @@
#name: SFrame generation on s390x - .cfi_register with SP
#as: --gsframe
-#warning: SP register 15 in \.cfi\_register
#objdump: --sframe=.sframe
#...
Contents of the SFrame section .sframe:
@@ -9,7 +8,14 @@ Contents of the SFrame section .sframe:
Version: SFRAME_VERSION_3
Flags: SFRAME_F_FDE_FUNC_START_PCREL
- Num FDEs: 0
- Num FREs: 0
+ Num FDEs: 1
+ Num FREs: 3
+ Function Index :
+
+ func idx \[0\]: pc = 0x0, size = 16 bytes
+ STARTPC +CFA +FP +RA +
+ 0+0000 +sp\+160 +u +u +
+ 0+000a +sp\+320 +u +u +
+ 0+000e +sp\+160 +u +u +
#pass
diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe-s390x-sp-register.s b/gas/testsuite/gas/cfi-sframe/cfi-sframe-s390x-sp-register.s
new file mode 100644
index 00000000000..223588faca7
--- /dev/null
+++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe-s390x-sp-register.s
@@ -0,0 +1,11 @@
+ .cfi_sections .sframe
+ .cfi_startproc
+ ldgr %f1,%r15
+ .cfi_register r15, f1
+ lay %r15,-160(%r15)
+ .cfi_adjust_cfa_offset 160
+ lgdr %r15,%f1
+ .cfi_restore r15
+ .cfi_adjust_cfa_offset -160
+ br %r14
+ .cfi_endproc
diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe.exp b/gas/testsuite/gas/cfi-sframe/cfi-sframe.exp
index 3f246d2da24..2e0942657ae 100644
--- a/gas/testsuite/gas/cfi-sframe/cfi-sframe.exp
+++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe.exp
@@ -100,11 +100,11 @@ if { [istarget "s390x*-*-*"] && [gas_sframe_check] } then {
run_dump_test "cfi-sframe-s390x-2"
run_dump_test "cfi-sframe-s390x-3"
run_dump_test "cfi-sframe-s390x-err-3"
- run_dump_test "cfi-sframe-s390x-err-4"
run_dump_test "cfi-sframe-s390x-fpra-offset-1"
run_dump_test "cfi-sframe-s390x-fpra-offset-2"
run_dump_test "cfi-sframe-s390x-fpra-register-1"
run_dump_test "cfi-sframe-s390x-fpra-register-2"
+ run_dump_test "cfi-sframe-s390x-sp-register"
run_dump_test "cfi-sframe-s390x-ra-undefined-1"
run_dump_test "cfi-sframe-s390x-pr33756"
run_dump_test "cfi-sframe-s390x-non-spfp-cfa-1"
More information about the Binutils-cvs
mailing list