diff options
author | Cristian Cadar <c.cadar@imperial.ac.uk> | 2020-11-06 16:23:31 +0000 |
---|---|---|
committer | MartinNowack <2443641+MartinNowack@users.noreply.github.com> | 2020-11-09 19:39:13 +0000 |
commit | 0d705e4aef74f22e80ad84112c9e85268b1d2f7d (patch) | |
tree | 53a476c3aedcae8546ce69d1e9a61c51d2caacba /tools | |
parent | 4547882135af886e002d134d6bb5b510f7c73a06 (diff) | |
download | klee-0d705e4aef74f22e80ad84112c9e85268b1d2f7d.tar.gz |
Added fortified library (for -D_FORTIFY_SOURCE), to be linked when uclibc is used.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/klee/main.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/tools/klee/main.cpp b/tools/klee/main.cpp index d1f588bc..7184bd44 100644 --- a/tools/klee/main.cpp +++ b/tools/klee/main.cpp @@ -1021,7 +1021,7 @@ static void halt_via_gdb(int pid) { #ifndef SUPPORT_KLEE_UCLIBC static void -linkWithUclibc(StringRef libDir, +linkWithUclibc(StringRef libDir, std::string opt_suffix, std::vector<std::unique_ptr<llvm::Module>> &modules) { klee_error("invalid libc, no uclibc support!\n"); } @@ -1112,7 +1112,7 @@ createLibCWrapper(std::vector<std::unique_ptr<llvm::Module>> &modules, } static void -linkWithUclibc(StringRef libDir, +linkWithUclibc(StringRef libDir, std::string opt_suffix, std::vector<std::unique_ptr<llvm::Module>> &modules) { LLVMContext &ctx = modules[0]->getContext(); @@ -1133,6 +1133,14 @@ linkWithUclibc(StringRef libDir, createLibCWrapper(modules, EntryPoint, "__uClibc_main"); klee_message("NOTE: Using klee-uclibc : %s", uclibcBCA.c_str()); + + // Link the fortified library + SmallString<128> FortifyPath(libDir); + llvm::sys::path::append(FortifyPath, + "libkleeRuntimeFortify" + opt_suffix + ".bca"); + if (!klee::loadFile(FortifyPath.c_str(), ctx, modules, errorMsg)) + klee_error("error loading the fortify library '%s': %s", + FortifyPath.c_str(), errorMsg.c_str()); } #endif @@ -1318,7 +1326,7 @@ int main(int argc, char **argv, char **envp) { break; } case LibcType::UcLibc: - linkWithUclibc(LibraryDir, loadedModules); + linkWithUclibc(LibraryDir, opt_suffix, loadedModules); break; } |