about summary refs log tree commit diff
path: root/patches/dafl-extract-file-name.patch
diff options
context:
space:
mode:
authorNguyễn Gia Phong <cnx@loang.net>2024-11-19 15:38:22 +0900
committerNguyễn Gia Phong <cnx@loang.net>2024-11-19 16:15:31 +0900
commit06ecd6c51765f1e6212ee4cf063daca51704daa0 (patch)
tree8d32e5dacc1ce49366308aa92c5c05a9ed51c3aa /patches/dafl-extract-file-name.patch
parent95309e93fa4d4b4f9893270151f2cd348b53905e (diff)
downloadloftix-main.tar.gz
Add DAFL packages HEAD main
Diffstat (limited to 'patches/dafl-extract-file-name.patch')
-rw-r--r--patches/dafl-extract-file-name.patch36
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;