about summary refs log tree commit diff homepage
path: root/tools
diff options
context:
space:
mode:
authorDan Liew <daniel.liew@imperial.ac.uk>2013-11-05 11:44:51 +0000
committerDan Liew <daniel.liew@imperial.ac.uk>2013-11-05 22:11:18 +0000
commit23225879b4e36c7926bc86dc22b4a6690fd0df4e (patch)
treec41acf9630c464b29a8ed8ea4946499296f45715 /tools
parenta8dbdafd32483da1f2aff3852a405c2cef9753f9 (diff)
downloadklee-23225879b4e36c7926bc86dc22b4a6690fd0df4e.tar.gz
Exit if using --libc=uclibc and KLEE was not configured with uclibc
or if the configured path does not exist.

Previously if KLEE was configured and compiled without uclibc linking
would still succeed because KLEE_UCLIBC was blank so LLVM was
effectively asked to link with "/lib/libc.a" i.e. the system's native
C library!
Diffstat (limited to 'tools')
-rw-r--r--tools/klee/main.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/tools/klee/main.cpp b/tools/klee/main.cpp
index 922f8bb5..769be28e 100644
--- a/tools/klee/main.cpp
+++ b/tools/klee/main.cpp
@@ -30,6 +30,7 @@
 #include "llvm/Instructions.h"
 #if LLVM_VERSION_CODE >= LLVM_VERSION(2, 7)
 #include "llvm/LLVMContext.h"
+#include "llvm/Support/FileSystem.h"
 #endif
 #endif
 #if LLVM_VERSION_CODE < LLVM_VERSION(2, 7)
@@ -1013,6 +1014,12 @@ static void replaceOrRenameFunction(llvm::Module *module,
 }
 
 static llvm::Module *linkWithUclibc(llvm::Module *mainModule) {
+  // Ensure that KLEE_UCLIBC exists
+  bool uclibcRootExists=false;
+  llvm::sys::fs::is_directory(KLEE_UCLIBC, uclibcRootExists);
+  if (!uclibcRootExists)
+    klee_error("Cannot link with uclibc. KLEE_UCLIBC (\"" KLEE_UCLIBC "\") is not a directory.");
+
   Function *f;
   // force import of __uClibc_main
   mainModule->getOrInsertFunction("__uClibc_main",