about summary refs log tree commit diff
path: root/llvm_mode
diff options
context:
space:
mode:
Diffstat (limited to 'llvm_mode')
-rw-r--r--llvm_mode/LLVMInsTrim.so.cc17
-rw-r--r--llvm_mode/Makefile2
-rw-r--r--llvm_mode/compare-transform-pass.so.cc4
3 files changed, 12 insertions, 11 deletions
diff --git a/llvm_mode/LLVMInsTrim.so.cc b/llvm_mode/LLVMInsTrim.so.cc
index 81cf98c4..0a15680d 100644
--- a/llvm_mode/LLVMInsTrim.so.cc
+++ b/llvm_mode/LLVMInsTrim.so.cc
@@ -46,15 +46,13 @@ namespace {
     std::mt19937 generator;
     int total_instr = 0;
 
-    unsigned genLabel() {
-      return generator() % 65536;
+    unsigned int genLabel() {
+      return generator() & (MAP_SIZE - 1);
     }
 
   public:
     static char ID;
-    InsTrim() : ModulePass(ID), generator(0) {//}
-    
-//    AFLCoverage() : ModulePass(ID) {
+    InsTrim() : ModulePass(ID), generator(0) {
       char* instWhiteListFilename = getenv("AFL_LLVM_WHITELIST");
       if (instWhiteListFilename) {
         std::string line;
@@ -294,10 +292,11 @@ namespace {
           Value *Incr = IRB.CreateAdd(Counter, ConstantInt::get(Int8Ty, 1));
 
 #if LLVM_VERSION_MAJOR < 9
-          if (neverZero_counters_str != NULL) { // with llvm 9 we make this the default as the bug in llvm is then fixed
+          if (neverZero_counters_str != NULL) // with llvm 9 we make this the default as the bug in llvm is then fixed
 #else
-  #warning "neverZero implementation needs to be reviewed!"
+          if (1) // with llvm 9 we make this the default as the bug in llvm is then fixed
 #endif
+          {
           /* hexcoder: Realize a counter that skips zero during overflow.
            * Once this counter reaches its maximum value, it next increments to 1
            *
@@ -310,15 +309,13 @@ namespace {
             auto cf = IRB.CreateICmpEQ(Incr, ConstantInt::get(Int8Ty, 0));
             auto carry = IRB.CreateZExt(cf, Int8Ty);
             Incr = IRB.CreateAdd(Incr, carry);
-#if LLVM_VERSION_MAJOR < 9
           }
-#endif
    
           IRB.CreateStore(Incr, MapPtrIdx)->setMetadata(M.getMDKindID("nosanitize"), MDNode::get(C, None));
    
           /* Set prev_loc to cur_loc >> 1 */
           /*
-          StoreInst *Store = IRB.CreateStore(ConstantInt::get(Int32Ty, cur_loc >> 1), AFLPrevLoc);
+          StoreInst *Store = IRB.CreateStore(ConstantInt::get(Int32Ty, L >> 1), OldPrev);
           Store->setMetadata(M.getMDKindID("nosanitize"), MDNode::get(C, None));
           */
 
diff --git a/llvm_mode/Makefile b/llvm_mode/Makefile
index 2b685ddc..d01fbbdf 100644
--- a/llvm_mode/Makefile
+++ b/llvm_mode/Makefile
@@ -174,7 +174,7 @@ endif
 test_build: $(PROGS)
 	@echo "[*] Testing the CC wrapper and instrumentation output..."
 	unset AFL_USE_ASAN AFL_USE_MSAN AFL_INST_RATIO; AFL_QUIET=1 AFL_PATH=. AFL_CC=$(CC) AFL_LLVM_LAF_SPLIT_SWITCHES=1 AFL_LLVM_LAF_TRANSFORM_COMPARES=1 AFL_LLVM_LAF_SPLIT_COMPARES=1 ../afl-clang-fast $(CFLAGS) ../test-instr.c -o test-instr $(LDFLAGS)
-	echo 0 | ../afl-showmap -m none -q -o .test-instr0 ./test-instr
+	../afl-showmap -m none -q -o .test-instr0 ./test-instr </dev/null
 	echo 1 | ../afl-showmap -m none -q -o .test-instr1 ./test-instr
 	@rm -f test-instr
 	@cmp -s .test-instr0 .test-instr1; DR="$$?"; rm -f .test-instr0 .test-instr1; if [ "$$DR" = "0" ]; then echo; echo "Oops, the instrumentation does not seem to be behaving correctly!"; echo; echo "Please ping <lcamtuf@google.com> to troubleshoot the issue."; echo; exit 1; fi
diff --git a/llvm_mode/compare-transform-pass.so.cc b/llvm_mode/compare-transform-pass.so.cc
index d0dbe8ec..e7886db1 100644
--- a/llvm_mode/compare-transform-pass.so.cc
+++ b/llvm_mode/compare-transform-pass.so.cc
@@ -82,7 +82,11 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp, const
 					 , nullptr
 #endif
 					 );
+#if LLVM_VERSION_MAJOR < 9
   Function* tolowerFn = cast<Function>(c);
+#else
+  FunctionCallee tolowerFn = c;
+#endif
 
   /* iterate over all functions, bbs and instruction and add suitable calls to strcmp/memcmp/strncmp/strcasecmp/strncasecmp */
   for (auto &F : M) {