]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
s390: gas: sframe: do not reject .cfi_register REG_SP, REG
authorJens Remus <jremus@linux.ibm.com>
Fri, 16 Jan 2026 00:44:12 +0000 (16:44 -0800)
committerIndu Bhagat <indu.bhagat@oracle.com>
Fri, 16 Jan 2026 01:02:28 +0000 (17:02 -0800)
commitc4b575f3b54a0a88778f3da034a5790892c8ed8e
tree4e8cf88cc2f53031cc2863dc7b9ec97437ebe57d
parent55575b6058fc228609e9a56c7860976f3e02b0ee
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.
gas/gen-sframe.c
gas/testsuite/gas/cfi-sframe/cfi-sframe-s390x-err-4.s [deleted file]
gas/testsuite/gas/cfi-sframe/cfi-sframe-s390x-sp-register.d [moved from gas/testsuite/gas/cfi-sframe/cfi-sframe-s390x-err-4.d with 53% similarity]
gas/testsuite/gas/cfi-sframe/cfi-sframe-s390x-sp-register.s [new file with mode: 0644]
gas/testsuite/gas/cfi-sframe/cfi-sframe.exp