about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAndrea Fioraldi <andreafioraldi@gmail.com>2021-03-04 15:12:08 +0100
committerAndrea Fioraldi <andreafioraldi@gmail.com>2021-03-04 15:12:08 +0100
commitbe5274d4a9c7fb835530be5054132253d2559ade (patch)
treef844521876164e6e4bc03f8a39c378630e992046
parent0aa93afeb82c610fd39b5dd4a3dd7482b9f86b1e (diff)
downloadafl++-be5274d4a9c7fb835530be5054132253d2559ade.tar.gz
fix kctx compilation hang
-rw-r--r--include/envs.h1
-rw-r--r--instrumentation/afl-llvm-pass.so.cc13
2 files changed, 9 insertions, 5 deletions
diff --git a/include/envs.h b/include/envs.h
index 26f4de90..e8595ef7 100644
--- a/include/envs.h
+++ b/include/envs.h
@@ -81,6 +81,7 @@ static char *afl_environment_variables[] = {
     "AFL_LLVM_CMPLOG",
     "AFL_LLVM_INSTRIM",
     "AFL_LLVM_CTX",
+    "AFL_LLVM_CTX_K",
     "AFL_LLVM_DICT2FILE",
     "AFL_LLVM_DOCUMENT_IDS",
     "AFL_LLVM_INSTRIM_LOOPHEAD",
diff --git a/instrumentation/afl-llvm-pass.so.cc b/instrumentation/afl-llvm-pass.so.cc
index c58e9d95..fbf55f81 100644
--- a/instrumentation/afl-llvm-pass.so.cc
+++ b/instrumentation/afl-llvm-pass.so.cc
@@ -363,15 +363,18 @@ bool AFLCoverage::runOnModule(Module &M) {
 
   Constant *PrevLocShuffleMask = ConstantVector::get(PrevLocShuffle);
   
+  Constant *PrevCallerShuffleMask = NULL;
   SmallVector<Constant *, 32> PrevCallerShuffle = {UndefValue::get(Int32Ty)};
 
-  for (unsigned I = 0; I < PrevCallerSize - 1; ++I)
-    PrevCallerShuffle.push_back(ConstantInt::get(Int32Ty, I));
+  if (ctx_k) {
+    for (unsigned I = 0; I < PrevCallerSize - 1; ++I)
+      PrevCallerShuffle.push_back(ConstantInt::get(Int32Ty, I));
 
-  for (int I = PrevCallerSize; I < PrevCallerVecSize; ++I)
-    PrevCallerShuffle.push_back(ConstantInt::get(Int32Ty, PrevCallerSize));
+    for (int I = PrevCallerSize; I < PrevCallerVecSize; ++I)
+      PrevCallerShuffle.push_back(ConstantInt::get(Int32Ty, PrevCallerSize));
 
-  Constant *PrevCallerShuffleMask = ConstantVector::get(PrevCallerShuffle);
+    PrevCallerShuffleMask = ConstantVector::get(PrevCallerShuffle);
+  }
 #endif
 
   // other constants we need