diff options
Diffstat (limited to 'patches/dafl-extract-file-name.patch')
-rw-r--r-- | patches/dafl-extract-file-name.patch | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/patches/dafl-extract-file-name.patch b/patches/dafl-extract-file-name.patch new file mode 100644 index 0000000..db6fdd6 --- /dev/null +++ b/patches/dafl-extract-file-name.patch @@ -0,0 +1,36 @@ +commit 50d68fc44948ab3b25a7af2f5fc9918110b1939a +Author: goodtaeeun <goodtaeeun@kaist.ac.kr> +Date: 2024-02-13 15:24:01 +0900 + + [DAFL] extract file name from function + +diff --git a/llvm_mode/afl-llvm-pass.so.cc b/llvm_mode/afl-llvm-pass.so.cc +index af989c2037b2..ecc017e9f3e0 100644 +--- a/llvm_mode/afl-llvm-pass.so.cc ++++ b/llvm_mode/afl-llvm-pass.so.cc +@@ -162,12 +162,21 @@ bool AFLCoverage::runOnModule(Module &M) { + std::string file_name = M.getSourceFileName(); + std::set<std::string> covered_targets; + +- std::size_t tokloc = file_name.find_last_of('/'); +- if (tokloc != std::string::npos) { +- file_name = file_name.substr(tokloc + 1, std::string::npos); +- } ++ + + for (auto &F : M) { ++ ++ // Get file name from function in case the module is a combined bc file. ++ if (auto *SP = F.getSubprogram()) { ++ file_name = SP->getFilename().str(); ++ } ++ ++ // Keep only the file name. ++ std::size_t tokloc = file_name.find_last_of('/'); ++ if (tokloc != std::string::npos) { ++ file_name = file_name.substr(tokloc + 1, std::string::npos); ++ } ++ + bool is_inst_targ = false; + const std::string func_name = F.getName().str(); + std::set<std::string>::iterator it; |