svf-lib 1.0.2503 → 1.0.2505
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-aarch64/bin/ae +0 -0
- package/SVF-linux-aarch64/bin/svf-ex +0 -0
- package/SVF-linux-aarch64/include/AE/Core/AbstractState.h +51 -106
- package/SVF-linux-aarch64/include/AE/Svfexe/AbstractInterpretation.h +4 -4
- package/SVF-linux-aarch64/lib/libSvfCore.so.3.3 +0 -0
- package/SVF-osx/include/AE/Svfexe/AbstractInterpretation.h +5 -13
- package/SVF-osx/lib/libSvfCore.3.3.dylib +0 -0
- package/package.json +1 -1
package/SVF-linux-aarch64/bin/ae
CHANGED
|
Binary file
|
|
Binary file
|
|
@@ -49,9 +49,6 @@
|
|
|
49
49
|
#include "AE/Core/AbstractValue.h"
|
|
50
50
|
#include "AE/Core/IntervalValue.h"
|
|
51
51
|
#include "SVFIR/SVFVariables.h"
|
|
52
|
-
#include "Util/Z3Expr.h"
|
|
53
|
-
|
|
54
|
-
#include <iomanip>
|
|
55
52
|
|
|
56
53
|
namespace SVF
|
|
57
54
|
{
|
|
@@ -62,10 +59,6 @@ class AbstractState
|
|
|
62
59
|
public:
|
|
63
60
|
typedef Map<u32_t, AbstractValue> VarToAbsValMap;
|
|
64
61
|
typedef VarToAbsValMap AddrToAbsValMap;
|
|
65
|
-
Set<NodeID> _freedAddrs;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
public:
|
|
69
62
|
/// default constructor
|
|
70
63
|
AbstractState()
|
|
71
64
|
{
|
|
@@ -74,7 +67,7 @@ public:
|
|
|
74
67
|
AbstractState(VarToAbsValMap&_varToValMap, AddrToAbsValMap&_locToValMap) : _varToAbsVal(_varToValMap), _addrToAbsVal(_locToValMap) {}
|
|
75
68
|
|
|
76
69
|
/// copy constructor
|
|
77
|
-
AbstractState(const AbstractState&rhs) :
|
|
70
|
+
AbstractState(const AbstractState&rhs) : _varToAbsVal(rhs.getVarToVal()), _addrToAbsVal(rhs.getLocToVal()), _freedAddrs(rhs._freedAddrs)
|
|
78
71
|
{
|
|
79
72
|
|
|
80
73
|
}
|
|
@@ -112,41 +105,19 @@ public:
|
|
|
112
105
|
}
|
|
113
106
|
|
|
114
107
|
/// Return the internal index if addr is an address otherwise return the value of idx
|
|
115
|
-
inline u32_t getIDFromAddr(u32_t addr)
|
|
108
|
+
inline u32_t getIDFromAddr(u32_t addr) const
|
|
116
109
|
{
|
|
117
110
|
return _freedAddrs.count(addr) ? AddressValue::getInternalID(BlackHoleObjAddr) : AddressValue::getInternalID(addr);
|
|
118
111
|
}
|
|
119
112
|
|
|
120
|
-
AbstractState&operator=(const AbstractState&rhs)
|
|
121
|
-
{
|
|
122
|
-
if (rhs != *this)
|
|
123
|
-
{
|
|
124
|
-
_varToAbsVal = rhs._varToAbsVal;
|
|
125
|
-
_addrToAbsVal = rhs._addrToAbsVal;
|
|
126
|
-
_freedAddrs = rhs._freedAddrs;
|
|
127
|
-
}
|
|
128
|
-
return *this;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
113
|
/// move constructor
|
|
132
114
|
AbstractState(AbstractState&&rhs) : _varToAbsVal(std::move(rhs._varToAbsVal)),
|
|
133
|
-
_addrToAbsVal(std::move(rhs._addrToAbsVal))
|
|
115
|
+
_addrToAbsVal(std::move(rhs._addrToAbsVal)),
|
|
116
|
+
_freedAddrs(std::move(rhs._freedAddrs))
|
|
134
117
|
{
|
|
135
118
|
|
|
136
119
|
}
|
|
137
120
|
|
|
138
|
-
/// operator= move constructor
|
|
139
|
-
AbstractState&operator=(AbstractState&&rhs)
|
|
140
|
-
{
|
|
141
|
-
if (&rhs != this)
|
|
142
|
-
{
|
|
143
|
-
_varToAbsVal = std::move(rhs._varToAbsVal);
|
|
144
|
-
_addrToAbsVal = std::move(rhs._addrToAbsVal);
|
|
145
|
-
_freedAddrs = std::move(rhs._freedAddrs);
|
|
146
|
-
}
|
|
147
|
-
return *this;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
121
|
/// Set all value bottom
|
|
151
122
|
AbstractState bottom() const
|
|
152
123
|
{
|
|
@@ -176,9 +147,7 @@ public:
|
|
|
176
147
|
{
|
|
177
148
|
AbstractState inv;
|
|
178
149
|
for (u32_t id: sl)
|
|
179
|
-
{
|
|
180
150
|
inv._varToAbsVal[id] = _varToAbsVal[id];
|
|
181
|
-
}
|
|
182
151
|
return inv;
|
|
183
152
|
}
|
|
184
153
|
|
|
@@ -196,6 +165,7 @@ public:
|
|
|
196
165
|
protected:
|
|
197
166
|
VarToAbsValMap _varToAbsVal; ///< Map a variable (symbol) to its abstract value
|
|
198
167
|
AddrToAbsValMap _addrToAbsVal; ///< Map a memory address to its stored abstract value
|
|
168
|
+
Set<NodeID> _freedAddrs;
|
|
199
169
|
|
|
200
170
|
public:
|
|
201
171
|
|
|
@@ -203,24 +173,46 @@ public:
|
|
|
203
173
|
/// get abstract value of variable
|
|
204
174
|
inline virtual AbstractValue &operator[](u32_t varId)
|
|
205
175
|
{
|
|
176
|
+
assert(!isVirtualMemAddress(varId) && "varId is a virtual memory address, use load() instead");
|
|
206
177
|
return _varToAbsVal[varId];
|
|
207
178
|
}
|
|
208
179
|
|
|
209
180
|
/// get abstract value of variable
|
|
210
181
|
inline virtual const AbstractValue &operator[](u32_t varId) const
|
|
211
182
|
{
|
|
183
|
+
assert(!isVirtualMemAddress(varId) && "varId is a virtual memory address, use load() instead");
|
|
212
184
|
return _varToAbsVal.at(varId);
|
|
213
185
|
}
|
|
214
186
|
|
|
187
|
+
inline virtual AbstractValue &load(u32_t addr)
|
|
188
|
+
{
|
|
189
|
+
assert(isVirtualMemAddress(addr) && "not virtual address?");
|
|
190
|
+
u32_t objId = getIDFromAddr(addr);
|
|
191
|
+
return _addrToAbsVal[objId];
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
inline virtual const AbstractValue &load(u32_t addr) const
|
|
195
|
+
{
|
|
196
|
+
assert(isVirtualMemAddress(addr) && "not virtual address?");
|
|
197
|
+
u32_t objId = getIDFromAddr(addr);
|
|
198
|
+
return _addrToAbsVal.at(objId);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
inline void store(u32_t addr, const AbstractValue &val)
|
|
202
|
+
{
|
|
203
|
+
assert(isVirtualMemAddress(addr) && "not virtual address?");
|
|
204
|
+
u32_t objId = getIDFromAddr(addr);
|
|
205
|
+
if (isNullMem(addr)) return;
|
|
206
|
+
_addrToAbsVal[objId] = val;
|
|
207
|
+
}
|
|
208
|
+
|
|
215
209
|
/// whether the variable is in varToAddrs table
|
|
216
210
|
inline bool inVarToAddrsTable(u32_t id) const
|
|
217
211
|
{
|
|
218
212
|
if (_varToAbsVal.find(id)!= _varToAbsVal.end())
|
|
219
213
|
{
|
|
220
214
|
if (_varToAbsVal.at(id).isAddr())
|
|
221
|
-
{
|
|
222
215
|
return true;
|
|
223
|
-
}
|
|
224
216
|
}
|
|
225
217
|
return false;
|
|
226
218
|
}
|
|
@@ -231,9 +223,7 @@ public:
|
|
|
231
223
|
if (_varToAbsVal.find(id) != _varToAbsVal.end())
|
|
232
224
|
{
|
|
233
225
|
if (_varToAbsVal.at(id).isInterval())
|
|
234
|
-
{
|
|
235
226
|
return true;
|
|
236
|
-
}
|
|
237
227
|
}
|
|
238
228
|
return false;
|
|
239
229
|
}
|
|
@@ -265,19 +255,17 @@ public:
|
|
|
265
255
|
}
|
|
266
256
|
|
|
267
257
|
/// get var2val map
|
|
268
|
-
const VarToAbsValMap&getVarToVal() const
|
|
258
|
+
inline const VarToAbsValMap&getVarToVal() const
|
|
269
259
|
{
|
|
270
260
|
return _varToAbsVal;
|
|
271
261
|
}
|
|
272
262
|
|
|
273
263
|
/// get loc2val map
|
|
274
|
-
const AddrToAbsValMap&getLocToVal() const
|
|
264
|
+
inline const AddrToAbsValMap&getLocToVal() const
|
|
275
265
|
{
|
|
276
266
|
return _addrToAbsVal;
|
|
277
267
|
}
|
|
278
268
|
|
|
279
|
-
public:
|
|
280
|
-
|
|
281
269
|
/// domain widen with other, and return the widened domain
|
|
282
270
|
AbstractState widening(const AbstractState&other);
|
|
283
271
|
|
|
@@ -310,81 +298,39 @@ public:
|
|
|
310
298
|
*/
|
|
311
299
|
const SVFType* getPointeeElement(NodeID id);
|
|
312
300
|
|
|
313
|
-
|
|
314
|
-
u32_t hash() const;
|
|
315
|
-
|
|
316
|
-
public:
|
|
317
|
-
inline void store(u32_t addr, const AbstractValue &val)
|
|
318
|
-
{
|
|
319
|
-
assert(isVirtualMemAddress(addr) && "not virtual address?");
|
|
320
|
-
u32_t objId = getIDFromAddr(addr);
|
|
321
|
-
if (isNullMem(addr)) return;
|
|
322
|
-
_addrToAbsVal[objId] = val;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
inline virtual AbstractValue &load(u32_t addr)
|
|
326
|
-
{
|
|
327
|
-
assert(isVirtualMemAddress(addr) && "not virtual address?");
|
|
328
|
-
u32_t objId = getIDFromAddr(addr);
|
|
329
|
-
return _addrToAbsVal[objId];
|
|
330
|
-
|
|
331
|
-
}
|
|
332
|
-
|
|
333
301
|
void printAbstractState() const;
|
|
334
302
|
|
|
335
|
-
|
|
336
|
-
{
|
|
337
|
-
return "";
|
|
338
|
-
}
|
|
303
|
+
u32_t hash() const;
|
|
339
304
|
|
|
305
|
+
// lhs == rhs for varToValMap
|
|
306
|
+
bool eqVarToValMap(const VarToAbsValMap&lhs, const VarToAbsValMap&rhs) const;
|
|
307
|
+
// lhs >= rhs for varToValMap
|
|
308
|
+
bool geqVarToValMap(const VarToAbsValMap&lhs, const VarToAbsValMap&rhs) const;
|
|
309
|
+
// lhs == rhs for AbstractState
|
|
340
310
|
bool equals(const AbstractState&other) const;
|
|
341
311
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
{
|
|
345
|
-
if (lhs.size() != rhs.size()) return false;
|
|
346
|
-
for (const auto &item: lhs)
|
|
347
|
-
{
|
|
348
|
-
auto it = rhs.find(item.first);
|
|
349
|
-
if (it == rhs.end())
|
|
350
|
-
return false;
|
|
351
|
-
if (!item.second.equals(it->second))
|
|
352
|
-
return false;
|
|
353
|
-
else
|
|
354
|
-
{
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
return true;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
static bool lessThanVarToValMap(const VarToAbsValMap&lhs, const VarToAbsValMap&rhs)
|
|
312
|
+
/// Assignment operator
|
|
313
|
+
AbstractState&operator=(const AbstractState&rhs)
|
|
361
314
|
{
|
|
362
|
-
if (
|
|
363
|
-
for (const auto &item: lhs)
|
|
315
|
+
if (&rhs != this)
|
|
364
316
|
{
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
if (item.second.getInterval().contain(it->second.getInterval())) return false;
|
|
317
|
+
_varToAbsVal = rhs._varToAbsVal;
|
|
318
|
+
_addrToAbsVal = rhs._addrToAbsVal;
|
|
319
|
+
_freedAddrs = rhs._freedAddrs;
|
|
369
320
|
}
|
|
370
|
-
return
|
|
321
|
+
return *this;
|
|
371
322
|
}
|
|
372
323
|
|
|
373
|
-
|
|
374
|
-
|
|
324
|
+
/// operator= move constructor
|
|
325
|
+
AbstractState&operator=(AbstractState&&rhs)
|
|
375
326
|
{
|
|
376
|
-
if (rhs
|
|
377
|
-
for (const auto &item: rhs)
|
|
327
|
+
if (&rhs != this)
|
|
378
328
|
{
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
if (!it->second.getInterval().contain(
|
|
383
|
-
item.second.getInterval()))
|
|
384
|
-
return false;
|
|
385
|
-
|
|
329
|
+
_varToAbsVal = std::move(rhs._varToAbsVal);
|
|
330
|
+
_addrToAbsVal = std::move(rhs._addrToAbsVal);
|
|
331
|
+
_freedAddrs = std::move(rhs._freedAddrs);
|
|
386
332
|
}
|
|
387
|
-
return
|
|
333
|
+
return *this;
|
|
388
334
|
}
|
|
389
335
|
|
|
390
336
|
bool operator==(const AbstractState&rhs) const
|
|
@@ -403,7 +349,6 @@ public:
|
|
|
403
349
|
return !(*this >= rhs);
|
|
404
350
|
}
|
|
405
351
|
|
|
406
|
-
|
|
407
352
|
bool operator>=(const AbstractState&rhs) const
|
|
408
353
|
{
|
|
409
354
|
return geqVarToValMap(_varToAbsVal, rhs.getVarToVal()) && geqVarToValMap(_addrToAbsVal, rhs.getLocToVal());
|
|
@@ -113,16 +113,16 @@ public:
|
|
|
113
113
|
AbstractState& getAbstractState(const ICFGNode* node);
|
|
114
114
|
|
|
115
115
|
/// Check if an abstract state exists in the trace for a given ICFG node
|
|
116
|
-
bool
|
|
116
|
+
bool hasAbstractState(const ICFGNode* node);
|
|
117
117
|
|
|
118
118
|
/// Retrieve abstract value for a top-level variable at a given ICFG node
|
|
119
|
-
AbstractValue& getAbstractValue(const ICFGNode* node, const ValVar* var);
|
|
119
|
+
const AbstractValue& getAbstractValue(const ICFGNode* node, const ValVar* var);
|
|
120
120
|
|
|
121
121
|
/// Retrieve abstract value for an address-taken variable at a given ICFG node
|
|
122
|
-
AbstractValue& getAbstractValue(const ICFGNode* node, const ObjVar* var);
|
|
122
|
+
const AbstractValue& getAbstractValue(const ICFGNode* node, const ObjVar* var);
|
|
123
123
|
|
|
124
124
|
/// Retrieve abstract value for any SVF variable at a given ICFG node
|
|
125
|
-
AbstractValue& getAbstractValue(const ICFGNode* node, const SVFVar* var);
|
|
125
|
+
const AbstractValue& getAbstractValue(const ICFGNode* node, const SVFVar* var);
|
|
126
126
|
|
|
127
127
|
/// Retrieve abstract state filtered to specific top-level variables
|
|
128
128
|
void getAbstractState(const ICFGNode* node, const Set<const ValVar*>& vars, AbstractState& result);
|
|
Binary file
|
|
@@ -138,15 +138,13 @@ private:
|
|
|
138
138
|
/// Initialize abstract state for the global ICFG node and process global statements
|
|
139
139
|
virtual void handleGlobalNode();
|
|
140
140
|
|
|
141
|
-
///
|
|
142
|
-
|
|
141
|
+
/// Propagate the post-state of a node to all its intra-procedural successors
|
|
142
|
+
void propagateToSuccessor(const ICFGNode* node,
|
|
143
|
+
const Set<const ICFGNode*>* withinSet = nullptr);
|
|
143
144
|
|
|
144
145
|
/// Check if the branch on intraEdge is feasible under abstract state as
|
|
145
146
|
bool isBranchFeasible(const IntraCFGEdge* intraEdge, AbstractState& as);
|
|
146
147
|
|
|
147
|
-
/// Process all SVF statements in a singleton WTO component (single basic block)
|
|
148
|
-
virtual void handleSingletonWTO(const ICFGSingletonWTO *icfgSingletonWto);
|
|
149
|
-
|
|
150
148
|
/// Handle a call site node: dispatch to ext-call, direct-call, or indirect-call handling
|
|
151
149
|
virtual void handleCallSite(const ICFGNode* node);
|
|
152
150
|
|
|
@@ -156,15 +154,9 @@ private:
|
|
|
156
154
|
/// Handle a function body via worklist-driven WTO traversal starting from funEntry
|
|
157
155
|
void handleFunction(const ICFGNode* funEntry, const CallICFGNode* caller = nullptr);
|
|
158
156
|
|
|
159
|
-
///
|
|
157
|
+
/// Handle an ICFG node: execute statements; return true if state changed
|
|
160
158
|
bool handleICFGNode(const ICFGNode* node);
|
|
161
159
|
|
|
162
|
-
/// Get intra-procedural successor nodes (including call-to-ret shortcut) within the same function
|
|
163
|
-
std::vector<const ICFGNode*> getNextNodes(const ICFGNode* node) const;
|
|
164
|
-
|
|
165
|
-
/// Get successor nodes that exit the given WTO cycle (skipping inner sub-cycles)
|
|
166
|
-
std::vector<const ICFGNode*> getNextNodesOfCycle(const ICFGCycleWTO* cycle) const;
|
|
167
|
-
|
|
168
160
|
/// Dispatch an SVF statement (Addr/Binary/Cmp/Load/Store/Copy/Gep/Select/Phi/Call/Ret) to its handler
|
|
169
161
|
virtual void handleSVFStatement(const SVFStmt* stmt);
|
|
170
162
|
|
|
@@ -232,7 +224,7 @@ private:
|
|
|
232
224
|
// there data should be shared with subclasses
|
|
233
225
|
Map<std::string, std::function<void(const CallICFGNode*)>> func_map;
|
|
234
226
|
|
|
235
|
-
Map<const ICFGNode*, AbstractState> abstractTrace; // abstract states
|
|
227
|
+
Map<const ICFGNode*, AbstractState> abstractTrace; // abstract states for nodes (pre-state before execution, post-state after)
|
|
236
228
|
Set<const ICFGNode*> allAnalyzedNodes; // All nodes ever analyzed (across all entry points)
|
|
237
229
|
std::string moduleName;
|
|
238
230
|
|
|
Binary file
|