From 23225879b4e36c7926bc86dc22b4a6690fd0df4e Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Tue, 5 Nov 2013 11:44:51 +0000 Subject: 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! --- tools/klee/main.cpp | 7 +++++++ 1 file changed, 7 insertions(+) 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", -- cgit 1.4.1