From: Jens Remus Date: Wed, 12 Aug 2026 12:39:50 +0000 (+0200) Subject: gas: sframe: Fix non-SP/FP CFA base register if flexible FDE X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=87027fd2372d79a3f44605efdeba8a4d7c41093a;p=thirdparty%2Fbinutils-gdb.git gas: sframe: Fix non-SP/FP CFA base register if flexible FDE .cfi_def_cfa_offset modifies the current CFA rule to use the provided offset but keep the current CFA base register. It therefore requires a CFA base register to be in effect. Relax the check to simply test for whether a CFA base register is in effect instead of restricting it to SP/FP. The latter is checked when the CFA base register is modified. This enables .cfi_def_cfa_offset with non-SP/FP CFA base register for targets that support SFrame flexible FDE. While at it simplify the logic to test for error cases first. gas/ * gen-sframe.c (sframe_xlate_do_def_cfa_offset): Allow non-SP/FP CFA base register if flexible FDE. Signed-off-by: Jens Remus --- diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c index 7b8c2f2f20e..031421d8ab7 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -1362,31 +1362,23 @@ sframe_xlate_do_def_cfa_offset (struct sframe_xlate_ctx *xlate_ctx, gas_assert (cur_fre); /* Define the current CFA rule to use the provided offset (but to keep - the old register). However, if the old register is not FP/SP, + the old register). However, if the old register is invalid, skip creating SFrame stack trace info for the function. */ - if (cur_cfa_reg == SFRAME_CFA_FP_REG || cur_cfa_reg == SFRAME_CFA_SP_REG) + if (cur_cfa_reg == SFRAME_FRE_REG_INVALID) { - if (sframe_fre_stack_offset_bound_p (cfi_insn->u.i, true)) - { - sframe_fre_set_cfa_offset (cur_fre, cfi_insn->u.i); - cur_fre->merge_candidate = false; - } - else - { - as_warn (_("no SFrame FDE emitted; " - ".cfi_def_cfa_offset with unsupported offset value")); - return SFRAME_XLATE_ERR_NOTREPRESENTED; - } + as_warn (_("no SFrame FDE emitted; " + ".cfi_def_cfa_offset without CFA base register in effect")); + return SFRAME_XLATE_ERR_NOTREPRESENTED; } - else + + if (!sframe_fre_stack_offset_bound_p (cfi_insn->u.i, true)) { - /* No CFA base register in effect. Non-SP/FP CFA base register should - not occur, as sframe_xlate_do_def_cfa[_register] would detect this. */ as_warn (_("no SFrame FDE emitted; " - ".cfi_def_cfa_offset without CFA base register in effect")); + ".cfi_def_cfa_offset with unsupported offset value")); return SFRAME_XLATE_ERR_NOTREPRESENTED; } + sframe_fre_set_cfa_offset (cur_fre, cfi_insn->u.i); return SFRAME_XLATE_OK; }