ROSE  0.11.83.1
Public Types | Public Attributes | List of all members
Rose::BinaryAnalysis::Variables::StackFrame Struct Reference

Description

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 387 of file Variables.h.

#include <Rose/BinaryAnalysis/Variables.h>

Collaboration diagram for Rose::BinaryAnalysis::Variables::StackFrame:
Collaboration graph
[legend]

Public Types

enum  Direction {
  GROWS_UP,
  GROWS_DOWN
}
 

Public Attributes

Direction growthDirection = GROWS_DOWN
 Direction that the stack grows when pushing a new frame. More...
 
RegisterDescriptor framePointerRegister
 Optional descriptor for register pointing to latest frame. More...
 
Sawyer::Optional< int64_t > maxOffset
 Maximum frame offset w.r.t. More...
 
Sawyer::Optional< int64_t > minOffset
 Minimum frame offset w.r.t. More...
 
Sawyer::Optional< uint64_t > size
 Size of the frame in bytes if known. More...
 
std::string rule
 Informal rule name used to detect frame characteristics. More...
 

Member Enumeration Documentation

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 388 of file Variables.h.

Member Data Documentation

Direction Rose::BinaryAnalysis::Variables::StackFrame::growthDirection = GROWS_DOWN

Direction that the stack grows when pushing a new frame.

Definition at line 393 of file Variables.h.

RegisterDescriptor Rose::BinaryAnalysis::Variables::StackFrame::framePointerRegister

Optional descriptor for register pointing to latest frame.

Definition at line 394 of file Variables.h.

Sawyer::Optional<int64_t> Rose::BinaryAnalysis::Variables::StackFrame::maxOffset

Maximum frame offset w.r.t.

frame pointer.

Definition at line 395 of file Variables.h.

Sawyer::Optional<int64_t> Rose::BinaryAnalysis::Variables::StackFrame::minOffset

Minimum frame offset w.r.t.

frame pointer.

Definition at line 396 of file Variables.h.

Sawyer::Optional<uint64_t> Rose::BinaryAnalysis::Variables::StackFrame::size

Size of the frame in bytes if known.

Definition at line 397 of file Variables.h.

std::string Rose::BinaryAnalysis::Variables::StackFrame::rule

Informal rule name used to detect frame characteristics.

Definition at line 398 of file Variables.h.


The documentation for this struct was generated from the following file: