xref: /freebsd/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_interface_internal.h (revision d9a42747950146bf03cda7f6e25d219253f8a57a)
1 //===-- sanitizer_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 shared between run-time libraries of sanitizers.
10 //
11 // This header declares the sanitizer runtime interface functions.
12 // The runtime library has to define these functions so the instrumented program
13 // could call them.
14 //
15 // See also include/sanitizer/common_interface_defs.h
16 //===----------------------------------------------------------------------===//
17 #ifndef SANITIZER_INTERFACE_INTERNAL_H
18 #define SANITIZER_INTERFACE_INTERNAL_H
19 
20 #include "sanitizer_internal_defs.h"
21 
22 extern "C" {
23 // Tell the tools to write their reports to "path.<pid>" instead of stderr.
24 // The special values are "stdout" and "stderr".
25 SANITIZER_INTERFACE_ATTRIBUTE
26 void __sanitizer_set_report_path(const char *path);
27 // Tell the tools to write their reports to the provided file descriptor
28 // (casted to void *).
29 SANITIZER_INTERFACE_ATTRIBUTE
30 void __sanitizer_set_report_fd(void *fd);
31 // Get the current full report file path, if a path was specified by
32 // an earlier call to __sanitizer_set_report_path. Returns null otherwise.
33 SANITIZER_INTERFACE_ATTRIBUTE
34 const char *__sanitizer_get_report_path();
35 
36 typedef struct {
37   int coverage_sandboxed;
38   __sanitizer::sptr coverage_fd;
39   unsigned int coverage_max_block_size;
40 } __sanitizer_sandbox_arguments;
41 
42 // Notify the tools that the sandbox is going to be turned on.
43 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
44 __sanitizer_sandbox_on_notify(__sanitizer_sandbox_arguments *args);
45 
46 // This function is called by the tool when it has just finished reporting
47 // an error. 'error_summary' is a one-line string that summarizes
48 // the error message. This function can be overridden by the client.
49 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
50 __sanitizer_report_error_summary(const char *error_summary);
51 
52 SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_cov_dump();
53 SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_dump_coverage(
54     const __sanitizer::uptr *pcs, const __sanitizer::uptr len);
55 SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_dump_trace_pc_guard_coverage();
56 
57 SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_cov(__sanitizer::u32 *guard);
58 
59 // Returns 1 on the first call, then returns 0 thereafter.  Called by the tool
60 // to ensure only one report is printed when multiple errors occur
61 // simultaneously.
62 SANITIZER_INTERFACE_ATTRIBUTE int __sanitizer_acquire_crash_state();
63 
64 SANITIZER_INTERFACE_ATTRIBUTE
65 void __sanitizer_annotate_contiguous_container(const void *beg, const void *end,
66                                                const void *old_mid,
67                                                const void *new_mid);
68 SANITIZER_INTERFACE_ATTRIBUTE
69 int __sanitizer_verify_contiguous_container(const void *beg, const void *mid,
70                                             const void *end);
71 SANITIZER_INTERFACE_ATTRIBUTE
72 const void *__sanitizer_contiguous_container_find_bad_address(const void *beg,
73                                                               const void *mid,
74                                                               const void *end);
75 
76 SANITIZER_INTERFACE_ATTRIBUTE
77 int __sanitizer_get_module_and_offset_for_pc(void *pc, char *module_path,
78                                              __sanitizer::uptr module_path_len,
79                                              void **pc_offset);
80 
81 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
82 __sanitizer_cov_trace_cmp();
83 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
84 __sanitizer_cov_trace_cmp1();
85 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
86 __sanitizer_cov_trace_cmp2();
87 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
88 __sanitizer_cov_trace_cmp4();
89 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
90 __sanitizer_cov_trace_cmp8();
91 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
92 __sanitizer_cov_trace_const_cmp1();
93 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
94 __sanitizer_cov_trace_const_cmp2();
95 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
96 __sanitizer_cov_trace_const_cmp4();
97 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
98 __sanitizer_cov_trace_const_cmp8();
99 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
100 __sanitizer_cov_trace_switch();
101 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
102 __sanitizer_cov_trace_div4();
103 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
104 __sanitizer_cov_trace_div8();
105 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
106 __sanitizer_cov_trace_gep();
107 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
108 __sanitizer_cov_trace_pc_indir();
109 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
110 __sanitizer_cov_load1();
111 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
112 __sanitizer_cov_load2();
113 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
114 __sanitizer_cov_load4();
115 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
116 __sanitizer_cov_load8();
117 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
118 __sanitizer_cov_load16();
119 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
120 __sanitizer_cov_store1();
121 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
122 __sanitizer_cov_store2();
123 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
124 __sanitizer_cov_store4();
125 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
126 __sanitizer_cov_store8();
127 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
128 __sanitizer_cov_store16();
129 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
130 __sanitizer_cov_trace_pc_guard(__sanitizer::u32 *);
131 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
132 __sanitizer_cov_trace_pc_guard_init(__sanitizer::u32 *, __sanitizer::u32 *);
133 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
134 __sanitizer_cov_8bit_counters_init(char *, char *);
135 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
136 __sanitizer_cov_bool_flag_init();
137 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
138 __sanitizer_cov_pcs_init(const __sanitizer::uptr *, const __sanitizer::uptr *);
139 }  // extern "C"
140 
141 #endif  // SANITIZER_INTERFACE_INTERNAL_H
142