diff options
author | Andrea Fioraldi <andreafioraldi@gmail.com> | 2020-09-08 20:58:44 +0200 |
---|---|---|
committer | Andrea Fioraldi <andreafioraldi@gmail.com> | 2020-09-08 20:58:44 +0200 |
commit | eb9f323d7c0252c8cb4229181c8b22dbdf113759 (patch) | |
tree | 4139fd9b343dcdcec9cd8c71a8984d167ed2b00c /instrumentation/afl-compiler-rt.o.c | |
parent | fe98e2d760a343938de229a4253a151e3b7f7abb (diff) | |
parent | ab744abc4b3c90bee355807e7b6e40ba86f23e74 (diff) | |
download | afl++-eb9f323d7c0252c8cb4229181c8b22dbdf113759.tar.gz |
Merge branch 'dev' of github.com:vanhauser-thc/AFLplusplus into dev
Diffstat (limited to 'instrumentation/afl-compiler-rt.o.c')
-rw-r--r-- | instrumentation/afl-compiler-rt.o.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/instrumentation/afl-compiler-rt.o.c b/instrumentation/afl-compiler-rt.o.c index a3d75b15..0e8b97a2 100644 --- a/instrumentation/afl-compiler-rt.o.c +++ b/instrumentation/afl-compiler-rt.o.c @@ -38,7 +38,9 @@ #include <sys/wait.h> #include <sys/types.h> -#include "llvm/Config/llvm-config.h" +#if !__GNUC__ + #include "llvm/Config/llvm-config.h" +#endif #ifdef __linux__ #include "snapshot-inl.h" @@ -109,14 +111,22 @@ static u8 _is_sancov; void __afl_trace(const u32 x) { + PREV_LOC_T prev = __afl_prev_loc[0]; + __afl_prev_loc[0] = (x >> 1); + + u8 *p = &__afl_area_ptr[prev ^ x]; + #if 1 /* enable for neverZero feature. */ - __afl_area_ptr[__afl_prev_loc[0] ^ x] += - 1 + ((u8)(1 + __afl_area_ptr[__afl_prev_loc[0] ^ x]) == 0); + #if __GNUC__ + u8 c = __builtin_add_overflow(*p, 1, p); + *p += c; + #else + *p += 1 + ((u8)(1 + *p == 0); + #endif #else - ++__afl_area_ptr[__afl_prev_loc[0] ^ x]; + ++*p; #endif - __afl_prev_loc[0] = (x >> 1); return; } |