about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2019-10-23 03:23:14 +0200
committervan Hauser <vh@thc.org>2019-10-23 03:23:14 +0200
commit1398d8d5a64b11a62e8ed25732e2114a5dc47564 (patch)
tree5c5c10101c27ef21328fe5aea38c8f8232b3d9a0
parent6bc874088fff699d170c89dd864c23507150fe3f (diff)
downloadafl++-1398d8d5a64b11a62e8ed25732e2114a5dc47564.tar.gz
gcc sucks
-rw-r--r--README.md4
-rw-r--r--gcc_plugin/afl-gcc-rt.o.c9
2 files changed, 8 insertions, 5 deletions
diff --git a/README.md b/README.md
index d58b49e2..de012e62 100644
--- a/README.md
+++ b/README.md
@@ -55,12 +55,14 @@
   | Feature/Instrumentation | AFL-GCC | LLVM_MODE | GCC_PLUGIN | QEMU_MODE | Unicorn |
   | ----------------------- |:-------:|:---------:|:----------:|:---------:|:-------:|
   | laf-intel / CompCov     |         |     x     |            |     x     |    x    |
-  | NeverZero               |    X    |     x(1)  |     X      |     x     |    x    |
+  | NeverZero               |    X    |     x(1)  |      (2)   |     x     |    x    |
   | Persistent mode         |         |     x     |     X      |     x     |         |
   | Whitelist               |         |     x     |     X      |           |         |
   | InsTrim                 |         |     x     |            |           |         |
 
+  neverZero:
   (1) only in LLVM >= 9.0 due to a bug in llvm in previous versions
+  (2) gcc create non-performant code, hence it is disabled in gcc_plugin
 
 
   So all in all this is the best-of AFL that is currently out there :-)
diff --git a/gcc_plugin/afl-gcc-rt.o.c b/gcc_plugin/afl-gcc-rt.o.c
index 1dfca9e3..47049167 100644
--- a/gcc_plugin/afl-gcc-rt.o.c
+++ b/gcc_plugin/afl-gcc-rt.o.c
@@ -58,10 +58,11 @@ __thread u32 __afl_prev_loc;
 void __afl_trace(u32 x) {
 
   u32 l = __afl_prev_loc;
-  const u32 n = l ^ x;
-  u8 *const bitmap_ptr = __afl_area_ptr + n;
-  *bitmap_ptr += 1 + (*bitmap_ptr == (u8)~0); /* neverZero */
-
+  __afl_area_ptr[l ^ x]++;
+  /* // neverZero is disable as gcc creates non-performant code. shame on you gcc
+  if (__afl_area_ptr[l ^ x] == 0)
+    __afl_area_ptr[l ^ x]++;
+  */
   __afl_prev_loc = (x >> 1);
   return;