more honoring be_quiet
MODIFY
llvm_mode/Makefile
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

MODIFY
llvm_mode/cmplog-instructions-pass.cc
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);

MODIFY
llvm_mode/cmplog-routines-pass.cc
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);

MODIFY
llvm_mode/compare-transform-pass.so.cc
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,6 +351,7 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp,
}
if (!calls.size()) return false;
+ if (!be_quiet)
errs() << "Replacing " << calls.size()
<< " calls to strcmp/memcmp/strncmp/strcasecmp/strncasecmp\n";
@@ -409,6 +411,7 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp,
if (isSizedcmp && constLen > sizedLen) { constLen = sizedLen; }
+ if (!be_quiet)
errs() << callInst->getCalledFunction()->getName() << ": len " << constLen
<< ": " << ConstStr << "\n";
@@ -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);

MODIFY
llvm_mode/split-compares-pass.so.cc
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,11 +1255,14 @@ bool SplitComparesTransform::runOnModule(Module &M) {
errs() << "Split-floatingpoint-compare-pass: " << splitFPCompares(M)
<< " FP comparisons splitted\n";
- }
+ } else
+
+ be_quiet = 1;
switch (bitw) {
case 64:
+ if (!be_quiet)
errs() << "Split-integer-compare-pass " << bitw
<< "bit: " << splitIntCompares(M, bitw) << " splitted\n";
@@ -1267,6 +1272,7 @@ bool SplitComparesTransform::runOnModule(Module &M) {
[[clang::fallthrough]]; /*FALLTHRU*/ /* FALLTHROUGH */
#endif
case 32:
+ if (!be_quiet)
errs() << "Split-integer-compare-pass " << bitw
<< "bit: " << splitIntCompares(M, bitw) << " splitted\n";
@@ -1276,6 +1282,7 @@ bool SplitComparesTransform::runOnModule(Module &M) {
[[clang::fallthrough]]; /*FALLTHRU*/ /* FALLTHROUGH */
#endif
case 16:
+ if (!be_quiet)
errs() << "Split-integer-compare-pass " << bitw
<< "bit: " << splitIntCompares(M, bitw) << " splitted\n";
@@ -1283,7 +1290,7 @@ bool SplitComparesTransform::runOnModule(Module &M) {
break;
default:
- errs() << "NOT Running split-compare-pass \n";
+ if (!be_quiet) errs() << "NOT Running split-compare-pass \n";
return false;
break;

MODIFY
llvm_mode/split-switches-pass.so.cc
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,6 +474,7 @@ bool SplitSwitchesTransform::splitSwitches(Module &M) {
}
if (!switches.size()) return false;
+ if (!be_quiet)
errs() << "Rewriting " << switches.size() << " switch statements "
<< "\n";
@@ -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);

more honoring be_quiet