brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · 97df280 Raw
79 lines · c
1//===-- tysan.h -------------------------------------------------*- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8//9// This file is a part of TypeSanitizer.10//11// Private TySan header.12//===----------------------------------------------------------------------===//13 14#ifndef TYSAN_H15#define TYSAN_H16 17#include "sanitizer_common/sanitizer_internal_defs.h"18 19using __sanitizer::sptr;20using __sanitizer::u16;21using __sanitizer::uptr;22 23#include "tysan_platform.h"24 25extern "C" {26void tysan_set_type_unknown(const void *addr, uptr size);27void tysan_copy_types(const void *daddr, const void *saddr, uptr size);28}29 30namespace __tysan {31extern bool tysan_inited;32extern bool tysan_init_is_running;33 34void InitializeInterceptors();35 36enum { TYSAN_MEMBER_TD = 1, TYSAN_STRUCT_TD = 2 };37 38struct tysan_member_type_descriptor {39  struct tysan_type_descriptor *Base;40  struct tysan_type_descriptor *Access;41  uptr Offset;42};43 44struct tysan_struct_type_descriptor {45  uptr MemberCount;46  struct {47    struct tysan_type_descriptor *Type;48    uptr Offset;49  } Members[1]; // Tail allocated.50};51 52struct tysan_type_descriptor {53  uptr Tag;54  union {55    tysan_member_type_descriptor Member;56    tysan_struct_type_descriptor Struct;57  };58};59 60inline tysan_type_descriptor **shadow_for(const void *ptr) {61  return (tysan_type_descriptor **)((((uptr)ptr) & AppMask()) * sizeof(ptr) +62                                    ShadowAddr());63}64 65struct Flags {66#define TYSAN_FLAG(Type, Name, DefaultValue, Description) Type Name;67#include "tysan_flags.inc"68#undef TYSAN_FLAG69 70  void SetDefaults();71};72 73extern Flags flags_data;74inline Flags &flags() { return flags_data; }75 76} // namespace __tysan77 78#endif // TYSAN_H79