[binutils-gdb] gas: sframe: Error on open CFI at EOF; missing .cfi_endproc
Jens Remus
jremus@sourceware.org
Thu Apr 30 10:18:53 GMT 2026
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=bc145a24033381e93bae0ee24add664386c66433
commit bc145a24033381e93bae0ee24add664386c66433
Author: Jens Remus <jremus@linux.ibm.com>
Date: Thu Apr 30 12:18:05 2026 +0200
gas: sframe: Error on open CFI at EOF; missing .cfi_endproc
Open CFI at end of file (i.e. .cfi_startproc without matching
.cfi_endproc) caused generation of SFrame strack trace information
to segfault.
Handle an open DWARF FDE in .sframe generation like it is handled
in .eh_frame and .debug_frame generation (see cfi_finish() in
gas/dw2gencfi.c). Report the following error and set the DWARF FDE
end address to its start address:
open CFI at the end of file; missing .cfi_endproc directive
gas/
PR/gas 34026
* gen-sframe.c (create_sframe_all): Error on open CFI.
gas/testsuite/
PR/gas 34026
* gas/cfi-sframe/cfi-sframe.exp: Run new test.
* gas/cfi-sframe/cfi-sframe-common-pr34026.d: New test.
* gas/cfi-sframe/cfi-sframe-common-pr34026.s: Likewise.
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Diff:
---
gas/gen-sframe.c | 8 ++++++++
gas/testsuite/gas/cfi-sframe/cfi-sframe-common-pr34026.d | 3 +++
gas/testsuite/gas/cfi-sframe/cfi-sframe-common-pr34026.s | 1 +
gas/testsuite/gas/cfi-sframe/cfi-sframe.exp | 1 +
4 files changed, 13 insertions(+)
diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c
index 7c1b7be93bb..b5c8f649bea 100644
--- a/gas/gen-sframe.c
+++ b/gas/gen-sframe.c
@@ -2478,6 +2478,14 @@ create_sframe_all (void)
/* Initialize the translation context with information anew. */
sframe_xlate_ctx_init (xlate_ctx);
+ /* Report and fix open CFI. */
+ if (dw_fde->end_address == NULL)
+ {
+ as_bad (_("open CFI at the end of file; "
+ "missing .cfi_endproc directive"));
+ dw_fde->end_address = dw_fde->start_address;
+ }
+
/* Process and link SFrame FDEs if no error. */
int err = sframe_do_fde (xlate_ctx, dw_fde);
if (err && get_dw_fde_signal_p (dw_fde))
diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-pr34026.d b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-pr34026.d
new file mode 100644
index 00000000000..a944e074404
--- /dev/null
+++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-pr34026.d
@@ -0,0 +1,3 @@
+#as: --gsframe
+#error: open CFI at the end of file; missing \.cfi_endproc directive
+#name: Open CFI at end of file (PR 34026)
diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-pr34026.s b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-pr34026.s
new file mode 100644
index 00000000000..df692dbcd98
--- /dev/null
+++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-pr34026.s
@@ -0,0 +1 @@
+ .cfi_startproc
diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe.exp b/gas/testsuite/gas/cfi-sframe/cfi-sframe.exp
index a73e5c84033..ba6cbc13f72 100644
--- a/gas/testsuite/gas/cfi-sframe/cfi-sframe.exp
+++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe.exp
@@ -55,6 +55,7 @@ if { ([istarget "x86_64-*-*"] || [istarget "aarch64*-*-*"]
run_dump_test "common-empty-3"
run_dump_test "cfi-sframe-common-pr33810"
+ run_dump_test "cfi-sframe-common-pr34026"
}
# x86-64 specific tests
More information about the Binutils-cvs
mailing list