svf-tools 1.0.1075 → 1.0.1077
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 +1 -1
- package/svf-llvm/lib/LLVMModule.cpp +63 -2
- package/svf-llvm/lib/extapi.c +105 -118
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svf-tools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1077",
|
|
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": {
|
|
@@ -727,7 +727,68 @@ void LLVMModuleSet::buildFunToFunMap()
|
|
|
727
727
|
}
|
|
728
728
|
if (cloneBody)
|
|
729
729
|
{
|
|
730
|
-
//
|
|
730
|
+
// Collect global variables referenced by extFunToClone
|
|
731
|
+
// This step identifies all global variables used within the function to be cloned
|
|
732
|
+
std::set<GlobalVariable*> referencedGlobals;
|
|
733
|
+
for (const BasicBlock& BB : *extFunToClone)
|
|
734
|
+
{
|
|
735
|
+
for (const Instruction& I : BB)
|
|
736
|
+
{
|
|
737
|
+
for (const Value* operand : I.operands())
|
|
738
|
+
{
|
|
739
|
+
// Check if the operand is a global variable
|
|
740
|
+
if (const GlobalVariable* GV = SVFUtil::dyn_cast<GlobalVariable>(operand))
|
|
741
|
+
{
|
|
742
|
+
referencedGlobals.insert(const_cast<GlobalVariable*>(GV));
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
// Copy global variables to target module and update valueMap
|
|
749
|
+
// When cloning a function, we need to ensure all global variables it references are available in the target module
|
|
750
|
+
for (GlobalVariable* GV : referencedGlobals)
|
|
751
|
+
{
|
|
752
|
+
// Check if the global variable already exists in the target module
|
|
753
|
+
GlobalVariable* existingGV = appModule->getGlobalVariable(GV->getName());
|
|
754
|
+
if (existingGV)
|
|
755
|
+
{
|
|
756
|
+
// If the global variable already exists, ensure type consistency
|
|
757
|
+
assert(existingGV->getType() == GV->getType() && "Global variable type mismatch in client module!");
|
|
758
|
+
// Map the original global to the existing one in the target module
|
|
759
|
+
valueMap[GV] = existingGV; // Map to existing global variable
|
|
760
|
+
}
|
|
761
|
+
else
|
|
762
|
+
{
|
|
763
|
+
// If the global variable doesn't exist in the target module, create a new one with the same properties
|
|
764
|
+
GlobalVariable* newGV = new GlobalVariable(
|
|
765
|
+
*appModule, // Target module
|
|
766
|
+
GV->getValueType(), // Type of the global variable
|
|
767
|
+
GV->isConstant(), // Whether it's constant
|
|
768
|
+
GV->getLinkage(), // Linkage type
|
|
769
|
+
nullptr, // No initializer yet
|
|
770
|
+
GV->getName(), // Same name
|
|
771
|
+
nullptr, // No insert before instruction
|
|
772
|
+
GV->getThreadLocalMode(), // Thread local mode
|
|
773
|
+
GV->getAddressSpace() // Address space
|
|
774
|
+
);
|
|
775
|
+
|
|
776
|
+
// Copy initializer if present to maintain the global's value
|
|
777
|
+
if (GV->hasInitializer())
|
|
778
|
+
{
|
|
779
|
+
Constant* init = GV->getInitializer();
|
|
780
|
+
newGV->setInitializer(init); // Simple case: direct copy
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
// Copy other attributes like alignment to ensure identical behavior
|
|
784
|
+
newGV->copyAttributesFrom(GV);
|
|
785
|
+
|
|
786
|
+
// Add mapping from original global to the new one for use during function cloning
|
|
787
|
+
valueMap[GV] = newGV;
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
// Clone function body with updated valueMap
|
|
731
792
|
llvm::SmallVector<ReturnInst*, 8> ignoredReturns;
|
|
732
793
|
CloneFunctionInto(clonedFunction, extFunToClone, valueMap, llvm::CloneFunctionChangeType::LocalChangesOnly, ignoredReturns, "", nullptr);
|
|
733
794
|
}
|
|
@@ -1505,4 +1566,4 @@ bool LLVMModuleSet::is_ext(const Function* F)
|
|
|
1505
1566
|
return false;
|
|
1506
1567
|
else
|
|
1507
1568
|
return !getExtFuncAnnotations(F).empty();
|
|
1508
|
-
}
|
|
1569
|
+
}
|
package/svf-llvm/lib/extapi.c
CHANGED
|
@@ -255,12 +255,6 @@ char *crypt(const char *key, const char *salt)
|
|
|
255
255
|
return NULL;
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
-
__attribute__((annotate("ALLOC_HEAP_RET"), annotate("AllocSize:UNKNOWN")))
|
|
259
|
-
char *ctime(const void *timer)
|
|
260
|
-
{
|
|
261
|
-
return NULL;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
258
|
__attribute__((annotate("ALLOC_HEAP_RET"), annotate("AllocSize:UNKNOWN")))
|
|
265
259
|
char *dlerror(void)
|
|
266
260
|
{
|
|
@@ -291,12 +285,6 @@ const char *svfgcry_md_algo_name_(int errcode)
|
|
|
291
285
|
return NULL;
|
|
292
286
|
}
|
|
293
287
|
|
|
294
|
-
__attribute__((annotate("ALLOC_HEAP_RET"), annotate("AllocSize:UNKNOWN")))
|
|
295
|
-
char *getenv(const char *name)
|
|
296
|
-
{
|
|
297
|
-
return NULL;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
288
|
__attribute__((annotate("ALLOC_HEAP_RET"), annotate("AllocSize:UNKNOWN")))
|
|
301
289
|
char *getlogin(void)
|
|
302
290
|
{
|
|
@@ -1045,242 +1033,241 @@ void _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1EPKcRKS3_(void **arg
|
|
|
1045
1033
|
*arg0 = arg1;
|
|
1046
1034
|
}
|
|
1047
1035
|
|
|
1048
|
-
|
|
1036
|
+
char getenv_global[10];
|
|
1037
|
+
char *getenv(const char *name)
|
|
1038
|
+
{
|
|
1039
|
+
return getenv_global;
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
unsigned short ctype_b_loc_global[10];
|
|
1049
1043
|
const unsigned short **__ctype_b_loc(void)
|
|
1050
1044
|
{
|
|
1051
|
-
return
|
|
1045
|
+
return (const unsigned short **)&ctype_b_loc_global;
|
|
1052
1046
|
}
|
|
1053
1047
|
|
|
1054
|
-
|
|
1048
|
+
int ctype_tolower_loc_global[10];
|
|
1055
1049
|
int **__ctype_tolower_loc(void)
|
|
1056
1050
|
{
|
|
1057
|
-
return
|
|
1051
|
+
return &ctype_tolower_loc_global;
|
|
1058
1052
|
}
|
|
1059
1053
|
|
|
1060
|
-
|
|
1054
|
+
int ctype_toupper_loc_global[10];
|
|
1061
1055
|
int **__ctype_toupper_loc(void)
|
|
1062
1056
|
{
|
|
1063
|
-
return
|
|
1057
|
+
return &ctype_toupper_loc_global;
|
|
1064
1058
|
}
|
|
1065
1059
|
|
|
1066
|
-
|
|
1060
|
+
int error_global[10];
|
|
1067
1061
|
int *__errno_location(void)
|
|
1068
1062
|
{
|
|
1069
|
-
return
|
|
1063
|
+
return error_global;
|
|
1070
1064
|
}
|
|
1071
1065
|
|
|
1072
|
-
|
|
1066
|
+
int h_error_global[10];
|
|
1073
1067
|
int * __h_errno_location(void)
|
|
1074
1068
|
{
|
|
1075
|
-
return
|
|
1069
|
+
return h_error_global;
|
|
1076
1070
|
}
|
|
1077
1071
|
|
|
1078
|
-
|
|
1072
|
+
int res_state_global[10];
|
|
1079
1073
|
void* __res_state(void)
|
|
1080
1074
|
{
|
|
1081
|
-
return
|
|
1075
|
+
return res_state_global;
|
|
1082
1076
|
}
|
|
1083
1077
|
|
|
1084
|
-
|
|
1078
|
+
void *time_global[10];
|
|
1085
1079
|
char *asctime(const void *timeptr)
|
|
1086
1080
|
{
|
|
1087
|
-
return
|
|
1081
|
+
return time_global;
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
char *ctime(const void *timer)
|
|
1085
|
+
{
|
|
1086
|
+
return time_global;
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
void *gmtime(const void *timer)
|
|
1090
|
+
{
|
|
1091
|
+
return time_global;
|
|
1088
1092
|
}
|
|
1089
1093
|
|
|
1090
|
-
|
|
1094
|
+
void *localtime(const void *timer)
|
|
1095
|
+
{
|
|
1096
|
+
return time_global;
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
char bindtextdomain_global[10];
|
|
1091
1100
|
char * bindtextdomain(const char * domainname, const char * dirname)
|
|
1092
1101
|
{
|
|
1093
|
-
return
|
|
1102
|
+
return bindtextdomain_global;
|
|
1094
1103
|
}
|
|
1095
1104
|
|
|
1096
|
-
|
|
1105
|
+
char bind_textdomain_codeset_global[10];
|
|
1097
1106
|
char * bind_textdomain_codeset(const char * domainname, const char * codeset)
|
|
1098
1107
|
{
|
|
1099
|
-
return
|
|
1108
|
+
return bind_textdomain_codeset_global;
|
|
1100
1109
|
}
|
|
1101
1110
|
|
|
1102
|
-
|
|
1111
|
+
char ctermid_global[10];
|
|
1103
1112
|
char *ctermid(char *s)
|
|
1104
1113
|
{
|
|
1105
|
-
return s;
|
|
1114
|
+
return s ? s : ctermid_global;
|
|
1106
1115
|
}
|
|
1107
1116
|
|
|
1108
|
-
|
|
1117
|
+
char gettext_global[10];
|
|
1109
1118
|
char * dcgettext(const char * domainname, const char * msgid, int category)
|
|
1110
1119
|
{
|
|
1111
|
-
return
|
|
1120
|
+
return gettext_global;
|
|
1112
1121
|
}
|
|
1113
1122
|
|
|
1114
|
-
__attribute__((annotate("ALLOC_STACK_RET")))
|
|
1115
1123
|
char * dgettext(const char * domainname, const char * msgid)
|
|
1116
1124
|
{
|
|
1117
|
-
return
|
|
1125
|
+
return gettext_global;
|
|
1118
1126
|
}
|
|
1119
1127
|
|
|
1120
|
-
__attribute__((annotate("ALLOC_STACK_RET")))
|
|
1121
1128
|
char * dngettext(const char * domainname, const char * msgid, const char * msgid_plural, unsigned long int n)
|
|
1122
1129
|
{
|
|
1123
|
-
return
|
|
1130
|
+
return gettext_global;
|
|
1124
1131
|
}
|
|
1125
1132
|
|
|
1126
|
-
|
|
1127
|
-
struct group *getgrgid(unsigned int gid)
|
|
1133
|
+
char * gettext(const char * msgid)
|
|
1128
1134
|
{
|
|
1129
|
-
return
|
|
1135
|
+
return gettext_global;
|
|
1130
1136
|
}
|
|
1131
1137
|
|
|
1132
|
-
|
|
1133
|
-
struct group *getgrnam(const char *name)
|
|
1138
|
+
char * ngettext(const char * msgid, const char * msgid_plural, unsigned long int n)
|
|
1134
1139
|
{
|
|
1135
|
-
return
|
|
1140
|
+
return gettext_global;
|
|
1136
1141
|
}
|
|
1137
1142
|
|
|
1138
|
-
|
|
1139
|
-
|
|
1143
|
+
void *getgrgid_global[10];
|
|
1144
|
+
void *getgrgid(unsigned int gid)
|
|
1140
1145
|
{
|
|
1141
|
-
return
|
|
1146
|
+
return getgrgid_global;
|
|
1142
1147
|
}
|
|
1143
1148
|
|
|
1144
|
-
|
|
1145
|
-
|
|
1149
|
+
void *getgrnam_global[10];
|
|
1150
|
+
void *getgrnam(const char *name)
|
|
1146
1151
|
{
|
|
1147
|
-
return
|
|
1152
|
+
return getgrnam_global;
|
|
1148
1153
|
}
|
|
1149
1154
|
|
|
1150
|
-
|
|
1151
|
-
|
|
1155
|
+
void *gethostby_global[10];
|
|
1156
|
+
void *gethostbyaddr(const void *addr, unsigned int len, int type)
|
|
1152
1157
|
{
|
|
1153
|
-
return
|
|
1158
|
+
return gethostby_global;
|
|
1154
1159
|
}
|
|
1155
1160
|
|
|
1156
|
-
|
|
1157
|
-
struct mntent *getmntent(void *stream)
|
|
1161
|
+
void *gethostbyname(const char *name)
|
|
1158
1162
|
{
|
|
1159
|
-
return
|
|
1163
|
+
return gethostby_global;
|
|
1160
1164
|
}
|
|
1161
1165
|
|
|
1162
|
-
|
|
1163
|
-
struct protoent *getprotobyname(const char *name)
|
|
1166
|
+
void *gethostbyname2(const char *name, int af)
|
|
1164
1167
|
{
|
|
1165
|
-
return
|
|
1168
|
+
return gethostby_global;
|
|
1166
1169
|
}
|
|
1167
1170
|
|
|
1168
|
-
|
|
1169
|
-
|
|
1171
|
+
void *getmntent_global[10];
|
|
1172
|
+
void *getmntent(void *stream)
|
|
1170
1173
|
{
|
|
1171
|
-
return
|
|
1174
|
+
return getmntent_global;
|
|
1172
1175
|
}
|
|
1173
1176
|
|
|
1174
|
-
|
|
1175
|
-
|
|
1177
|
+
void *getproto_global[10];
|
|
1178
|
+
void *getprotobyname(const char *name)
|
|
1176
1179
|
{
|
|
1177
|
-
return
|
|
1180
|
+
return getproto_global;
|
|
1178
1181
|
}
|
|
1179
1182
|
|
|
1180
|
-
|
|
1181
|
-
struct passwd *getpwnam(const char *name)
|
|
1183
|
+
void *getprotobynumber(int proto)
|
|
1182
1184
|
{
|
|
1183
|
-
return
|
|
1185
|
+
return getproto_global;
|
|
1184
1186
|
}
|
|
1185
1187
|
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
+
void *getpw_global[10];
|
|
1189
|
+
void *getpwent(void)
|
|
1188
1190
|
{
|
|
1189
|
-
return
|
|
1191
|
+
return getpw_global;
|
|
1190
1192
|
}
|
|
1191
1193
|
|
|
1192
|
-
|
|
1193
|
-
struct servent *getservbyname(const char *name, const char *proto)
|
|
1194
|
+
void *getpwnam(const char *name)
|
|
1194
1195
|
{
|
|
1195
|
-
return
|
|
1196
|
+
return getpw_global;
|
|
1196
1197
|
}
|
|
1197
1198
|
|
|
1198
|
-
|
|
1199
|
-
struct servent *getservbyport(int port, const char *proto)
|
|
1199
|
+
void *getpwuid(unsigned int uid)
|
|
1200
1200
|
{
|
|
1201
|
-
return
|
|
1201
|
+
return getpw_global;
|
|
1202
1202
|
}
|
|
1203
1203
|
|
|
1204
|
-
|
|
1205
|
-
|
|
1204
|
+
void *getserv_global[10];
|
|
1205
|
+
void *getservbyname(const char *name, const char *proto)
|
|
1206
1206
|
{
|
|
1207
|
-
return
|
|
1207
|
+
return getserv_global;
|
|
1208
1208
|
}
|
|
1209
1209
|
|
|
1210
|
-
|
|
1211
|
-
char * gettext(const char * msgid)
|
|
1210
|
+
void *getservbyport(int port, const char *proto)
|
|
1212
1211
|
{
|
|
1213
|
-
return
|
|
1212
|
+
return getserv_global;
|
|
1214
1213
|
}
|
|
1215
1214
|
|
|
1216
|
-
|
|
1217
|
-
|
|
1215
|
+
void *getspnam_global[10];
|
|
1216
|
+
void *getspnam(const char *name)
|
|
1218
1217
|
{
|
|
1219
|
-
return
|
|
1218
|
+
return getspnam_global;
|
|
1220
1219
|
}
|
|
1221
1220
|
|
|
1222
|
-
|
|
1221
|
+
char gnu_get_libc_version_global[10];
|
|
1223
1222
|
const char *gnu_get_libc_version(void)
|
|
1224
1223
|
{
|
|
1225
|
-
return
|
|
1224
|
+
return gnu_get_libc_version_global;
|
|
1226
1225
|
}
|
|
1227
1226
|
|
|
1228
|
-
|
|
1227
|
+
char gnutls_check_version_global[10];
|
|
1229
1228
|
const char * gnutls_check_version(const char * req_version)
|
|
1230
1229
|
{
|
|
1231
|
-
return
|
|
1232
|
-
}
|
|
1233
|
-
|
|
1234
|
-
__attribute__((annotate("ALLOC_STACK_RET")))
|
|
1235
|
-
struct lconv *localeconv(void)
|
|
1236
|
-
{
|
|
1237
|
-
return NULL;
|
|
1230
|
+
return gnutls_check_version_global;
|
|
1238
1231
|
}
|
|
1239
1232
|
|
|
1240
|
-
|
|
1241
|
-
|
|
1233
|
+
void *localeconv_global[10];
|
|
1234
|
+
void *localeconv(void)
|
|
1242
1235
|
{
|
|
1243
|
-
return
|
|
1236
|
+
return localeconv_global;
|
|
1244
1237
|
}
|
|
1245
1238
|
|
|
1246
|
-
|
|
1247
|
-
char * ngettext(const char * msgid, const char * msgid_plural, unsigned long int n)
|
|
1248
|
-
{
|
|
1249
|
-
return NULL;
|
|
1250
|
-
}
|
|
1251
|
-
|
|
1252
|
-
__attribute__((annotate("ALLOC_STACK_RET")))
|
|
1239
|
+
void *pango_cairo_font_map_global[10];
|
|
1253
1240
|
void *pango_cairo_font_map_get_default(void)
|
|
1254
1241
|
{
|
|
1255
|
-
return
|
|
1242
|
+
return pango_cairo_font_map_global;
|
|
1256
1243
|
}
|
|
1257
1244
|
|
|
1258
|
-
|
|
1245
|
+
char re_comp_global[10];
|
|
1259
1246
|
char *re_comp(const char *regex)
|
|
1260
1247
|
{
|
|
1261
|
-
return
|
|
1248
|
+
return re_comp_global;
|
|
1262
1249
|
}
|
|
1263
1250
|
|
|
1264
|
-
|
|
1251
|
+
char setlocale_global[10];
|
|
1265
1252
|
char *setlocale(int category, const char *locale)
|
|
1266
1253
|
{
|
|
1267
|
-
return
|
|
1254
|
+
return setlocale_global;
|
|
1268
1255
|
}
|
|
1269
1256
|
|
|
1270
|
-
|
|
1257
|
+
char tgoto_global[10];
|
|
1271
1258
|
char *tgoto(const char *cap, int col, int row)
|
|
1272
1259
|
{
|
|
1273
|
-
return
|
|
1260
|
+
return tgoto_global;
|
|
1274
1261
|
}
|
|
1275
1262
|
|
|
1276
|
-
|
|
1263
|
+
char tparm_global[10];
|
|
1277
1264
|
char *tparm(char *str, ...)
|
|
1278
1265
|
{
|
|
1279
|
-
return
|
|
1266
|
+
return tparm_global;
|
|
1280
1267
|
}
|
|
1281
1268
|
|
|
1282
|
-
|
|
1269
|
+
char zError_global[10];
|
|
1283
1270
|
const char *zError(int a)
|
|
1284
1271
|
{
|
|
1285
|
-
return
|
|
1286
|
-
}
|
|
1272
|
+
return zError_global;
|
|
1273
|
+
}
|