selective coverage fix
MODIFY
instrumentation/afl-compiler-rt.o.c
instrumentation/afl-compiler-rt.o.c
@@ -1435,19 +1435,15 @@ void __afl_coverage_abort() {
}
// mark this area as especially interesting
-void __afl_coverage_interesting(u32 id, u8 val) {
+void __afl_coverage_interesting(u8 val, u32 id) {
- if (val) {
+ if (id) {
__afl_area_ptr[id] = val;
} else {
- do {
-
- __afl_area_ptr[id] = (u8)rand();
-
- } while (!__afl_area_ptr[id]);
+ __afl_area_ptr[(rand() % __afl_map_size)] = val;
}

MODIFY
src/afl-cc.c
src/afl-cc.c
@@ -829,8 +829,10 @@ static void edit_params(u32 argc, char **argv, char **envp) {
"extern unsigned char *__afl_fuzz_ptr;"
"unsigned char __afl_fuzz_alt[1048576];"
"unsigned char *__afl_fuzz_alt_ptr = __afl_fuzz_alt;";
+
if (plusplus_mode) {
+ cc_params[cc_par_cnt++] =
"-D__AFL_COVERAGE()=int __afl_selective_coverage = 1;"
"extern \"C\" void __afl_coverage_discard();"
"extern \"C\" void __afl_coverage_abort();"
@@ -1639,8 +1641,8 @@ int main(int argc, char **argv, char **envp) {
if (have_lto)
SAYF("afl-cc LTO with ld=%s %s\n", AFL_REAL_LD, AFL_CLANG_FLTO);
if (have_llvm)
- SAYF("afl-cc LLVM version %d using binary path \"%s\".\n",
- LLVM_MAJOR, LLVM_BINDIR);
+ SAYF("afl-cc LLVM version %d using binary path \"%s\".\n", LLVM_MAJOR,
+ LLVM_BINDIR);
#endif
#if defined(USEMMAP)

selective coverage fix