svf-lib 1.0.1058 → 1.0.1059
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.
|
Binary file
|
|
Binary file
|
|
@@ -40,54 +40,66 @@
|
|
|
40
40
|
#include <map>
|
|
41
41
|
|
|
42
42
|
#define EXTAPI_JSON_PATH "/lib/Util/ExtAPI.json"
|
|
43
|
+
#define JSON_OPT_OVERWRITE "overwrite_app_function"
|
|
44
|
+
#define JSON_OPT_FUNCTIONTYPE "type"
|
|
43
45
|
|
|
44
46
|
namespace SVF
|
|
45
47
|
{
|
|
46
48
|
|
|
47
49
|
/*
|
|
48
50
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
51
|
+
** Specifications in ExtAPI.json
|
|
52
|
+
|
|
53
|
+
*** [1] Overview of the Specification Language
|
|
54
|
+
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:
|
|
55
|
+
1. the name of the function,
|
|
56
|
+
2. the switch that controls whether the specification rules defined in the ExtAPI.json overwrite the functions defined in the user code,
|
|
57
|
+
3. the type of the function,
|
|
58
|
+
4. the operations conducted by the function.
|
|
59
|
+
|
|
60
|
+
*** [2] Overwriting the user-defined functions
|
|
61
|
+
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.
|
|
62
|
+
overwrite_app_function = 0: Analyze the user-defined functions.
|
|
63
|
+
overwrite_app_function = 1: Use specifications in ExtAPI.json to overwrite the user-defined functions.
|
|
64
|
+
|
|
65
|
+
*** [3] Function types
|
|
66
|
+
Function type represents the properties of the function.
|
|
67
|
+
For example,
|
|
68
|
+
"EFT_ALLOC" represents if this external function allocates a new object and assigns it to one of its arguments,
|
|
69
|
+
For the selection of function type and a more detailed explanation, please refer to the definition of enum *extf_t* in ExtAPI.h.
|
|
70
|
+
|
|
71
|
+
*** [4] Function operations
|
|
72
|
+
Function operations indicate the relationships between input and output,
|
|
73
|
+
mainly between function parameters or between parameters and return values after the execution.
|
|
74
|
+
For example,
|
|
75
|
+
"copy": ["A2", "L"] indicates that after this external function is executed, the value of the 2nd parameter is copied into the return value.
|
|
76
|
+
For the selection of function type and a more detailed explanation, please refer to the definition of enum *extType* in ExtAPI.h.
|
|
77
|
+
|
|
78
|
+
For operands of function operation, e.g., "A2", "L", there are the following options:
|
|
79
|
+
"A": represents a parameter;
|
|
80
|
+
"N": represents a number;
|
|
81
|
+
"R": represents a reference;
|
|
82
|
+
"L": represents a return value;
|
|
83
|
+
"V": represents a dummy node;
|
|
84
|
+
|
|
85
|
+
Among them, a parameter may have multiple forms because there may be various parameters, and the parameter may be a reference or complex structure,
|
|
86
|
+
|
|
87
|
+
Here we use regular expressions "(AN)(R|RN)^*" to represent parameters, for example,
|
|
88
|
+
"A0": represents the 1st parameter;
|
|
89
|
+
"A2R": represents that the 3rd parameter is a reference;
|
|
90
|
+
"A1R2": represents the 3rd substructure of the 2nd parameter "A1R", where "A1R" is a complex structure;
|
|
91
|
+
"A2R3R": represents the 4th substructure of the 3rd parameter "A2R" is a reference, where "A2R" is a complex structure;
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
** Specification format:
|
|
95
|
+
"functionName": {
|
|
96
|
+
"type": "functional type",
|
|
97
|
+
"overwrite_app_function:" 0/1,
|
|
98
|
+
"function operation_1": [ operand_1, operand_2, ... , operand_n],
|
|
99
|
+
"function operation_2": [ operand_1, operand_2, ... , operand_n],
|
|
100
|
+
...
|
|
101
|
+
"function operation_n": [ operand_1, operand_2, ... , operand_n]
|
|
102
|
+
}
|
|
91
103
|
*/
|
|
92
104
|
|
|
93
105
|
|
|
@@ -233,6 +245,11 @@ public:
|
|
|
233
245
|
// Get property of the operation, e.g. "EFT_A1R_A0R"
|
|
234
246
|
extType get_type(const SVF::SVFFunction *callee);
|
|
235
247
|
|
|
248
|
+
// Get priority of he function, return value
|
|
249
|
+
// 0: Apply user-defined functions
|
|
250
|
+
// 1: Apply function specification in ExtAPI.json
|
|
251
|
+
u32_t isOverwrittenAppFunction(const SVF::SVFFunction *callee);
|
|
252
|
+
|
|
236
253
|
// Does (F) have a static var X (unavailable to us) that its return points to?
|
|
237
254
|
bool has_static(const SVFFunction *F);
|
|
238
255
|
|