forked from OSchip/llvm-project
73 lines
1.8 KiB
C++
73 lines
1.8 KiB
C++
//===-- dfsan.h -------------------------------------------------*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file is a part of DataFlowSanitizer.
|
|
//
|
|
// Private DFSan header.
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef DFSAN_H
|
|
#define DFSAN_H
|
|
|
|
#include "sanitizer_common/sanitizer_internal_defs.h"
|
|
#include "dfsan_platform.h"
|
|
|
|
using __sanitizer::uptr;
|
|
using __sanitizer::u16;
|
|
|
|
// 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_add_label(dfsan_label label, void *addr, uptr size);
|
|
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) & ShadowMask()) << 1);
|
|
}
|
|
|
|
inline const dfsan_label *shadow_for(const void *ptr) {
|
|
return shadow_for(const_cast<void *>(ptr));
|
|
}
|
|
|
|
struct Flags {
|
|
#define DFSAN_FLAG(Type, Name, DefaultValue, Description) Type Name;
|
|
#include "dfsan_flags.inc"
|
|
#undef DFSAN_FLAG
|
|
|
|
void SetDefaults();
|
|
};
|
|
|
|
extern Flags flags_data;
|
|
inline Flags &flags() {
|
|
return flags_data;
|
|
}
|
|
|
|
} // namespace __dfsan
|
|
|
|
#endif // DFSAN_H
|