Gas: sframe: Error on open CFI at EOF; missing .cfi_endproc
A patch to prevent segfaults in gas when an open CFI is encountered at EOF has been approved.
Alan Modra approved a patch from Jens Remus that prevents the assembler (gas) from segfaulting when it encounters an open CFI (Call Frame Information) at the end of a file, meaning a .cfi_startproc directive is present without a corresponding .cfi_endproc. The patch handles this situation similarly to how it’s handled in .eh_frame and .debug_frame generation, by reporting an error and setting the DWARF FDE end address to its start address.
- maintainer
Approved the patch to prevent segfaults when an open CFI is encountered at EOF.
- proposer
Original patch submitter
In Details
This patch addresses a bug in the GNU assembler (gas) related to handling CFI (Call Frame Information) when generating .sframe sections. CFI is used for stack unwinding during debugging or exception handling. The patch ensures that a missing .cfi_endproc at the end of the file doesn't cause a segfault, aligning the behavior with .eh_frame and .debug_frame handling.
For Context
The GNU assembler (gas) translates assembly language code into machine code. Call Frame Information (CFI) is metadata that describes the layout of the stack, which is essential for debugging and handling exceptions. This patch fixes a bug where the assembler would crash if a function's CFI was started but not ended at the end of the assembly file. The fix ensures a graceful error message instead of a crash, and provides more robust assembly processing.