Creating assembler source with CFI support
In this section:
The recommended way to create an assembler language routine that handles call frame information correctly is to start with an assembler language source file created by the compiler.
Start with suitable C source code, for example:
int F(int);int cfiExample(int i){return i + F(i);}Compile the C source code, and make sure to create a list file that contains call frame information—the CFI directives.
Danger
On the command line, use the option
-lA.Caution
In the IDE, choose Project>Options>C/C++ Compiler>List and make sure the suboption Include call frame information is selected.
For the source code in this example, the list file in 32-bit mode looks like this.
NAME Cfi RTMODEL "__SystemLibrary", "DLib" EXTERN FPUBLIC cfiExample CFI Names cfiNames0 CFI StackFrame CFA R13 DATA CFI Resource R0:32, R1:32, R2:32, R3:32, R4:32, R5:32, R6:32, R7:32 CFI Resource R8:32, R9:32, R10:32, R11:32, R12:32, R13:32, R14:32 CFI EndNames cfiNames0CFI Common cfiCommon0 Using cfiNames0 CFI CodeAlign 4 CFI DataAlign 4 CFI ReturnAddress R14 CODE CFI CFA R13+0 CFI R0 Undefined CFI R1 Undefined CFI R2 Undefined CFI R3 Undefined CFI R4 SameValue CFI R5 SameValue CFI R6 SameValue CFI R7 SameValue CFI R8 SameValue CFI R9 SameValue CFI R10 SameValue CFI R11 SameValue CFI R12 Undefined CFI R14 SameValue CFI EndCommon cfiCommon0SECTION `.text`:CODE:NOROOT(2) CFI Block cfiBlock0 Using cfiCommon0 CFI Function cfiExample ARMcfiExample: PUSH {R4,LR} CFI R14 Frame(CFA, -4) CFI R4 Frame(CFA, -8) CFI CFA R13+8 MOVS R4,R0 MOVS R0,R4 BL F ADDS R0,R0,R4 POP {R4,PC} ;; return CFI EndBlock cfiBlock0 END