ETISS 0.8.0
Extendable Translating Instruction Set Simulator (version 0.8.0)
common_interface_defs.h
Go to the documentation of this file.
1 //===-- sanitizer/common_interface_defs.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 // Common part of the public sanitizer interface.
10 //===----------------------------------------------------------------------===//
11 
12 #ifndef SANITIZER_COMMON_INTERFACE_DEFS_H
13 #define SANITIZER_COMMON_INTERFACE_DEFS_H
14 
15 #include <stddef.h>
16 #include <stdint.h>
17 
18 // GCC does not understand __has_feature.
19 #if !defined(__has_feature)
20 #define __has_feature(x) 0
21 #endif
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 // Arguments for __sanitizer_sandbox_on_notify() below.
27 typedef struct {
28  // Enable sandbox support in sanitizer coverage.
30  // File descriptor to write coverage data to. If -1 is passed, a file will
31  // be pre-opened by __sanitizer_sandobx_on_notify(). This field has no
32  // effect if coverage_sandboxed == 0.
34  // If non-zero, split the coverage data into well-formed blocks. This is
35  // useful when coverage_fd is a socket descriptor. Each block will contain
36  // a header, allowing data from multiple processes to be sent over the same
37  // socket.
40 
41 // Tell the tools to write their reports to "path.<pid>" instead of stderr.
42 void __sanitizer_set_report_path(const char *path);
43 // Tell the tools to write their reports to the provided file descriptor
44 // (casted to void *).
46 
47 // Notify the tools that the sandbox is going to be turned on. The reserved
48 // parameter will be used in the future to hold a structure with functions
49 // that the tools may call to bypass the sandbox.
51 
52 // This function is called by the tool when it has just finished reporting
53 // an error. 'error_summary' is a one-line string that summarizes
54 // the error message. This function can be overridden by the client.
55 void __sanitizer_report_error_summary(const char *error_summary);
56 
57 // Some of the sanitizers (for example ASan/TSan) could miss bugs that happen
58 // in unaligned loads/stores. To find such bugs reliably, you need to replace
59 // plain unaligned loads/stores with these calls.
60 
67 
74 
81 
87 
93 
99 
100 // Returns 1 on the first call, then returns 0 thereafter. Called by the tool
101 // to ensure only one report is printed when multiple errors occur
102 // simultaneously.
104 
155  const void *end,
156  const void *old_mid,
157  const void *new_mid);
158 
175 int __sanitizer_verify_contiguous_container(const void *beg, const void *mid,
176  const void *end);
177 
189  const void *mid,
190  const void *end);
191 
195 
196 // Symbolizes the supplied 'pc' using the format string 'fmt'.
197 // Outputs at most 'out_buf_size' bytes into 'out_buf'.
198 // If 'out_buf' is not empty then output is zero or more non empty C strings
199 // followed by single empty C string. Multiple strings can be returned if PC
200 // corresponds to inlined function. Inlined frames are printed in the order
201 // from "most-inlined" to the "least-inlined", so the last frame should be the
202 // not inlined function.
203 // Inlined frames can be removed with 'symbolize_inline_frames=0'.
204 // The format syntax is described in
205 // lib/sanitizer_common/sanitizer_stacktrace_printer.h.
206 void __sanitizer_symbolize_pc(void *pc, const char *fmt, char *out_buf,
207  size_t out_buf_size);
208 // Same as __sanitizer_symbolize_pc, but for data section (i.e. globals).
209 void __sanitizer_symbolize_global(void *data_ptr, const char *fmt,
210  char *out_buf, size_t out_buf_size);
211 
217 void __sanitizer_set_death_callback(void (*callback)(void));
218 
219 
220 // Interceptor hooks.
221 // Whenever a libc function interceptor is called, it checks if the
222 // corresponding weak hook is defined, and calls it if it is indeed defined.
223 // The primary use-case is data-flow-guided fuzzing, where the fuzzer needs
224 // to know what is being passed to libc functions (for example memcmp).
225 // FIXME: implement more hooks.
226 
234 void __sanitizer_weak_hook_memcmp(void *called_pc, const void *s1,
235  const void *s2, size_t n, int result);
236 
244 void __sanitizer_weak_hook_strncmp(void *called_pc, const char *s1,
245  const char *s2, size_t n, int result);
246 
254 void __sanitizer_weak_hook_strncasecmp(void *called_pc, const char *s1,
255  const char *s2, size_t n, int result);
256 
263 void __sanitizer_weak_hook_strcmp(void *called_pc, const char *s1,
264  const char *s2, int result);
265 
272 void __sanitizer_weak_hook_strcasecmp(void *called_pc, const char *s1,
273  const char *s2, int result);
274 
281 void __sanitizer_weak_hook_strstr(void *called_pc, const char *s1,
282  const char *s2, char *result);
283 
284 void __sanitizer_weak_hook_strcasestr(void *called_pc, const char *s1,
285  const char *s2, char *result);
286 
287 void __sanitizer_weak_hook_memmem(void *called_pc,
288  const void *s1, size_t len1,
289  const void *s2, size_t len2, void *result);
290 
291 // Prints stack traces for all live heap allocations ordered by total
292 // allocation size until top_percent of total live heap is shown. top_percent
293 // should be between 1 and 100. At most max_number_of_contexts contexts
294 // (stack traces) are printed.
295 // Experimental feature currently available only with ASan on Linux/x86_64.
296 void __sanitizer_print_memory_profile(size_t top_percent,
297  size_t max_number_of_contexts);
298 
326 void __sanitizer_start_switch_fiber(void **fake_stack_save,
327  const void *bottom, size_t size);
328 
340 void __sanitizer_finish_switch_fiber(void *fake_stack_save,
341  const void **bottom_old,
342  size_t *size_old);
343 
344 // Get full module name and calculate pc offset within it.
345 // Returns 1 if pc belongs to some module, 0 if module was not found.
346 int __sanitizer_get_module_and_offset_for_pc(void *pc, char *module_path,
347  size_t module_path_len,
348  void **pc_offset);
349 
350 #ifdef __cplusplus
351 } // extern "C"
352 #endif
353 
354 #endif // SANITIZER_COMMON_INTERFACE_DEFS_H
static __inline__ uint32_t
Definition: arm_cde.h:25
static __inline__ uint64_t
Definition: arm_cde.h:31
static __inline__ uint16_t
Definition: arm_mve.h:315
void __sanitizer_weak_hook_strcasestr(void *called_pc, const char *s1, const char *s2, char *result)
void __sanitizer_print_memory_profile(size_t top_percent, size_t max_number_of_contexts)
void __sanitizer_unaligned_store64(void *p, uint64_t x)
Stores a 64-bit unaligned value.
void __sanitizer_set_death_callback(void(*callback)(void))
Sets the callback to be called immediately before death on error.
void __sanitizer_sandbox_on_notify(__sanitizer_sandbox_arguments *args)
void __sanitizer_start_switch_fiber(void **fake_stack_save, const void *bottom, size_t size)
Notify ASan that a fiber switch has started (required only if implementing your own fiber library).
void __sanitizer_weak_hook_strncasecmp(void *called_pc, const char *s1, const char *s2, size_t n, int result)
Interceptor hook for strncasecmp().
void __sanitizer_set_report_fd(void *fd)
int __sanitizer_get_module_and_offset_for_pc(void *pc, char *module_path, size_t module_path_len, void **pc_offset)
const void * __sanitizer_contiguous_container_find_bad_address(const void *beg, const void *mid, const void *end)
Similar to __sanitizer_verify_contiguous_container() but also returns the address of the first improp...
uint64_t __sanitizer_unaligned_load64(const void *p)
Loads a 64-bit unaligned value.
void __sanitizer_report_error_summary(const char *error_summary)
void __sanitizer_weak_hook_memcmp(void *called_pc, const void *s1, const void *s2, size_t n, int result)
Interceptor hook for memcmp().
void __sanitizer_annotate_contiguous_container(const void *beg, const void *end, const void *old_mid, const void *new_mid)
Annotates the current state of a contiguous container, such as std::vector, std::string,...
void __sanitizer_weak_hook_strncmp(void *called_pc, const char *s1, const char *s2, size_t n, int result)
Interceptor hook for strncmp().
uint16_t __sanitizer_unaligned_load16(const void *p)
Loads a 16-bit unaligned value.
void __sanitizer_unaligned_store16(void *p, uint16_t x)
Stores a 16-bit unaligned value.
int __sanitizer_verify_contiguous_container(const void *beg, const void *mid, const void *end)
Returns true if the contiguous container [beg, end) is properly poisoned.
void __sanitizer_unaligned_store32(void *p, uint32_t x)
Stores a 32-bit unaligned value.
uint32_t __sanitizer_unaligned_load32(const void *p)
Loads a 32-bit unaligned value.
void __sanitizer_weak_hook_strstr(void *called_pc, const char *s1, const char *s2, char *result)
Interceptor hook for strstr().
void __sanitizer_print_stack_trace(void)
Prints the stack trace leading to this call (useful for calling from the debugger).
void __sanitizer_symbolize_global(void *data_ptr, const char *fmt, char *out_buf, size_t out_buf_size)
void __sanitizer_weak_hook_strcasecmp(void *called_pc, const char *s1, const char *s2, int result)
Interceptor hook for strcasecmp().
void __sanitizer_weak_hook_strcmp(void *called_pc, const char *s1, const char *s2, int result)
Interceptor hook for strcmp().
int __sanitizer_acquire_crash_state()
void __sanitizer_finish_switch_fiber(void *fake_stack_save, const void **bottom_old, size_t *size_old)
Notify ASan that a fiber switch has completed (required only if implementing your own fiber library).
void __sanitizer_set_report_path(const char *path)
void __sanitizer_weak_hook_memmem(void *called_pc, const void *s1, size_t len1, const void *s2, size_t len2, void *result)
void __sanitizer_symbolize_pc(void *pc, const char *fmt, char *out_buf, size_t out_buf_size)
__INTPTR_TYPE__ intptr_t
A signed integer type with the property that any valid pointer to void can be converted to this type,...
Definition: opencl-c-base.h:55