diff options
Diffstat (limited to 'lib/dfsan/dfsan.h')
-rw-r--r-- | lib/dfsan/dfsan.h | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/lib/dfsan/dfsan.h b/lib/dfsan/dfsan.h new file mode 100644 index 000000000000..693e0c5efe04 --- /dev/null +++ b/lib/dfsan/dfsan.h @@ -0,0 +1,67 @@ +//===-- dfsan.h -------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file is a part of DataFlowSanitizer. +// +// Private DFSan header. +//===----------------------------------------------------------------------===// + +#ifndef DFSAN_H +#define DFSAN_H + +#include "sanitizer_common/sanitizer_internal_defs.h" + +// Copy declarations from public sanitizer/dfsan_interface.h header here. +typedef u16 dfsan_label; + +struct dfsan_label_info { + dfsan_label l1; + dfsan_label l2; + const char *desc; + void *userdata; +}; + +extern "C" { +void dfsan_set_label(dfsan_label label, void *addr, uptr size); +dfsan_label dfsan_read_label(const void *addr, uptr size); +dfsan_label dfsan_union(dfsan_label l1, dfsan_label l2); +} // extern "C" + +template <typename T> +void dfsan_set_label(dfsan_label label, T &data) { // NOLINT + dfsan_set_label(label, (void *)&data, sizeof(T)); +} + +namespace __dfsan { + +void InitializeInterceptors(); + +inline dfsan_label *shadow_for(void *ptr) { + return (dfsan_label *) ((((uptr) ptr) & ~0x700000000000) << 1); +} + +inline const dfsan_label *shadow_for(const void *ptr) { + return shadow_for(const_cast<void *>(ptr)); +} + +struct Flags { + // Whether to warn on unimplemented functions. + bool warn_unimplemented; + // Whether to warn on non-zero labels. + bool warn_nonzero_labels; +}; + +extern Flags flags_data; +inline Flags &flags() { + return flags_data; +} + +} // namespace __dfsan + +#endif // DFSAN_H |