diff options
Diffstat (limited to 'llvm_mode')
-rw-r--r-- | llvm_mode/afl-clang-fast.c | 9 | ||||
-rw-r--r-- | llvm_mode/afl-llvm-rt.o.c | 3 | ||||
-rw-r--r-- | llvm_mode/cmplog-instructions-pass.cc | 41 |
3 files changed, 28 insertions, 25 deletions
diff --git a/llvm_mode/afl-clang-fast.c b/llvm_mode/afl-clang-fast.c index fa534438..fe958ac7 100644 --- a/llvm_mode/afl-clang-fast.c +++ b/llvm_mode/afl-clang-fast.c @@ -206,20 +206,20 @@ static void edit_params(u32 argc, char** argv) { cc_params[cc_par_cnt++] = "-Xclang"; cc_params[cc_par_cnt++] = alloc_printf("%s/cmplog-routines-pass.so", obj_path); - + // reuse split switches from laf cc_params[cc_par_cnt++] = "-Xclang"; cc_params[cc_par_cnt++] = "-load"; cc_params[cc_par_cnt++] = "-Xclang"; cc_params[cc_par_cnt++] = alloc_printf("%s/split-switches-pass.so", obj_path); - + cc_params[cc_par_cnt++] = "-Xclang"; cc_params[cc_par_cnt++] = "-load"; cc_params[cc_par_cnt++] = "-Xclang"; cc_params[cc_par_cnt++] = alloc_printf("%s/cmplog-instructions-pass.so", obj_path); - + cc_params[cc_par_cnt++] = "-fno-inline"; } @@ -245,8 +245,7 @@ static void edit_params(u32 argc, char** argv) { cc_params[cc_par_cnt++] = "-load"; cc_params[cc_par_cnt++] = "-Xclang"; if (getenv("AFL_LLVM_INSTRIM") != NULL || getenv("INSTRIM_LIB") != NULL) - cc_params[cc_par_cnt++] = - alloc_printf("%s/libLLVMInsTrim.so", obj_path); + cc_params[cc_par_cnt++] = alloc_printf("%s/libLLVMInsTrim.so", obj_path); else cc_params[cc_par_cnt++] = alloc_printf("%s/afl-llvm-pass.so", obj_path); diff --git a/llvm_mode/afl-llvm-rt.o.c b/llvm_mode/afl-llvm-rt.o.c index bd349504..320b3d96 100644 --- a/llvm_mode/afl-llvm-rt.o.c +++ b/llvm_mode/afl-llvm-rt.o.c @@ -260,7 +260,8 @@ static void __afl_start_forkserver(void) { } -/* A simplified persistent mode handler, used as explained in llvm_mode/README.md. */ +/* A simplified persistent mode handler, used as explained in + * llvm_mode/README.md. */ int __afl_persistent_loop(unsigned int max_cnt) { diff --git a/llvm_mode/cmplog-instructions-pass.cc b/llvm_mode/cmplog-instructions-pass.cc index f6ee4a4c..586a8244 100644 --- a/llvm_mode/cmplog-instructions-pass.cc +++ b/llvm_mode/cmplog-instructions-pass.cc @@ -105,14 +105,14 @@ char CmpLogInstructions::ID = 0; bool CmpLogInstructions::hookInstrs(Module &M) { std::vector<Instruction *> icomps; - LLVMContext & C = M.getContext(); + LLVMContext & C = M.getContext(); Type * VoidTy = Type::getVoidTy(C); - IntegerType * Int8Ty = IntegerType::getInt8Ty(C); - IntegerType * Int16Ty = IntegerType::getInt16Ty(C); - IntegerType * Int32Ty = IntegerType::getInt32Ty(C); - IntegerType * Int64Ty = IntegerType::getInt64Ty(C); - + IntegerType *Int8Ty = IntegerType::getInt8Ty(C); + IntegerType *Int16Ty = IntegerType::getInt16Ty(C); + IntegerType *Int32Ty = IntegerType::getInt32Ty(C); + IntegerType *Int64Ty = IntegerType::getInt64Ty(C); + #if LLVM_VERSION_MAJOR < 9 Constant * #else @@ -120,8 +120,8 @@ bool CmpLogInstructions::hookInstrs(Module &M) { #endif c1 = M.getOrInsertFunction("__cmplog_ins_hook1", VoidTy, Int8Ty, Int8Ty #if LLVM_VERSION_MAJOR < 5 - , - NULL + , + NULL #endif ); #if LLVM_VERSION_MAJOR < 9 @@ -137,8 +137,8 @@ bool CmpLogInstructions::hookInstrs(Module &M) { #endif c2 = M.getOrInsertFunction("__cmplog_ins_hook2", VoidTy, Int16Ty, Int16Ty #if LLVM_VERSION_MAJOR < 5 - , - NULL + , + NULL #endif ); #if LLVM_VERSION_MAJOR < 9 @@ -154,8 +154,8 @@ bool CmpLogInstructions::hookInstrs(Module &M) { #endif c4 = M.getOrInsertFunction("__cmplog_ins_hook4", VoidTy, Int32Ty, Int32Ty #if LLVM_VERSION_MAJOR < 5 - , - NULL + , + NULL #endif ); #if LLVM_VERSION_MAJOR < 9 @@ -171,8 +171,8 @@ bool CmpLogInstructions::hookInstrs(Module &M) { #endif c8 = M.getOrInsertFunction("__cmplog_ins_hook8", VoidTy, Int64Ty, Int64Ty #if LLVM_VERSION_MAJOR < 5 - , - NULL + , + NULL #endif ); #if LLVM_VERSION_MAJOR < 9 @@ -339,29 +339,32 @@ bool CmpLogInstructions::hookInstrs(Module &M) { errs() << "Hooking " << icomps.size() << " cmp instructions\n"; for (auto &selectcmpInst : icomps) { - + IRBuilder<> IRB(selectcmpInst->getParent()); IRB.SetInsertPoint(selectcmpInst); auto op0 = selectcmpInst->getOperand(0); auto op1 = selectcmpInst->getOperand(1); - + IntegerType *intTyOp0 = dyn_cast<IntegerType>(op0->getType()); IntegerType *intTyOp1 = dyn_cast<IntegerType>(op1->getType()); - unsigned max_size = intTyOp0->getBitWidth() > intTyOp1->getBitWidth() ? - intTyOp0->getBitWidth() : intTyOp1->getBitWidth(); + unsigned max_size = intTyOp0->getBitWidth() > intTyOp1->getBitWidth() + ? intTyOp0->getBitWidth() + : intTyOp1->getBitWidth(); std::vector<Value *> args; args.push_back(op0); args.push_back(op1); switch (max_size) { + case 8: IRB.CreateCall(cmplogHookIns1, args, "tmp"); break; case 16: IRB.CreateCall(cmplogHookIns2, args, "tmp"); break; case 32: IRB.CreateCall(cmplogHookIns4, args, "tmp"); break; case 64: IRB.CreateCall(cmplogHookIns8, args, "tmp"); break; default: break; + } } @@ -383,7 +386,7 @@ bool CmpLogInstructions::runOnModule(Module &M) { } static void registerCmpLogInstructionsPass(const PassManagerBuilder &, - legacy::PassManagerBase &PM) { + legacy::PassManagerBase &PM) { auto p = new CmpLogInstructions(); PM.add(p); |