Skip to content

Commit fc756f3

Browse files
thk123peterschrammel
thk123
authored andcommitted
Adding more symbols that should be excluded
The existing symbols were missing a few symbols from the files they were supposed to be symbols for. Further, for some reason the math functions were sometimes used with a double underscore prefix. Some included files were missed (fenv.h, errno.c, noop.c). There were some other prefixes that clearly have internal meaning (__VERIFIER, nondet_). Also asserts weren't being included. These problems were discovered by running the make and seeing which tests failed and what functions were being stubbed. It is therefore not necessarily exhaustive. Perhaps there is a better approach to this problem.
1 parent fb616c5 commit fc756f3

File tree

1 file changed

+63
-8
lines changed

1 file changed

+63
-8
lines changed

src/goto-programs/system_library_symbols.cpp

Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Author: Thomas Kiley
1010
#include <util/cprover_prefix.h>
1111
#include <util/prefix.h>
1212
#include <util/symbol.h>
13+
#include <sstream>
1314

1415
system_library_symbolst::system_library_symbolst()
1516
{
@@ -61,16 +62,28 @@ void system_library_symbolst::init_system_library_map()
6162
"acos", "acosh", "asin", "asinh", "atan", "atan2", "atanh",
6263
"cbrt", "ceil", "copysign", "cos", "cosh", "erf", "erfc", "exp",
6364
"exp2", "expm1", "fabs", "fdim", "floor", "fma", "fmax", "fmin",
64-
"fmod", "fpclassify", "frexp", "hypot", "ilogb", "isfinite",
65-
"isinf", "isnan", "isnormal", "j0", "j1", "jn", "ldexp", "lgamma",
66-
"llrint", "llround", "log", "log10", "log1p", "log2", "logb",
67-
"lrint", "lround", "modf", "nan", "nearbyint", "nextafter", "pow",
68-
"remainder", "remquo", "rint", "round", "scalbln", "scalbn",
69-
"signbit", "sin", "sinh", "sqrt", "tan", "tanh", "tgamma",
70-
"trunc", "y0", "y1", "yn"
65+
"fmod", "fpclassify", "fpclassifyl", "fpclassifyf", "frexp",
66+
"hypot", "ilogb", "isfinite", "isinf", "isnan", "isnormal",
67+
"j0", "j1", "jn", "ldexp", "lgamma", "llrint", "llround", "log",
68+
"log10", "log1p", "log2", "logb", "lrint", "lround", "modf", "nan",
69+
"nearbyint", "nextafter", "pow", "remainder", "remquo", "rint",
70+
"round", "scalbln", "scalbn", "signbit", "sin", "sinh", "sqrt",
71+
"tan", "tanh", "tgamma", "trunc", "y0", "y1", "yn", "isinff",
72+
"isinfl", "isnanf", "isnanl"
7173
};
7274
add_to_system_library("math.h", math_syms);
7375

76+
// for some reason the math functions can sometimes be prefixed with
77+
// a double underscore
78+
std::list<irep_idt> underscore_math_syms;
79+
for(const irep_idt &math_sym : math_syms)
80+
{
81+
std::ostringstream underscore_id;
82+
underscore_id << "__" << math_sym;
83+
underscore_math_syms.push_back(irep_idt(underscore_id.str()));
84+
}
85+
add_to_system_library("math.h", underscore_math_syms);
86+
7487
// pthread.h
7588
std::list<irep_idt> pthread_syms=
7689
{
@@ -140,7 +153,8 @@ void system_library_symbolst::init_system_library_map()
140153
{
141154
"strcat", "strncat", "strchr", "strrchr", "strcmp", "strncmp",
142155
"strcpy", "strncpy", "strerror", "strlen", "strpbrk", "strspn",
143-
"strcspn", "strstr", "strtok"
156+
"strcspn", "strstr", "strtok", "strcasecmp", "strncasecmp", "strdup",
157+
"memset"
144158
};
145159
add_to_system_library("string.h", string_syms);
146160

@@ -189,6 +203,27 @@ void system_library_symbolst::init_system_library_map()
189203
};
190204
add_to_system_library("sys/stat.h", sys_stat_syms);
191205

206+
std::list<irep_idt> fenv_syms=
207+
{
208+
"fenv_t", "fexcept_t", "feclearexcept", "fegetexceptflag",
209+
"feraiseexcept", "fesetexceptflag", "fetestexcept",
210+
"fegetround", "fesetround", "fegetenv", "feholdexcept",
211+
"fesetenv", "feupdateenv"
212+
};
213+
add_to_system_library("fenv.h", fenv_syms);
214+
215+
std::list<irep_idt> errno_syms=
216+
{
217+
"__error", "__errno_location", "__errno"
218+
};
219+
add_to_system_library("errno.c", errno_syms);
220+
221+
std::list<irep_idt> noop_syms=
222+
{
223+
"__noop"
224+
};
225+
add_to_system_library("noop.c", noop_syms);
226+
192227
#if 0
193228
// sys/types.h
194229
std::list<irep_idt> sys_types_syms=
@@ -263,6 +298,17 @@ bool system_library_symbolst::is_symbol_internal_symbol(
263298
name_str=="envp_size'")
264299
return true;
265300

301+
// exclude nondet instructions
302+
if(has_prefix(name_str, "nondet_"))
303+
{
304+
return true;
305+
}
306+
307+
if(has_prefix(name_str, "__VERIFIER"))
308+
{
309+
return true;
310+
}
311+
266312
const std::string &file_str=id2string(symbol.location.get_file());
267313

268314
// don't dump internal GCC builtins
@@ -283,6 +329,15 @@ bool system_library_symbolst::is_symbol_internal_symbol(
283329
return true;
284330
}
285331

332+
// don't dump asserts
333+
else if(name_str=="__assert_fail" ||
334+
name_str=="_assert" ||
335+
name_str=="__assert_c99" ||
336+
name_str=="_wassert")
337+
{
338+
return true;
339+
}
340+
286341
if(name_str.find("$link")!=std::string::npos)
287342
return false;
288343

0 commit comments

Comments
 (0)