ROSE 0.11.145.192
|
Information about a stack frame.
A stack frame is a contiguous area of the stack with one frame for each function in a call chain. As functions are called and return, frames are pushed onto and popped from the stack. Typically, when a frame is pushed onto the stack, a pointer is also added so that the frames form a linked list from most recent function call to the oldest function call.
Typically, a dedicated register points to the most recent frame. E.g., for x86 this is usually the bp/ebp/rbp register. Sometimes there is no dedicated frame pointer register (such as when x86 is compiled with GCC/LLVM -fomit-frame-pointer). In these cases, the compiler keeps track of the frame address and when needed, emits code that finds the frame based on the current value of the stack pointer register (which can change throughout a function's execution). The frame pointer (explicit or calculated) defines the zero offset for the frame. The frame itself extends in positive and/or negative directions from this anchor point.
The frame pointer register can point to any position within the frame. For instance, x86 rbp register points to the top of the frame, whereas PowerPC's r31 register points to the bottom. Likewise, the pointers forming the linked list can point to any position within the frame. These pointer offsets into the frame are known by the compiler, which adds/subtracts the appropriate constant to access the desired bytes in the frame.
A stack containing the frames can grow (when frames are pushed) in a positive or negative direction.
A function can access areas of the stack that are outside its own frame. For instance, x86 function stack arguments are stored in the caller's frame. Pointers to local variables can point into earlier frames. The latest function can use parts of the stack that are after the latest frame and which therefore out outside any frame.
Definition at line 35 of file StackFrame.h.
#include <Rose/BinaryAnalysis/Variables/StackFrame.h>
Public Types | |
enum | Direction { GROWS_UP , GROWS_DOWN } |
Public Attributes | |
Direction | growthDirection = GROWS_DOWN |
Direction that the stack grows when pushing a new frame. | |
Sawyer::Optional< int64_t > | maxOffset |
Maximum frame offset w.r.t. | |
Sawyer::Optional< int64_t > | minOffset |
Minimum frame offset w.r.t. | |
Sawyer::Optional< uint64_t > | size |
Size of the frame in bytes if known. | |
std::string | rule |
Informal rule name used to detect frame characteristics. | |
Enumerator | |
---|---|
GROWS_UP | New frames are added at higher addresses than old frames. |
GROWS_DOWN | New frames are added at lower addresses than old frames. |
Definition at line 37 of file StackFrame.h.
Direction Rose::BinaryAnalysis::Variables::StackFrame::growthDirection = GROWS_DOWN |
Direction that the stack grows when pushing a new frame.
Definition at line 42 of file StackFrame.h.
Sawyer::Optional<int64_t> Rose::BinaryAnalysis::Variables::StackFrame::maxOffset |
Maximum frame offset w.r.t.
function's initial stack pointer.
Definition at line 43 of file StackFrame.h.
Sawyer::Optional<int64_t> Rose::BinaryAnalysis::Variables::StackFrame::minOffset |
Minimum frame offset w.r.t.
function's initial stack pointer.
Definition at line 44 of file StackFrame.h.
Sawyer::Optional<uint64_t> Rose::BinaryAnalysis::Variables::StackFrame::size |
Size of the frame in bytes if known.
Definition at line 45 of file StackFrame.h.
std::string Rose::BinaryAnalysis::Variables::StackFrame::rule |
Informal rule name used to detect frame characteristics.
Definition at line 46 of file StackFrame.h.