From 4ccb533158d40e15db9e9f2ade9bb28c3f83f38e Mon Sep 17 00:00:00 2001 From: Pavel Yatcheniy Date: Thu, 28 Jan 2021 17:51:04 +0300 Subject: Support UBSan-enabled binaries --- tools/klee/main.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'tools') diff --git a/tools/klee/main.cpp b/tools/klee/main.cpp index d94cdc76..7d938ab2 100644 --- a/tools/klee/main.cpp +++ b/tools/klee/main.cpp @@ -187,6 +187,10 @@ namespace { cl::init(false), cl::cat(LinkCat)); + cl::opt WithUBSanRuntime("ubsan-runtime", + cl::desc("Link with UBSan runtime."), + cl::init(false), cl::cat(LinkCat)); + cl::opt RuntimeBuild( "runtime-build", cl::desc("Link with versions of the runtime library that were built with " @@ -794,10 +798,6 @@ static const char *modelledExternals[] = { "_Znwj", "_Znam", "_Znwm", - "__ubsan_handle_add_overflow", - "__ubsan_handle_sub_overflow", - "__ubsan_handle_mul_overflow", - "__ubsan_handle_divrem_overflow", }; // Symbols we aren't going to warn about @@ -1265,6 +1265,15 @@ int main(int argc, char **argv, char **envp) { preparePOSIX(loadedModules, libcPrefix); } + if (WithUBSanRuntime) { + SmallString<128> Path(Opts.LibraryDir); + llvm::sys::path::append(Path, "libkleeUBSan" + opt_suffix + ".bca"); + if (!klee::loadFile(Path.c_str(), mainModule->getContext(), loadedModules, + errorMsg)) + klee_error("error loading UBSan support '%s': %s", Path.c_str(), + errorMsg.c_str()); + } + if (Libcxx) { #ifndef SUPPORT_KLEE_LIBCXX klee_error("KLEE was not compiled with libc++ support"); -- cgit 1.4.1