]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gas: sframe: Fix non-SP/FP CFA base register if flexible FDE
authorJens Remus <jremus@linux.ibm.com>
Wed, 12 Aug 2026 12:39:50 +0000 (14:39 +0200)
committerJens Remus <jremus@linux.ibm.com>
Wed, 12 Aug 2026 12:39:50 +0000 (14:39 +0200)
.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 <jremus@linux.ibm.com>
gas/gen-sframe.c

index 7b8c2f2f20e3626134135b4098bde9b7433192e2..031421d8ab7c461fc0c4123e5d8e20c197c1c19e 100644 (file)
@@ -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;
 }