summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Fuzzer/FuzzerDFSan.h
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2015-09-10 18:48:38 +0000
committerKostya Serebryany <kcc@google.com>2015-09-10 18:48:38 +0000
commit65f50868e5a7637afef2d11be33f41116134a621 (patch)
tree61113651fe85c8e87736a5c6029c4ad52c694d2e /llvm/lib/Fuzzer/FuzzerDFSan.h
parentd26e213d1132fcffee523517e732473209b248c6 (diff)
downloadbcm5719-llvm-65f50868e5a7637afef2d11be33f41116134a621.tar.gz
bcm5719-llvm-65f50868e5a7637afef2d11be33f41116134a621.zip
[libFuzzer] refactor the code to allow building libFuzzer on platforms that don't have dfsan and don't support weak functions
llvm-svn: 247321
Diffstat (limited to 'llvm/lib/Fuzzer/FuzzerDFSan.h')
-rw-r--r--llvm/lib/Fuzzer/FuzzerDFSan.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerDFSan.h b/llvm/lib/Fuzzer/FuzzerDFSan.h
new file mode 100644
index 00000000000..6398575e695
--- /dev/null
+++ b/llvm/lib/Fuzzer/FuzzerDFSan.h
@@ -0,0 +1,51 @@
+//===- FuzzerDFSan.h - Internal header for the Fuzzer -----------*- C++ -* ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// DFSan interface.
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_FUZZER_DFSAN_H
+#define LLVM_FUZZER_DFSAN_H
+
+#ifndef LLVM_FUZZER_SUPPORTS_DFSAN
+# if defined(__linux__)
+# define LLVM_FUZZER_SUPPORTS_DFSAN 1
+# else
+# define LLVM_FUZZER_SUPPORTS_DFSAN 0
+# endif // __linux__
+#endif // LLVM_FUZZER_SUPPORTS_DFSAN
+
+#include <sanitizer/dfsan_interface.h>
+#if LLVM_FUZZER_SUPPORTS_DFSAN
+
+extern "C" {
+__attribute__((weak))
+dfsan_label dfsan_create_label(const char *desc, void *userdata);
+__attribute__((weak))
+void dfsan_set_label(dfsan_label label, void *addr, size_t size);
+__attribute__((weak))
+void dfsan_add_label(dfsan_label label, void *addr, size_t size);
+__attribute__((weak))
+const struct dfsan_label_info *dfsan_get_label_info(dfsan_label label);
+__attribute__((weak))
+dfsan_label dfsan_read_label(const void *addr, size_t size);
+} // extern "C"
+
+namespace fuzzer {
+static bool ReallyHaveDFSan() {
+ return &dfsan_create_label != nullptr;
+}
+} // namespace fuzzer
+#else
+namespace fuzzer {
+static bool ReallyHaveDFSan() { return false; }
+} // namespace fuzzer
+
+#endif
+
+#endif // LLVM_FUZZER_DFSAN_H
OpenPOWER on IntegriCloud