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