Static Value-Flow Analysis
|
#include <SymbolTableBuilder.h>
Public Member Functions | |
SymbolTableBuilder (SymbolTableInfo *si) | |
Constructor. | |
void | buildMemModel (SVFModule *svfModule) |
Start building memory model. | |
u32_t | getNumOfElements (const Type *ety) |
Return size of this object based on LLVM value. | |
Protected Member Functions | |
void | collectSVFTypeInfo (const Value *val) |
collect the syms | |
void | collectSym (const Value *val) |
void | collectVal (const Value *val) |
void | collectObj (const Value *val) |
void | collectRet (const Function *val) |
void | collectVararg (const Function *val) |
void | handleGlobalCE (const GlobalVariable *G) |
Handle constant expression. | |
void | handleGlobalInitializerCE (const Constant *C) |
void | handleCE (const Value *val) |
ObjTypeInference * | getTypeInference () |
const Type * | inferObjType (const Value *startValue) |
Forward collect all possible infer sites starting from a value. | |
const Type * | inferTypeOfHeapObjOrStaticObj (const Instruction *inst) |
Get the reference type of heap/static object from an allocation site. | |
ObjTypeInfo * | createObjTypeInfo (const Value *val) |
Create an objectInfo based on LLVM value. | |
void | initTypeInfo (ObjTypeInfo *typeinfo, const Value *value, const Type *ty) |
Initialize TypeInfo based on LLVM Value. | |
void | analyzeObjType (ObjTypeInfo *typeinfo, const Value *val) |
Analyse types of all flattened fields of this object. | |
u32_t | analyzeHeapObjType (ObjTypeInfo *typeinfo, const Value *val) |
Analyse types of heap and static objects. | |
void | analyzeStaticObjType (ObjTypeInfo *typeinfo, const Value *val) |
Analyse types of heap and static objects. | |
u32_t | analyzeHeapAllocByteSize (const Value *val) |
Analyze byte size of heap alloc function (e.g. malloc/calloc/...) | |
u32_t | getNumOfFlattenElements (const Type *T) |
Number of flattened elements of an array or struct. | |
StInfo * | getOrAddSVFTypeInfo (const Type *T) |
Get a reference to StructInfo. | |
MemObj * | createBlkObj (SymID symId) |
MemObj * | createConstantObj (SymID symId) |
Private Attributes | |
SymbolTableInfo * | symInfo |
Friends | |
class | SVFIRBuilder |
Definition at line 44 of file SymbolTableBuilder.h.
|
inline |
Analyze byte size of heap alloc function (e.g. malloc/calloc/...)
Analyze byte size of heap alloc function (e.g. malloc/calloc/...) 1) attribute((annotate("ALLOC_HEAP_RET"), annotate("AllocSize:Arg0"))) void* safe_malloc(unsigned long size). Byte Size is the size(Arg0) 2)__attribute__((annotate("ALLOC_HEAP_RET"), annotate("AllocSize:Arg0*Arg1"))) char* safecalloc(int a, int b) Byte Size is a(Arg0) * b(Arg1) 3)__attribute__((annotate("ALLOC_HEAP_RET"), annotate("UNKNOWN"))) void* __sysv_signal(int a, void *b) Byte Size is Unknown If all required arg values are constant, byte Size is also constant, otherwise return ByteSize 0
Definition at line 739 of file SymbolTableBuilder.cpp.
|
protected |
Analyse types of heap and static objects.
Analyse types of heap and static objects
For an C++ class, it can have variant elements depending on the vtable size, Hence we only handle non-cpp-class object, the type of the cpp class is treated as default PointerType
Definition at line 809 of file SymbolTableBuilder.cpp.
|
protected |
Analyse types of all flattened fields of this object.
Analyse types of all flattened fields of this object
Definition at line 698 of file SymbolTableBuilder.cpp.
|
protected |
Analyse types of heap and static objects.
Analyse types of heap and static objects
Definition at line 832 of file SymbolTableBuilder.cpp.
void SymbolTableBuilder::buildMemModel | ( | SVFModule * | svfModule | ) |
Start building memory model.
This method identify which is value sym and which is object sym
if (SVFUtil::isa<InlineAsm>(Callee))
Definition at line 75 of file SymbolTableBuilder.cpp.
Get memory object sym, if not available create a new one
Definition at line 318 of file SymbolTableBuilder.cpp.
Create unique return sym, if not available create a new one
Definition at line 354 of file SymbolTableBuilder.cpp.
collect the syms
Definition at line 240 of file SymbolTableBuilder.cpp.
Collect symbols, including value and object syms
Definition at line 260 of file SymbolTableBuilder.cpp.
Get value sym, if not available create a new one
handle global constant expression here
Definition at line 289 of file SymbolTableBuilder.cpp.
Create vararg sym, if not available create a new one
Definition at line 371 of file SymbolTableBuilder.cpp.
Definition at line 47 of file SymbolTableBuilder.cpp.
Definition at line 59 of file SymbolTableBuilder.cpp.
|
protected |
Create an objectInfo based on LLVM value.
Definition at line 629 of file SymbolTableBuilder.cpp.
Return size of this object based on LLVM value.
Return size of this Object
Definition at line 940 of file SymbolTableBuilder.cpp.
Number of flattened elements of an array or struct.
Get a reference to the components of struct_info. Number of flattened elements of an array or struct
Definition at line 952 of file SymbolTableBuilder.cpp.
Get a reference to StructInfo.
Definition at line 960 of file SymbolTableBuilder.cpp.
|
protected |
Definition at line 576 of file SymbolTableBuilder.cpp.
Handle constant expression
Definition at line 388 of file SymbolTableBuilder.cpp.
|
protected |
Handle constant expression.
Handle global constant expression
Definition at line 482 of file SymbolTableBuilder.cpp.
Handle global variable initialization
Definition at line 521 of file SymbolTableBuilder.cpp.
Forward collect all possible infer sites starting from a value.
Definition at line 582 of file SymbolTableBuilder.cpp.
|
protected |
Get the reference type of heap/static object from an allocation site.
Return the type of the object from a heap allocation
Definition at line 590 of file SymbolTableBuilder.cpp.
|
protected |
Initialize TypeInfo based on LLVM Value.
Initialize the type info of an object
if val is AllocaInst, byteSize is Type's LLVM ByteSize * ArraySize e.g. alloc i32, 10. byteSize is 4 (i32's size) * 10 (ArraySize) = 40
This is for alloca <ty> <NumElements>
. For example, alloca i64 3
allocates 3 i64 on the stack (objSize=3) In most cases, NumElements
is not specified in the instruction, which means there is only one element (objSize=1).
if ArraySize is not constant, byteSize is not static determined.
if val is GlobalVar, byteSize is Type's LLVM ByteSize All GlobalVariable must have constant size
if val is heap alloc
Definition at line 848 of file SymbolTableBuilder.cpp.
|
friend |
Definition at line 46 of file SymbolTableBuilder.h.
|
private |
Definition at line 48 of file SymbolTableBuilder.h.