1//===-- hwasan_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 HWAddressSanitizer.
10//
11// Private Hwasan interface header.
12//===----------------------------------------------------------------------===//
13
14#ifndef HWASAN_INTERFACE_INTERNAL_H
15#define HWASAN_INTERFACE_INTERNAL_H
16
17#include "sanitizer_common/sanitizer_internal_defs.h"
18#include "sanitizer_common/sanitizer_platform_limits_posix.h"
19#include <link.h>
20
21extern "C" {
22
23SANITIZER_INTERFACE_ATTRIBUTE
24void __hwasan_init_static();
25
26SANITIZER_INTERFACE_ATTRIBUTE
27void __hwasan_init();
28
29SANITIZER_INTERFACE_ATTRIBUTE
30void __hwasan_library_loaded(ElfW(Addr) base, const ElfW(Phdr) * phdr,
31 ElfW(Half) phnum);
32
33SANITIZER_INTERFACE_ATTRIBUTE
34void __hwasan_library_unloaded(ElfW(Addr) base, const ElfW(Phdr) * phdr,
35 ElfW(Half) phnum);
36
37using __sanitizer::uptr;
38using __sanitizer::sptr;
39using __sanitizer::uu64;
40using __sanitizer::uu32;
41using __sanitizer::uu16;
42using __sanitizer::u64;
43using __sanitizer::u32;
44using __sanitizer::u16;
45using __sanitizer::u8;
46
47SANITIZER_INTERFACE_ATTRIBUTE
48void __hwasan_init_frames(uptr, uptr);
49
50SANITIZER_INTERFACE_ATTRIBUTE
51extern uptr __hwasan_shadow_memory_dynamic_address;
52
53SANITIZER_INTERFACE_ATTRIBUTE
54void __hwasan_loadN(uptr, uptr);
55SANITIZER_INTERFACE_ATTRIBUTE
56void __hwasan_load1(uptr);
57SANITIZER_INTERFACE_ATTRIBUTE
58void __hwasan_load2(uptr);
59SANITIZER_INTERFACE_ATTRIBUTE
60void __hwasan_load4(uptr);
61SANITIZER_INTERFACE_ATTRIBUTE
62void __hwasan_load8(uptr);
63SANITIZER_INTERFACE_ATTRIBUTE
64void __hwasan_load16(uptr);
65
66SANITIZER_INTERFACE_ATTRIBUTE
67void __hwasan_loadN_noabort(uptr, uptr);
68SANITIZER_INTERFACE_ATTRIBUTE
69void __hwasan_load1_noabort(uptr);
70SANITIZER_INTERFACE_ATTRIBUTE
71void __hwasan_load2_noabort(uptr);
72SANITIZER_INTERFACE_ATTRIBUTE
73void __hwasan_load4_noabort(uptr);
74SANITIZER_INTERFACE_ATTRIBUTE
75void __hwasan_load8_noabort(uptr);
76SANITIZER_INTERFACE_ATTRIBUTE
77void __hwasan_load16_noabort(uptr);
78
79SANITIZER_INTERFACE_ATTRIBUTE
80void __hwasan_loadN_match_all(uptr, uptr, u8);
81SANITIZER_INTERFACE_ATTRIBUTE
82void __hwasan_load1_match_all(uptr, u8);
83SANITIZER_INTERFACE_ATTRIBUTE
84void __hwasan_load2_match_all(uptr, u8);
85SANITIZER_INTERFACE_ATTRIBUTE
86void __hwasan_load4_match_all(uptr, u8);
87SANITIZER_INTERFACE_ATTRIBUTE
88void __hwasan_load8_match_all(uptr, u8);
89SANITIZER_INTERFACE_ATTRIBUTE
90void __hwasan_load16_match_all(uptr, u8);
91
92SANITIZER_INTERFACE_ATTRIBUTE
93void __hwasan_loadN_match_all_noabort(uptr, uptr, u8);
94SANITIZER_INTERFACE_ATTRIBUTE
95void __hwasan_load1_match_all_noabort(uptr, u8);
96SANITIZER_INTERFACE_ATTRIBUTE
97void __hwasan_load2_match_all_noabort(uptr, u8);
98SANITIZER_INTERFACE_ATTRIBUTE
99void __hwasan_load4_match_all_noabort(uptr, u8);
100SANITIZER_INTERFACE_ATTRIBUTE
101void __hwasan_load8_match_all_noabort(uptr, u8);
102SANITIZER_INTERFACE_ATTRIBUTE
103void __hwasan_load16_match_all_noabort(uptr, u8);
104
105SANITIZER_INTERFACE_ATTRIBUTE
106void __hwasan_storeN(uptr, uptr);
107SANITIZER_INTERFACE_ATTRIBUTE
108void __hwasan_store1(uptr);
109SANITIZER_INTERFACE_ATTRIBUTE
110void __hwasan_store2(uptr);
111SANITIZER_INTERFACE_ATTRIBUTE
112void __hwasan_store4(uptr);
113SANITIZER_INTERFACE_ATTRIBUTE
114void __hwasan_store8(uptr);
115SANITIZER_INTERFACE_ATTRIBUTE
116void __hwasan_store16(uptr);
117
118SANITIZER_INTERFACE_ATTRIBUTE
119void __hwasan_storeN_noabort(uptr, uptr);
120SANITIZER_INTERFACE_ATTRIBUTE
121void __hwasan_store1_noabort(uptr);
122SANITIZER_INTERFACE_ATTRIBUTE
123void __hwasan_store2_noabort(uptr);
124SANITIZER_INTERFACE_ATTRIBUTE
125void __hwasan_store4_noabort(uptr);
126SANITIZER_INTERFACE_ATTRIBUTE
127void __hwasan_store8_noabort(uptr);
128SANITIZER_INTERFACE_ATTRIBUTE
129void __hwasan_store16_noabort(uptr);
130
131SANITIZER_INTERFACE_ATTRIBUTE
132void __hwasan_storeN_match_all(uptr, uptr, u8);
133SANITIZER_INTERFACE_ATTRIBUTE
134void __hwasan_store1_match_all(uptr, u8);
135SANITIZER_INTERFACE_ATTRIBUTE
136void __hwasan_store2_match_all(uptr, u8);
137SANITIZER_INTERFACE_ATTRIBUTE
138void __hwasan_store4_match_all(uptr, u8);
139SANITIZER_INTERFACE_ATTRIBUTE
140void __hwasan_store8_match_all(uptr, u8);
141SANITIZER_INTERFACE_ATTRIBUTE
142void __hwasan_store16_match_all(uptr, u8);
143
144SANITIZER_INTERFACE_ATTRIBUTE
145void __hwasan_storeN_match_all_noabort(uptr, uptr, u8);
146SANITIZER_INTERFACE_ATTRIBUTE
147void __hwasan_store1_match_all_noabort(uptr, u8);
148SANITIZER_INTERFACE_ATTRIBUTE
149void __hwasan_store2_match_all_noabort(uptr, u8);
150SANITIZER_INTERFACE_ATTRIBUTE
151void __hwasan_store4_match_all_noabort(uptr, u8);
152SANITIZER_INTERFACE_ATTRIBUTE
153void __hwasan_store8_match_all_noabort(uptr, u8);
154SANITIZER_INTERFACE_ATTRIBUTE
155void __hwasan_store16_match_all_noabort(uptr, u8);
156
157SANITIZER_INTERFACE_ATTRIBUTE
158void __hwasan_tag_memory(uptr p, u8 tag, uptr sz);
159
160SANITIZER_INTERFACE_ATTRIBUTE
161uptr __hwasan_tag_pointer(uptr p, u8 tag);
162
163SANITIZER_INTERFACE_ATTRIBUTE
164u8 __hwasan_get_tag_from_pointer(uptr p);
165
166SANITIZER_INTERFACE_ATTRIBUTE
167void __hwasan_tag_mismatch(uptr addr, u8 ts);
168
169SANITIZER_INTERFACE_ATTRIBUTE
170void __hwasan_tag_mismatch4(uptr addr, uptr access_info, uptr *registers_frame,
171 size_t outsize);
172
173SANITIZER_INTERFACE_ATTRIBUTE
174u8 __hwasan_generate_tag();
175
176// Returns the offset of the first tag mismatch or -1 if the whole range is
177// good.
178SANITIZER_INTERFACE_ATTRIBUTE
179sptr __hwasan_test_shadow(const void *x, uptr size);
180
181SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
182/* OPTIONAL */ const char* __hwasan_default_options();
183
184SANITIZER_INTERFACE_ATTRIBUTE
185void __hwasan_print_shadow(const void *x, uptr size);
186
187SANITIZER_INTERFACE_ATTRIBUTE
188void __hwasan_handle_longjmp(const void *sp_dst);
189
190SANITIZER_INTERFACE_ATTRIBUTE
191void __hwasan_handle_vfork(const void *sp_dst);
192
193SANITIZER_INTERFACE_ATTRIBUTE
194u16 __sanitizer_unaligned_load16(const uu16 *p);
195
196SANITIZER_INTERFACE_ATTRIBUTE
197u32 __sanitizer_unaligned_load32(const uu32 *p);
198
199SANITIZER_INTERFACE_ATTRIBUTE
200u64 __sanitizer_unaligned_load64(const uu64 *p);
201
202SANITIZER_INTERFACE_ATTRIBUTE
203void __sanitizer_unaligned_store16(uu16 *p, u16 x);
204
205SANITIZER_INTERFACE_ATTRIBUTE
206void __sanitizer_unaligned_store32(uu32 *p, u32 x);
207
208SANITIZER_INTERFACE_ATTRIBUTE
209void __sanitizer_unaligned_store64(uu64 *p, u64 x);
210
211SANITIZER_INTERFACE_ATTRIBUTE
212void __hwasan_enable_allocator_tagging();
213
214SANITIZER_INTERFACE_ATTRIBUTE
215void __hwasan_disable_allocator_tagging();
216
217SANITIZER_INTERFACE_ATTRIBUTE
218void __hwasan_thread_enter();
219
220SANITIZER_INTERFACE_ATTRIBUTE
221void __hwasan_thread_exit();
222
223SANITIZER_INTERFACE_ATTRIBUTE
224void __hwasan_print_memory_usage();
225
226// The compiler will generate this when
227// `-hwasan-record-stack-history-with-calls` is added as a flag, which will add
228// frame record information to the stack ring buffer. This is an alternative to
229// the compiler emitting instructions in the prologue for doing the same thing
230// by accessing the ring buffer directly.
231SANITIZER_INTERFACE_ATTRIBUTE
232void __hwasan_add_frame_record(u64 frame_record_info);
233
234SANITIZER_INTERFACE_ATTRIBUTE
235void *__hwasan_memcpy(void *dst, const void *src, uptr size);
236SANITIZER_INTERFACE_ATTRIBUTE
237void *__hwasan_memset(void *s, int c, uptr n);
238SANITIZER_INTERFACE_ATTRIBUTE
239void *__hwasan_memmove(void *dest, const void *src, uptr n);
240
241SANITIZER_INTERFACE_ATTRIBUTE
242void *__hwasan_memcpy_match_all(void *dst, const void *src, uptr size, u8);
243SANITIZER_INTERFACE_ATTRIBUTE
244void *__hwasan_memset_match_all(void *s, int c, uptr n, u8);
245SANITIZER_INTERFACE_ATTRIBUTE
246void *__hwasan_memmove_match_all(void *dest, const void *src, uptr n, u8);
247
248SANITIZER_INTERFACE_ATTRIBUTE
249void __hwasan_set_error_report_callback(void (*callback)(const char *));
250} // extern "C"
251
252#endif // HWASAN_INTERFACE_INTERNAL_H
253

source code of compiler-rt/lib/hwasan/hwasan_interface_internal.h