aboutsummaryrefslogtreecommitdiff
path: root/instrumentation
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2021-01-05 10:35:12 +0100
committervan Hauser <vh@thc.org>2021-01-05 10:35:12 +0100
commit7acf410ab6a15de0ed339ad0b2a334943e24491f (patch)
tree2edf5fb9f47ed2a33adcf93f78cc2f312be38fa6 /instrumentation
parent6c095b3937565e0e3c645cab706269e8c764701e (diff)
downloadAFLplusplus-7acf410ab6a15de0ed339ad0b2a334943e24491f.tar.gz
afl coverage feature example
Diffstat (limited to 'instrumentation')
-rw-r--r--instrumentation/afl-compiler-rt.o.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/instrumentation/afl-compiler-rt.o.c b/instrumentation/afl-compiler-rt.o.c
index fdfc8d58..dbc49646 100644
--- a/instrumentation/afl-compiler-rt.o.c
+++ b/instrumentation/afl-compiler-rt.o.c
@@ -1313,3 +1313,46 @@ void __cmplog_rtn_hook(u8 *ptr1, u8 *ptr2) {
}
+/* COVERAGE manipulation features */
+
+// discard all coverage up to this point
+void __afl_coverage_discard() {
+
+ memset(__afl_area_ptr, 0, __afl_map_size);
+ __afl_area_ptr[0] = 1;
+
+ if (__afl_cmp_map) { memset(__afl_cmp_map, 0, sizeof(cmp_map)); }
+
+}
+
+// discard the testcase
+void __afl_coverage_abort() {
+
+ __afl_coverage_discard();
+ exit(0);
+
+}
+
+// For the following two functions to work there needs to be a global define,
+// eg. __AFL_COVERAGE(); after the headers which translates to
+// int __afl_selective_coverage = 1; by a -D from afl-cc
+int __afl_selective_coverage __attribute__((weak));
+// this variable is then used in the shm setup to create an additional map
+// if __afl_map_size > MAP_SIZE or cmplog is used.
+// Especially with cmplog this would result in a ~260MB mem increase per
+// target run.
+
+// disable coverage from this point onwards until turned on again
+void __afl_coverage_off() {
+
+ // switch __afl_area_ptr and __afl_cmp_map to (the same) dummy pointer
+
+}
+
+// enable coverage
+void __afl_coverage_on() {
+
+ // switch __afl_area_ptr and __afl_cmp_map to the real map
+
+}
+