about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-08-02 15:00:49 +0200
committervan Hauser <vh@thc.org>2020-08-02 15:00:49 +0200
commit6041b1c4866d11b443545f5b9d6f17ef5483304c (patch)
treeff77a40930cf82625867e719381548e3c0844cfa
parent349fed3fcd9ba8dcda7764a439c95071b6a509ce (diff)
downloadafl++-6041b1c4866d11b443545f5b9d6f17ef5483304c.tar.gz
fix LTO document id feature, warnings for INSTRUMENT_FILE
-rw-r--r--llvm_mode/afl-llvm-lto-instrumentation.so.cc9
-rw-r--r--llvm_mode/afl-llvm-lto-instrumentlist.so.cc48
2 files changed, 37 insertions, 20 deletions
diff --git a/llvm_mode/afl-llvm-lto-instrumentation.so.cc b/llvm_mode/afl-llvm-lto-instrumentation.so.cc
index 430cb0ad..d81b35f4 100644
--- a/llvm_mode/afl-llvm-lto-instrumentation.so.cc
+++ b/llvm_mode/afl-llvm-lto-instrumentation.so.cc
@@ -206,8 +206,8 @@ bool AFLLTOPass::runOnModule(Module &M) {
 
       if (debug)
         fprintf(stderr,
-                "DEBUG: Function %s is not the instrument file listed\n",
-                F.getName().str().c_str());
+                "DEBUG: Function %s is not in a source file that was specified "
+                "in the instrument file list\n", F.getName().str().c_str());
       continue;
 
     }
@@ -660,10 +660,11 @@ bool AFLLTOPass::runOnModule(Module &M) {
 
     }
 
-    if (documentFile) fclose(documentFile);
-
   }
 
+  if (documentFile) fclose(documentFile);
+  documentFile = NULL;
+
   // save highest location ID to global variable
   // do this after each function to fail faster
   if (!be_quiet && afl_global_id > MAP_SIZE &&
diff --git a/llvm_mode/afl-llvm-lto-instrumentlist.so.cc b/llvm_mode/afl-llvm-lto-instrumentlist.so.cc
index 6e6199e9..dc1a9a61 100644
--- a/llvm_mode/afl-llvm-lto-instrumentlist.so.cc
+++ b/llvm_mode/afl-llvm-lto-instrumentlist.so.cc
@@ -164,32 +164,41 @@ bool AFLcheckIfInstrument::runOnModule(Module &M) {
 
           }
 
+          if (instFilename.str().empty()) {
+
+            if (!be_quiet)
+              WARNF(
+                  "Function %s has no source file name information and will "
+                  "not be instrumented.",
+                  F.getName().str().c_str());
+            continue;
+
+          }
+
         }
 
-        (void)instLine;
+        //(void)instLine;
 
+        fprintf(stderr, "xxx %s %s\n", F.getName().str().c_str(),
+                instFilename.str().c_str());
         if (debug)
           SAYF(cMGN "[D] " cRST "function %s is in file %s\n",
                F.getName().str().c_str(), instFilename.str().c_str());
-        /* Continue only if we know where we actually are */
-        if (!instFilename.str().empty()) {
 
-          for (std::list<std::string>::iterator it = myInstrumentList.begin();
-               it != myInstrumentList.end(); ++it) {
+        for (std::list<std::string>::iterator it = myInstrumentList.begin();
+             it != myInstrumentList.end(); ++it) {
 
-            /* We don't check for filename equality here because
-             * filenames might actually be full paths. Instead we
-             * check that the actual filename ends in the filename
-             * specified in the list. */
-            if (instFilename.str().length() >= it->length()) {
+          /* We don't check for filename equality here because
+           * filenames might actually be full paths. Instead we
+           * check that the actual filename ends in the filename
+           * specified in the list. */
+          if (instFilename.str().length() >= it->length()) {
 
-              if (fnmatch(("*" + *it).c_str(), instFilename.str().c_str(), 0) ==
-                  0) {
+            if (fnmatch(("*" + *it).c_str(), instFilename.str().c_str(), 0) ==
+                0) {
 
-                instrumentFunction = true;
-                break;
-
-              }
+              instrumentFunction = true;
+              break;
 
             }
 
@@ -197,6 +206,13 @@ bool AFLcheckIfInstrument::runOnModule(Module &M) {
 
         }
 
+      } else {
+
+        if (!be_quiet)
+          WARNF("No debug information found for function %s, recompile with -g",
+                F.getName().str().c_str());
+        continue;
+
       }
 
       /* Either we couldn't figure out our location or the location is