https://sourceware.org/bugzilla/show_bug.cgi?id=34758
Bug ID: 34758
Summary: gas: internal error in sframe_xlate_do_restore_state
on .cfi_restore_state without .cfi_remember_state
Product: binutils
Version: 2.48 (HEAD)
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: gas
Assignee: unassigned at sourceware dot org
Reporter: martin.mirchev at u dot nus.edu
Target Milestone: ---
With SFrame generation enabled, an unmatched .cfi_restore_state is first
diagnosed by the CFI parser, but the instruction still reaches the SFrame
translator, where gas_assert (xlate_ctx->remember_fre) fails:
$ cat rs.s
.text
.globl f
f:
.cfi_startproc
push %rbp
.cfi_def_cfa_offset 16
.cfi_restore_state
pop %rbp
ret
.cfi_endproc
$ as --64 rs.s -o rs.o
rs.s: Assembler messages:
rs.s:7: Error: CFI state restore without previous remember
$ as --64 --gsframe=yes rs.s -o rs.o
rs.s: Assembler messages:
rs.s:7: Error: CFI state restore without previous remember
rs.s: Internal error in int sframe_xlate_do_restore_state(struct
sframe_xlate_ctx *) at gen-sframe.c:1585.
Please report this bug.
sframe_xlate_do_remember_state() already handles the opposite case by
warning and returning SFRAME_XLATE_ERR_INVAL (no SFrame FDE for the
function). Suggested fix doing the same for restore:
--- a/gas/gen-sframe.c
+++ b/gas/gen-sframe.c
@@ -1578,7 +1578,14 @@
list of FREs for the specific function. */
struct sframe_row_entry *cur_fre = xlate_ctx->cur_fre;
- gas_assert (xlate_ctx->remember_fre);
+ /* An unmatched .cfi_restore_state has already been diagnosed by the CFI
+ parser. */
+ if (!xlate_ctx->remember_fre)
+ {
+ as_warn (_("no SFrame FDE emitted; "
+ ".cfi_restore_state without prior .cfi_remember_state"));
+ return SFRAME_XLATE_ERR_INVAL;
+ }
gas_assert (cur_fre && cur_fre->merge_candidate);
/* Get the CFA state from the DW_CFA_remember_state insn. */
With it, the example reports the CFI error plus "Warning: no SFrame FDE
emitted; .cfi_restore_state without prior .cfi_remember_state" and no
internal error; a function with a matched remember/restore pair assembles
to a byte-identical object.
Possibly related, but a different trigger: bug 34026.
Seen with binutils 2.47; the same assertion is present on current master.
This issue was found by an LLM-Enhanced Static Analysis Engine and verified
manually.
--
You are receiving this mail because:
You are on the CC list for the bug.