svf-lib 1.0.1925 → 1.0.1927
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/bin/ae +0 -0
- package/SVF-linux/Release-build/bin/svf-ex +0 -0
- package/SVF-linux/Release-build/include/AE/Core/AbstractState.h +750 -0
- package/SVF-linux/Release-build/include/AE/Core/AbstractValue.h +514 -39
- package/SVF-linux/Release-build/include/AE/Core/AddressValue.h +32 -25
- package/SVF-linux/Release-build/include/AE/Core/ExeState.h +2 -2
- package/SVF-linux/Release-build/include/AE/Core/IntervalValue.h +9 -24
- package/SVF-linux/Release-build/include/AE/Core/RelationSolver.h +9 -9
- package/SVF-linux/Release-build/include/AE/Svfexe/{AbstractExecution.h → AbstractInterpretation.h} +24 -22
- package/SVF-linux/Release-build/include/AE/Svfexe/BufOverflowChecker.h +5 -5
- package/SVF-linux/Release-build/include/AE/Svfexe/SVFIR2ItvExeState.h +23 -25
- package/SVF-linux/Release-build/lib/libSvfCore.a +0 -0
- package/SVF-osx/Release-build/bin/ae +0 -0
- package/SVF-osx/Release-build/bin/svf-ex +0 -0
- package/SVF-osx/Release-build/include/AE/Core/AbstractState.h +2 -3
- package/SVF-osx/Release-build/include/AE/Core/IntervalValue.h +1 -0
- package/SVF-osx/Release-build/include/AE/Core/RelExeState.h +1 -1
- package/SVF-osx/Release-build/include/AE/Svfexe/AbstractInterpretation.h +3 -4
- package/SVF-osx/Release-build/include/AE/Svfexe/ICFGSimplification.h +1 -2
- package/SVF-osx/Release-build/include/AE/Svfexe/{SVFIR2ItvExeState.h → SVFIR2AbsState.h} +8 -9
- package/SVF-osx/Release-build/lib/libSvfCore.a +0 -0
- package/SVF-osx/Release-build/lib/libSvfLLVM.a +0 -0
- package/package.json +1 -1
- package/SVF-linux/Release-build/include/AE/Core/IntervalExeState.h +0 -650
- package/SVF-osx/Release-build/include/AE/Core/ConsExeState.h +0 -453
- package/SVF-osx/Release-build/include/AE/Core/ExeState.h +0 -304
- package/SVF-osx/Release-build/include/AE/Core/SingleAbsValue.h +0 -477
- package/SVF-osx/Release-build/include/AE/Core/SymState.h +0 -221
- package/SVF-osx/Release-build/include/AE/Svfexe/SVFIR2ConsExeState.h +0 -148
|
@@ -1,304 +0,0 @@
|
|
|
1
|
-
//===- ExeState.h ----General Execution States-------------------------//
|
|
2
|
-
//
|
|
3
|
-
// SVF: Static Value-Flow Analysis
|
|
4
|
-
//
|
|
5
|
-
// Copyright (C) <2013-2022> <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 Affero 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 Affero General Public License for more details.
|
|
17
|
-
|
|
18
|
-
// You should have received a copy of the GNU Affero General Public License
|
|
19
|
-
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
-
//
|
|
21
|
-
//===----------------------------------------------------------------------===//
|
|
22
|
-
/*
|
|
23
|
-
* ExeState.h
|
|
24
|
-
*
|
|
25
|
-
* Created on: Aug 4, 2022
|
|
26
|
-
* Author: Xiao Cheng
|
|
27
|
-
*
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
#ifndef Z3_EXAMPLE_EXESTATE_H
|
|
32
|
-
#define Z3_EXAMPLE_EXESTATE_H
|
|
33
|
-
|
|
34
|
-
#include "AE/Core/NumericLiteral.h"
|
|
35
|
-
#include "AE/Core/AddressValue.h"
|
|
36
|
-
#include "Util/Z3Expr.h"
|
|
37
|
-
#include "Util/SVFUtil.h"
|
|
38
|
-
|
|
39
|
-
namespace SVF
|
|
40
|
-
{
|
|
41
|
-
|
|
42
|
-
class SparseAbstractState;
|
|
43
|
-
|
|
44
|
-
/*!
|
|
45
|
-
* Base execution state
|
|
46
|
-
*/
|
|
47
|
-
class ExeState
|
|
48
|
-
{
|
|
49
|
-
friend class SVFIR2ItvExeState;
|
|
50
|
-
|
|
51
|
-
public:
|
|
52
|
-
|
|
53
|
-
typedef AddressValue Addrs;
|
|
54
|
-
typedef Map<u32_t, Addrs> VarToAddrs;
|
|
55
|
-
/// Execution state type
|
|
56
|
-
enum ExeState_TYPE
|
|
57
|
-
{
|
|
58
|
-
IntervalK, SingleValueK
|
|
59
|
-
};
|
|
60
|
-
private:
|
|
61
|
-
ExeState_TYPE _kind;
|
|
62
|
-
|
|
63
|
-
public:
|
|
64
|
-
ExeState(ExeState_TYPE kind) : _kind(kind) {}
|
|
65
|
-
|
|
66
|
-
virtual ~ExeState() = default;
|
|
67
|
-
|
|
68
|
-
ExeState(const ExeState &rhs) : _varToAddrs(rhs._varToAddrs),
|
|
69
|
-
_locToAddrs(rhs._locToAddrs) {}
|
|
70
|
-
|
|
71
|
-
ExeState(ExeState &&rhs) noexcept: _varToAddrs(std::move(rhs._varToAddrs)),
|
|
72
|
-
_locToAddrs(std::move(rhs._locToAddrs)) {}
|
|
73
|
-
|
|
74
|
-
ExeState &operator=(const ExeState &rhs)
|
|
75
|
-
{
|
|
76
|
-
if(*this != rhs)
|
|
77
|
-
{
|
|
78
|
-
_varToAddrs = rhs._varToAddrs;
|
|
79
|
-
_locToAddrs = rhs._locToAddrs;
|
|
80
|
-
}
|
|
81
|
-
return *this;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
ExeState &operator=(ExeState &&rhs) noexcept
|
|
85
|
-
{
|
|
86
|
-
if (this != &rhs)
|
|
87
|
-
{
|
|
88
|
-
_varToAddrs = std::move(rhs._varToAddrs);
|
|
89
|
-
_locToAddrs = std::move(rhs._locToAddrs);
|
|
90
|
-
}
|
|
91
|
-
return *this;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
protected:
|
|
96
|
-
VarToAddrs _varToAddrs{{0, getVirtualMemAddress(0)}}; ///< Map a variable (symbol) to its memory addresses
|
|
97
|
-
VarToAddrs _locToAddrs; ///< Map a memory address to its stored memory addresses
|
|
98
|
-
|
|
99
|
-
public:
|
|
100
|
-
|
|
101
|
-
/// get memory addresses of variable
|
|
102
|
-
virtual Addrs &getAddrs(u32_t id)
|
|
103
|
-
{
|
|
104
|
-
return _varToAddrs[id];
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/// whether the variable is in varToAddrs table
|
|
108
|
-
inline virtual bool inVarToAddrsTable(u32_t id) const
|
|
109
|
-
{
|
|
110
|
-
return _varToAddrs.find(id) != _varToAddrs.end();
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/// whether the memory address stores memory addresses
|
|
114
|
-
inline virtual bool inLocToAddrsTable(u32_t id) const
|
|
115
|
-
{
|
|
116
|
-
return _locToAddrs.find(id) != _locToAddrs.end();
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
inline virtual const VarToAddrs &getVarToAddrs() const
|
|
121
|
-
{
|
|
122
|
-
return _varToAddrs;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
inline virtual const VarToAddrs &getLocToAddrs() const
|
|
126
|
-
{
|
|
127
|
-
return _locToAddrs;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
public:
|
|
131
|
-
/// Make all value join with the other
|
|
132
|
-
bool joinWith(const ExeState &other);
|
|
133
|
-
|
|
134
|
-
/// Make all value meet with the other
|
|
135
|
-
bool meetWith(const ExeState &other);
|
|
136
|
-
|
|
137
|
-
virtual u32_t hash() const;
|
|
138
|
-
|
|
139
|
-
/// Print values of all expressions
|
|
140
|
-
virtual void printExprValues(std::ostream &oss) const {}
|
|
141
|
-
|
|
142
|
-
virtual std::string toString() const
|
|
143
|
-
{
|
|
144
|
-
return "";
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
inline ExeState_TYPE getExeStateKind() const
|
|
148
|
-
{
|
|
149
|
-
return _kind;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
public:
|
|
155
|
-
inline virtual void storeAddrs(u32_t addr, const Addrs &vaddrs)
|
|
156
|
-
{
|
|
157
|
-
assert(isVirtualMemAddress(addr) && "not virtual address?");
|
|
158
|
-
if(isNullPtr(addr)) return;
|
|
159
|
-
u32_t objId = getInternalID(addr);
|
|
160
|
-
_locToAddrs[objId] = vaddrs;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
inline virtual Addrs &loadAddrs(u32_t addr)
|
|
164
|
-
{
|
|
165
|
-
assert(isVirtualMemAddress(addr) && "not virtual address?");
|
|
166
|
-
u32_t objId = getInternalID(addr);
|
|
167
|
-
return _locToAddrs[objId];
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
inline bool isNullPtr(u32_t addr)
|
|
171
|
-
{
|
|
172
|
-
return getInternalID(addr) == 0;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
public:
|
|
176
|
-
|
|
177
|
-
virtual bool operator==(const ExeState &rhs) const;
|
|
178
|
-
|
|
179
|
-
inline virtual bool operator!=(const ExeState &rhs) const
|
|
180
|
-
{
|
|
181
|
-
return !(*this == rhs);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
bool equals(const ExeState *other) const
|
|
185
|
-
{
|
|
186
|
-
return false;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
protected:
|
|
190
|
-
|
|
191
|
-
static bool eqVarToAddrs(const VarToAddrs &lhs, const VarToAddrs &rhs)
|
|
192
|
-
{
|
|
193
|
-
if (lhs.size() != rhs.size()) return false;
|
|
194
|
-
for (const auto &item: lhs)
|
|
195
|
-
{
|
|
196
|
-
auto it = rhs.find(item.first);
|
|
197
|
-
if (it == rhs.end())
|
|
198
|
-
return false;
|
|
199
|
-
if (item.second.equals(it->second))
|
|
200
|
-
{
|
|
201
|
-
return false;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
return true;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
public:
|
|
208
|
-
|
|
209
|
-
virtual std::string varToAddrs(u32_t varId) const
|
|
210
|
-
{
|
|
211
|
-
std::stringstream exprName;
|
|
212
|
-
auto it = _varToAddrs.find(varId);
|
|
213
|
-
if (it == _varToAddrs.end())
|
|
214
|
-
{
|
|
215
|
-
exprName << "Var not in varToAddrs!\n";
|
|
216
|
-
}
|
|
217
|
-
else
|
|
218
|
-
{
|
|
219
|
-
const Addrs &vaddrs = it->second;
|
|
220
|
-
if (vaddrs.size() == 1)
|
|
221
|
-
{
|
|
222
|
-
exprName << "addr: {" << std::dec << getInternalID(*vaddrs.begin()) << "}\n";
|
|
223
|
-
}
|
|
224
|
-
else
|
|
225
|
-
{
|
|
226
|
-
exprName << "addr: {";
|
|
227
|
-
for (const auto &addr: vaddrs)
|
|
228
|
-
{
|
|
229
|
-
exprName << std::dec << getInternalID(addr) << ", ";
|
|
230
|
-
}
|
|
231
|
-
exprName << "}\n";
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
return SVFUtil::move(exprName.str());
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
virtual std::string locToAddrs(u32_t objId) const
|
|
238
|
-
{
|
|
239
|
-
std::stringstream exprName;
|
|
240
|
-
auto it = _locToAddrs.find(objId);
|
|
241
|
-
if (it == _locToAddrs.end())
|
|
242
|
-
{
|
|
243
|
-
exprName << "Var not in varToAddrs!\n";
|
|
244
|
-
}
|
|
245
|
-
else
|
|
246
|
-
{
|
|
247
|
-
const Addrs &vaddrs = it->second;
|
|
248
|
-
if (vaddrs.size() == 1)
|
|
249
|
-
{
|
|
250
|
-
exprName << "addr: {" << std::dec << getInternalID(*vaddrs.begin()) << "}\n";
|
|
251
|
-
}
|
|
252
|
-
else
|
|
253
|
-
{
|
|
254
|
-
exprName << "addr: {";
|
|
255
|
-
for (const auto &addr: vaddrs)
|
|
256
|
-
{
|
|
257
|
-
exprName << std::dec << getInternalID(addr) << ", ";
|
|
258
|
-
}
|
|
259
|
-
exprName << "}\n";
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
return SVFUtil::move(exprName.str());
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
public:
|
|
266
|
-
static z3::context &getContext()
|
|
267
|
-
{
|
|
268
|
-
return Z3Expr::getContext();
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
/// The physical address starts with 0x7f...... + idx
|
|
272
|
-
static inline u32_t getVirtualMemAddress(u32_t idx)
|
|
273
|
-
{
|
|
274
|
-
return AddressValue::getVirtualMemAddress(idx);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
/// Check bit value of val start with 0x7F000000, filter by 0xFF000000
|
|
278
|
-
static inline bool isVirtualMemAddress(u32_t val)
|
|
279
|
-
{
|
|
280
|
-
return AddressValue::isVirtualMemAddress(val);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
/// Return the internal index if idx is an address otherwise return the value of idx
|
|
284
|
-
static inline u32_t getInternalID(u32_t idx)
|
|
285
|
-
{
|
|
286
|
-
return AddressValue::getInternalID(idx);
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
}; // end class ExeState
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
} // end namespace SVF
|
|
295
|
-
|
|
296
|
-
template<>
|
|
297
|
-
struct std::hash<SVF::ExeState>
|
|
298
|
-
{
|
|
299
|
-
size_t operator()(const SVF::ExeState &es) const
|
|
300
|
-
{
|
|
301
|
-
return es.hash();
|
|
302
|
-
}
|
|
303
|
-
};
|
|
304
|
-
#endif //Z3_EXAMPLE_EXESTATE_H
|