svf-tools 1.0.729 → 1.0.730
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svf-tools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.730",
|
|
4
4
|
"description": "* <b>[TypeClone](https://github.com/SVF-tools/SVF/wiki/TypeClone) published in our [ECOOP paper](https://yuleisui.github.io/publications/ecoop20.pdf) is now available in SVF </b> * <b>SVF now uses a single script for its build. Just type [`source ./build.sh`](https://github.com/SVF-tools/SVF/blob/master/build.sh) in your terminal, that's it!</b> * <b>SVF now supports LLVM-10.0.0! </b> * <b>We thank [bsauce](https://github.com/bsauce) for writing a user manual of SVF ([link1](https://www.jianshu.com/p/068a08ec749c) and [link2](https://www.jianshu.com/p/777c30d4240e)) in Chinese </b> * <b>SVF now supports LLVM-9.0.0 (Thank [Byoungyoung Lee](https://github.com/SVF-tools/SVF/issues/142) for his help!). </b> * <b>SVF now supports a set of [field-sensitive pointer analyses](https://yuleisui.github.io/publications/sas2019a.pdf). </b> * <b>[Use SVF as an external lib](https://github.com/SVF-tools/SVF/wiki/Using-SVF-as-a-lib-in-your-own-tool) for your own project (Contributed by [Hongxu Chen](https://github.com/HongxuChen)). </b> * <b>SVF now supports LLVM-7.0.0. </b> * <b>SVF now supports Docker. [Try SVF in Docker](https://github.com/SVF-tools/SVF/wiki/Try-SVF-in-Docker)! </b> * <b>SVF now supports [LLVM-6.0.0](https://github.com/svf-tools/SVF/pull/38) (Contributed by [Jack Anthony](https://github.com/jackanth)). </b> * <b>SVF now supports [LLVM-4.0.0](https://github.com/svf-tools/SVF/pull/23) (Contributed by Jared Carlson. Thank [Jared](https://github.com/jcarlson23) and [Will](https://github.com/dtzWill) for their in-depth [discussions](https://github.com/svf-tools/SVF/pull/18) about updating SVF!) </b> * <b>SVF now supports analysis for C++ programs.</b> <br />",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -409,6 +409,29 @@ void viewCFG(const Function* fun);
|
|
|
409
409
|
// Dump Control Flow Graph of llvm function, without instructions
|
|
410
410
|
void viewCFGOnly(const Function* fun);
|
|
411
411
|
|
|
412
|
+
/*
|
|
413
|
+
* Get the vtable struct of a class.
|
|
414
|
+
*
|
|
415
|
+
* Given the class:
|
|
416
|
+
*
|
|
417
|
+
* class A {
|
|
418
|
+
* virtual ~A();
|
|
419
|
+
* };
|
|
420
|
+
* A::~A() = default;
|
|
421
|
+
*
|
|
422
|
+
* The corresponding vtable @_ZTV1A is of type:
|
|
423
|
+
*
|
|
424
|
+
* { [4 x i8*] }
|
|
425
|
+
*
|
|
426
|
+
* If the program has been compiled with AddressSanitizer,
|
|
427
|
+
* the vtable will have redzones and appear as:
|
|
428
|
+
*
|
|
429
|
+
* { { [4 x i8*] }, [32 x i8] }
|
|
430
|
+
*
|
|
431
|
+
* See https://github.com/SVF-tools/SVF/issues/1114 for more.
|
|
432
|
+
*/
|
|
433
|
+
const ConstantStruct *getVtblStruct(const GlobalValue *vtbl);
|
|
434
|
+
|
|
412
435
|
bool isValVtbl(const Value* val);
|
|
413
436
|
bool isLoadVtblInst(const LoadInst* loadInst);
|
|
414
437
|
bool isVirtualCallSite(const CallBase* cs);
|
|
@@ -90,8 +90,7 @@ void CHGBuilder::buildCHGNodes(const GlobalValue *globalvalue)
|
|
|
90
90
|
{
|
|
91
91
|
if (LLVMUtil::isValVtbl(globalvalue) && globalvalue->getNumOperands() > 0)
|
|
92
92
|
{
|
|
93
|
-
const ConstantStruct *vtblStruct =
|
|
94
|
-
assert(vtblStruct && "Initializer of a vtable not a struct?");
|
|
93
|
+
const ConstantStruct *vtblStruct = LLVMUtil::getVtblStruct(globalvalue);
|
|
95
94
|
string className = getClassNameFromVtblObj(globalvalue->getName().str());
|
|
96
95
|
if (!chg->getNode(className))
|
|
97
96
|
createNode(className);
|
|
@@ -367,9 +366,7 @@ void CHGBuilder::analyzeVTables(const Module &M)
|
|
|
367
366
|
const GlobalValue *globalvalue = SVFUtil::dyn_cast<const GlobalValue>(&(*I));
|
|
368
367
|
if (LLVMUtil::isValVtbl(globalvalue) && globalvalue->getNumOperands() > 0)
|
|
369
368
|
{
|
|
370
|
-
const ConstantStruct *vtblStruct =
|
|
371
|
-
SVFUtil::dyn_cast<ConstantStruct>(globalvalue->getOperand(0));
|
|
372
|
-
assert(vtblStruct && "Initializer of a vtable not a struct?");
|
|
369
|
+
const ConstantStruct *vtblStruct = LLVMUtil::getVtblStruct(globalvalue);
|
|
373
370
|
|
|
374
371
|
string vtblClassName = getClassNameFromVtblObj(globalvalue->getName().str());
|
|
375
372
|
CHNode *node = chg->getNode(vtblClassName);
|
package/svf-llvm/lib/DCHG.cpp
CHANGED
|
@@ -180,8 +180,7 @@ void DCHGraph::buildVTables(const SVFModule &module)
|
|
|
180
180
|
node->setVTable(svfgv);
|
|
181
181
|
vtblToTypeMap[svfgv] = getCanonicalType(type);
|
|
182
182
|
|
|
183
|
-
const ConstantStruct *vtbls =
|
|
184
|
-
assert(vtbls && "unexpected vtable type");
|
|
183
|
+
const ConstantStruct *vtbls = LLVMUtil::getVtblStruct(gv);
|
|
185
184
|
for (unsigned nthVtbl = 0; nthVtbl < vtbls->getNumOperands(); ++nthVtbl)
|
|
186
185
|
{
|
|
187
186
|
const ConstantArray *vtbl = SVFUtil::dyn_cast<ConstantArray>(vtbls->getOperand(nthVtbl));
|
|
@@ -682,6 +682,19 @@ bool LLVMUtil::isConstantObjSym(const Value* val)
|
|
|
682
682
|
return LLVMUtil::isConstDataOrAggData(val);
|
|
683
683
|
}
|
|
684
684
|
|
|
685
|
+
const ConstantStruct *LLVMUtil::getVtblStruct(const GlobalValue *vtbl)
|
|
686
|
+
{
|
|
687
|
+
const ConstantStruct *vtblStruct = SVFUtil::dyn_cast<ConstantStruct>(vtbl->getOperand(0));
|
|
688
|
+
assert(vtblStruct && "Initializer of a vtable not a struct?");
|
|
689
|
+
|
|
690
|
+
if (vtblStruct->getNumOperands() == 2 &&
|
|
691
|
+
SVFUtil::isa<ConstantStruct>(vtblStruct->getOperand(0)) &&
|
|
692
|
+
vtblStruct->getOperand(1)->getType()->isArrayTy())
|
|
693
|
+
return SVFUtil::cast<ConstantStruct>(vtblStruct->getOperand(0));
|
|
694
|
+
|
|
695
|
+
return vtblStruct;
|
|
696
|
+
}
|
|
697
|
+
|
|
685
698
|
bool LLVMUtil::isValVtbl(const Value* val)
|
|
686
699
|
{
|
|
687
700
|
if (!SVFUtil::isa<GlobalVariable>(val))
|