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
22extern "C" {
23// Tell the tools to write their reports to "path.<pid>" instead of stderr.
24// The special values are "stdout" and "stderr".
25SANITIZER_INTERFACE_ATTRIBUTE
26void __sanitizer_set_report_path(const char *path);
27// Tell the tools to write their reports to the provided file descriptor
28// (casted to void *).
29SANITIZER_INTERFACE_ATTRIBUTE
30void __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.
33SANITIZER_INTERFACE_ATTRIBUTE
34const char *__sanitizer_get_report_path();
35
36typedef 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.
43SANITIZER_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.
49SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
50__sanitizer_report_error_summary(const char *error_summary);
51
52SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_cov_dump();
53SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_dump_coverage(
54 const __sanitizer::uptr *pcs, const __sanitizer::uptr len);
55SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_dump_trace_pc_guard_coverage();
56
57SANITIZER_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.
62SANITIZER_INTERFACE_ATTRIBUTE int __sanitizer_acquire_crash_state();
63
64SANITIZER_INTERFACE_ATTRIBUTE
65void __sanitizer_annotate_contiguous_container(const void *beg, const void *end,
66 const void *old_mid,
67 const void *new_mid);
68SANITIZER_INTERFACE_ATTRIBUTE
69void __sanitizer_annotate_double_ended_contiguous_container(
70 const void *storage_beg, const void *storage_end,
71 const void *old_container_beg, const void *old_container_end,
72 const void *new_container_beg, const void *new_container_end);
73SANITIZER_INTERFACE_ATTRIBUTE
74int __sanitizer_verify_contiguous_container(const void *beg, const void *mid,
75 const void *end);
76SANITIZER_INTERFACE_ATTRIBUTE
77int __sanitizer_verify_double_ended_contiguous_container(
78 const void *storage_beg, const void *container_beg,
79 const void *container_end, const void *storage_end);
80SANITIZER_INTERFACE_ATTRIBUTE
81const void *__sanitizer_contiguous_container_find_bad_address(const void *beg,
82 const void *mid,
83 const void *end);
84SANITIZER_INTERFACE_ATTRIBUTE
85const void *__sanitizer_double_ended_contiguous_container_find_bad_address(
86 const void *storage_beg, const void *container_beg,
87 const void *container_end, const void *storage_end);
88
89SANITIZER_INTERFACE_ATTRIBUTE
90int __sanitizer_get_module_and_offset_for_pc(void *pc, char *module_path,
91 __sanitizer::uptr module_path_len,
92 void **pc_offset);
93SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
94__sanitizer_cov_trace_cmp();
95SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
96__sanitizer_cov_trace_cmp1();
97SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
98__sanitizer_cov_trace_cmp2();
99SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
100__sanitizer_cov_trace_cmp4();
101SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
102__sanitizer_cov_trace_cmp8();
103SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
104__sanitizer_cov_trace_const_cmp1();
105SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
106__sanitizer_cov_trace_const_cmp2();
107SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
108__sanitizer_cov_trace_const_cmp4();
109SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
110__sanitizer_cov_trace_const_cmp8();
111SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
112__sanitizer_cov_trace_switch();
113SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
114__sanitizer_cov_trace_div4();
115SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
116__sanitizer_cov_trace_div8();
117SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
118__sanitizer_cov_trace_gep();
119SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
120__sanitizer_cov_trace_pc_indir();
121SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
122__sanitizer_cov_load1();
123SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
124__sanitizer_cov_load2();
125SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
126__sanitizer_cov_load4();
127SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
128__sanitizer_cov_load8();
129SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
130__sanitizer_cov_load16();
131SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
132__sanitizer_cov_store1();
133SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
134__sanitizer_cov_store2();
135SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
136__sanitizer_cov_store4();
137SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
138__sanitizer_cov_store8();
139SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
140__sanitizer_cov_store16();
141SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
142__sanitizer_cov_trace_pc_guard(__sanitizer::u32 *);
143SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
144__sanitizer_cov_trace_pc_guard_init(__sanitizer::u32 *, __sanitizer::u32 *);
145SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
146__sanitizer_cov_8bit_counters_init(char *, char *);
147SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
148__sanitizer_cov_bool_flag_init();
149SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
150__sanitizer_cov_pcs_init(const __sanitizer::uptr *, const __sanitizer::uptr *);
151} // extern "C"
152
153#endif // SANITIZER_INTERFACE_INTERNAL_H
154

source code of compiler-rt/lib/sanitizer_common/sanitizer_interface_internal.h