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
|
-
|
|
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
|
|
53
|
-
2. the
|
|
54
|
-
3. the
|
|
55
|
-
4. the
|
|
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
|
-
*** [
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
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
|
-
|
|
69
|
-
|
|
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
|
-
"
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
"
|
|
93
|
-
|
|
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
|