2013-08-13 07:51:33 +08:00
|
|
|
//===-- dfsan.h -------------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// 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
|
2013-08-13 07:51:33 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file is a part of DataFlowSanitizer.
|
|
|
|
//
|
|
|
|
// Private DFSan header.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef DFSAN_H
|
|
|
|
#define DFSAN_H
|
|
|
|
|
2013-11-17 17:41:47 +08:00
|
|
|
#include "sanitizer_common/sanitizer_internal_defs.h"
|
2015-11-27 20:43:33 +08:00
|
|
|
#include "dfsan_platform.h"
|
2013-11-17 17:41:47 +08:00
|
|
|
|
2016-09-16 05:02:18 +08:00
|
|
|
using __sanitizer::uptr;
|
|
|
|
using __sanitizer::u16;
|
|
|
|
|
2013-11-17 17:41:47 +08:00
|
|
|
// 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" {
|
2014-06-05 01:54:51 +08:00
|
|
|
void dfsan_add_label(dfsan_label label, void *addr, uptr size);
|
2013-11-17 17:41:47 +08:00
|
|
|
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>
|
2019-09-12 10:20:36 +08:00
|
|
|
void dfsan_set_label(dfsan_label label, T &data) { // NOLINT
|
2013-11-17 17:41:47 +08:00
|
|
|
dfsan_set_label(label, (void *)&data, sizeof(T));
|
|
|
|
}
|
2013-08-13 07:51:33 +08:00
|
|
|
|
|
|
|
namespace __dfsan {
|
|
|
|
|
2013-08-16 05:18:53 +08:00
|
|
|
void InitializeInterceptors();
|
|
|
|
|
2013-08-13 07:51:33 +08:00
|
|
|
inline dfsan_label *shadow_for(void *ptr) {
|
2015-11-27 20:43:33 +08:00
|
|
|
return (dfsan_label *) ((((uptr) ptr) & ShadowMask()) << 1);
|
2013-08-13 07:51:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
inline const dfsan_label *shadow_for(const void *ptr) {
|
|
|
|
return shadow_for(const_cast<void *>(ptr));
|
|
|
|
}
|
|
|
|
|
2013-09-10 09:51:35 +08:00
|
|
|
struct Flags {
|
2015-01-07 08:38:00 +08:00
|
|
|
#define DFSAN_FLAG(Type, Name, DefaultValue, Description) Type Name;
|
|
|
|
#include "dfsan_flags.inc"
|
|
|
|
#undef DFSAN_FLAG
|
|
|
|
|
|
|
|
void SetDefaults();
|
2013-09-10 09:51:35 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
extern Flags flags_data;
|
|
|
|
inline Flags &flags() {
|
|
|
|
return flags_data;
|
|
|
|
}
|
|
|
|
|
2013-08-13 07:51:33 +08:00
|
|
|
} // namespace __dfsan
|
|
|
|
|
|
|
|
#endif // DFSAN_H
|