1 //===-- dfsan.h -------------------------------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file is a part of DataFlowSanitizer.
11 //
12 // Private DFSan header.
13 //===----------------------------------------------------------------------===//
14
15 #ifndef DFSAN_H
16 #define DFSAN_H
17
18 #include "sanitizer_common/sanitizer_internal_defs.h"
19 #include "dfsan_platform.h"
20
21 // Copy declarations from public sanitizer/dfsan_interface.h header here.
22 typedef u16 dfsan_label;
23
24 struct dfsan_label_info {
25 dfsan_label l1;
26 dfsan_label l2;
27 const char *desc;
28 void *userdata;
29 };
30
31 extern "C" {
32 void dfsan_add_label(dfsan_label label, void *addr, uptr size);
33 void dfsan_set_label(dfsan_label label, void *addr, uptr size);
34 dfsan_label dfsan_read_label(const void *addr, uptr size);
35 dfsan_label dfsan_union(dfsan_label l1, dfsan_label l2);
36 } // extern "C"
37
38 template <typename T>
dfsan_set_label(dfsan_label label,T & data)39 void dfsan_set_label(dfsan_label label, T &data) { // NOLINT
40 dfsan_set_label(label, (void *)&data, sizeof(T));
41 }
42
43 namespace __dfsan {
44
45 void InitializeInterceptors();
46
shadow_for(void * ptr)47 inline dfsan_label *shadow_for(void *ptr) {
48 return (dfsan_label *) ((((uptr) ptr) & ShadowMask()) << 1);
49 }
50
shadow_for(const void * ptr)51 inline const dfsan_label *shadow_for(const void *ptr) {
52 return shadow_for(const_cast<void *>(ptr));
53 }
54
55 struct Flags {
56 #define DFSAN_FLAG(Type, Name, DefaultValue, Description) Type Name;
57 #include "dfsan_flags.inc"
58 #undef DFSAN_FLAG
59
60 void SetDefaults();
61 };
62
63 extern Flags flags_data;
flags()64 inline Flags &flags() {
65 return flags_data;
66 }
67
68 } // namespace __dfsan
69
70 #endif // DFSAN_H
71