s390: sframe: gas: Represent .cfi_def_cfa[_register] for non-SP/FP reg. using FLEX_TOPMOST_FRAME

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
This commit is contained in:
Jens Remus
2025-12-12 16:03:33 +01:00
parent af833d1163
commit b4e5e9e670
8 changed files with 59 additions and 40 deletions

View File

@@ -1259,15 +1259,15 @@ sframe_xlate_do_def_cfa (struct sframe_xlate_ctx *xlate_ctx,
SFrame V3 specification, if the CFA register is not FP/SP, SFrame FDE type
SFRAME_FDE_TYPE_FLEX_TOPMOST_FRAME type may be used.
ATM however, GAS implements non-SP/FP based CFA only for AMD64, where such
a CFA pattern may be seen (e.g., DRAP, stack alignment). On s390x, this
may be seen for (GCC) generated code for static stack clash protection.
This remains sufficiently rare and is currently unimplemented for s390x.
*/
ATM however, GAS implements non-SP/FP based CFA only for:
- AMD64, where such a CFA pattern may be seen (e.g., DRAP, stack alignment).
- s390x, where this may be seen for (GCC) generated code for static stack
clash protection. */
if (cfi_insn->u.ri.reg != SFRAME_CFA_SP_REG
&& cfi_insn->u.ri.reg != SFRAME_CFA_FP_REG)
{
if (sframe_get_abi_arch () != SFRAME_ABI_AMD64_ENDIAN_LITTLE
if ((sframe_get_abi_arch () != SFRAME_ABI_AMD64_ENDIAN_LITTLE
&& sframe_get_abi_arch () != SFRAME_ABI_S390X_ENDIAN_BIG)
|| !sframe_fre_reg_encodable_p (cfi_insn->u.ri.reg))
{
as_warn (_("no SFrame FDE emitted; "
@@ -1305,7 +1305,8 @@ sframe_xlate_do_def_cfa_register (struct sframe_xlate_ctx *xlate_ctx,
if (cfi_insn->u.r != SFRAME_CFA_SP_REG
&& cfi_insn->u.r != SFRAME_CFA_FP_REG)
{
if (sframe_get_abi_arch () != SFRAME_ABI_AMD64_ENDIAN_LITTLE)
if (sframe_get_abi_arch () != SFRAME_ABI_AMD64_ENDIAN_LITTLE
&& sframe_get_abi_arch () != SFRAME_ABI_S390X_ENDIAN_BIG)
{
as_warn (_("no SFrame FDE emitted; "
"non-SP/FP register %u in .cfi_def_cfa_register"),
@@ -1314,7 +1315,7 @@ sframe_xlate_do_def_cfa_register (struct sframe_xlate_ctx *xlate_ctx,
}
else
/* Currently, SFRAME_FDE_TYPE_FLEX_TOPMOST_FRAME is generated for AMD64
only. */
and s390x only. */
xlate_ctx->flex_topmost_p = true;
}

View File

@@ -1,15 +0,0 @@
#name: SFrame generation on s390x - .cfi_def_cfa_register with non-SP/FP register
#as: --gsframe
#warning: non-SP/FP register 10 in \.cfi_def_cfa_register
#objdump: --sframe=.sframe
#...
Contents of the SFrame section .sframe:
Header :
Version: SFRAME_VERSION_3
Flags: SFRAME_F_FDE_FUNC_START_PCREL
Num FDEs: 0
Num FREs: 0
#pass

View File

@@ -1,15 +0,0 @@
#name: SFrame generation on s390x - .cfi_def_cfa with non-SP/FP register
#as: --gsframe
#warning: non-SP/FP register 10 in \.cfi_def_cfa
#objdump: --sframe=.sframe
#...
Contents of the SFrame section .sframe:
Header :
Version: SFRAME_VERSION_3
Flags: SFRAME_F_FDE_FUNC_START_PCREL
Num FDEs: 0
Num FREs: 0
#pass

View File

@@ -0,0 +1,24 @@
#name: SFrame generation on s390x - .cfi_def_cfa_register with non-SP/FP register
#as: --gsframe
#objdump: --sframe=.sframe
#...
Contents of the SFrame section .sframe:
Header :
Version: SFRAME_VERSION_3
Flags: SFRAME_F_FDE_FUNC_START_PCREL
Num FDEs: 1
Num FREs: 6
Function Index :
func idx \[0\]: pc = 0x0, size = 40 bytes
STARTPC +CFA +FP +RA +
0+0000 +sp\+160 +u +u +
0+0006 +sp\+160 +c\-72 +c\-48 +
0+000c +sp\+320 +c\-72 +c\-48 +
0+0010 +r10\+320 +c\-72 +c\-48 +
0+001c +sp\+160 +u +u +
0+001e +r10\+320 +c\-72 +c\-48 +
#pass

View File

@@ -0,0 +1,24 @@
#name: SFrame generation on s390x - .cfi_def_cfa with non-SP/FP register
#as: --gsframe
#objdump: --sframe=.sframe
#...
Contents of the SFrame section .sframe:
Header :
Version: SFRAME_VERSION_3
Flags: SFRAME_F_FDE_FUNC_START_PCREL
Num FDEs: 1
Num FREs: 6
Function Index :
func idx \[0\]: pc = 0x0, size = 40 bytes
STARTPC +CFA +FP +RA +
0+0000 +sp\+160 +u +u +
0+0006 +sp\+160 +c\-72 +c\-48 +
0+000c +sp\+320 +c\-72 +c\-48 +
0+0010 +r10\+320 +c\-72 +c\-48 +
0+001c +sp\+160 +u +u +
0+001e +r10\+320 +c\-72 +c\-48 +
#pass

View File

@@ -93,12 +93,12 @@ if { [istarget "s390x*-*-*"] && [gas_sframe_check] } then {
run_dump_test "cfi-sframe-s390x-1"
run_dump_test "cfi-sframe-s390x-2"
run_dump_test "cfi-sframe-s390x-3"
run_dump_test "cfi-sframe-s390x-err-1"
run_dump_test "cfi-sframe-s390x-err-2"
run_dump_test "cfi-sframe-s390x-err-3"
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-ra-undefined-1"
run_dump_test "cfi-sframe-s390x-non-spfp-cfa-1"
run_dump_test "cfi-sframe-s390x-non-spfp-cfa-2"
}