Ghidra Decompiler Analysis Engine
|
A light-weight class for analyzing pointers and aliasing on the stack. More...
#include <varmap.hh>
Classes | |
struct | AddBase |
A helper class holding a Varnode pointer reference and a possible index added to it. More... | |
Public Member Functions | |
void | gather (const Funcdata *f, AddrSpace *spc, bool defer) |
Gather Varnodes that point on the stack. More... | |
bool | hasLocalAlias (Varnode *vn) const |
Return true if it looks like the given Varnode is aliased by a pointer. More... | |
void | sortAlias (void) const |
Sort the alias starting offsets. | |
Static Public Member Functions | |
static void | gatherAdditiveBase (Varnode *startvn, vector< AddBase > &addbase) |
Gather result Varnodes for all sums that the given starting Varnode is involved in. More... | |
static uintb | gatherOffset (Varnode *vn) |
If the given Varnode is a sum result, return the constant portion of this sum. More... | |
A light-weight class for analyzing pointers and aliasing on the stack.
The gather() method looks for pointer references into a specific AddressSpace (usually the stack). Then hasLocalAlias() checks if a specific Varnode within the AddressSpace is (possibly) aliased by one of the gathered pointer references.
Gather Varnodes that point on the stack.
For the given function and address space, gather all Varnodes that are pointers into the address space. The actual calculation can be deferred until the first time hasLocalAlias() is called.
f | is the given function |
spc | is the given address space |
defer | is true is gathering is deferred |
Gather result Varnodes for all sums that the given starting Varnode is involved in.
For every sum that involves startvn, collect the final result Varnode of the sum. A sum is any expression involving only the additive operators INT_ADD, INT_SUB, PTRADD, PTRSUB, and SEGMENTOP. The routine traverses forward recursively through all descendants of vn that are additive operations and collects all the roots of the traversed trees.
startvn | is the Varnode to trace |
addbase | will contain all the collected roots |
|
static |
If the given Varnode is a sum result, return the constant portion of this sum.
Treat vn as the result of a series of ADD operations. Examine all the constant terms of this sum and add them together by traversing the syntax tree rooted at vn, backwards, only through additive operations.
vn | is the given Varnode to gather off of |
bool AliasChecker::hasLocalAlias | ( | Varnode * | vn | ) | const |
Return true if it looks like the given Varnode is aliased by a pointer.
This is gives a rough analysis of whether the given Varnode might be aliased by another pointer in the function. If false is returned, the Varnode is not likely to have an alias. If true is returned, the Varnode might have an alias.
vn | is the given Varnode |