]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gas: sframe: Error on open CFI at EOF; missing .cfi_endproc
authorJens Remus <jremus@linux.ibm.com>
Thu, 30 Apr 2026 10:18:05 +0000 (12:18 +0200)
committerJens Remus <jremus@linux.ibm.com>
Thu, 30 Apr 2026 10:18:05 +0000 (12:18 +0200)
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>
gas/gen-sframe.c
gas/testsuite/gas/cfi-sframe/cfi-sframe-common-pr34026.d [new file with mode: 0644]
gas/testsuite/gas/cfi-sframe/cfi-sframe-common-pr34026.s [new file with mode: 0644]
gas/testsuite/gas/cfi-sframe/cfi-sframe.exp

index 7c1b7be93bb3434a93cc128430c3aabe153c214a..b5c8f649beac0ef246ddcfd5816f2e6480da1661 100644 (file)
@@ -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 (file)
index 0000000..a944e07
--- /dev/null
@@ -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 (file)
index 0000000..df692db
--- /dev/null
@@ -0,0 +1 @@
+       .cfi_startproc
index a73e5c84033ea7e51406af3cdbd8472512842789..ba6cbc13f72ae44085c612987b3148c016bcb8be 100644 (file)
@@ -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