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