[CMake] Rename add_compiler_rt_static_runtime to add_compiler_rt_runtime.
[blocksruntime.git] / lib / asan / asan_interface_internal.h
blob15d4b60ef5cd009f9510fa4fb8aa9e6f25c2ccf7
1 //===-- asan_interface_internal.h -------------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file is a part of AddressSanitizer, an address sanity checker.
12 // This header can be included by the instrumented program to fetch
13 // data (mostly allocator statistics) from ASan runtime library.
14 //===----------------------------------------------------------------------===//
15 #ifndef ASAN_INTERFACE_INTERNAL_H
16 #define ASAN_INTERFACE_INTERNAL_H
18 #include "sanitizer_common/sanitizer_internal_defs.h"
20 using __sanitizer::uptr;
22 extern "C" {
23 // This function should be called at the very beginning of the process,
24 // before any instrumented code is executed and before any call to malloc.
25 // Everytime the asan ABI changes we also change the version number in this
26 // name. Objects build with incompatible asan ABI version
27 // will not link with run-time.
28 // Changes between ABI versions:
29 // v1=>v2: added 'module_name' to __asan_global
30 // v2=>v3: stack frame description (created by the compiler)
31 // contains the function PC as the 3-rd field (see
32 // DescribeAddressIfStack).
33 SANITIZER_INTERFACE_ATTRIBUTE void __asan_init_v3();
34 #define __asan_init __asan_init_v3
36 // This structure describes an instrumented global variable.
37 struct __asan_global {
38 uptr beg; // The address of the global.
39 uptr size; // The original size of the global.
40 uptr size_with_redzone; // The size with the redzone.
41 const char *name; // Name as a C string.
42 const char *module_name; // Module name as a C string. This pointer is a
43 // unique identifier of a module.
44 uptr has_dynamic_init; // Non-zero if the global has dynamic initializer.
47 // These two functions should be called by the instrumented code.
48 // 'globals' is an array of structures describing 'n' globals.
49 SANITIZER_INTERFACE_ATTRIBUTE
50 void __asan_register_globals(__asan_global *globals, uptr n);
51 SANITIZER_INTERFACE_ATTRIBUTE
52 void __asan_unregister_globals(__asan_global *globals, uptr n);
54 // These two functions should be called before and after dynamic initializers
55 // of a single module run, respectively.
56 SANITIZER_INTERFACE_ATTRIBUTE
57 void __asan_before_dynamic_init(const char *module_name);
58 SANITIZER_INTERFACE_ATTRIBUTE
59 void __asan_after_dynamic_init();
61 // These two functions are used by instrumented code in the
62 // use-after-scope mode. They mark memory for local variables as
63 // unaddressable when they leave scope and addressable before the
64 // function exits.
65 SANITIZER_INTERFACE_ATTRIBUTE
66 void __asan_poison_stack_memory(uptr addr, uptr size);
67 SANITIZER_INTERFACE_ATTRIBUTE
68 void __asan_unpoison_stack_memory(uptr addr, uptr size);
70 // Performs cleanup before a NoReturn function. Must be called before things
71 // like _exit and execl to avoid false positives on stack.
72 SANITIZER_INTERFACE_ATTRIBUTE void __asan_handle_no_return();
74 SANITIZER_INTERFACE_ATTRIBUTE
75 void __asan_poison_memory_region(void const volatile *addr, uptr size);
76 SANITIZER_INTERFACE_ATTRIBUTE
77 void __asan_unpoison_memory_region(void const volatile *addr, uptr size);
79 SANITIZER_INTERFACE_ATTRIBUTE
80 bool __asan_address_is_poisoned(void const volatile *addr);
82 SANITIZER_INTERFACE_ATTRIBUTE
83 uptr __asan_region_is_poisoned(uptr beg, uptr size);
85 SANITIZER_INTERFACE_ATTRIBUTE
86 void __asan_describe_address(uptr addr);
88 SANITIZER_INTERFACE_ATTRIBUTE
89 void __asan_report_error(uptr pc, uptr bp, uptr sp,
90 uptr addr, bool is_write, uptr access_size);
92 SANITIZER_INTERFACE_ATTRIBUTE
93 int __asan_set_error_exit_code(int exit_code);
94 SANITIZER_INTERFACE_ATTRIBUTE
95 void __asan_set_death_callback(void (*callback)(void));
96 SANITIZER_INTERFACE_ATTRIBUTE
97 void __asan_set_error_report_callback(void (*callback)(const char*));
99 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
100 /* OPTIONAL */ void __asan_on_error();
102 SANITIZER_INTERFACE_ATTRIBUTE
103 uptr __asan_get_estimated_allocated_size(uptr size);
105 SANITIZER_INTERFACE_ATTRIBUTE bool __asan_get_ownership(const void *p);
106 SANITIZER_INTERFACE_ATTRIBUTE uptr __asan_get_allocated_size(const void *p);
107 SANITIZER_INTERFACE_ATTRIBUTE uptr __asan_get_current_allocated_bytes();
108 SANITIZER_INTERFACE_ATTRIBUTE uptr __asan_get_heap_size();
109 SANITIZER_INTERFACE_ATTRIBUTE uptr __asan_get_free_bytes();
110 SANITIZER_INTERFACE_ATTRIBUTE uptr __asan_get_unmapped_bytes();
111 SANITIZER_INTERFACE_ATTRIBUTE void __asan_print_accumulated_stats();
113 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
114 /* OPTIONAL */ const char* __asan_default_options();
116 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
117 /* OPTIONAL */ void __asan_malloc_hook(void *ptr, uptr size);
118 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
119 /* OPTIONAL */ void __asan_free_hook(void *ptr);
121 // Global flag, copy of ASAN_OPTIONS=detect_stack_use_after_return
122 SANITIZER_INTERFACE_ATTRIBUTE
123 extern int __asan_option_detect_stack_use_after_return;
124 } // extern "C"
126 #endif // ASAN_INTERFACE_INTERNAL_H