svf-lib 1.0.1349 → 1.0.1351

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.
@@ -47,56 +47,81 @@ namespace SVF
47
47
 
48
48
  ** Specifications in ExtAPI.json
49
49
 
50
- *** [1] Overview of the Specification Language
50
+ **** Overview of the Specification Language
51
51
  The specification language of external functions is based on the JSON format. And every function defined by the Specification Language is an object that represents the specification rules. These Specification Language objects for functions contain four parts:
52
- 1. the name of the function,
53
- 2. the switch that controls whether the specification rules defined in the ExtAPI.json overwrite the functions defined in the user code,
54
- 3. the type of the function,
55
- 4. the operations conducted by the function.
52
+ 1. the signature of the function, (Mandatory)
53
+ 2. the type of the function, (Mandatory)
54
+ 3. the switch that controls whether the specification rules defined in the ExtAPI.json overwrite the functions defined in the user code, (Mandatory)
55
+ 4. the side-effect of the function. (Optional)
56
56
 
57
- *** [2] Overwriting the user-defined functions
58
- The switch *overwrite_app_function* controls whether the specification rules defined in the ExtAPI.json overwrite the functions defined in the user code (e.g., CPP files). When the switch *overwrite_app_function* is set to a value of 1, SVF will use the specification rules in ExtAPI.json to conduct the analysis and ignore the user-defined functions in the input CPP/bc files.
59
- overwrite_app_function = 0: Analyze the user-defined functions.
60
- overwrite_app_function = 1: Use specifications in ExtAPI.json to overwrite the user-defined functions.
57
+ *** [1] the signature of the function (Mandatory)
58
+ "return": return value type (Only care about whether the return value is a pointer during analysis)
59
+ "argument": argument types (Only care about the number of arguments during analysis)
61
60
 
62
- *** [3] Function types
61
+
62
+ *** [2] the type of the function (Mandatory)
63
63
  Function type represents the properties of the function.
64
64
  For example,
65
65
  "EFT_ALLOC" represents if this external function allocates a new object and assigns it to one of its arguments,
66
66
  For the selection of function type and a more detailed explanation, please refer to the definition of enum *extType* in ExtAPI.h.
67
67
 
68
- *** [4] Function operations
69
- Function operations indicate the relationships between input and output,
68
+
69
+ *** [3] the switch that controls whether the specification rules defined in the ExtAPI.json overwrite the functions defined in the user code (Mandatory)
70
+ The switch *overwrite_app_function* controls whether the specification rules defined in the ExtAPI.json overwrite the functions defined in the user code (e.g., CPP files). When the switch *overwrite_app_function* is set to a value of 1, SVF will use the specification rules in ExtAPI.json to conduct the analysis and ignore the user-defined functions in the input CPP/bc files.
71
+ overwrite_app_function = 0: Analyze the user-defined functions.
72
+ overwrite_app_function = 1: Use specifications in ExtAPI.json to overwrite the user-defined functions.
73
+
74
+ For example, The following is the code to be analyzed, which has a foo() function,
75
+ --------------------------------------------------------
76
+ char* foo(char* arg)
77
+ {
78
+ return arg;
79
+ }
80
+
81
+ int main()
82
+ {
83
+ char* ret = foo("abc");
84
+ return 0;
85
+ }
86
+ --------------------------------------------------------
87
+ function foo() has a definition, but you want SVF not to use this definition when analyzing, and you think foo () should do nothing, Then you can add a new entry in ExtAPI.json, and set *"overwrite_app_function": 1*
88
+ "foo": {
89
+ "return": "char*",
90
+ "arguments": "(char*)",
91
+ "type": "EFT_NOOP",
92
+ "overwrite_app_function": 1
93
+ }
94
+ When SVF is analyzing foo(), SVF will use the entry you defined in ExtAPI.json, and ignore the actual definition of foo() in the program.
95
+
96
+ Most of the time, overwrite_app_function is 0, unless you want to redefine a function.
97
+
98
+
99
+ *** [4] the side-effect of the function (Optional, if there is no side-effect of that function)
100
+ Function side-effect indicate the relationships between input and output,
70
101
  mainly between function parameters or between parameters and return values after the execution.
71
102
  For example,
72
- "copy": ["A2", "L"] indicates that after this external function is executed, the value of the 2nd parameter is copied into the return value.
73
- For the selection of function type and a more detailed explanation, please refer to the definition of enum *extf_t* in ExtAPI.h.
74
-
75
- For operands of function operation, e.g., "A2", "L", there are the following options:
76
- "A": represents a parameter;
77
- "N": represents a number;
78
- "R": represents a reference;
79
- "L": represents a return value;
80
- "V": represents a dummy node;
81
-
82
- Among them, a parameter may have multiple forms because there may be various parameters, and the parameter may be a reference or complex structure,
83
-
84
- Here we use regular expressions "(AN)(R|RN)^*" to represent parameters, for example,
85
- "A0": represents the 1st parameter;
86
- "A2R": represents that the 3rd parameter is a reference;
87
- "A1R2": represents the 3rd substructure of the 2nd parameter "A1R", where "A1R" is a complex structure;
88
- "A2R3R": represents the 4th substructure of the 3rd parameter "A2R" is a reference, where "A2R" is a complex structure;
89
-
90
-
91
- ** Specification format:
92
- "functionName": {
93
- "type": "functional type",
94
- "overwrite_app_function:" 0/1,
95
- "function operation_1": [ operand_1, operand_2, ... , operand_n],
96
- "function operation_2": [ operand_1, operand_2, ... , operand_n],
97
- ...
98
- "function operation_n": [ operand_1, operand_2, ... , operand_n]
99
- }
103
+ "CopyStmt": ["Arg2", "Ret"] indicates that after this external function is executed, the value of the 2nd parameter is copied into the return value.
104
+
105
+ For operators of function operation, there are the following options:
106
+ "AddrStmt",
107
+ "CopyStmt",
108
+ "LoadStmt"
109
+ "StoreStmt",
110
+ "GepStmt",
111
+ "BinaryOPStmt",
112
+ "UnaryOPStmt",
113
+ "CmpStmt",
114
+ "memset_like": the function has similar side-effect to function "void *memset(void *str, int c, size_t n)",
115
+ "memcpy_like": the function has similar side-effect to function "void *memcpy(void *dest, const void * src, size_t n)",
116
+ "funptr_ops": the function has similar side-effect to function "void *dlsym(void *handle, const char *symbol)",
117
+ "Rb_tree_ops: the function has similar side-effect to function "_ZSt29_Rb_tree_insert_and_rebalancebPSt18_Rb_tree_node_baseS0_RS_".
118
+
119
+ For operands of function operation,, there are the following options:
120
+ "Arg": represents a parameter,
121
+ "Obj": represents a object,
122
+ "Ret": represents a return value,
123
+ "Dummy": represents a dummy node.
124
+
100
125
  */
101
126
 
102
127
  class ExtAPI
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.1349",
3
+ "version": "1.0.1351",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {