Is there a simple DWARF CFI clause for functions that set a regular frame pointer?

I program in a combination of C, C ++ and assembly, and I would like to get reliable return paths from any part of the code.

This basically works fine for C and C ++ code, since I can generate debugging information using -g, which for modern x86 compilers and generates DWARF- debugging information, which means that the final binary includes CFI (frame frame information) . This information allows you to go back though functions in the current call stack. It can support complex scripts, such as functions without a base pointer, and where it rspchanges dynamically. For C and C ++ code, I care: the compiler simply generates the correct CFI, even for optimized code.

For the x86 build code I am writing in nasm, the CFI issue is the issue. Both nasm and yasm syntax-compliant competition have some limited support for generating DWARF information, but basically it includes an instruction to display strings and does not include any CFI 1 (indeed, an assembly cannot really do this, even if this is because the assembly is too low to express the semantics of the call / return).

I would like to add CFI for the generated procedure assemblies, but I do not need the full CFI flexibility to define CFAs based on the -g commands related to raster changes in rsp, etc .: I am very happy to set up a standard pointer view in rbpfor each assembly function and leave it intact for the entire function. Does DWARF3 support this scenario with a simple bit of CFI information, hopefully the one I can create with an assembler macro?


1 The experimental version of "rage" "nextgen" has support for CFI directives, but this project has not been updated after 5 years. There is an open problem with porting this support back to the main version of yasm.

+5

Source: https://habr.com/ru/post/1688431/


All Articles