gas: sframe: Error on open CFI at EOF; missing .cfi_endproc
Checks
| Context |
Check |
Description |
| linaro-tcwg-bot/tcwg_binutils_build--master-arm |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 |
success
|
Test passed
|
| linaro-tcwg-bot/tcwg_binutils_check--master-arm |
success
|
Test passed
|
Commit Message
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>
---
Notes (jremus):
Note regarding test:
While the assembler can be forced to output an object using option -Z
I could not find how to get the test to run objdump --sframe on the
resulting object and check the output. A successful #error pattern
match seems to cause the test to pass immediately without performing
any remaining steps (e.g. #objdump).
Alternatives:
- The check could be performed cfi_finish() in gas/dw2gencfi.c to
keep all of the now three places this error is emitted closely
together, but that would add another iteration over all DWARF FDEs.
- The now three places that check and emit this error could be
consolidated into one, but that would require an additional
iteration over all DWARF FDEs and possibly duplication of the
conditions when they are processed.
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(+)
create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-common-pr34026.d
create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-common-pr34026.s
Comments
On Mon, Apr 13, 2026 at 04:42:25PM +0200, Jens Remus wrote:
> 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>
I was leaving this for Indu to approve, but since that hasn't happened
I'll approve it.
> ---
>
> Notes (jremus):
> Note regarding test:
> While the assembler can be forced to output an object using option -Z
> I could not find how to get the test to run objdump --sframe on the
> resulting object and check the output. A successful #error pattern
> match seems to cause the test to pass immediately without performing
> any remaining steps (e.g. #objdump).
>
> Alternatives:
> - The check could be performed cfi_finish() in gas/dw2gencfi.c to
> keep all of the now three places this error is emitted closely
> together, but that would add another iteration over all DWARF FDEs.
> - The now three places that check and emit this error could be
> consolidated into one, but that would require an additional
> iteration over all DWARF FDEs and possibly duplication of the
> conditions when they are processed.
>
> 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(+)
> create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-common-pr34026.d
> create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-common-pr34026.s
>
> diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c
> index 7c1b7be93bb3..b5c8f649beac 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 000000000000..ee613c1246de
> --- /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 (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 000000000000..df692dbcd989
> --- /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 a73e5c84033e..ba6cbc13f72a 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
> --
> 2.51.0
On 4/30/2026 9:07 AM, Alan Modra wrote:
> On Mon, Apr 13, 2026 at 04:42:25PM +0200, Jens Remus wrote:
>> 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>
>
> I was leaving this for Indu to approve, but since that hasn't happened
> I'll approve it.
Thanks! Committed to mainline. Note that I took the freedom to improve
the added test name:
>> diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-pr34026.d b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-pr34026.d
>> +#as: --gsframe
>> +#error: open CFI at the end of file; missing \.cfi_endproc directive
>> +#name: Open CFI (PR 34026)
#name: Open CFI at end of file (PR 34026)
Regards,
Jens
@@ -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))
new file mode 100644
@@ -0,0 +1,3 @@
+#as: --gsframe
+#error: open CFI at the end of file; missing \.cfi_endproc directive
+#name: Open CFI (PR 34026)
new file mode 100644
@@ -0,0 +1 @@
+ .cfi_startproc
@@ -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