1 1.1 kamil //===-- sanitizer/asan_interface.h ------------------------------*- C++ -*-===// 2 1.1 kamil // 3 1.1 kamil // The LLVM Compiler Infrastructure 4 1.1 kamil // 5 1.1 kamil // This file is distributed under the University of Illinois Open Source 6 1.1 kamil // License. See LICENSE.TXT for details. 7 1.1 kamil // 8 1.1 kamil //===----------------------------------------------------------------------===// 9 1.1 kamil // 10 1.1 kamil // This file is a part of HWAddressSanitizer. 11 1.1 kamil // 12 1.1 kamil // Public interface header. 13 1.1 kamil //===----------------------------------------------------------------------===// 14 1.1 kamil #ifndef SANITIZER_HWASAN_INTERFACE_H 15 1.1 kamil #define SANITIZER_HWASAN_INTERFACE_H 16 1.1 kamil 17 1.1 kamil #include <sanitizer/common_interface_defs.h> 18 1.1 kamil 19 1.1 kamil #ifdef __cplusplus 20 1.1 kamil extern "C" { 21 1.1 kamil #endif 22 1.1 kamil // Initialize shadow but not the rest of the runtime. 23 1.1 kamil // Does not call libc unless there is an error. 24 1.1 kamil // Can be called multiple times, or not at all (in which case shadow will 25 1.1 kamil // be initialized in compiler-inserted __hwasan_init() call). 26 1.1 kamil void __hwasan_shadow_init(void); 27 1.1 kamil 28 1.1 kamil // This function may be optionally provided by user and should return 29 1.1 kamil // a string containing HWASan runtime options. See asan_flags.h for details. 30 1.1 kamil const char* __hwasan_default_options(void); 31 1.1 kamil 32 1.1 kamil void __hwasan_enable_allocator_tagging(void); 33 1.1 kamil void __hwasan_disable_allocator_tagging(void); 34 1.1 kamil 35 1.1 kamil // Mark region of memory with the given tag. Both address and size need to be 36 1.1 kamil // 16-byte aligned. 37 1.1 kamil void __hwasan_tag_memory(const volatile void *p, unsigned char tag, 38 1.1 kamil size_t size); 39 1.1 kamil 40 1.1 kamil /// Set pointer tag. Previous tag is lost. 41 1.1 kamil void *__hwasan_tag_pointer(const volatile void *p, unsigned char tag); 42 1.1 kamil 43 1.1 kamil // Set memory tag from the current SP address to the given address to zero. 44 1.1 kamil // This is meant to annotate longjmp and other non-local jumps. 45 1.1 kamil // This function needs to know the (almost) exact destination frame address; 46 1.1 kamil // clearing shadow for the entire thread stack like __asan_handle_no_return 47 1.1 kamil // does would cause false reports. 48 1.1 kamil void __hwasan_handle_longjmp(const void *sp_dst); 49 1.1 kamil 50 1.1 kamil // Libc hook for thread creation. Should be called in the child thread before 51 1.1 kamil // any instrumented code. 52 1.1 kamil void __hwasan_thread_enter(); 53 1.1 kamil 54 1.1 kamil // Libc hook for thread destruction. No instrumented code should run after 55 1.1 kamil // this call. 56 1.1 kamil void __hwasan_thread_exit(); 57 1.1 kamil 58 1.1 kamil // Print shadow and origin for the memory range to stderr in a human-readable 59 1.1 kamil // format. 60 1.1 kamil void __hwasan_print_shadow(const volatile void *x, size_t size); 61 1.1 kamil 62 1.1 kamil // Print one-line report about the memory usage of the current process. 63 1.1 kamil void __hwasan_print_memory_usage(); 64 1.1 kamil 65 1.1 kamil int __sanitizer_posix_memalign(void **memptr, size_t alignment, size_t size); 66 1.1 kamil void * __sanitizer_memalign(size_t alignment, size_t size); 67 1.1 kamil void * __sanitizer_aligned_alloc(size_t alignment, size_t size); 68 1.1 kamil void * __sanitizer___libc_memalign(size_t alignment, size_t size); 69 1.1 kamil void * __sanitizer_valloc(size_t size); 70 1.1 kamil void * __sanitizer_pvalloc(size_t size); 71 1.1 kamil void __sanitizer_free(void *ptr); 72 1.1 kamil void __sanitizer_cfree(void *ptr); 73 1.1 kamil size_t __sanitizer_malloc_usable_size(const void *ptr); 74 1.1 kamil struct mallinfo __sanitizer_mallinfo(); 75 1.1 kamil int __sanitizer_mallopt(int cmd, int value); 76 1.1 kamil void __sanitizer_malloc_stats(void); 77 1.1 kamil void * __sanitizer_calloc(size_t nmemb, size_t size); 78 1.1 kamil void * __sanitizer_realloc(void *ptr, size_t size); 79 1.1 kamil void * __sanitizer_malloc(size_t size); 80 1.1 kamil #ifdef __cplusplus 81 1.1 kamil } // extern "C" 82 1.1 kamil #endif 83 1.1 kamil 84 1.1 kamil #endif // SANITIZER_HWASAN_INTERFACE_H 85