Documentation
¶
Overview ¶
Package stacksize tries to determine the call graph for ELF binaries and tries to parse stack size information from DWARF call frame information.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CallGraph ¶
CallGraph parses the ELF file and reads DWARF call frame information to determine frame sizes for each function, as far as that's possible. Because at this point it is not possible to determine indirect calls, a list of indirect function calling functions needs to be supplied separately.
This function does not attempt to determine the stack size for functions. This is done by calling StackSize on a function in the call graph.
Types ¶
type CallNode ¶
type CallNode struct { Names []string Address uint64 // address at which the function is linked (without T bit on ARM) Size uint64 // symbol size, in bytes Children []*CallNode // functions this function calls FrameSize uint64 // frame size, if FrameSizeType is Bounded FrameSizeType SizeType // can be Undefined or Bounded // contains filtered or unexported fields }
CallNode is a node in the call graph (that is, a function). Because this is determined after linking, there may be multiple names for a single function (due to aliases). It is also possible multiple functions have the same name (but are in fact different), for example for static functions in C.
func (*CallNode) StackSize ¶
StackSize tries to determine the stack size of the given call graph node. It returns the maximum stack size, whether this size can be known at compile time and the call node responsible for failing to determine the maximum stack usage. The stack size is only valid if sizeType is Bounded.
type SizeType ¶ added in v0.15.0
type SizeType uint8
SizeType indicates whether a stack or frame size could be determined and if not, why.
const ( Undefined SizeType = iota // not yet calculated Unknown // child has unknown stack size Bounded // stack size is fixed at compile time (no recursion etc) Recursive IndirectCall )
Results after trying to determine the stack size of a function in the call graph. The goal is to find a maximum (bounded) stack size, but sometimes this is not possible for some reasons such as recursion or indirect calls.