Re: [PATCH 1/2] gas: sframe: Fix non-SP/FP CFA base register if flexible FDE
Indu Bhagat <[email protected]>
| Newsgroups | gmane.comp.gnu.binutils |
|---|---|
| Message-ID | <[email protected]> |
On 2026-07-29 09:34, Jens Remus wrote: > If a target supports SFrame V3 flexible FDE, a non-SP/FP CFA base > register can be represented. Do not warn and skip generating FDE, if > .cfi_def_cfa_offset with a non-SP/FP register in effect, if target > supports flexible FDE. > > gas/ > * gen-sframe.c (sframe_xlate_do_def_cfa_offset): Allow non-SP/FP > CFA base register if flexible FDE. > > gas/testsuite/ > * gas/cfi-sframe/common-empty-2.d: Skip test on targets that > support SFrame V3 flexible FDE. > > Signed-off-by: Jens Remus <[email protected]> > --- > > Notes (jremus): > Why does sframe_xlate_do_def_cfa_offset care about the CFA base > register at all? With SFrame V3 it could test cur_cfa_reg for > SFRAME_FRE_REG_INVALID. But wouldn't the following be valid DWARF CFI: > > .cfi_startproc simple > .cfi_def_cfa_offset 0 > .cfi_def_cfa_register <SP> > ... > .cfi_endproc > > to express the same as: > > .cfi_startproc simple > .cfi_def_cfa <SP>, 0 > ... > .cfi_endproc > In theory yes, but SFrame code enforces a presence of DW_CFA_def_cfa_register (or others as applicable to basically setup the CFA register) to apply the following specified in the DWARF standard: For the DW_CFA_def_cfa_offset, it says: "This operation is valid only if the current CFA rule is defined to use a register and offset." > gas/gen-sframe.c | 3 ++- > gas/testsuite/gas/cfi-sframe/common-empty-2.d | 1 + > 2 files changed, 3 insertions(+), 1 deletion(-) > > diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c > index b5c8f649beac..f0576869579a 100644 > --- a/gas/gen-sframe.c > +++ b/gas/gen-sframe.c > @@ -1360,7 +1360,8 @@ sframe_xlate_do_def_cfa_offset (struct sframe_xlate_ctx *xlate_ctx, > /* 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, > 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_CFA_FP_REG || cur_cfa_reg == SFRAME_CFA_SP_REG > + || sframe_support_flex_fde_p ()) > { > if (sframe_fre_stack_offset_bound_p (cfi_insn->u.i, true)) > { > diff --git a/gas/testsuite/gas/cfi-sframe/common-empty-2.d b/gas/testsuite/gas/cfi-sframe/common-empty-2.d > index c80ea50c75f9..ce13d5ef055a 100644 > --- a/gas/testsuite/gas/cfi-sframe/common-empty-2.d > +++ b/gas/testsuite/gas/cfi-sframe/common-empty-2.d > @@ -2,6 +2,7 @@ > #warning: \.cfi_def_cfa_offset without CFA base register in effect > #objdump: --sframe=.sframe > #name: SFrame supports only FP/SP based CFA > +#notarget: s390x-*-* x86_64-*-* > #... > Contents of the SFrame section .sframe: >