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-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file is a part of TypeSanitizer. 10 // 11 // Private TySan header. 12 //===----------------------------------------------------------------------===// 13 14 #ifndef TYSAN_H 15 #define TYSAN_H 16 17 #include "sanitizer_common/sanitizer_internal_defs.h" 18 19 using __sanitizer::sptr; 20 using __sanitizer::u16; 21 using __sanitizer::uptr; 22 23 #include "tysan_platform.h" 24 25 extern "C" { 26 void tysan_set_type_unknown(const void *addr, uptr size); 27 void tysan_copy_types(const void *daddr, const void *saddr, uptr size); 28 } 29 30 namespace __tysan { 31 extern bool tysan_inited; 32 extern bool tysan_init_is_running; 33 34 void InitializeInterceptors(); 35 36 enum { TYSAN_MEMBER_TD = 1, TYSAN_STRUCT_TD = 2 }; 37 38 struct tysan_member_type_descriptor { 39 struct tysan_type_descriptor *Base; 40 struct tysan_type_descriptor *Access; 41 uptr Offset; 42 }; 43 44 struct 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 52 struct tysan_type_descriptor { 53 uptr Tag; 54 union { 55 tysan_member_type_descriptor Member; 56 tysan_struct_type_descriptor Struct; 57 }; 58 }; 59 shadow_for(const void * ptr)60inline tysan_type_descriptor **shadow_for(const void *ptr) { 61 return (tysan_type_descriptor **)((((uptr)ptr) & AppMask()) * sizeof(ptr) + 62 ShadowAddr()); 63 } 64 65 struct Flags { 66 #define TYSAN_FLAG(Type, Name, DefaultValue, Description) Type Name; 67 #include "tysan_flags.inc" 68 #undef TYSAN_FLAG 69 70 void SetDefaults(); 71 }; 72 73 extern Flags flags_data; flags()74inline Flags &flags() { return flags_data; } 75 76 } // namespace __tysan 77 78 #endif // TYSAN_H 79