Static Value-Flow Analysis
|
Handles external API calls and manages abstract states. More...
#include <AbsExtAPI.h>
Public Types | |
enum | ExtAPIType { UNCLASSIFIED , MEMCPY , MEMSET , STRCPY , STRCAT } |
Enumeration of external API types. More... | |
Public Member Functions | |
AbsExtAPI (Map< const ICFGNode *, AbstractState > &traces) | |
Constructor for AbsExtAPI. | |
void | initExtFunMap () |
Initializes the external function map. | |
std::string | strRead (AbstractState &as, const SVFVar *rhs) |
Reads a string from the abstract state. | |
void | handleExtAPI (const CallICFGNode *call) |
Handles an external API call. | |
void | handleStrcpy (const CallICFGNode *call) |
Handles the strcpy API call. | |
IntervalValue | getStrlen (AbstractState &as, const SVF::SVFVar *strValue) |
Calculates the length of a string. | |
void | handleStrcat (const SVF::CallICFGNode *call) |
Handles the strcat API call. | |
void | handleMemcpy (AbstractState &as, const SVF::SVFVar *dst, const SVF::SVFVar *src, IntervalValue len, u32_t start_idx) |
Handles the memcpy API call. | |
void | handleMemset (AbstractState &as, const SVFVar *dst, IntervalValue elem, IntervalValue len) |
Handles the memset API call. | |
IntervalValue | getRangeLimitFromType (const SVFType *type) |
Gets the range limit from a type. | |
AbstractState & | getAbsStateFromTrace (const ICFGNode *node) |
Retrieves the abstract state from the trace for a given ICFG node. | |
const SVFVar * | getSVFVar (const SVFValue *val) |
Retrieves the SVF variable from a given SVF value. | |
Protected Attributes | |
SVFIR * | svfir |
Pointer to the SVF intermediate representation. | |
ICFG * | icfg |
Pointer to the interprocedural control flow graph. | |
Map< const ICFGNode *, AbstractState > & | abstractTrace |
Map of ICFG nodes to abstract states. | |
Map< std::string, std::function< void(const CallICFGNode *)> > | func_map |
Map of function names to handlers. | |
Handles external API calls and manages abstract states.
Definition at line 45 of file AbsExtAPI.h.
Enumeration of external API types.
Enumerator | |
---|---|
UNCLASSIFIED | |
MEMCPY | |
MEMSET | |
STRCPY | |
STRCAT |
Definition at line 52 of file AbsExtAPI.h.
AbsExtAPI::AbsExtAPI | ( | Map< const ICFGNode *, AbstractState > & | traces | ) |
Constructor for AbsExtAPI.
abstractTrace | Reference to a map of ICFG nodes to abstract states. |
Definition at line 31 of file AbsExtAPI.cpp.
AbstractState & AbsExtAPI::getAbsStateFromTrace | ( | const ICFGNode * | node | ) |
Retrieves the abstract state from the trace for a given ICFG node.
node | Pointer to the ICFG node. |
Assertion | if no trace exists for the node. |
Definition at line 343 of file AbsExtAPI.cpp.
IntervalValue AbsExtAPI::getRangeLimitFromType | ( | const SVFType * | type | ) |
Gets the range limit from a type.
type | Pointer to the SVF type. |
This function, getRangeLimitFromType, calculates the lower and upper bounds of a numeric range for a given SVFType. It is used to determine the possible value range of integer types. If the type is an SVFIntegerType, it calculates the bounds based on the size and signedness of the type. The calculated bounds are returned as an IntervalValue representing the lower (lb) and upper (ub) limits of the range.
type | The SVFType for which to calculate the value range. |
Definition at line 700 of file AbsExtAPI.cpp.
IntervalValue AbsExtAPI::getStrlen | ( | AbstractState & | as, |
const SVF::SVFVar * | strValue | ||
) |
Calculates the length of a string.
as | Reference to the abstract state. |
strValue | Pointer to the SVF variable representing the string. |
Definition at line 468 of file AbsExtAPI.cpp.
Retrieves the SVF variable from a given SVF value.
val | Pointer to the SVF value. |
Definition at line 762 of file AbsExtAPI.cpp.
void AbsExtAPI::handleExtAPI | ( | const CallICFGNode * | call | ) |
Handles an external API call.
call | Pointer to the call ICFG node. |
Definition at line 386 of file AbsExtAPI.cpp.
void AbsExtAPI::handleMemcpy | ( | AbstractState & | as, |
const SVF::SVFVar * | dst, | ||
const SVF::SVFVar * | src, | ||
IntervalValue | len, | ||
u32_t | start_idx | ||
) |
Handles the memcpy API call.
as | Reference to the abstract state. |
dst | Pointer to the destination SVF variable. |
src | Pointer to the source SVF variable. |
len | The interval value representing the length to copy. |
start_idx | The starting index for copying. |
Definition at line 579 of file AbsExtAPI.cpp.
void AbsExtAPI::handleMemset | ( | AbstractState & | as, |
const SVFVar * | dst, | ||
IntervalValue | elem, | ||
IntervalValue | len | ||
) |
Handles the memset API call.
as | Reference to the abstract state. |
dst | Pointer to the destination SVF variable. |
elem | The interval value representing the element to set. |
len | The interval value representing the length to set. |
Definition at line 637 of file AbsExtAPI.cpp.
void AbsExtAPI::handleStrcat | ( | const SVF::CallICFGNode * | call | ) |
Handles the strcat API call.
call | Pointer to the call ICFG node. |
Definition at line 544 of file AbsExtAPI.cpp.
void AbsExtAPI::handleStrcpy | ( | const CallICFGNode * | call | ) |
Handles the strcpy API call.
call | Pointer to the call ICFG node. |
Definition at line 456 of file AbsExtAPI.cpp.
void AbsExtAPI::initExtFunMap | ( | ) |
Initializes the external function map.
Definition at line 38 of file AbsExtAPI.cpp.
std::string AbsExtAPI::strRead | ( | AbstractState & | as, |
const SVFVar * | rhs | ||
) |
Reads a string from the abstract state.
as | Reference to the abstract state. |
rhs | Pointer to the SVF variable representing the string. |
Definition at line 356 of file AbsExtAPI.cpp.
|
protected |
Map of ICFG nodes to abstract states.
Definition at line 143 of file AbsExtAPI.h.
|
protected |
Map of function names to handlers.
Definition at line 144 of file AbsExtAPI.h.
|
protected |
Pointer to the interprocedural control flow graph.
Definition at line 142 of file AbsExtAPI.h.
|
protected |
Pointer to the SVF intermediate representation.
Definition at line 141 of file AbsExtAPI.h.