notzero for afl-gcc

This commit is contained in:
van Hauser 2019-07-03 19:10:48 +02:00
parent 00b22e37df
commit 04c92c8470
2 changed files with 12 additions and 0 deletions

View File

@ -189,6 +189,7 @@ static const u8* main_payload_32 =
" orb $1, (%edx, %edi, 1)\n" " orb $1, (%edx, %edi, 1)\n"
#else #else
" incb (%edx, %edi, 1)\n" " incb (%edx, %edi, 1)\n"
" adcb $0, (%edx, %edi, 1)\n"
#endif /* ^SKIP_COUNTS */ #endif /* ^SKIP_COUNTS */
"\n" "\n"
"__afl_return:\n" "__afl_return:\n"
@ -417,6 +418,7 @@ static const u8* main_payload_64 =
" orb $1, (%rdx, %rcx, 1)\n" " orb $1, (%rdx, %rcx, 1)\n"
#else #else
" incb (%rdx, %rcx, 1)\n" " incb (%rdx, %rcx, 1)\n"
" adcb $0, (%rdx, %rcx, 1)\n"
#endif /* ^SKIP_COUNTS */ #endif /* ^SKIP_COUNTS */
"\n" "\n"
"__afl_return:\n" "__afl_return:\n"

View File

@ -287,6 +287,16 @@ bool AFLCoverage::runOnModule(Module &M) {
Value *HowMuch = IRB.CreateAdd(ConstantInt::get(Int8Ty, 1), cf); Value *HowMuch = IRB.CreateAdd(ConstantInt::get(Int8Ty, 1), cf);
Incr = IRB.CreateAdd(Counter, HowMuch); Incr = IRB.CreateAdd(Counter, HowMuch);
} else if (neverZero_counters_str[0] == '5') {
auto cf = IRB.CreateICmpEQ(Incr, ConstantInt::get(Int8Ty, 0));
auto carry = IRB.CreateZExt(cf, Int8Ty);
Incr = IRB.CreateAdd(Incr, carry);
} else if (neverZero_counters_str[0] == '6') {
auto cf = IRB.CreateICmpULT(Incr, ConstantInt::get(Int8Ty, 1));
auto carry = IRB.CreateZExt(cf, Int8Ty);
Incr = IRB.CreateAdd(Incr, carry);
// no other implementations yet // no other implementations yet
} else { } else {
fprintf(stderr, "Error: unknown value for AFL_NZERO_COUNTS: %s (valid is 1-4)\n", neverZero_counters_str); fprintf(stderr, "Error: unknown value for AFL_NZERO_COUNTS: %s (valid is 1-4)\n", neverZero_counters_str);