summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Fuzzer/FuzzerDFSan.h
blob: 6398575e6955454f0f97ae5de891f95272c81c60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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