]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gas: sframe: ignore .cfi_offset for RA selectively
authorIndu Bhagat <indu.bhagat@oracle.com>
Fri, 14 Nov 2025 18:15:15 +0000 (10:15 -0800)
committerIndu Bhagat <indu.bhagat@oracle.com>
Tue, 9 Dec 2025 08:26:11 +0000 (00:26 -0800)
For ABIs not tracking RA (e.g., AMD64), the return address is expected
to be in a specific location (usually a fixed offset from CFA on stack).
Explicit manourvering to a different offset may be non-representable in
SFrame, and should not be simply ignored.

Although such patterns are not usually seen in the wild, it is more
correct to catch them if at all they manifest.

gas/
        * gen-sframe.c (sframe_xlate_do_offset): Do not ignore
.cfi_offset for RA all the time.

gas/gen-sframe.c

index eead58b00f66351833675c98cad76c4ae338afc4..f39b4f495b4d69533e4a201489fb8a023942284d 100644 (file)
@@ -1179,8 +1179,19 @@ sframe_xlate_do_offset (struct sframe_xlate_ctx *xlate_ctx,
      being interpreted.  This FRE eventually gets linked in into the
      list of FREs for the specific function.  */
   struct sframe_row_entry *cur_fre = xlate_ctx->cur_fre;
-
   gas_assert (cur_fre);
+
+  /* For ABIs not tracking RA, the return address is expected to be in a
+     specific location.  Explicit manourvering to a different offset (than the
+     default offset) is non-representable in SFrame.  */
+  if (!sframe_ra_tracking_p () && cfi_insn->u.ri.reg == SFRAME_CFA_RA_REG
+      && cfi_insn->u.ri.offset != sframe_cfa_ra_offset ())
+    {
+      as_warn (_("no SFrame FDE emitted; %s register %u in .cfi_offset"),
+              sframe_register_name (cfi_insn->u.ri.reg), cfi_insn->u.ri.reg);
+      return SFRAME_XLATE_ERR_NOTREPRESENTED;  /* Not represented.  */
+    }
+
   /* Change the rule for the register indicated by the register number to
      be the specified offset.  */
   /* Ignore SP reg, as it can be recovered from the CFA tracking info.  */