about summary refs log tree commit diff homepage
path: root/tools
diff options
context:
space:
mode:
authorDan Liew <daniel.liew@imperial.ac.uk>2013-12-16 01:23:07 +0000
committerDan Liew <daniel.liew@imperial.ac.uk>2013-12-21 23:22:46 +0000
commit2f6e89baf9cd5f5292cd0aa6047144920a564202 (patch)
tree645ceda7642bb3c4acc1e701a8869809b28e1683 /tools
parent8d541d5e7613bd42be0714c2654138bcc3c2c6d4 (diff)
downloadklee-2f6e89baf9cd5f5292cd0aa6047144920a564202.tar.gz
klee-uclibc detection is now a lot cleaner. KLEE now assumes
it can find klee-uclibc inside the same folder as the other
runtime libraries with the name "klee-uclibc.bca"

This is implemented as follows:

* When building, a sym-link is created to klee-uclibc's libc.a file
  in the same directory that the rest of KLEE's runtime libraries
  are built. This done so that if a developer changes klee-uclibc
  on their system then the correct version of klee-uclibc is used
  by KLEE.

* When installing, klee-uclibc's libc.a file is installed in the same
  directory that the rest of KLEE's runtime libraries are installed.

In addition the configure script argument --with-uclibc can now
operate in two ways. It can either be passed the path to the root
of klee-uclibc or it can be passed a path to the libc.a file built
by klee-uclibc. This new behaviour has been added to allow users
to potential use pre-built versions of klee-uclibc.
Diffstat (limited to 'tools')
-rw-r--r--tools/klee/main.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/tools/klee/main.cpp b/tools/klee/main.cpp
index faf53439..f9698fdf 100644
--- a/tools/klee/main.cpp
+++ b/tools/klee/main.cpp
@@ -1006,8 +1006,8 @@ static char *format_tdiff(char *buf, long seconds)
   return buf;
 }
 
-#ifndef KLEE_UCLIBC
-static llvm::Module *linkWithUclibc(llvm::Module *mainModule) {
+#ifndef SUPPORT_KLEE_UCLIBC
+static llvm::Module *linkWithUclibc(llvm::Module *mainModule, llvm::sys::Path libDir) {
   fprintf(stderr, "error: invalid libc, no uclibc support!\n");
   exit(1);
   return 0;
@@ -1030,12 +1030,15 @@ 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.");
+static llvm::Module *linkWithUclibc(llvm::Module *mainModule, llvm::sys::Path libDir) {
+  // Ensure that klee-uclibc exists
+  llvm::sys::Path uclibcBCA(libDir);
+  uclibcBCA.appendComponent(KLEE_UCLIBC_BCA_NAME);
+
+  bool uclibcExists=false;
+  llvm::sys::fs::exists(uclibcBCA.c_str(), uclibcExists);
+  if (!uclibcExists)
+    klee_error("Cannot find klee-uclibc : %s", uclibcBCA.c_str());
 
   Function *f;
   // force import of __uClibc_main
@@ -1094,8 +1097,7 @@ static llvm::Module *linkWithUclibc(llvm::Module *mainModule) {
     }
   }
   
-  mainModule = klee::linkWithLibrary(mainModule, 
-                                     KLEE_UCLIBC "/lib/libc.a");
+  mainModule = klee::linkWithLibrary(mainModule, uclibcBCA.c_str());
   assert(mainModule && "unable to link with uclibc");
 
 
@@ -1148,6 +1150,7 @@ static llvm::Module *linkWithUclibc(llvm::Module *mainModule) {
   
   new UnreachableInst(getGlobalContext(), bb);
 
+  klee_message("NOTE: Using klee-uclibc : %s", uclibcBCA.c_str());
   return mainModule;
 }
 #endif
@@ -1281,7 +1284,7 @@ int main(int argc, char **argv, char **envp) {
   }
 
   case UcLibc:
-    mainModule = linkWithUclibc(mainModule);
+    mainModule = linkWithUclibc(mainModule, LibraryDir);
     break;
   }