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.
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"),
+++ /dev/null
- .cfi_sections .sframe
- .cfi_startproc
- .cfi_register r15, r5
- br %r7
- .cfi_endproc
#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:
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
--- /dev/null
+ .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
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"