]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gas: sframe: ignore .cfi_offset for RA selectively
authorIndu Bhagat <indu.bhagat@oracle.com>
Tue, 23 Dec 2025 22:59:09 +0000 (14:59 -0800)
committerIndu Bhagat <indu.bhagat@oracle.com>
Tue, 23 Dec 2025 22:59:09 +0000 (14:59 -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.

Reviewed-by: Jens Remus <jremus@linux.ibm.com>
gas/
* gen-sframe.c (sframe_xlate_do_offset): Do not ignore
.cfi_offset for RA all the time.

gas/gen-sframe.c

index 5b1b1ba23ea8ac7420a3eb61dc562c6df23d2f7e..61afd36f10507f15efd04617b3a073bb8af300be 100644 (file)
@@ -1185,8 +1185,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.  */