From b5c41d2689c2b05987232a1e206e6a1ac46b8489 Mon Sep 17 00:00:00 2001 From: Damir Shaykhutdinov Date: Tue, 10 May 2016 14:09:55 +0300 Subject: Allow relocation of installed klee tree If klee is configured with certain bindir and runtime dir, allow klee to be relocated, as long as subdirectory structure remains intact. For example, if klee is configured with bindir /usr/bin, and with runtime dir /usr/lib/klee, but is relocated to certain directory $RDIR, then running $RDIR/usr/bin/klee will search for runtime libraries in $RDIR/usr/lib/klee. Klee will use global runtime directory only when installed to global binary directory. Inspired by relocation code in gcc. --- tools/klee/main.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/klee/main.cpp b/tools/klee/main.cpp index 80161caa..7fe64c72 100644 --- a/tools/klee/main.cpp +++ b/tools/klee/main.cpp @@ -606,11 +606,15 @@ std::string KleeHandler::getRunTimeLibraryPath(const char *argv0) { SmallString<128> libDir; - if ( strcmp(toolRoot.c_str(), KLEE_INSTALL_BIN_DIR ) == 0) + if (strlen( KLEE_INSTALL_BIN_DIR ) != 0 && + strlen( KLEE_INSTALL_RUNTIME_DIR ) != 0 && + toolRoot.str().endswith( KLEE_INSTALL_BIN_DIR )) { KLEE_DEBUG_WITH_TYPE("klee_runtime", llvm::dbgs() << "Using installed KLEE library runtime: "); - libDir = KLEE_INSTALL_RUNTIME_DIR ; + libDir = toolRoot.str().substr(0, + toolRoot.str().size() - strlen( KLEE_INSTALL_BIN_DIR )); + llvm::sys::path::append(libDir, KLEE_INSTALL_RUNTIME_DIR); } else { -- cgit 1.4.1