1 //===-asan_abi.h - ASan Stable ABI Interface-------------------------------===// 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 #ifndef ASAN_ABI_H 10 #define ASAN_ABI_H 11 12 #include <stdbool.h> 13 #include <stddef.h> 14 #include <sys/types.h> 15 16 extern "C" { 17 // Functions concerning instrumented global variables: 18 void __asan_abi_register_image_globals(); 19 void __asan_abi_unregister_image_globals(); 20 21 // Functions concerning dynamic library initialization 22 void __asan_abi_before_dynamic_init(const char *module_name); 23 void __asan_abi_after_dynamic_init(); 24 25 // Functions concerning block memory destinations 26 void *__asan_abi_memcpy(void *d, const void *s, size_t n); 27 void *__asan_abi_memmove(void *d, const void *s, size_t n); 28 void *__asan_abi_memset(void *p, int c, size_t n); 29 30 // Functions concerning RTL startup and initialization 31 void __asan_abi_init(); 32 void __asan_abi_handle_no_return(); 33 34 // Functions concerning memory load and store reporting 35 void __asan_abi_report_load_n(void *p, size_t n, bool abort); 36 void __asan_abi_report_exp_load_n(void *p, size_t n, int exp, bool abort); 37 void __asan_abi_report_store_n(void *p, size_t n, bool abort); 38 void __asan_abi_report_exp_store_n(void *p, size_t n, int exp, bool abort); 39 40 // Functions concerning memory load and store 41 void __asan_abi_load_n(void *p, size_t n, bool abort); 42 void __asan_abi_exp_load_n(void *p, size_t n, int exp, bool abort); 43 void __asan_abi_store_n(void *p, size_t n, bool abort); 44 void __asan_abi_exp_store_n(void *p, size_t n, int exp, bool abort); 45 46 // Functions concerning query about whether memory is poisoned 47 int __asan_abi_address_is_poisoned(void const volatile *p); 48 void *__asan_abi_region_is_poisoned(void const volatile *p, size_t size); 49 50 // Functions concerning the poisoning of memory 51 void __asan_abi_unpoison_memory_region(void const volatile *p, size_t n); 52 void __asan_abi_poison_memory_region(void const volatile *p, size_t n); 53 54 // Functions concerning the partial poisoning of memory 55 void __asan_abi_set_shadow_xx_n(void *p, unsigned char xx, size_t n); 56 57 // Functions concerning stack poisoning 58 void __asan_abi_poison_stack_memory(void *p, size_t n); 59 void __asan_abi_unpoison_stack_memory(void *p, size_t n); 60 61 // Functions concerning redzone poisoning 62 void __asan_abi_poison_intra_object_redzone(void *p, size_t size); 63 void __asan_abi_unpoison_intra_object_redzone(void *p, size_t size); 64 65 // Functions concerning array cookie poisoning 66 void __asan_abi_poison_cxx_array_cookie(void *p); 67 void *__asan_abi_load_cxx_array_cookie(void **p); 68 69 // Functions concerning fake stacks 70 void *__asan_abi_get_current_fake_stack(); 71 void *__asan_abi_addr_is_in_fake_stack(void *fake_stack, void *addr, void **beg, 72 void **end); 73 // Functions concerning poisoning and unpoisoning fake stack alloca 74 void __asan_abi_alloca_poison(void *addr, size_t size); 75 void __asan_abi_allocas_unpoison(void *top, void *bottom); 76 77 // Functions concerning fake stack malloc 78 void *__asan_abi_stack_malloc_n(size_t scale, size_t size); 79 void *__asan_abi_stack_malloc_always_n(size_t scale, size_t size); 80 81 // Functions concerning fake stack free 82 void __asan_abi_stack_free_n(int scale, void *p, size_t n); 83 } 84 #endif // ASAN_ABI_H 85