summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Fuzzer/FuzzerTraceState.cpp
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2015-07-30 01:34:58 +0000
committerKostya Serebryany <kcc@google.com>2015-07-30 01:34:58 +0000
commit0e776a2250e0c269aefae5d04598199545ce9bd2 (patch)
treeeb37d8e42180b468b84f5f7e281a369bcc3c3254 /llvm/lib/Fuzzer/FuzzerTraceState.cpp
parent00bd0a403419952b46ae2e679dc71f8d044f115c (diff)
downloadbcm5719-llvm-0e776a2250e0c269aefae5d04598199545ce9bd2.tar.gz
bcm5719-llvm-0e776a2250e0c269aefae5d04598199545ce9bd2.zip
[libFuzzer] implement memcmp hook for data-flow-guided fuzzing (w/o dfsan), extend the memcmp fuzzer test
llvm-svn: 243603
Diffstat (limited to 'llvm/lib/Fuzzer/FuzzerTraceState.cpp')
-rw-r--r--llvm/lib/Fuzzer/FuzzerTraceState.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerTraceState.cpp b/llvm/lib/Fuzzer/FuzzerTraceState.cpp
index 60524a91320..9c7f9966708 100644
--- a/llvm/lib/Fuzzer/FuzzerTraceState.cpp
+++ b/llvm/lib/Fuzzer/FuzzerTraceState.cpp
@@ -394,6 +394,18 @@ void dfsan_weak_hook_memcmp(void *caller_pc, const void *s1, const void *s2,
TS->DFSanCmpCallback(PC, n, fuzzer::ICMP_EQ, S1, S2, L1, L2);
}
+void __sanitizer_weak_hook_memcmp(void *caller_pc, const void *s1,
+ const void *s2, size_t n) {
+ if (!TS) return;
+ uintptr_t PC = reinterpret_cast<uintptr_t>(caller_pc);
+ uint64_t S1 = 0, S2 = 0;
+ // Simplification: handle only first 8 bytes.
+ memcpy(&S1, s1, std::min(n, sizeof(S1)));
+ memcpy(&S2, s2, std::min(n, sizeof(S2)));
+ TS->TraceCmpCallback(PC, n, fuzzer::ICMP_EQ, S1, S2);
+ // fuzzer::Printf("ZZZ %p %p %zd\n", s1, s2, n);
+}
+
void __sanitizer_cov_trace_cmp(uint64_t SizeAndType, uint64_t Arg1,
uint64_t Arg2) {
if (!TS) return;
OpenPOWER on IntegriCloud