summaryrefslogtreecommitdiff
path: root/lib/dfsan/dfsan_custom.cc
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2015-05-07 00:04:39 +0000
committerKostya Serebryany <kcc@google.com>2015-05-07 00:04:39 +0000
commit0d1fa9f3440bb80cf016341a5948097533be95fa (patch)
treeb3f20dc462c64a48fb3851f8b29b0d7b43499881 /lib/dfsan/dfsan_custom.cc
parent12e289a3b21337ea63845d55d36cf7b3931a0dc0 (diff)
Add dfsan_weak_hook_memcmp
Summary: Add a weak hook to be called from dfsan's custom memcmp. The primary user will be lib/Fuzzer. If this works well we'll add more hooks (strcmp, etc). Test Plan: Will be covered by lib/Fuzzer tests. Reviewers: pcc Reviewed By: pcc Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D9541 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@236679 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/dfsan/dfsan_custom.cc')
-rw-r--r--lib/dfsan/dfsan_custom.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/dfsan/dfsan_custom.cc b/lib/dfsan/dfsan_custom.cc
index 35f6fb4cd..c58b471db 100644
--- a/lib/dfsan/dfsan_custom.cc
+++ b/lib/dfsan/dfsan_custom.cc
@@ -82,11 +82,20 @@ SANITIZER_INTERFACE_ATTRIBUTE char *__dfsw_strchr(const char *s, int c,
}
}
+SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
+void
+dfsan_weak_hook_memcmp(uptr caller_pc, const void *s1, const void *s2, size_t n,
+ dfsan_label s1_label, dfsan_label s2_label,
+ dfsan_label n_label);
+
SANITIZER_INTERFACE_ATTRIBUTE int __dfsw_memcmp(const void *s1, const void *s2,
size_t n, dfsan_label s1_label,
dfsan_label s2_label,
dfsan_label n_label,
dfsan_label *ret_label) {
+ if (dfsan_weak_hook_memcmp)
+ dfsan_weak_hook_memcmp(GET_CALLER_PC(), s1, s2, n, s1_label, s2_label,
+ n_label);
const char *cs1 = (const char *) s1, *cs2 = (const char *) s2;
for (size_t i = 0; i != n; ++i) {
if (cs1[i] != cs2[i]) {