diff options
Diffstat (limited to 'llvm_mode')
-rw-r--r-- | llvm_mode/Makefile | 2 | ||||
-rw-r--r-- | llvm_mode/cmplog-instructions-pass.cc | 5 | ||||
-rw-r--r-- | llvm_mode/cmplog-routines-pass.cc | 7 | ||||
-rw-r--r-- | llvm_mode/compare-transform-pass.so.cc | 13 | ||||
-rw-r--r-- | llvm_mode/split-compares-pass.so.cc | 25 | ||||
-rw-r--r-- | llvm_mode/split-switches-pass.so.cc | 15 |
6 files changed, 46 insertions, 21 deletions
diff --git a/llvm_mode/Makefile b/llvm_mode/Makefile index b4746da3..9d68ddc7 100644 --- a/llvm_mode/Makefile +++ b/llvm_mode/Makefile @@ -137,7 +137,7 @@ override CFLAGS = -Wall \ -DAFL_PATH=\"$(HELPER_PATH)\" -DBIN_PATH=\"$(BIN_PATH)\" \ -DLLVM_BINDIR=\"$(LLVM_BINDIR)\" -DVERSION=\"$(VERSION)\" \ -DLLVM_VERSION=\"$(LLVMVER)\" -DAFL_CLANG_FLTO=\"$(AFL_CLANG_FLTO)\" \ - -DAFL_REAL_LD=\"$(AFL_REAL_LD)\" + -DAFL_REAL_LD=\"$(AFL_REAL_LD)\" -Wno-unused-function ifdef AFL_TRACE_PC CFLAGS += -DUSE_TRACE_PC=1 endif diff --git a/llvm_mode/cmplog-instructions-pass.cc b/llvm_mode/cmplog-instructions-pass.cc index 586a8244..dc72a3e4 100644 --- a/llvm_mode/cmplog-instructions-pass.cc +++ b/llvm_mode/cmplog-instructions-pass.cc @@ -92,6 +92,7 @@ class CmpLogInstructions : public ModulePass { protected: std::list<std::string> myWhitelist; + int be_quiet = 0; private: bool hookInstrs(Module &M); @@ -336,7 +337,7 @@ bool CmpLogInstructions::hookInstrs(Module &M) { } if (!icomps.size()) return false; - errs() << "Hooking " << icomps.size() << " cmp instructions\n"; + if (!be_quiet) errs() << "Hooking " << icomps.size() << " cmp instructions\n"; for (auto &selectcmpInst : icomps) { @@ -378,6 +379,8 @@ bool CmpLogInstructions::runOnModule(Module &M) { if (getenv("AFL_QUIET") == NULL) llvm::errs() << "Running cmplog-instructions-pass by andreafioraldi@gmail.com\n"; + else + be_quiet = 1; hookInstrs(M); verifyModule(M); diff --git a/llvm_mode/cmplog-routines-pass.cc b/llvm_mode/cmplog-routines-pass.cc index b24aaa4e..f58e351c 100644 --- a/llvm_mode/cmplog-routines-pass.cc +++ b/llvm_mode/cmplog-routines-pass.cc @@ -92,6 +92,7 @@ class CmpLogRoutines : public ModulePass { protected: std::list<std::string> myWhitelist; + int be_quiet = 0; private: bool hookRtns(Module &M); @@ -274,7 +275,9 @@ bool CmpLogRoutines::hookRtns(Module &M) { } if (!calls.size()) return false; - errs() << "Hooking " << calls.size() << " calls with pointers as arguments\n"; + if (!be_quiet) + errs() << "Hooking " << calls.size() + << " calls with pointers as arguments\n"; for (auto &callInst : calls) { @@ -302,6 +305,8 @@ bool CmpLogRoutines::runOnModule(Module &M) { if (getenv("AFL_QUIET") == NULL) llvm::errs() << "Running cmplog-routines-pass by andreafioraldi@gmail.com\n"; + else + be_quiet = 1; hookRtns(M); verifyModule(M); diff --git a/llvm_mode/compare-transform-pass.so.cc b/llvm_mode/compare-transform-pass.so.cc index b08bcb8c..2ca70659 100644 --- a/llvm_mode/compare-transform-pass.so.cc +++ b/llvm_mode/compare-transform-pass.so.cc @@ -92,6 +92,7 @@ class CompareTransform : public ModulePass { protected: std::list<std::string> myWhitelist; + int be_quiet = 0; private: bool transformCmps(Module &M, const bool processStrcmp, @@ -350,8 +351,9 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp, } if (!calls.size()) return false; - errs() << "Replacing " << calls.size() - << " calls to strcmp/memcmp/strncmp/strcasecmp/strncasecmp\n"; + if (!be_quiet) + errs() << "Replacing " << calls.size() + << " calls to strcmp/memcmp/strncmp/strcasecmp/strncasecmp\n"; for (auto &callInst : calls) { @@ -409,8 +411,9 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp, if (isSizedcmp && constLen > sizedLen) { constLen = sizedLen; } - errs() << callInst->getCalledFunction()->getName() << ": len " << constLen - << ": " << ConstStr << "\n"; + if (!be_quiet) + errs() << callInst->getCalledFunction()->getName() << ": len " << constLen + << ": " << ConstStr << "\n"; /* split before the call instruction */ BasicBlock *bb = callInst->getParent(); @@ -500,6 +503,8 @@ bool CompareTransform::runOnModule(Module &M) { if (isatty(2) && getenv("AFL_QUIET") == NULL) llvm::errs() << "Running compare-transform-pass by laf.intel@gmail.com, " "extended by heiko@hexco.de\n"; + else + be_quiet = 1; transformCmps(M, true, true, true, true, true); verifyModule(M); diff --git a/llvm_mode/split-compares-pass.so.cc b/llvm_mode/split-compares-pass.so.cc index ec301b6a..d296ba3d 100644 --- a/llvm_mode/split-compares-pass.so.cc +++ b/llvm_mode/split-compares-pass.so.cc @@ -106,6 +106,7 @@ class SplitComparesTransform : public ModulePass { protected: std::list<std::string> myWhitelist; + int be_quiet = 0; private: int enableFPSplit; @@ -1244,7 +1245,8 @@ bool SplitComparesTransform::runOnModule(Module &M) { simplifyIntSignedness(M); - if (isatty(2) && getenv("AFL_QUIET") == NULL) { + if ((isatty(2) && getenv("AFL_QUIET") == NULL) || + getenv("AFL_DEBUG") != NULL) { errs() << "Split-compare-pass by laf.intel@gmail.com, extended by " "heiko@hexco.de\n"; @@ -1253,13 +1255,16 @@ bool SplitComparesTransform::runOnModule(Module &M) { errs() << "Split-floatingpoint-compare-pass: " << splitFPCompares(M) << " FP comparisons splitted\n"; - } + } else + + be_quiet = 1; switch (bitw) { case 64: - errs() << "Split-integer-compare-pass " << bitw - << "bit: " << splitIntCompares(M, bitw) << " splitted\n"; + if (!be_quiet) + errs() << "Split-integer-compare-pass " << bitw + << "bit: " << splitIntCompares(M, bitw) << " splitted\n"; bitw >>= 1; #if LLVM_VERSION_MAJOR > 3 || \ @@ -1267,8 +1272,9 @@ bool SplitComparesTransform::runOnModule(Module &M) { [[clang::fallthrough]]; /*FALLTHRU*/ /* FALLTHROUGH */ #endif case 32: - errs() << "Split-integer-compare-pass " << bitw - << "bit: " << splitIntCompares(M, bitw) << " splitted\n"; + if (!be_quiet) + errs() << "Split-integer-compare-pass " << bitw + << "bit: " << splitIntCompares(M, bitw) << " splitted\n"; bitw >>= 1; #if LLVM_VERSION_MAJOR > 3 || \ @@ -1276,14 +1282,15 @@ bool SplitComparesTransform::runOnModule(Module &M) { [[clang::fallthrough]]; /*FALLTHRU*/ /* FALLTHROUGH */ #endif case 16: - errs() << "Split-integer-compare-pass " << bitw - << "bit: " << splitIntCompares(M, bitw) << " splitted\n"; + if (!be_quiet) + errs() << "Split-integer-compare-pass " << bitw + << "bit: " << splitIntCompares(M, bitw) << " splitted\n"; bitw >>= 1; break; default: - errs() << "NOT Running split-compare-pass \n"; + if (!be_quiet) errs() << "NOT Running split-compare-pass \n"; return false; break; diff --git a/llvm_mode/split-switches-pass.so.cc b/llvm_mode/split-switches-pass.so.cc index c6f74b73..980dcb12 100644 --- a/llvm_mode/split-switches-pass.so.cc +++ b/llvm_mode/split-switches-pass.so.cc @@ -126,6 +126,7 @@ class SplitSwitchesTransform : public ModulePass { protected: std::list<std::string> myWhitelist; + int be_quiet = 0; private: bool splitSwitches(Module &M); @@ -473,8 +474,9 @@ bool SplitSwitchesTransform::splitSwitches(Module &M) { } if (!switches.size()) return false; - errs() << "Rewriting " << switches.size() << " switch statements " - << "\n"; + if (!be_quiet) + errs() << "Rewriting " << switches.size() << " switch statements " + << "\n"; for (auto &SI : switches) { @@ -486,14 +488,15 @@ bool SplitSwitchesTransform::splitSwitches(Module &M) { BasicBlock *Default = SI->getDefaultDest(); unsigned bitw = Val->getType()->getIntegerBitWidth(); - errs() << "switch: " << SI->getNumCases() << " cases " << bitw << " bit\n"; + if (!be_quiet) + errs() << "switch: " << SI->getNumCases() << " cases " << bitw + << " bit\n"; /* If there is only the default destination or the condition checks 8 bit or * less, don't bother with the code below. */ if (!SI->getNumCases() || bitw <= 8) { - if (isatty(2) && getenv("AFL_QUIET") == NULL) - errs() << "skip trivial switch..\n"; + if (!be_quiet) errs() << "skip trivial switch..\n"; continue; } @@ -560,6 +563,8 @@ bool SplitSwitchesTransform::runOnModule(Module &M) { if (isatty(2) && getenv("AFL_QUIET") == NULL) llvm::errs() << "Running split-switches-pass by laf.intel@gmail.com\n"; + else + be_quiet = 1; splitSwitches(M); verifyModule(M); |