| |||
| Home > ARM Procedure Call Standard > APCS definition > The stack backtrace data structure | |||
For chunked stacks, the value in fp must be zero or must point to a list of stack backtrace data structures that describe the sequence of outstanding function calls. If this constraint holds when external functions are called, the program is conforming. If it holds at all instants of execution, the program is strictly conforming.
The stack backtrace data structure shows between four and 27 words, with those words higher on the page being at higher addresses in memory. The values shown in brackets are optional, and their presence need not imply the presence of any other. The floating-point values are stored in an internal format, and occupy three words each. Figure 9.1 shows the stack backtrace structure.
Figure 9.1. Stack backtrace structure
save code pointer [fp, #0] <-fp points to here
return link value [fp, #-4]
return sp value [fp, #-8]
return fp value [fp, #-12]
{saved v7 value}
{saved v6 value}
{saved v5 value}
{saved v4 value}
{saved v3 value}
{saved v2 value}
{saved v1 value}
{saved a4 value}
{saved a3 value}
{saved a2 value}
{saved a1 value}
{saved f7 value} three words
{saved f6 value} three words
{saved f5 value} three words
{saved f4 value} three words
The save code pointer (the value of pc) is the value of the pc at the instruction that starts to create the stack backtrace structure. Typically this is a store multiple instruction of the form:
STMFD sp!, {optional_registers,old_fp,sp,lr,pc}
The save code pointer (the value of pc) allows the function corresponding to a stack backtrace structure to be located.
Table 9.3 shows the registers to which the values in the stack backtrace structure are restored on function exit.