svf-lib 1.0.725 → 1.0.729
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SVF-linux/Release-build/lib/libSvf.a +0 -0
- package/SVF-linux/include/Graphs/PAGNode.h +1 -1
- package/SVF-linux/include/MemoryModel/LocationSet.h +0 -1
- package/SVF-linux/include/MemoryModel/SVFIR.h +380 -0
- package/SVF-linux/include/MemoryModel/SymbolTableInfo.h +428 -0
- package/SVF-linux/include/SVF-FE/MemModelBuilder.h +102 -0
- package/SVF-linux/include/SVF-FE/SymbolTableBuilder.h +90 -0
- package/SVF-linux/include/SVF-FE/SymbolTableInfo.h +7 -32
- package/SVF-linux/include/Util/BasicTypes.h +0 -10
- package/SVF-linux/include/Util/NodeIDAllocator.h +1 -1
- package/SVF-linux/include/Util/SVFUtil.h +11 -0
- package/SVF-linux/include/WPA/Andersen.h +0 -89
- package/SVF-osx/Release-build/lib/CUDD/libCudd.a +0 -0
- package/SVF-osx/Release-build/lib/libSvf.a +0 -0
- package/SVF-osx/include/MemoryModel/MemModel.h +5 -21
- package/SVF-osx/include/SVF-FE/MemModelBuilder.h +102 -0
- package/SVF-osx/include/SVF-FE/SymbolTableInfo.h +12 -79
- package/SVF-osx/include/Util/NodeIDAllocator.h +1 -1
- package/package.json +1 -1
|
@@ -68,7 +68,7 @@ public:
|
|
|
68
68
|
NodeID allocateValueId(void);
|
|
69
69
|
|
|
70
70
|
/// Notify the allocator that all symbols have had IDs allocated.
|
|
71
|
-
|
|
71
|
+
NodeID endSymbolAllocation(void);
|
|
72
72
|
|
|
73
73
|
/// Returns the total number of memory objects.
|
|
74
74
|
NodeID getNumObjects(void) const { return numObjects; }
|
|
@@ -241,6 +241,17 @@ inline const SVFFunction* getFunction(StringRef name)
|
|
|
241
241
|
return nullptr;
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
+
/// find the unique defined global across multiple modules
|
|
245
|
+
inline const Value* getGlobalRep(const Value* val)
|
|
246
|
+
{
|
|
247
|
+
if(const GlobalVariable* gvar = SVFUtil::dyn_cast<GlobalVariable>(val))
|
|
248
|
+
{
|
|
249
|
+
if (LLVMModuleSet::getLLVMModuleSet()->hasGlobalRep(gvar))
|
|
250
|
+
val = LLVMModuleSet::getLLVMModuleSet()->getGlobalRep(gvar);
|
|
251
|
+
}
|
|
252
|
+
return val;
|
|
253
|
+
}
|
|
254
|
+
|
|
244
255
|
/// Get the definition of a function across multiple modules
|
|
245
256
|
inline const SVFFunction* getDefFunForMultipleModule(const Function* fun)
|
|
246
257
|
{
|
|
@@ -40,7 +40,6 @@
|
|
|
40
40
|
namespace SVF
|
|
41
41
|
{
|
|
42
42
|
|
|
43
|
-
class PTAType;
|
|
44
43
|
class SVFModule;
|
|
45
44
|
|
|
46
45
|
/*!
|
|
@@ -464,94 +463,6 @@ protected:
|
|
|
464
463
|
};
|
|
465
464
|
|
|
466
465
|
|
|
467
|
-
|
|
468
|
-
/**
|
|
469
|
-
* Wave propagation with diff points-to set with type filter.
|
|
470
|
-
*/
|
|
471
|
-
class AndersenWaveDiffWithType : public AndersenWaveDiff
|
|
472
|
-
{
|
|
473
|
-
|
|
474
|
-
private:
|
|
475
|
-
|
|
476
|
-
typedef Map<NodeID, Set<const GepCGEdge*>> TypeMismatchedObjToEdgeTy;
|
|
477
|
-
|
|
478
|
-
TypeMismatchedObjToEdgeTy typeMismatchedObjToEdges;
|
|
479
|
-
|
|
480
|
-
void recordTypeMismatchedGep(NodeID obj, const GepCGEdge* gepEdge)
|
|
481
|
-
{
|
|
482
|
-
TypeMismatchedObjToEdgeTy::iterator it = typeMismatchedObjToEdges.find(obj);
|
|
483
|
-
if (it != typeMismatchedObjToEdges.end())
|
|
484
|
-
{
|
|
485
|
-
Set<const GepCGEdge*> &edges = it->second;
|
|
486
|
-
edges.insert(gepEdge);
|
|
487
|
-
}
|
|
488
|
-
else
|
|
489
|
-
{
|
|
490
|
-
Set<const GepCGEdge*> edges;
|
|
491
|
-
edges.insert(gepEdge);
|
|
492
|
-
typeMismatchedObjToEdges[obj] = edges;
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
static AndersenWaveDiffWithType* diffWaveWithType; // static instance
|
|
497
|
-
|
|
498
|
-
/// Handle diff points-to set.
|
|
499
|
-
//@{
|
|
500
|
-
virtual inline void computeDiffPts(NodeID id)
|
|
501
|
-
{
|
|
502
|
-
NodeID rep = sccRepNode(id);
|
|
503
|
-
getDiffPTDataTy()->computeDiffPts(rep, getDiffPTDataTy()->getPts(rep));
|
|
504
|
-
}
|
|
505
|
-
virtual inline const PointsTo& getDiffPts(NodeID id)
|
|
506
|
-
{
|
|
507
|
-
NodeID rep = sccRepNode(id);
|
|
508
|
-
return getDiffPTDataTy()->getDiffPts(rep);
|
|
509
|
-
}
|
|
510
|
-
//@}
|
|
511
|
-
|
|
512
|
-
public:
|
|
513
|
-
AndersenWaveDiffWithType(PAG* _pag, PTATY type = AndersenWaveDiffWithType_WPA): AndersenWaveDiff(_pag,type)
|
|
514
|
-
{
|
|
515
|
-
assert(getTypeSystem()!=nullptr && "a type system is required for this pointer analysis");
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
/// Create an singleton instance directly instead of invoking llvm pass manager
|
|
519
|
-
static AndersenWaveDiffWithType* createAndersenWaveDiffWithType(PAG* p)
|
|
520
|
-
{
|
|
521
|
-
if(diffWaveWithType==nullptr)
|
|
522
|
-
{
|
|
523
|
-
diffWaveWithType = new AndersenWaveDiffWithType(p);
|
|
524
|
-
diffWaveWithType->analyze();
|
|
525
|
-
return diffWaveWithType;
|
|
526
|
-
}
|
|
527
|
-
return diffWaveWithType;
|
|
528
|
-
}
|
|
529
|
-
static void releaseAndersenWaveDiffWithType()
|
|
530
|
-
{
|
|
531
|
-
if (diffWaveWithType)
|
|
532
|
-
delete diffWaveWithType;
|
|
533
|
-
diffWaveWithType = nullptr;
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
protected:
|
|
537
|
-
/// SCC detection
|
|
538
|
-
virtual NodeStack& SCCDetect();
|
|
539
|
-
/// merge types of nodes in a cycle
|
|
540
|
-
void mergeTypeOfNodes(const NodeBS &nodes);
|
|
541
|
-
/// process "bitcast" CopyCGEdge
|
|
542
|
-
virtual void processCast(const ConstraintEdge *edge);
|
|
543
|
-
/// update type of objects when process "bitcast" CopyCGEdge
|
|
544
|
-
void updateObjType(const Type *type, const PointsTo &objs);
|
|
545
|
-
/// process mismatched gep edges
|
|
546
|
-
void processTypeMismatchedGep(NodeID obj, const Type *type);
|
|
547
|
-
/// match types for Gep Edges
|
|
548
|
-
virtual bool matchType(NodeID ptrid, NodeID objid, const NormalGepCGEdge *normalGepEdge);
|
|
549
|
-
/// add type for newly created GepObjNode
|
|
550
|
-
virtual void addTypeForGepObjNode(NodeID id, const NormalGepCGEdge* normalGepEdge);
|
|
551
|
-
};
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
466
|
/*
|
|
556
467
|
* Lazy Cycle Detection Based Andersen Analysis
|
|
557
468
|
*/
|
|
Binary file
|
|
Binary file
|
|
@@ -172,18 +172,12 @@ public:
|
|
|
172
172
|
{
|
|
173
173
|
|
|
174
174
|
}
|
|
175
|
-
/// Initialize the object type
|
|
176
|
-
void init(const Value* value);
|
|
177
175
|
|
|
178
|
-
///
|
|
179
|
-
|
|
180
|
-
virtual u32_t getObjSize(const Value* val);
|
|
181
|
-
|
|
182
|
-
/// Analyse types of gobal and stack objects
|
|
183
|
-
void analyzeGlobalStackObjType(const Value* val);
|
|
176
|
+
/// Analyse types of heap and static objects
|
|
177
|
+
void analyzeHeapObjType(const Type* type);
|
|
184
178
|
|
|
185
179
|
/// Analyse types of heap and static objects
|
|
186
|
-
void
|
|
180
|
+
void analyzeStaticObjType(const Type* type);
|
|
187
181
|
|
|
188
182
|
/// Get LLVM type
|
|
189
183
|
inline const Type* getType() const
|
|
@@ -295,25 +289,15 @@ private:
|
|
|
295
289
|
public:
|
|
296
290
|
|
|
297
291
|
/// Constructor
|
|
298
|
-
MemObj(const Value *val
|
|
299
|
-
|
|
300
|
-
/// Constructor for black hole and constant obj
|
|
301
|
-
MemObj(SymID id, const Type* type = nullptr);
|
|
292
|
+
MemObj(SymID id, ObjTypeInfo* ti, const Value *val = nullptr);
|
|
302
293
|
|
|
303
294
|
/// Destructor
|
|
304
295
|
~MemObj()
|
|
305
296
|
{
|
|
306
297
|
destroy();
|
|
307
298
|
}
|
|
308
|
-
|
|
309
|
-
/// Initialize the object
|
|
310
|
-
void init(const Value *val);
|
|
311
|
-
|
|
312
|
-
/// Initialize black hole and constant object
|
|
313
|
-
void init(const Type* type);
|
|
314
|
-
|
|
315
299
|
/// Get obj type
|
|
316
|
-
const
|
|
300
|
+
const Type* getType() const;
|
|
317
301
|
|
|
318
302
|
/// Get max field offset limit
|
|
319
303
|
inline Size_t getMaxFieldOffsetLimit() const
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
//===- LocMemModel.h -- Memory model builder-----------------------//
|
|
2
|
+
//
|
|
3
|
+
// SVF: Static Value-Flow Analysis
|
|
4
|
+
//
|
|
5
|
+
// Copyright (C) <2013-2017> <Yulei Sui>
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
// This program is free software: you can redistribute it and/or modify
|
|
9
|
+
// it under the terms of the GNU General Public License as published by
|
|
10
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
// (at your option) any later version.
|
|
12
|
+
|
|
13
|
+
// This program is distributed in the hope that it will be useful,
|
|
14
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
// GNU General Public License for more details.
|
|
17
|
+
|
|
18
|
+
// You should have received a copy of the GNU General Public License
|
|
19
|
+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
//
|
|
21
|
+
//===----------------------------------------------------------------------===//
|
|
22
|
+
|
|
23
|
+
/*
|
|
24
|
+
* MemModelBuilder.h
|
|
25
|
+
*
|
|
26
|
+
* Created on: Apr 28, 2014
|
|
27
|
+
* Author: Yulei
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
#ifndef MEMMODELBUILDER_H_
|
|
31
|
+
#define MEMMODELBUILDER_H_
|
|
32
|
+
|
|
33
|
+
#include "MemoryModel/MemModel.h"
|
|
34
|
+
#include "SVF-FE/LLVMModule.h"
|
|
35
|
+
#include "SVF-FE/SymbolTableInfo.h"
|
|
36
|
+
|
|
37
|
+
/*
|
|
38
|
+
* This class is to build SymbolTableInfo, MemObjs and ObjTypeInfo
|
|
39
|
+
*/
|
|
40
|
+
namespace SVF
|
|
41
|
+
{
|
|
42
|
+
|
|
43
|
+
class MemModelBuilder
|
|
44
|
+
{
|
|
45
|
+
|
|
46
|
+
private:
|
|
47
|
+
SymbolTableInfo* symInfo;
|
|
48
|
+
|
|
49
|
+
public:
|
|
50
|
+
/// Constructor
|
|
51
|
+
MemModelBuilder(SymbolTableInfo* si): symInfo(si){
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/// Start building memory model
|
|
56
|
+
void buildMemModel(SVFModule* svfModule);
|
|
57
|
+
|
|
58
|
+
/// collect the syms
|
|
59
|
+
//@{
|
|
60
|
+
void collectSym(const Value *val);
|
|
61
|
+
|
|
62
|
+
void collectVal(const Value *val);
|
|
63
|
+
|
|
64
|
+
void collectObj(const Value *val);
|
|
65
|
+
|
|
66
|
+
void collectRet(const Function *val);
|
|
67
|
+
|
|
68
|
+
void collectVararg(const Function *val);
|
|
69
|
+
//@}
|
|
70
|
+
|
|
71
|
+
/// Handle constant expression
|
|
72
|
+
// @{
|
|
73
|
+
void handleGlobalCE(const GlobalVariable *G);
|
|
74
|
+
void handleGlobalInitializerCE(const Constant *C, u32_t offset);
|
|
75
|
+
void handleCE(const Value *val);
|
|
76
|
+
// @}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
// /// Collect the struct info
|
|
80
|
+
// virtual void collectStructInfo(const StructType *T);
|
|
81
|
+
// /// Collect the array info
|
|
82
|
+
// virtual void collectArrayInfo(const ArrayType* T);
|
|
83
|
+
// /// Collect simple type (non-aggregate) info
|
|
84
|
+
// virtual void collectSimpleTypeInfo(const Type* T);
|
|
85
|
+
|
|
86
|
+
/// Create an objectInfo based on LLVM value
|
|
87
|
+
ObjTypeInfo* createObjTypeInfo(const Value *val);
|
|
88
|
+
/// Create an objectInfo based on LLVM type (value is null, and type could be null, representing a dummy object)
|
|
89
|
+
// ObjTypeInfo* createObjTypeInfo(const Type *type = nullptr);
|
|
90
|
+
|
|
91
|
+
/// Initialize TypeInfo based on LLVM Value
|
|
92
|
+
void initTypeInfo(ObjTypeInfo* typeinfo, const Value* value);
|
|
93
|
+
/// Analyse types of all flattened fields of this object
|
|
94
|
+
void analyzeGlobalStackObjType(ObjTypeInfo* typeinfo, const Value* val);
|
|
95
|
+
/// Return size of this object based on LLVM value
|
|
96
|
+
u32_t getObjSize(const Value* val);
|
|
97
|
+
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
#endif /* MEMMODELBUILDER_H_ */
|
|
@@ -42,6 +42,8 @@ namespace SVF
|
|
|
42
42
|
class SymbolTableInfo
|
|
43
43
|
{
|
|
44
44
|
|
|
45
|
+
friend class MemModelBuilder;
|
|
46
|
+
|
|
45
47
|
public:
|
|
46
48
|
/// various maps defined
|
|
47
49
|
//{@
|
|
@@ -142,6 +144,11 @@ public:
|
|
|
142
144
|
{
|
|
143
145
|
return mod;
|
|
144
146
|
}
|
|
147
|
+
/// Module
|
|
148
|
+
inline void setModule(SVFModule* m)
|
|
149
|
+
{
|
|
150
|
+
mod = m;
|
|
151
|
+
}
|
|
145
152
|
|
|
146
153
|
/// Get target machine data layout
|
|
147
154
|
inline static DataLayout* getDataLayout(Module* mod)
|
|
@@ -157,22 +164,6 @@ public:
|
|
|
157
164
|
u32_t getTypeSizeInBytes(const StructType *sty, u32_t field_index);
|
|
158
165
|
//@}
|
|
159
166
|
|
|
160
|
-
/// Start building memory model
|
|
161
|
-
void buildMemModel(SVFModule* svfModule);
|
|
162
|
-
|
|
163
|
-
/// collect the syms
|
|
164
|
-
//@{
|
|
165
|
-
void collectSym(const Value *val);
|
|
166
|
-
|
|
167
|
-
void collectVal(const Value *val);
|
|
168
|
-
|
|
169
|
-
void collectObj(const Value *val);
|
|
170
|
-
|
|
171
|
-
void collectRet(const Function *val);
|
|
172
|
-
|
|
173
|
-
void collectVararg(const Function *val);
|
|
174
|
-
//@}
|
|
175
|
-
|
|
176
167
|
/// special value
|
|
177
168
|
// @{
|
|
178
169
|
static bool isNullPtrSym(const Value *val);
|
|
@@ -206,7 +197,7 @@ public:
|
|
|
206
197
|
{
|
|
207
198
|
assert(isBlkObjOrConstantObj(symId));
|
|
208
199
|
assert(objMap.find(symId)==objMap.end());
|
|
209
|
-
objMap[symId] = new MemObj(symId);;
|
|
200
|
+
objMap[symId] = new MemObj(symId, createObjTypeInfo());;
|
|
210
201
|
}
|
|
211
202
|
|
|
212
203
|
inline MemObj* getBlkObj() const
|
|
@@ -242,19 +233,12 @@ public:
|
|
|
242
233
|
inline const MemObj* createDummyObj(SymID symId, const Type* type)
|
|
243
234
|
{
|
|
244
235
|
assert(objMap.find(symId)==objMap.end() && "this dummy obj has been created before");
|
|
245
|
-
MemObj* memObj = new MemObj(symId, type);
|
|
236
|
+
MemObj* memObj = new MemObj(symId, createObjTypeInfo(type));
|
|
246
237
|
objMap[symId] = memObj;
|
|
247
238
|
return memObj;
|
|
248
239
|
}
|
|
249
240
|
// @}
|
|
250
241
|
|
|
251
|
-
/// Handle constant expression
|
|
252
|
-
// @{
|
|
253
|
-
void handleGlobalCE(const GlobalVariable *G);
|
|
254
|
-
void handleGlobalInitializerCE(const Constant *C, u32_t offset);
|
|
255
|
-
void handleCE(const Value *val);
|
|
256
|
-
// @}
|
|
257
|
-
|
|
258
242
|
/// Get different kinds of syms
|
|
259
243
|
//@{
|
|
260
244
|
SymID getValSym(const Value *val)
|
|
@@ -433,6 +417,9 @@ protected:
|
|
|
433
417
|
/// Collect simple type (non-aggregate) info
|
|
434
418
|
virtual void collectSimpleTypeInfo(const Type* T);
|
|
435
419
|
|
|
420
|
+
/// Create an objectInfo based on LLVM type (value is null, and type could be null, representing a dummy object)
|
|
421
|
+
ObjTypeInfo* createObjTypeInfo(const Type *type = nullptr);
|
|
422
|
+
|
|
436
423
|
/// Every type T is mapped to StInfo
|
|
437
424
|
/// which contains size (fsize) , offset(foffset)
|
|
438
425
|
/// fsize[i] is the number of fields in the largest such struct, else fsize[i] = 1.
|
|
@@ -447,60 +434,6 @@ protected:
|
|
|
447
434
|
};
|
|
448
435
|
|
|
449
436
|
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
/*!
|
|
453
|
-
* Bytes/bits-level modeling of memory locations to handle weakly type languages.
|
|
454
|
-
* (declared with one type but accessed as another)
|
|
455
|
-
* Abstract memory objects are created according to the static allocated size.
|
|
456
|
-
*/
|
|
457
|
-
class LocSymTableInfo : public SymbolTableInfo
|
|
458
|
-
{
|
|
459
|
-
|
|
460
|
-
public:
|
|
461
|
-
/// Constructor
|
|
462
|
-
LocSymTableInfo()
|
|
463
|
-
{
|
|
464
|
-
}
|
|
465
|
-
/// Destructor
|
|
466
|
-
virtual ~LocSymTableInfo()
|
|
467
|
-
{
|
|
468
|
-
}
|
|
469
|
-
/// Compute gep offset
|
|
470
|
-
virtual bool computeGepOffset(const User *V, LocationSet& ls);
|
|
471
|
-
/// Given an offset from a Gep Instruction, return it modulus offset by considering memory layout
|
|
472
|
-
virtual LocationSet getModulusOffset(const MemObj* obj, const LocationSet& ls);
|
|
473
|
-
|
|
474
|
-
/// Verify struct size construction
|
|
475
|
-
void verifyStructSize(StInfo *stInfo, u32_t structSize);
|
|
476
|
-
|
|
477
|
-
protected:
|
|
478
|
-
/// Collect the struct info
|
|
479
|
-
virtual void collectStructInfo(const StructType *T);
|
|
480
|
-
/// Collect the array info
|
|
481
|
-
virtual void collectArrayInfo(const ArrayType *T);
|
|
482
|
-
};
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
class LocObjTypeInfo : public ObjTypeInfo
|
|
486
|
-
{
|
|
487
|
-
|
|
488
|
-
public:
|
|
489
|
-
/// Constructor
|
|
490
|
-
LocObjTypeInfo(const Value* val, Type* t, Size_t max) : ObjTypeInfo(val,t,max)
|
|
491
|
-
{
|
|
492
|
-
|
|
493
|
-
}
|
|
494
|
-
/// Destructor
|
|
495
|
-
virtual ~LocObjTypeInfo()
|
|
496
|
-
{
|
|
497
|
-
|
|
498
|
-
}
|
|
499
|
-
/// Get the size of this object
|
|
500
|
-
u32_t getObjSize(const Value* val);
|
|
501
|
-
|
|
502
|
-
};
|
|
503
|
-
|
|
504
437
|
} // End namespace SVF
|
|
505
438
|
|
|
506
439
|
#endif /* INCLUDE_SVF_FE_SYMBOLTABLEINFO_H_ */
|
|
@@ -68,7 +68,7 @@ public:
|
|
|
68
68
|
NodeID allocateValueId(void);
|
|
69
69
|
|
|
70
70
|
/// Notify the allocator that all symbols have had IDs allocated.
|
|
71
|
-
|
|
71
|
+
NodeID endSymbolAllocation(void);
|
|
72
72
|
|
|
73
73
|
/// Returns the total number of memory objects.
|
|
74
74
|
NodeID getNumObjects(void) const { return numObjects; }
|