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