From 0d705e4aef74f22e80ad84112c9e85268b1d2f7d Mon Sep 17 00:00:00 2001 From: Cristian Cadar Date: Fri, 6 Nov 2020 16:23:31 +0000 Subject: Added fortified library (for -D_FORTIFY_SOURCE), to be linked when uclibc is used. --- tools/klee/main.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'tools') 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> &modules) { klee_error("invalid libc, no uclibc support!\n"); } @@ -1112,7 +1112,7 @@ createLibCWrapper(std::vector> &modules, } static void -linkWithUclibc(StringRef libDir, +linkWithUclibc(StringRef libDir, std::string opt_suffix, std::vector> &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; } -- cgit 1.4.1