svf-lib 1.0.1289 → 1.0.1291
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/CFL/CFLAlias.h +1 -1
- package/SVF-linux/include/CFL/CFLBase.h +1 -1
- package/SVF-linux/include/CFL/CFLGrammar.h +1 -1
- package/SVF-linux/include/DDA/DDAClient.h +2 -2
- package/SVF-linux/include/DDA/DDAPass.h +3 -3
- package/SVF-linux/include/Graphs/CHG.h +5 -5
- package/SVF-linux/include/Graphs/ConsG.h +1 -1
- package/SVF-linux/include/Graphs/ConsGEdge.h +1 -1
- package/SVF-linux/include/Graphs/GenericGraph.h +1 -1
- package/SVF-linux/include/Graphs/ICFG.h +1 -1
- package/SVF-linux/include/Graphs/ICFGEdge.h +3 -3
- package/SVF-linux/include/Graphs/IRGraph.h +13 -9
- package/SVF-linux/include/Graphs/PTACallGraph.h +1 -1
- package/SVF-linux/include/Graphs/SVFGOPT.h +2 -2
- package/SVF-linux/include/Graphs/ThreadCallGraph.h +2 -2
- package/SVF-linux/include/Graphs/VFG.h +1 -1
- package/SVF-linux/include/Graphs/VFGNode.h +7 -7
- package/SVF-linux/include/MSSA/MemRegion.h +2 -2
- package/SVF-linux/include/MTA/LockAnalysis.h +1 -4
- package/SVF-linux/include/MTA/MHP.h +22 -31
- package/SVF-linux/include/MTA/MTA.h +13 -32
- package/SVF-linux/include/MTA/MTAResultValidator.h +17 -16
- package/SVF-linux/include/MTA/MTAStat.h +1 -1
- package/SVF-linux/include/MTA/TCT.h +25 -18
- package/SVF-linux/include/MemoryModel/AbstractPointsToDS.h +1 -1
- package/SVF-linux/include/MemoryModel/ConditionalPT.h +3 -2
- package/SVF-linux/include/MemoryModel/LocationSet.h +4 -4
- package/SVF-linux/include/MemoryModel/MutablePointsToDS.h +1 -1
- package/SVF-linux/include/MemoryModel/PersistentPointsToCache.h +1 -1
- package/SVF-linux/include/MemoryModel/PointerAnalysis.h +5 -4
- package/SVF-linux/include/MemoryModel/PointerAnalysisImpl.h +4 -4
- package/SVF-linux/include/MemoryModel/PointsTo.h +1 -1
- package/SVF-linux/include/MemoryModel/SVFLoop.h +1 -1
- package/SVF-linux/include/SABER/DoubleFreeChecker.h +2 -2
- package/SVF-linux/include/SABER/FileChecker.h +2 -2
- package/SVF-linux/include/SABER/LeakChecker.h +2 -2
- package/SVF-linux/include/SABER/ProgSlice.h +0 -3
- package/SVF-linux/include/SABER/SaberCondAllocator.h +7 -9
- package/SVF-linux/include/SABER/SaberSVFGBuilder.h +1 -1
- package/SVF-linux/include/SVF-LLVM/BasicTypes.h +248 -0
- package/SVF-linux/include/SVF-LLVM/BreakConstantExpr.h +94 -0
- package/SVF-linux/include/SVF-LLVM/CHGBuilder.h +73 -0
- package/SVF-linux/include/SVF-LLVM/CPPUtil.h +130 -0
- package/SVF-linux/include/SVF-LLVM/DCHG.h +481 -0
- package/SVF-linux/include/SVF-LLVM/GEPTypeBridgeIterator.h +183 -0
- package/SVF-linux/include/SVF-LLVM/ICFGBuilder.h +106 -0
- package/SVF-linux/include/SVF-LLVM/IRAnnotator.h +323 -0
- package/SVF-linux/include/SVF-LLVM/LLVMLoopAnalysis.h +59 -0
- package/SVF-linux/include/SVF-LLVM/LLVMModule.h +358 -0
- package/SVF-linux/include/SVF-LLVM/LLVMUtil.h +405 -0
- package/SVF-linux/include/SVF-LLVM/SVFIRBuilder.h +413 -0
- package/SVF-linux/include/SVF-LLVM/SymbolTableBuilder.h +113 -0
- package/SVF-linux/include/SVFIR/PAGBuilderFromFile.h +80 -0
- package/SVF-linux/include/SVFIR/SVFIR.h +661 -0
- package/SVF-linux/include/SVFIR/SVFModule.h +233 -0
- package/SVF-linux/include/SVFIR/SVFStatements.h +1101 -0
- package/SVF-linux/include/SVFIR/SVFType.h +514 -0
- package/SVF-linux/include/SVFIR/SVFValue.h +1129 -0
- package/SVF-linux/include/SVFIR/SVFVariables.h +721 -0
- package/SVF-linux/include/SVFIR/SymbolTableInfo.h +597 -0
- package/SVF-linux/include/Util/Annotator.h +1 -1
- package/SVF-linux/include/Util/CallGraphBuilder.h +74 -0
- package/SVF-linux/include/Util/Casting.h +1 -3
- package/SVF-linux/include/Util/CoreBitVector.h +1 -1
- package/SVF-linux/include/Util/CxtStmt.h +8 -8
- package/SVF-linux/include/Util/DPItem.h +1 -1
- package/SVF-linux/include/Util/ExtAPI.h +1 -1
- package/SVF-linux/include/Util/NodeIDAllocator.h +1 -1
- package/SVF-linux/include/Util/Options.h +1 -0
- package/SVF-linux/include/Util/PTAStat.h +1 -1
- package/SVF-linux/include/Util/SCC.h +1 -1
- package/SVF-linux/include/Util/SVFUtil.h +26 -95
- package/SVF-linux/include/Util/ThreadAPI.h +27 -27
- package/SVF-linux/include/Util/WorkList.h +1 -1
- package/SVF-linux/include/Util/Z3Expr.h +1 -1
- package/SVF-linux/include/WPA/Andersen.h +1 -1
- package/SVF-linux/include/WPA/CSC.h +1 -1
- package/SVF-linux/include/WPA/TypeAnalysis.h +0 -3
- package/SVF-linux/include/WPA/WPAPass.h +8 -8
- package/SVF-osx/Release-build/lib/libSvf.a +0 -0
- package/SVF-osx/include/CFL/CFLAlias.h +1 -1
- package/SVF-osx/include/CFL/CFLBase.h +1 -1
- package/SVF-osx/include/CFL/CFLGrammar.h +1 -1
- package/SVF-osx/include/DDA/DDAClient.h +2 -2
- package/SVF-osx/include/DDA/DDAPass.h +3 -3
- package/SVF-osx/include/Graphs/CHG.h +5 -5
- package/SVF-osx/include/Graphs/ConsG.h +1 -1
- package/SVF-osx/include/Graphs/ConsGEdge.h +1 -1
- package/SVF-osx/include/Graphs/GenericGraph.h +1 -1
- package/SVF-osx/include/Graphs/ICFG.h +1 -1
- package/SVF-osx/include/Graphs/ICFGEdge.h +3 -3
- package/SVF-osx/include/Graphs/IRGraph.h +13 -9
- package/SVF-osx/include/Graphs/PTACallGraph.h +1 -1
- package/SVF-osx/include/Graphs/SVFGOPT.h +2 -2
- package/SVF-osx/include/Graphs/ThreadCallGraph.h +2 -2
- package/SVF-osx/include/Graphs/VFG.h +1 -1
- package/SVF-osx/include/Graphs/VFGNode.h +7 -7
- package/SVF-osx/include/MSSA/MemRegion.h +2 -2
- package/SVF-osx/include/MTA/LockAnalysis.h +1 -4
- package/SVF-osx/include/MTA/MHP.h +22 -31
- package/SVF-osx/include/MTA/MTA.h +13 -32
- package/SVF-osx/include/MTA/MTAResultValidator.h +17 -16
- package/SVF-osx/include/MTA/MTAStat.h +1 -1
- package/SVF-osx/include/MTA/TCT.h +25 -18
- package/SVF-osx/include/MemoryModel/AbstractPointsToDS.h +1 -1
- package/SVF-osx/include/MemoryModel/ConditionalPT.h +3 -2
- package/SVF-osx/include/MemoryModel/LocationSet.h +4 -4
- package/SVF-osx/include/MemoryModel/MutablePointsToDS.h +1 -1
- package/SVF-osx/include/MemoryModel/PersistentPointsToCache.h +1 -1
- package/SVF-osx/include/MemoryModel/PointerAnalysis.h +5 -4
- package/SVF-osx/include/MemoryModel/PointerAnalysisImpl.h +4 -4
- package/SVF-osx/include/MemoryModel/PointsTo.h +1 -1
- package/SVF-osx/include/MemoryModel/SVFLoop.h +1 -1
- package/SVF-osx/include/SABER/DoubleFreeChecker.h +2 -2
- package/SVF-osx/include/SABER/FileChecker.h +2 -2
- package/SVF-osx/include/SABER/LeakChecker.h +2 -2
- package/SVF-osx/include/SABER/ProgSlice.h +0 -3
- package/SVF-osx/include/SABER/SaberCondAllocator.h +7 -9
- package/SVF-osx/include/SABER/SaberSVFGBuilder.h +1 -1
- package/SVF-osx/include/SVF-LLVM/BasicTypes.h +248 -0
- package/SVF-osx/include/SVF-LLVM/BreakConstantExpr.h +94 -0
- package/SVF-osx/include/SVF-LLVM/CHGBuilder.h +73 -0
- package/SVF-osx/include/SVF-LLVM/CPPUtil.h +130 -0
- package/SVF-osx/include/SVF-LLVM/DCHG.h +481 -0
- package/SVF-osx/include/SVF-LLVM/GEPTypeBridgeIterator.h +183 -0
- package/SVF-osx/include/SVF-LLVM/ICFGBuilder.h +106 -0
- package/SVF-osx/include/SVF-LLVM/IRAnnotator.h +323 -0
- package/SVF-osx/include/SVF-LLVM/LLVMLoopAnalysis.h +59 -0
- package/SVF-osx/include/SVF-LLVM/LLVMModule.h +358 -0
- package/SVF-osx/include/SVF-LLVM/LLVMUtil.h +405 -0
- package/SVF-osx/include/SVF-LLVM/SVFIRBuilder.h +413 -0
- package/SVF-osx/include/SVF-LLVM/SymbolTableBuilder.h +113 -0
- package/SVF-osx/include/SVFIR/PAGBuilderFromFile.h +80 -0
- package/SVF-osx/include/SVFIR/SVFIR.h +661 -0
- package/SVF-osx/include/SVFIR/SVFModule.h +233 -0
- package/SVF-osx/include/SVFIR/SVFStatements.h +1101 -0
- package/SVF-osx/include/SVFIR/SVFType.h +514 -0
- package/SVF-osx/include/SVFIR/SVFValue.h +1129 -0
- package/SVF-osx/include/SVFIR/SVFVariables.h +721 -0
- package/SVF-osx/include/SVFIR/SymbolTableInfo.h +597 -0
- package/SVF-osx/include/Util/Annotator.h +1 -1
- package/SVF-osx/include/Util/CallGraphBuilder.h +74 -0
- package/SVF-osx/include/Util/Casting.h +1 -3
- package/SVF-osx/include/Util/CoreBitVector.h +1 -1
- package/SVF-osx/include/Util/CxtStmt.h +8 -8
- package/SVF-osx/include/Util/DPItem.h +1 -1
- package/SVF-osx/include/Util/ExtAPI.h +1 -1
- package/SVF-osx/include/Util/NodeIDAllocator.h +1 -1
- package/SVF-osx/include/Util/Options.h +1 -0
- package/SVF-osx/include/Util/PTAStat.h +1 -1
- package/SVF-osx/include/Util/SCC.h +1 -1
- package/SVF-osx/include/Util/SVFUtil.h +26 -95
- package/SVF-osx/include/Util/ThreadAPI.h +27 -27
- package/SVF-osx/include/Util/WorkList.h +1 -1
- package/SVF-osx/include/Util/Z3Expr.h +1 -1
- package/SVF-osx/include/WPA/Andersen.h +1 -1
- package/SVF-osx/include/WPA/CSC.h +1 -1
- package/SVF-osx/include/WPA/TypeAnalysis.h +0 -3
- package/SVF-osx/include/WPA/WPAPass.h +8 -8
- package/package.json +1 -1
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
//===- SVFIRBuilder.h -- Building SVFIR-------------------------------------------//
|
|
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
|
+
* SVFIRBuilder.h
|
|
25
|
+
*
|
|
26
|
+
* Created on: Nov 1, 2013
|
|
27
|
+
* Author: Yulei Sui
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
#ifndef PAGBUILDER_H_
|
|
31
|
+
#define PAGBUILDER_H_
|
|
32
|
+
|
|
33
|
+
#include "SVFIR/SVFIR.h"
|
|
34
|
+
#include "Util/ExtAPI.h"
|
|
35
|
+
#include "SVF-LLVM/BasicTypes.h"
|
|
36
|
+
#include "SVF-LLVM/ICFGBuilder.h"
|
|
37
|
+
|
|
38
|
+
namespace SVF
|
|
39
|
+
{
|
|
40
|
+
|
|
41
|
+
class SVFModule;
|
|
42
|
+
/*!
|
|
43
|
+
* SVFIR Builder to create SVF variables and statements and PAG
|
|
44
|
+
*/
|
|
45
|
+
class SVFIRBuilder: public llvm::InstVisitor<SVFIRBuilder>
|
|
46
|
+
{
|
|
47
|
+
|
|
48
|
+
private:
|
|
49
|
+
SVFIR* pag;
|
|
50
|
+
SVFModule* svfModule;
|
|
51
|
+
const SVFBasicBlock* curBB; ///< Current basic block during SVFIR construction when visiting the module
|
|
52
|
+
const SVFValue* curVal; ///< Current Value during SVFIR construction when visiting the module
|
|
53
|
+
|
|
54
|
+
public:
|
|
55
|
+
/// Constructor
|
|
56
|
+
SVFIRBuilder(SVFModule* mod): pag(SVFIR::getPAG()), svfModule(mod), curBB(nullptr),curVal(nullptr)
|
|
57
|
+
{
|
|
58
|
+
}
|
|
59
|
+
/// Destructor
|
|
60
|
+
virtual ~SVFIRBuilder()
|
|
61
|
+
{
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/// Start building SVFIR here
|
|
65
|
+
virtual SVFIR* build();
|
|
66
|
+
|
|
67
|
+
/// Return SVFIR
|
|
68
|
+
SVFIR* getPAG() const
|
|
69
|
+
{
|
|
70
|
+
return pag;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/// Initialize nodes and edges
|
|
74
|
+
//@{
|
|
75
|
+
void initialiseNodes();
|
|
76
|
+
void addEdge(NodeID src, NodeID dst, SVFStmt::PEDGEK kind,
|
|
77
|
+
s32_t offset = 0, Instruction* cs = nullptr);
|
|
78
|
+
// @}
|
|
79
|
+
|
|
80
|
+
/// Sanity check for SVFIR
|
|
81
|
+
void sanityCheck();
|
|
82
|
+
|
|
83
|
+
/// Get different kinds of node
|
|
84
|
+
//@{
|
|
85
|
+
// GetValNode - Return the value node according to a LLVM Value.
|
|
86
|
+
NodeID getValueNode(const Value* V)
|
|
87
|
+
{
|
|
88
|
+
// first handle gep edge if val if a constant expression
|
|
89
|
+
processCE(V);
|
|
90
|
+
|
|
91
|
+
// strip off the constant cast and return the value node
|
|
92
|
+
SVFValue* svfVal = LLVMModuleSet::getLLVMModuleSet()->getSVFValue(V);
|
|
93
|
+
return pag->getValueNode(svfVal);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/// GetObject - Return the object node (stack/global/heap/function) according to a LLVM Value
|
|
97
|
+
inline NodeID getObjectNode(const Value* V)
|
|
98
|
+
{
|
|
99
|
+
SVFValue* svfVal = LLVMModuleSet::getLLVMModuleSet()->getSVFValue(V);
|
|
100
|
+
return pag->getObjectNode(svfVal);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/// getReturnNode - Return the node representing the unique return value of a function.
|
|
104
|
+
inline NodeID getReturnNode(const SVFFunction *func)
|
|
105
|
+
{
|
|
106
|
+
return pag->getReturnNode(func);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/// getVarargNode - Return the node representing the unique variadic argument of a function.
|
|
110
|
+
inline NodeID getVarargNode(const SVFFunction *func)
|
|
111
|
+
{
|
|
112
|
+
return pag->getVarargNode(func);
|
|
113
|
+
}
|
|
114
|
+
//@}
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
/// Our visit overrides.
|
|
118
|
+
//@{
|
|
119
|
+
// Instructions that cannot be folded away.
|
|
120
|
+
virtual void visitAllocaInst(AllocaInst &AI);
|
|
121
|
+
void visitPHINode(PHINode &I);
|
|
122
|
+
void visitStoreInst(StoreInst &I);
|
|
123
|
+
void visitLoadInst(LoadInst &I);
|
|
124
|
+
void visitGetElementPtrInst(GetElementPtrInst &I);
|
|
125
|
+
void visitCallInst(CallInst &I);
|
|
126
|
+
void visitInvokeInst(InvokeInst &II);
|
|
127
|
+
void visitCallBrInst(CallBrInst &I);
|
|
128
|
+
void visitCallSite(CallBase* cs);
|
|
129
|
+
void visitReturnInst(ReturnInst &I);
|
|
130
|
+
void visitCastInst(CastInst &I);
|
|
131
|
+
void visitSelectInst(SelectInst &I);
|
|
132
|
+
void visitExtractValueInst(ExtractValueInst &EVI);
|
|
133
|
+
void visitBranchInst(BranchInst &I);
|
|
134
|
+
void visitSwitchInst(SwitchInst &I);
|
|
135
|
+
void visitInsertValueInst(InsertValueInst &I)
|
|
136
|
+
{
|
|
137
|
+
addBlackHoleAddrEdge(getValueNode(&I));
|
|
138
|
+
}
|
|
139
|
+
// TerminatorInst and UnwindInst have been removed since llvm-8.0.0
|
|
140
|
+
// void visitTerminatorInst(TerminatorInst &TI) {}
|
|
141
|
+
// void visitUnwindInst(UnwindInst &I) { /*returns void*/}
|
|
142
|
+
|
|
143
|
+
void visitBinaryOperator(BinaryOperator &I);
|
|
144
|
+
void visitUnaryOperator(UnaryOperator &I);
|
|
145
|
+
void visitCmpInst(CmpInst &I);
|
|
146
|
+
|
|
147
|
+
/// TODO: var arguments need to be handled.
|
|
148
|
+
/// https://llvm.org/docs/LangRef.html#id1911
|
|
149
|
+
void visitVAArgInst(VAArgInst&);
|
|
150
|
+
void visitVACopyInst(VACopyInst&) {}
|
|
151
|
+
void visitVAEndInst(VAEndInst&) {}
|
|
152
|
+
void visitVAStartInst(VAStartInst&) {}
|
|
153
|
+
|
|
154
|
+
/// <result> = freeze ty <val>
|
|
155
|
+
/// If <val> is undef or poison, ‘freeze’ returns an arbitrary, but fixed value of type `ty`
|
|
156
|
+
/// Otherwise, this instruction is a no-op and returns the input <val>
|
|
157
|
+
void visitFreezeInst(FreezeInst& I);
|
|
158
|
+
|
|
159
|
+
void visitExtractElementInst(ExtractElementInst &I);
|
|
160
|
+
|
|
161
|
+
void visitInsertElementInst(InsertElementInst &I)
|
|
162
|
+
{
|
|
163
|
+
addBlackHoleAddrEdge(getValueNode(&I));
|
|
164
|
+
}
|
|
165
|
+
void visitShuffleVectorInst(ShuffleVectorInst &I)
|
|
166
|
+
{
|
|
167
|
+
addBlackHoleAddrEdge(getValueNode(&I));
|
|
168
|
+
}
|
|
169
|
+
void visitLandingPadInst(LandingPadInst &I)
|
|
170
|
+
{
|
|
171
|
+
addBlackHoleAddrEdge(getValueNode(&I));
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/// Instruction not that often
|
|
175
|
+
void visitResumeInst(ResumeInst&) /*returns void*/
|
|
176
|
+
{
|
|
177
|
+
}
|
|
178
|
+
void visitUnreachableInst(UnreachableInst&) /*returns void*/
|
|
179
|
+
{
|
|
180
|
+
}
|
|
181
|
+
void visitFenceInst(FenceInst &I) /*returns void*/
|
|
182
|
+
{
|
|
183
|
+
addBlackHoleAddrEdge(getValueNode(&I));
|
|
184
|
+
}
|
|
185
|
+
void visitAtomicCmpXchgInst(AtomicCmpXchgInst &I)
|
|
186
|
+
{
|
|
187
|
+
addBlackHoleAddrEdge(getValueNode(&I));
|
|
188
|
+
}
|
|
189
|
+
void visitAtomicRMWInst(AtomicRMWInst &I)
|
|
190
|
+
{
|
|
191
|
+
addBlackHoleAddrEdge(getValueNode(&I));
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/// Provide base case for our instruction visit.
|
|
195
|
+
inline void visitInstruction(Instruction&)
|
|
196
|
+
{
|
|
197
|
+
// If a new instruction is added to LLVM that we don't handle.
|
|
198
|
+
// TODO: ignore here:
|
|
199
|
+
}
|
|
200
|
+
//}@
|
|
201
|
+
|
|
202
|
+
protected:
|
|
203
|
+
/// Handle globals including (global variable and functions)
|
|
204
|
+
//@{
|
|
205
|
+
void visitGlobal(SVFModule* svfModule);
|
|
206
|
+
void InitialGlobal(const GlobalVariable *gvar, Constant *C,
|
|
207
|
+
u32_t offset);
|
|
208
|
+
NodeID getGlobalVarField(const GlobalVariable *gvar, u32_t offset, SVFType* tpy);
|
|
209
|
+
//@}
|
|
210
|
+
|
|
211
|
+
/// Process constant expression
|
|
212
|
+
void processCE(const Value* val);
|
|
213
|
+
|
|
214
|
+
/// Infer field index from byteoffset.
|
|
215
|
+
u32_t inferFieldIdxFromByteOffset(const llvm::GEPOperator* gepOp, DataLayout *dl, LocationSet& ls, s32_t idx);
|
|
216
|
+
|
|
217
|
+
/// Compute offset of a gep instruction or gep constant expression
|
|
218
|
+
bool computeGepOffset(const User *V, LocationSet& ls);
|
|
219
|
+
|
|
220
|
+
/// Get the base value of (i8* src and i8* dst) for external argument (e.g. memcpy(i8* dst, i8* src, int size))
|
|
221
|
+
const Value* getBaseValueForExtArg(const Value* V);
|
|
222
|
+
|
|
223
|
+
/// Get the base type and max offset
|
|
224
|
+
const Type* getBaseTypeAndFlattenedFields(const Value* V, std::vector<LocationSet> &fields, const Value* sz);
|
|
225
|
+
|
|
226
|
+
/// Handle direct call
|
|
227
|
+
void handleDirectCall(CallBase* cs, const Function *F);
|
|
228
|
+
|
|
229
|
+
/// Handle indirect call
|
|
230
|
+
void handleIndCall(CallBase* cs);
|
|
231
|
+
|
|
232
|
+
/// Handle external call
|
|
233
|
+
//@{
|
|
234
|
+
virtual void parseOperations(std::vector<ExtAPI::Operation> &operations, CallBase* cs);
|
|
235
|
+
virtual void handleExtCall(CallBase* cs, const Function *F);
|
|
236
|
+
void addComplexConsForExt(const Value* D, const Value* S, const Value* sz);
|
|
237
|
+
//@}
|
|
238
|
+
|
|
239
|
+
/// Set current basic block in order to keep track of control flow information
|
|
240
|
+
inline void setCurrentLocation(const Value* val, const BasicBlock* bb)
|
|
241
|
+
{
|
|
242
|
+
curBB = (bb == nullptr? nullptr : LLVMModuleSet::getLLVMModuleSet()->getSVFBasicBlock(bb));
|
|
243
|
+
curVal = (val == nullptr ? nullptr: LLVMModuleSet::getLLVMModuleSet()->getSVFValue(val));
|
|
244
|
+
}
|
|
245
|
+
inline void setCurrentLocation(const SVFValue* val, const SVFBasicBlock* bb)
|
|
246
|
+
{
|
|
247
|
+
curBB = bb;
|
|
248
|
+
curVal = val;
|
|
249
|
+
}
|
|
250
|
+
inline const SVFValue* getCurrentValue() const
|
|
251
|
+
{
|
|
252
|
+
return curVal;
|
|
253
|
+
}
|
|
254
|
+
inline const SVFBasicBlock* getCurrentBB() const
|
|
255
|
+
{
|
|
256
|
+
return curBB;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/// Add global black hole Address edge
|
|
260
|
+
void addGlobalBlackHoleAddrEdge(NodeID node, const ConstantExpr *int2Ptrce)
|
|
261
|
+
{
|
|
262
|
+
const SVFValue* cval = getCurrentValue();
|
|
263
|
+
const SVFBasicBlock* cbb = getCurrentBB();
|
|
264
|
+
setCurrentLocation(int2Ptrce,nullptr);
|
|
265
|
+
addBlackHoleAddrEdge(node);
|
|
266
|
+
setCurrentLocation(cval,cbb);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/// Add NullPtr PAGNode
|
|
270
|
+
inline NodeID addNullPtrNode()
|
|
271
|
+
{
|
|
272
|
+
LLVMContext& cxt = LLVMModuleSet::getLLVMModuleSet()->getContext();
|
|
273
|
+
ConstantPointerNull* constNull = ConstantPointerNull::get(Type::getInt8PtrTy(cxt));
|
|
274
|
+
NodeID nullPtr = pag->addValNode(LLVMModuleSet::getLLVMModuleSet()->getSVFValue(constNull),pag->getNullPtr());
|
|
275
|
+
setCurrentLocation(constNull, nullptr);
|
|
276
|
+
addBlackHoleAddrEdge(pag->getBlkPtr());
|
|
277
|
+
return nullPtr;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
NodeID getGepValVar(const Value* val, const LocationSet& ls, const SVFType* baseType);
|
|
281
|
+
|
|
282
|
+
void setCurrentBBAndValueForPAGEdge(PAGEdge* edge);
|
|
283
|
+
|
|
284
|
+
inline void addBlackHoleAddrEdge(NodeID node)
|
|
285
|
+
{
|
|
286
|
+
if(PAGEdge *edge = pag->addBlackHoleAddrStmt(node))
|
|
287
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/// Add Address edge
|
|
291
|
+
inline AddrStmt* addAddrEdge(NodeID src, NodeID dst)
|
|
292
|
+
{
|
|
293
|
+
if(AddrStmt *edge = pag->addAddrStmt(src, dst))
|
|
294
|
+
{
|
|
295
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
296
|
+
return edge;
|
|
297
|
+
}
|
|
298
|
+
return nullptr;
|
|
299
|
+
}
|
|
300
|
+
/// Add Copy edge
|
|
301
|
+
inline CopyStmt* addCopyEdge(NodeID src, NodeID dst)
|
|
302
|
+
{
|
|
303
|
+
if(CopyStmt *edge = pag->addCopyStmt(src, dst))
|
|
304
|
+
{
|
|
305
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
306
|
+
return edge;
|
|
307
|
+
}
|
|
308
|
+
return nullptr;
|
|
309
|
+
}
|
|
310
|
+
/// Add Copy edge
|
|
311
|
+
inline void addPhiStmt(NodeID res, NodeID opnd, const ICFGNode* pred)
|
|
312
|
+
{
|
|
313
|
+
/// If we already added this phi node, then skip this adding
|
|
314
|
+
if(PhiStmt *edge = pag->addPhiStmt(res,opnd,pred))
|
|
315
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
316
|
+
}
|
|
317
|
+
/// Add SelectStmt
|
|
318
|
+
inline void addSelectStmt(NodeID res, NodeID op1, NodeID op2, NodeID cond)
|
|
319
|
+
{
|
|
320
|
+
if(SelectStmt *edge = pag->addSelectStmt(res,op1,op2,cond))
|
|
321
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
322
|
+
}
|
|
323
|
+
/// Add Copy edge
|
|
324
|
+
inline void addCmpEdge(NodeID op1, NodeID op2, NodeID dst, u32_t predict)
|
|
325
|
+
{
|
|
326
|
+
if(CmpStmt *edge = pag->addCmpStmt(op1, op2, dst, predict))
|
|
327
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
328
|
+
}
|
|
329
|
+
/// Add Copy edge
|
|
330
|
+
inline void addBinaryOPEdge(NodeID op1, NodeID op2, NodeID dst, u32_t opcode)
|
|
331
|
+
{
|
|
332
|
+
if(BinaryOPStmt *edge = pag->addBinaryOPStmt(op1, op2, dst, opcode))
|
|
333
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
334
|
+
}
|
|
335
|
+
/// Add Unary edge
|
|
336
|
+
inline void addUnaryOPEdge(NodeID src, NodeID dst, u32_t opcode)
|
|
337
|
+
{
|
|
338
|
+
if(UnaryOPStmt *edge = pag->addUnaryOPStmt(src, dst, opcode))
|
|
339
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
340
|
+
}
|
|
341
|
+
/// Add Branch statement
|
|
342
|
+
inline void addBranchStmt(NodeID br, NodeID cond, const BranchStmt::SuccAndCondPairVec& succs)
|
|
343
|
+
{
|
|
344
|
+
if(BranchStmt *edge = pag->addBranchStmt(br, cond, succs))
|
|
345
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
346
|
+
}
|
|
347
|
+
/// Add Load edge
|
|
348
|
+
inline void addLoadEdge(NodeID src, NodeID dst)
|
|
349
|
+
{
|
|
350
|
+
if(LoadStmt *edge = pag->addLoadStmt(src, dst))
|
|
351
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
352
|
+
}
|
|
353
|
+
/// Add Store edge
|
|
354
|
+
inline void addStoreEdge(NodeID src, NodeID dst)
|
|
355
|
+
{
|
|
356
|
+
IntraICFGNode* node;
|
|
357
|
+
if(const SVFInstruction* inst = SVFUtil::dyn_cast<SVFInstruction>(curVal))
|
|
358
|
+
node = pag->getICFG()->getIntraICFGNode(inst);
|
|
359
|
+
else
|
|
360
|
+
node = nullptr;
|
|
361
|
+
if(StoreStmt *edge = pag->addStoreStmt(src, dst, node))
|
|
362
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
363
|
+
}
|
|
364
|
+
/// Add Call edge
|
|
365
|
+
inline void addCallEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunEntryICFGNode* entry)
|
|
366
|
+
{
|
|
367
|
+
if(CallPE *edge = pag->addCallPE(src, dst, cs, entry))
|
|
368
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
369
|
+
}
|
|
370
|
+
/// Add Return edge
|
|
371
|
+
inline void addRetEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunExitICFGNode* exit)
|
|
372
|
+
{
|
|
373
|
+
if(RetPE *edge = pag->addRetPE(src, dst, cs, exit))
|
|
374
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
375
|
+
}
|
|
376
|
+
/// Add Gep edge
|
|
377
|
+
inline void addGepEdge(NodeID src, NodeID dst, const LocationSet& ls, bool constGep)
|
|
378
|
+
{
|
|
379
|
+
if(GepStmt *edge = pag->addGepStmt(src, dst, ls, constGep))
|
|
380
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
381
|
+
}
|
|
382
|
+
/// Add Offset(Gep) edge
|
|
383
|
+
inline void addNormalGepEdge(NodeID src, NodeID dst, const LocationSet& ls)
|
|
384
|
+
{
|
|
385
|
+
if(GepStmt *edge = pag->addNormalGepStmt(src, dst, ls))
|
|
386
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
387
|
+
}
|
|
388
|
+
/// Add Variant(Gep) edge
|
|
389
|
+
inline void addVariantGepEdge(NodeID src, NodeID dst, const LocationSet& ls)
|
|
390
|
+
{
|
|
391
|
+
if(GepStmt *edge = pag->addVariantGepStmt(src, dst, ls))
|
|
392
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
393
|
+
}
|
|
394
|
+
/// Add Thread fork edge for parameter passing
|
|
395
|
+
inline void addThreadForkEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunEntryICFGNode* entry)
|
|
396
|
+
{
|
|
397
|
+
if(TDForkPE *edge = pag->addThreadForkPE(src, dst, cs, entry))
|
|
398
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
399
|
+
}
|
|
400
|
+
/// Add Thread join edge for parameter passing
|
|
401
|
+
inline void addThreadJoinEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunExitICFGNode* exit)
|
|
402
|
+
{
|
|
403
|
+
if(TDJoinPE *edge = pag->addThreadJoinPE(src, dst, cs, exit))
|
|
404
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
405
|
+
}
|
|
406
|
+
//@}
|
|
407
|
+
|
|
408
|
+
LocationSet getLocationSetFromBaseNode(NodeID nodeId);
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
} // End namespace SVF
|
|
412
|
+
|
|
413
|
+
#endif /* PAGBUILDER_H_ */
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
//===- SymbolTableBuilder.h -- Symbol Table builder-----------------------//
|
|
2
|
+
//
|
|
3
|
+
// SVF: Static Value-Flow Analysis
|
|
4
|
+
//
|
|
5
|
+
// Copyright (C) <2013-> <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
|
+
* SymbolTableBuilder.h
|
|
25
|
+
*
|
|
26
|
+
* Created on: Apr 28, 2014
|
|
27
|
+
* Author: Yulei
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
#ifndef SymbolTableBuilder_H_
|
|
31
|
+
#define SymbolTableBuilder_H_
|
|
32
|
+
|
|
33
|
+
#include "SVF-LLVM/LLVMModule.h"
|
|
34
|
+
#include "SVFIR/SymbolTableInfo.h"
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
* This class is to build SymbolTableInfo, MemObjs and ObjTypeInfo
|
|
38
|
+
*/
|
|
39
|
+
namespace SVF
|
|
40
|
+
{
|
|
41
|
+
|
|
42
|
+
class SymbolTableBuilder
|
|
43
|
+
{
|
|
44
|
+
|
|
45
|
+
private:
|
|
46
|
+
SymbolTableInfo* symInfo;
|
|
47
|
+
|
|
48
|
+
public:
|
|
49
|
+
/// Constructor
|
|
50
|
+
SymbolTableBuilder(SymbolTableInfo* si): symInfo(si)
|
|
51
|
+
{
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/// Start building memory model
|
|
55
|
+
void buildMemModel(SVFModule* svfModule);
|
|
56
|
+
|
|
57
|
+
/// Return size of this object based on LLVM value
|
|
58
|
+
u32_t getObjSize(const Type* type);
|
|
59
|
+
|
|
60
|
+
/// Check whether this value points-to a constant object
|
|
61
|
+
bool isConstantObjSym(const Value* val);
|
|
62
|
+
|
|
63
|
+
protected:
|
|
64
|
+
|
|
65
|
+
/// collect the syms
|
|
66
|
+
//@{
|
|
67
|
+
void collectSVFTypeInfo(const Value* val);
|
|
68
|
+
|
|
69
|
+
void collectSym(const Value* val);
|
|
70
|
+
|
|
71
|
+
void collectVal(const Value* val);
|
|
72
|
+
|
|
73
|
+
void collectObj(const Value* val);
|
|
74
|
+
|
|
75
|
+
void collectRet(const Function* val);
|
|
76
|
+
|
|
77
|
+
void collectVararg(const Function* val);
|
|
78
|
+
//@}
|
|
79
|
+
|
|
80
|
+
/// Handle constant expression
|
|
81
|
+
// @{
|
|
82
|
+
void handleGlobalCE(const GlobalVariable *G);
|
|
83
|
+
void handleGlobalInitializerCE(const Constant *C);
|
|
84
|
+
void handleCE(const Value* val);
|
|
85
|
+
// @}
|
|
86
|
+
|
|
87
|
+
/// Create an objectInfo based on LLVM value
|
|
88
|
+
ObjTypeInfo* createObjTypeInfo(const Value* val);
|
|
89
|
+
|
|
90
|
+
/// Initialize TypeInfo based on LLVM Value
|
|
91
|
+
void initTypeInfo(ObjTypeInfo* typeinfo, const Value* value, const Type* ty);
|
|
92
|
+
/// Analyse types of all flattened fields of this object
|
|
93
|
+
void analyzeObjType(ObjTypeInfo* typeinfo, const Value* val);
|
|
94
|
+
/// Analyse types of heap and static objects
|
|
95
|
+
void analyzeHeapObjType(ObjTypeInfo* typeinfo, const Value* val);
|
|
96
|
+
/// Analyse types of heap and static objects
|
|
97
|
+
void analyzeStaticObjType(ObjTypeInfo* typeinfo, const Value* val);
|
|
98
|
+
|
|
99
|
+
///Get a reference to the components of struct_info.
|
|
100
|
+
/// Number of flattenned elements of an array or struct
|
|
101
|
+
u32_t getNumOfFlattenElements(const Type* T);
|
|
102
|
+
|
|
103
|
+
///Get a reference to StructInfo.
|
|
104
|
+
StInfo* getOrAddSVFTypeInfo(const Type* T);
|
|
105
|
+
|
|
106
|
+
MemObj* createBlkObj(SymID symId);
|
|
107
|
+
|
|
108
|
+
MemObj* createConstantObj(SymID symId);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
} // End namespace SVF
|
|
112
|
+
|
|
113
|
+
#endif /* SymbolTableBuilder_H_ */
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
//===- PAGBuilderFromFile.h -- Building SVFIR from File--------------------------------//
|
|
2
|
+
//
|
|
3
|
+
// SVF: Static Value-Flow Analysis
|
|
4
|
+
//
|
|
5
|
+
// Copyright (C) <2013-> <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
|
+
* PAGBuilderFromFile.h
|
|
25
|
+
*
|
|
26
|
+
* Created on: 20 Sep. 2018
|
|
27
|
+
* Author: Yulei Sui
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
#ifndef INCLUDE_MEMORYMODEL_PAGBUILDERFROMFILE_H_
|
|
31
|
+
#define INCLUDE_MEMORYMODEL_PAGBUILDERFROMFILE_H_
|
|
32
|
+
|
|
33
|
+
#include "SVFIR/SVFIR.h"
|
|
34
|
+
|
|
35
|
+
namespace SVF
|
|
36
|
+
{
|
|
37
|
+
|
|
38
|
+
/*!
|
|
39
|
+
* Build SVFIR from a user specified file (for debugging purpose)
|
|
40
|
+
*/
|
|
41
|
+
class PAGBuilderFromFile
|
|
42
|
+
{
|
|
43
|
+
|
|
44
|
+
private:
|
|
45
|
+
SVFIR* pag;
|
|
46
|
+
std::string file;
|
|
47
|
+
public:
|
|
48
|
+
/// Constructor
|
|
49
|
+
PAGBuilderFromFile(std::string f) :
|
|
50
|
+
pag(SVFIR::getPAG(true)), file(f)
|
|
51
|
+
{
|
|
52
|
+
}
|
|
53
|
+
/// Destructor
|
|
54
|
+
~PAGBuilderFromFile()
|
|
55
|
+
{
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/// Return SVFIR
|
|
59
|
+
SVFIR* getPAG() const
|
|
60
|
+
{
|
|
61
|
+
return pag;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/// Return file name
|
|
65
|
+
std::string getFileName() const
|
|
66
|
+
{
|
|
67
|
+
return file;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/// Start building
|
|
71
|
+
SVFIR* build();
|
|
72
|
+
|
|
73
|
+
// Add edges
|
|
74
|
+
void addEdge(NodeID nodeSrc, NodeID nodeDst, s32_t offset,
|
|
75
|
+
std::string edge);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
} // End namespace SVF
|
|
79
|
+
|
|
80
|
+
#endif /* INCLUDE_MEMORYMODEL_PAGBUILDERFROMFILE_H_ */
|