[PATCH c++/86881] -Wshadow-local-compatible ICE
[official-gcc.git] / libsanitizer / asan / asan_interface_internal.h
blobbe9605d9e6e5ed7e66b46e17ba6ebde764673cb8
1 //===-- asan_interface_internal.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 AddressSanitizer, an address sanity checker.
9 //
10 // This header declares the AddressSanitizer runtime interface functions.
11 // The runtime library has to define these functions so the instrumented program
12 // could call them.
14 // See also include/sanitizer/asan_interface.h
15 //===----------------------------------------------------------------------===//
16 #ifndef ASAN_INTERFACE_INTERNAL_H
17 #define ASAN_INTERFACE_INTERNAL_H
19 #include "sanitizer_common/sanitizer_internal_defs.h"
21 #include "asan_init_version.h"
23 using __sanitizer::uptr;
24 using __sanitizer::u64;
25 using __sanitizer::u32;
27 extern "C" {
28 // This function should be called at the very beginning of the process,
29 // before any instrumented code is executed and before any call to malloc.
30 SANITIZER_INTERFACE_ATTRIBUTE void __asan_init();
32 // This function exists purely to get a linker/loader error when using
33 // incompatible versions of instrumentation and runtime library. Please note
34 // that __asan_version_mismatch_check is a macro that is replaced with
35 // __asan_version_mismatch_check_vXXX at compile-time.
36 SANITIZER_INTERFACE_ATTRIBUTE void __asan_version_mismatch_check();
38 // This structure is used to describe the source location of a place where
39 // global was defined.
40 struct __asan_global_source_location {
41 const char *filename;
42 int line_no;
43 int column_no;
46 // This structure describes an instrumented global variable.
47 struct __asan_global {
48 uptr beg; // The address of the global.
49 uptr size; // The original size of the global.
50 uptr size_with_redzone; // The size with the redzone.
51 const char *name; // Name as a C string.
52 const char *module_name; // Module name as a C string. This pointer is a
53 // unique identifier of a module.
54 uptr has_dynamic_init; // Non-zero if the global has dynamic initializer.
55 __asan_global_source_location *location; // Source location of a global,
56 // or NULL if it is unknown.
57 uptr odr_indicator; // The address of the ODR indicator symbol.
60 // These functions can be called on some platforms to find globals in the same
61 // loaded image as `flag' and apply __asan_(un)register_globals to them,
62 // filtering out redundant calls.
63 SANITIZER_INTERFACE_ATTRIBUTE
64 void __asan_register_image_globals(uptr *flag);
65 SANITIZER_INTERFACE_ATTRIBUTE
66 void __asan_unregister_image_globals(uptr *flag);
68 SANITIZER_INTERFACE_ATTRIBUTE
69 void __asan_register_elf_globals(uptr *flag, void *start, void *stop);
70 SANITIZER_INTERFACE_ATTRIBUTE
71 void __asan_unregister_elf_globals(uptr *flag, void *start, void *stop);
73 // These two functions should be called by the instrumented code.
74 // 'globals' is an array of structures describing 'n' globals.
75 SANITIZER_INTERFACE_ATTRIBUTE
76 void __asan_register_globals(__asan_global *globals, uptr n);
77 SANITIZER_INTERFACE_ATTRIBUTE
78 void __asan_unregister_globals(__asan_global *globals, uptr n);
80 // These two functions should be called before and after dynamic initializers
81 // of a single module run, respectively.
82 SANITIZER_INTERFACE_ATTRIBUTE
83 void __asan_before_dynamic_init(const char *module_name);
84 SANITIZER_INTERFACE_ATTRIBUTE
85 void __asan_after_dynamic_init();
87 // Sets bytes of the given range of the shadow memory into specific value.
88 SANITIZER_INTERFACE_ATTRIBUTE
89 void __asan_set_shadow_00(uptr addr, uptr size);
90 SANITIZER_INTERFACE_ATTRIBUTE
91 void __asan_set_shadow_f1(uptr addr, uptr size);
92 SANITIZER_INTERFACE_ATTRIBUTE
93 void __asan_set_shadow_f2(uptr addr, uptr size);
94 SANITIZER_INTERFACE_ATTRIBUTE
95 void __asan_set_shadow_f3(uptr addr, uptr size);
96 SANITIZER_INTERFACE_ATTRIBUTE
97 void __asan_set_shadow_f5(uptr addr, uptr size);
98 SANITIZER_INTERFACE_ATTRIBUTE
99 void __asan_set_shadow_f8(uptr addr, uptr size);
101 // These two functions are used by instrumented code in the
102 // use-after-scope mode. They mark memory for local variables as
103 // unaddressable when they leave scope and addressable before the
104 // function exits.
105 SANITIZER_INTERFACE_ATTRIBUTE
106 void __asan_poison_stack_memory(uptr addr, uptr size);
107 SANITIZER_INTERFACE_ATTRIBUTE
108 void __asan_unpoison_stack_memory(uptr addr, uptr size);
110 // Performs cleanup before a NoReturn function. Must be called before things
111 // like _exit and execl to avoid false positives on stack.
112 SANITIZER_INTERFACE_ATTRIBUTE void __asan_handle_no_return();
114 SANITIZER_INTERFACE_ATTRIBUTE
115 void __asan_poison_memory_region(void const volatile *addr, uptr size);
116 SANITIZER_INTERFACE_ATTRIBUTE
117 void __asan_unpoison_memory_region(void const volatile *addr, uptr size);
119 SANITIZER_INTERFACE_ATTRIBUTE
120 int __asan_address_is_poisoned(void const volatile *addr);
122 SANITIZER_INTERFACE_ATTRIBUTE
123 uptr __asan_region_is_poisoned(uptr beg, uptr size);
125 SANITIZER_INTERFACE_ATTRIBUTE
126 void __asan_describe_address(uptr addr);
128 SANITIZER_INTERFACE_ATTRIBUTE
129 int __asan_report_present();
131 SANITIZER_INTERFACE_ATTRIBUTE
132 uptr __asan_get_report_pc();
133 SANITIZER_INTERFACE_ATTRIBUTE
134 uptr __asan_get_report_bp();
135 SANITIZER_INTERFACE_ATTRIBUTE
136 uptr __asan_get_report_sp();
137 SANITIZER_INTERFACE_ATTRIBUTE
138 uptr __asan_get_report_address();
139 SANITIZER_INTERFACE_ATTRIBUTE
140 int __asan_get_report_access_type();
141 SANITIZER_INTERFACE_ATTRIBUTE
142 uptr __asan_get_report_access_size();
143 SANITIZER_INTERFACE_ATTRIBUTE
144 const char * __asan_get_report_description();
146 SANITIZER_INTERFACE_ATTRIBUTE
147 const char * __asan_locate_address(uptr addr, char *name, uptr name_size,
148 uptr *region_address, uptr *region_size);
150 SANITIZER_INTERFACE_ATTRIBUTE
151 uptr __asan_get_alloc_stack(uptr addr, uptr *trace, uptr size,
152 u32 *thread_id);
154 SANITIZER_INTERFACE_ATTRIBUTE
155 uptr __asan_get_free_stack(uptr addr, uptr *trace, uptr size,
156 u32 *thread_id);
158 SANITIZER_INTERFACE_ATTRIBUTE
159 void __asan_get_shadow_mapping(uptr *shadow_scale, uptr *shadow_offset);
161 SANITIZER_INTERFACE_ATTRIBUTE
162 void __asan_report_error(uptr pc, uptr bp, uptr sp,
163 uptr addr, int is_write, uptr access_size, u32 exp);
165 SANITIZER_INTERFACE_ATTRIBUTE
166 void __asan_set_death_callback(void (*callback)(void));
167 SANITIZER_INTERFACE_ATTRIBUTE
168 void __asan_set_error_report_callback(void (*callback)(const char*));
170 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
171 void __asan_on_error();
173 SANITIZER_INTERFACE_ATTRIBUTE void __asan_print_accumulated_stats();
175 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
176 const char* __asan_default_options();
178 SANITIZER_INTERFACE_ATTRIBUTE
179 extern uptr __asan_shadow_memory_dynamic_address;
181 // Global flag, copy of ASAN_OPTIONS=detect_stack_use_after_return
182 SANITIZER_INTERFACE_ATTRIBUTE
183 extern int __asan_option_detect_stack_use_after_return;
185 SANITIZER_INTERFACE_ATTRIBUTE
186 extern uptr *__asan_test_only_reported_buggy_pointer;
188 SANITIZER_INTERFACE_ATTRIBUTE void __asan_load1(uptr p);
189 SANITIZER_INTERFACE_ATTRIBUTE void __asan_load2(uptr p);
190 SANITIZER_INTERFACE_ATTRIBUTE void __asan_load4(uptr p);
191 SANITIZER_INTERFACE_ATTRIBUTE void __asan_load8(uptr p);
192 SANITIZER_INTERFACE_ATTRIBUTE void __asan_load16(uptr p);
193 SANITIZER_INTERFACE_ATTRIBUTE void __asan_store1(uptr p);
194 SANITIZER_INTERFACE_ATTRIBUTE void __asan_store2(uptr p);
195 SANITIZER_INTERFACE_ATTRIBUTE void __asan_store4(uptr p);
196 SANITIZER_INTERFACE_ATTRIBUTE void __asan_store8(uptr p);
197 SANITIZER_INTERFACE_ATTRIBUTE void __asan_store16(uptr p);
198 SANITIZER_INTERFACE_ATTRIBUTE void __asan_loadN(uptr p, uptr size);
199 SANITIZER_INTERFACE_ATTRIBUTE void __asan_storeN(uptr p, uptr size);
201 SANITIZER_INTERFACE_ATTRIBUTE void __asan_load1_noabort(uptr p);
202 SANITIZER_INTERFACE_ATTRIBUTE void __asan_load2_noabort(uptr p);
203 SANITIZER_INTERFACE_ATTRIBUTE void __asan_load4_noabort(uptr p);
204 SANITIZER_INTERFACE_ATTRIBUTE void __asan_load8_noabort(uptr p);
205 SANITIZER_INTERFACE_ATTRIBUTE void __asan_load16_noabort(uptr p);
206 SANITIZER_INTERFACE_ATTRIBUTE void __asan_store1_noabort(uptr p);
207 SANITIZER_INTERFACE_ATTRIBUTE void __asan_store2_noabort(uptr p);
208 SANITIZER_INTERFACE_ATTRIBUTE void __asan_store4_noabort(uptr p);
209 SANITIZER_INTERFACE_ATTRIBUTE void __asan_store8_noabort(uptr p);
210 SANITIZER_INTERFACE_ATTRIBUTE void __asan_store16_noabort(uptr p);
211 SANITIZER_INTERFACE_ATTRIBUTE void __asan_loadN_noabort(uptr p, uptr size);
212 SANITIZER_INTERFACE_ATTRIBUTE void __asan_storeN_noabort(uptr p, uptr size);
214 SANITIZER_INTERFACE_ATTRIBUTE void __asan_exp_load1(uptr p, u32 exp);
215 SANITIZER_INTERFACE_ATTRIBUTE void __asan_exp_load2(uptr p, u32 exp);
216 SANITIZER_INTERFACE_ATTRIBUTE void __asan_exp_load4(uptr p, u32 exp);
217 SANITIZER_INTERFACE_ATTRIBUTE void __asan_exp_load8(uptr p, u32 exp);
218 SANITIZER_INTERFACE_ATTRIBUTE void __asan_exp_load16(uptr p, u32 exp);
219 SANITIZER_INTERFACE_ATTRIBUTE void __asan_exp_store1(uptr p, u32 exp);
220 SANITIZER_INTERFACE_ATTRIBUTE void __asan_exp_store2(uptr p, u32 exp);
221 SANITIZER_INTERFACE_ATTRIBUTE void __asan_exp_store4(uptr p, u32 exp);
222 SANITIZER_INTERFACE_ATTRIBUTE void __asan_exp_store8(uptr p, u32 exp);
223 SANITIZER_INTERFACE_ATTRIBUTE void __asan_exp_store16(uptr p, u32 exp);
224 SANITIZER_INTERFACE_ATTRIBUTE void __asan_exp_loadN(uptr p, uptr size,
225 u32 exp);
226 SANITIZER_INTERFACE_ATTRIBUTE void __asan_exp_storeN(uptr p, uptr size,
227 u32 exp);
229 SANITIZER_INTERFACE_ATTRIBUTE
230 void* __asan_memcpy(void *dst, const void *src, uptr size);
231 SANITIZER_INTERFACE_ATTRIBUTE
232 void* __asan_memset(void *s, int c, uptr n);
233 SANITIZER_INTERFACE_ATTRIBUTE
234 void* __asan_memmove(void* dest, const void* src, uptr n);
236 SANITIZER_INTERFACE_ATTRIBUTE
237 void __asan_poison_cxx_array_cookie(uptr p);
238 SANITIZER_INTERFACE_ATTRIBUTE
239 uptr __asan_load_cxx_array_cookie(uptr *p);
240 SANITIZER_INTERFACE_ATTRIBUTE
241 void __asan_poison_intra_object_redzone(uptr p, uptr size);
242 SANITIZER_INTERFACE_ATTRIBUTE
243 void __asan_unpoison_intra_object_redzone(uptr p, uptr size);
244 SANITIZER_INTERFACE_ATTRIBUTE
245 void __asan_alloca_poison(uptr addr, uptr size);
246 SANITIZER_INTERFACE_ATTRIBUTE
247 void __asan_allocas_unpoison(uptr top, uptr bottom);
249 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
250 const char* __asan_default_suppressions();
251 } // extern "C"
253 #endif // ASAN_INTERFACE_INTERNAL_H