#ifndef HWASAN_H
#define HWASAN_H
#include "hwasan_flags.h"
#include "hwasan_interface_internal.h"
#include "hwasan_mapping.h"
#include "sanitizer_common/sanitizer_common.h"
#include "sanitizer_common/sanitizer_flags.h"
#include "sanitizer_common/sanitizer_internal_defs.h"
#include "sanitizer_common/sanitizer_stacktrace.h"
#include "ubsan/ubsan_platform.h"
#ifndef HWASAN_CONTAINS_UBSAN
#define HWASAN_CONTAINS_UBSAN …
#endif
#ifndef HWASAN_WITH_INTERCEPTORS
#define HWASAN_WITH_INTERCEPTORS …
#endif
#ifndef HWASAN_REPLACE_OPERATORS_NEW_AND_DELETE
#define HWASAN_REPLACE_OPERATORS_NEW_AND_DELETE …
#endif
tag_t;
#if defined(HWASAN_ALIASING_MODE)
# if !defined(__x86_64__)
# error Aliasing mode is only supported on x86_64
# endif
constexpr unsigned kAddressTagShift = 39;
constexpr unsigned kTagBits = 3;
constexpr unsigned kTaggableRegionCheckShift =
__sanitizer::Max(kAddressTagShift + kTagBits + 1U, 44U);
#elif defined(__x86_64__)
constexpr unsigned kAddressTagShift = …;
constexpr unsigned kTagBits = …;
#else
constexpr unsigned kAddressTagShift = 56;
constexpr unsigned kTagBits = 8;
#endif
constexpr uptr kTagMask = …;
constexpr uptr kAddressTagMask = …;
const unsigned kShadowBaseAlignment = …;
const unsigned kRecordAddrBaseTagShift = …;
const unsigned kRecordFPShift = …;
const unsigned kRecordFPLShift = …;
const unsigned kRecordFPModulus = …;
static inline bool InTaggableRegion(uptr addr) { … }
static inline tag_t GetTagFromPointer(uptr p) { … }
static inline uptr UntagAddr(uptr tagged_addr) { … }
static inline void *UntagPtr(const void *tagged_ptr) { … }
static inline uptr AddTagToPointer(uptr p, tag_t tag) { … }
namespace __hwasan {
extern int hwasan_inited;
extern bool hwasan_init_is_running;
extern int hwasan_report_count;
bool InitShadow();
void InitializeOsSupport();
void InitThreads();
void InitializeInterceptors();
void HwasanAllocatorInit();
void HwasanAllocatorLock();
void HwasanAllocatorUnlock();
void *hwasan_malloc(uptr size, StackTrace *stack);
void *hwasan_calloc(uptr nmemb, uptr size, StackTrace *stack);
void *hwasan_realloc(void *ptr, uptr size, StackTrace *stack);
void *hwasan_reallocarray(void *ptr, uptr nmemb, uptr size, StackTrace *stack);
void *hwasan_valloc(uptr size, StackTrace *stack);
void *hwasan_pvalloc(uptr size, StackTrace *stack);
void *hwasan_aligned_alloc(uptr alignment, uptr size, StackTrace *stack);
void *hwasan_memalign(uptr alignment, uptr size, StackTrace *stack);
int hwasan_posix_memalign(void **memptr, uptr alignment, uptr size,
StackTrace *stack);
void hwasan_free(void *ptr, StackTrace *stack);
void InstallAtExitHandler();
#define GET_MALLOC_STACK_TRACE …
#define GET_FATAL_STACK_TRACE_PC_BP(pc, bp) …
void HwasanTSDInit();
void HwasanTSDThreadInit();
void HwasanAtExit();
void HwasanOnDeadlySignal(int signo, void *info, void *context);
void HwasanInstallAtForkHandler();
void InstallAtExitCheckLeaks();
void UpdateMemoryUsage();
void AppendToErrorMessageBuffer(const char *buffer);
void AndroidTestTlsSlot();
struct AccessInfo { … };
void HandleTagMismatch(AccessInfo ai, uptr pc, uptr frame, void *uc,
uptr *registers_frame = nullptr);
void HwasanTagMismatch(uptr addr, uptr pc, uptr frame, uptr access_info,
uptr *registers_frame, size_t outsize);
}
#if HWASAN_WITH_INTERCEPTORS
__hw_sigset_t;
# if defined(__aarch64__)
constexpr size_t kHwRegisterBufSize = 22;
# elif defined(__x86_64__)
constexpr size_t kHwRegisterBufSize = …;
# elif SANITIZER_RISCV64
# ifndef __riscv_float_abi_soft
constexpr size_t kHwRegisterBufSize = 1 + 12 + 1 + 12;
# else
constexpr size_t kHwRegisterBufSize = 1 + 12 + 1;
# endif
# endif
__hw_register_buf;
struct __hw_jmp_buf_struct { … };
__hw_jmp_buf;
__hw_sigjmp_buf;
constexpr unsigned kHwJmpBufMagic = …;
#endif
#define ENSURE_HWASAN_INITED() …
#endif