aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorCristian Cadar <c.cadar@imperial.ac.uk>2020-11-06 16:23:31 +0000
committerMartinNowack <2443641+MartinNowack@users.noreply.github.com>2020-11-09 19:39:13 +0000
commit0d705e4aef74f22e80ad84112c9e85268b1d2f7d (patch)
tree53a476c3aedcae8546ce69d1e9a61c51d2caacba /tools
parent4547882135af886e002d134d6bb5b510f7c73a06 (diff)
downloadklee-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.cpp14
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;
}