svf-tools 1.0.704 → 1.0.705

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.704",
3
+ "version": "1.0.705",
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": {
@@ -31,8 +31,8 @@
31
31
  #define __ExtAPI_H
32
32
 
33
33
  #include "SVFIR/SVFValue.h"
34
- #include "Util/cJSON.h"
35
- #include "Util/config.h"
34
+ #include <Util/cJSON.h>
35
+ #include <Util/config.h>
36
36
  #include <string>
37
37
  #include <map>
38
38
 
@@ -261,7 +261,9 @@ public:
261
261
  static void destory();
262
262
 
263
263
  // Add an entry with the specified fields to the ExtAPI, which will be reflected immediately by further ExtAPI queries
264
- void add_entry(const char* funName, extType type, bool overwrite_app_function);
264
+ void add_entry(const char* funName, const char* returnType,
265
+ std::vector<const char*> argTypes, extType type,
266
+ bool overwrite_app_function);
265
267
 
266
268
  // Get numeric index of the argument in external function
267
269
  u32_t getArgPos(const std::string& s);
@@ -299,6 +301,9 @@ public:
299
301
  // 0: Apply user-defined functions
300
302
  // 1: Apply function specification in ExtAPI.json
301
303
  u32_t isOverwrittenAppFunction(const SVF::SVFFunction *callee);
304
+ u32_t isOverwrittenAppFunction(const std::string& funcName);
305
+ // set priority of the function
306
+ void setOverWrittenAppFunction(const std::string& funcName, u32_t overwrite_app_function);
302
307
 
303
308
  // Does (F) have a static var X (unavailable to us) that its return points to?
304
309
  bool has_static(const SVFFunction *F);
@@ -185,13 +185,30 @@ void ExtAPI::destory()
185
185
  }
186
186
  }
187
187
 
188
- void ExtAPI::add_entry(const char* funName, extType type,
188
+ void ExtAPI::add_entry(const char* funName, const char* returnType,
189
+ std::vector<const char*> argTypes, extType type,
189
190
  bool overwrite_app_function)
190
191
  {
191
- assert(root);
192
- assert(get_type(funName) == EFT_NULL);
192
+ assert(root && "Parse the json before adding additional entries");
193
+ assert(get_type(funName) == EFT_NULL && "Do not add entries that already exist");
193
194
  auto entry = cJSON_CreateObject();
194
195
 
196
+ // add the signature fields
197
+ auto returnTypeString = cJSON_CreateString(returnType);
198
+ cJSON_AddItemToObject(entry, "return", returnTypeString);
199
+
200
+ std::stringstream ss;
201
+ ss << "(";
202
+ for (auto str : argTypes)
203
+ ss << str << ",";
204
+ std::string formattedArgs = ss.str();
205
+ if (formattedArgs.back() == ',')
206
+ formattedArgs.back() = ')';
207
+ else
208
+ formattedArgs.append(")");
209
+ auto argsString = cJSON_CreateString(formattedArgs.c_str());
210
+ cJSON_AddItemToObject(entry, "argument", argsString);
211
+
195
212
  // add the type field
196
213
  auto typeString = cJSON_CreateString(extType_toString(type).c_str());
197
214
  cJSON_AddItemToObject(entry, JSON_OPT_FUNCTIONTYPE, typeString);
@@ -200,8 +217,8 @@ void ExtAPI::add_entry(const char* funName, extType type,
200
217
  auto overwriteBool = cJSON_CreateNumber(overwrite_app_function ? 1 : 0);
201
218
  cJSON_AddItemToObject(entry, JSON_OPT_OVERWRITE, overwriteBool);
202
219
 
203
- // we don't know where the `funName` comes from, so copy it just in case
204
- cJSON_AddItemToObject(root, strdup(funName), entry);
220
+ // add object to root
221
+ cJSON_AddItemToObject(root, funName, entry);
205
222
  }
206
223
 
207
224
  // Get the corresponding name in ext_t, e.g. "EXT_ADDR" in {"addr", EXT_ADDR},
@@ -416,6 +433,11 @@ ExtAPI::extType ExtAPI::get_type(const SVF::SVFFunction* F)
416
433
  u32_t ExtAPI::isOverwrittenAppFunction(const SVF::SVFFunction* callee)
417
434
  {
418
435
  std::string funName = get_name(callee);
436
+ return isOverwrittenAppFunction(funName);
437
+ }
438
+
439
+ u32_t ExtAPI::isOverwrittenAppFunction(const std::string& funName)
440
+ {
419
441
  cJSON* item = get_FunJson(funName);
420
442
  if (item != nullptr)
421
443
  {
@@ -429,6 +451,16 @@ u32_t ExtAPI::isOverwrittenAppFunction(const SVF::SVFFunction* callee)
429
451
  return 0;
430
452
  }
431
453
 
454
+ void ExtAPI::setOverWrittenAppFunction(const std::string& funcName, u32_t overwrite_app_function)
455
+ {
456
+ auto item = get_FunJson(funcName);
457
+ assert(item && "Do not set fields for ExtAPI funcs that don't exist!");
458
+ auto overwrite_obj = item->child->next->next->next;
459
+ assert(overwrite_obj);
460
+ assert(strcmp(overwrite_obj->string, JSON_OPT_OVERWRITE) == 0);
461
+ cJSON_SetIntValue(overwrite_obj, overwrite_app_function);
462
+ }
463
+
432
464
  // Does (F) have a static var X (unavailable to us) that its return points to?
433
465
  bool ExtAPI::has_static(const SVFFunction* F)
434
466
  {