about summary refs log tree commit diff
path: root/llvm_mode/LLVMInsTrim.so.cc
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2019-07-14 10:50:13 +0200
committervan Hauser <vh@thc.org>2019-07-14 10:50:13 +0200
commite66402485342088e6fcaecfe2abbba291a48bda5 (patch)
treea540cac715243825b4d8971dfd368fc09a291da8 /llvm_mode/LLVMInsTrim.so.cc
parent495f3b9a681af527018a92d3d0e3240568ac7997 (diff)
downloadafl++-e66402485342088e6fcaecfe2abbba291a48bda5.tar.gz
whitelist features works now
Diffstat (limited to 'llvm_mode/LLVMInsTrim.so.cc')
-rw-r--r--llvm_mode/LLVMInsTrim.so.cc19
1 files changed, 14 insertions, 5 deletions
diff --git a/llvm_mode/LLVMInsTrim.so.cc b/llvm_mode/LLVMInsTrim.so.cc
index 62977e97..51640870 100644
--- a/llvm_mode/LLVMInsTrim.so.cc
+++ b/llvm_mode/LLVMInsTrim.so.cc
@@ -1,3 +1,6 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
 #include <unistd.h>
 
 #include "llvm/ADT/DenseMap.h"
@@ -131,12 +134,16 @@ namespace {
 
         if (!myWhitelist.empty()) {
           bool instrumentBlock = false;
-          BasicBlock &BB = F.getEntryBlock();
-          BasicBlock::iterator IP = BB.getFirstInsertionPt();
-          IRBuilder<> IRB(&(*IP));
-          DebugLoc Loc = IP->getDebugLoc();
+          DebugLoc Loc;
           StringRef instFilename;
 
+          for (auto &BB : F) {
+            BasicBlock::iterator IP = BB.getFirstInsertionPt();
+            IRBuilder<> IRB(&(*IP));
+            if (!Loc)
+              Loc = IP->getDebugLoc();
+          }
+
           if ( Loc ) {
               DILocation *cDILoc = dyn_cast<DILocation>(Loc.getAsMDNode());
 
@@ -169,7 +176,9 @@ namespace {
            * not whitelisted, so we skip instrumentation. */
           if (!instrumentBlock) {
             if (!instFilename.str().empty())
-              SAYF( "Not in whitelist, skipping %s ...\n", instFilename.str().c_str());
+              SAYF(cYEL "[!] " cBRI "Not in whitelist, skipping %s ...\n", instFilename.str().c_str());
+            else
+              SAYF(cYEL "[!] " cBRI "No filename information found, skipping it");
             continue;
           }
         }