Ghidra Decompiler Analysis Engine
Classes | Public Member Functions | Static Public Member Functions | List of all members
AliasChecker Class Reference

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...
 

Detailed Description

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.

Member Function Documentation

◆ gather()

void AliasChecker::gather ( const Funcdata f,
AddrSpace spc,
bool  defer 
)

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.

Parameters
fis the given function
spcis the given address space
deferis true is gathering is deferred

◆ gatherAdditiveBase()

void AliasChecker::gatherAdditiveBase ( Varnode startvn,
vector< AddBase > &  addbase 
)
static

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.

Parameters
startvnis the Varnode to trace
addbasewill contain all the collected roots

◆ gatherOffset()

uintb AliasChecker::gatherOffset ( Varnode vn)
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.

Parameters
vnis the given Varnode to gather off of
Returns
the resulting sub-sum

◆ hasLocalAlias()

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.

Parameters
vnis the given Varnode
Returns
true if the Varnode might have a pointer alias

The documentation for this class was generated from the following files: