about summary refs log tree commit diff
path: root/llvm_mode/afl-llvm-common.cc
diff options
context:
space:
mode:
authorhexcoder- <heiko@hexco.de>2020-05-07 18:33:38 +0200
committerhexcoder- <heiko@hexco.de>2020-05-07 18:33:38 +0200
commitd217c7df055b9ca44e5398d8c7d50d43e0b2e56d (patch)
tree39b381389f65c029a6bdb6dae9bba9c9ec4160e6 /llvm_mode/afl-llvm-common.cc
parent9484da57ed3f421ac274ac51282dba779994da9a (diff)
parentef2ccc8117bb899616472e2d95525ae0ca1a2098 (diff)
downloadafl++-d217c7df055b9ca44e5398d8c7d50d43e0b2e56d.tar.gz
Merge branch 'dev' of https://github.com/AFLplusplus/AFLplusplus into dev
Diffstat (limited to 'llvm_mode/afl-llvm-common.cc')
-rw-r--r--llvm_mode/afl-llvm-common.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm_mode/afl-llvm-common.cc b/llvm_mode/afl-llvm-common.cc
index 04dd9475..c62b4c14 100644
--- a/llvm_mode/afl-llvm-common.cc
+++ b/llvm_mode/afl-llvm-common.cc
@@ -201,3 +201,20 @@ bool isInWhitelist(llvm::Function *F) {
 
 }
 
+// Calculate the number of average collisions that would occur if all
+// location IDs would be assigned randomly (like normal afl/afl++).
+// This uses the "balls in bins" algorithm.
+unsigned long long int calculateCollisions(uint32_t edges) {
+
+  double                 bins = MAP_SIZE;
+  double                 balls = edges;
+  double                 step1 = 1 - (1 / bins);
+  double                 step2 = pow(step1, balls);
+  double                 step3 = bins * step2;
+  double                 step4 = round(step3);
+  unsigned long long int empty = step4;
+  unsigned long long int collisions = edges - (MAP_SIZE - empty);
+  return collisions;
+
+}
+