2013-01-29 22:33:29 +08:00
|
|
|
//===-- msan_interface_internal.h -------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file is a part of MemorySanitizer.
|
|
|
|
//
|
|
|
|
// Private MSan interface header.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef MSAN_INTERFACE_INTERNAL_H
|
|
|
|
#define MSAN_INTERFACE_INTERNAL_H
|
|
|
|
|
2013-01-30 21:12:08 +08:00
|
|
|
#include "sanitizer_common/sanitizer_internal_defs.h"
|
2013-01-29 22:33:29 +08:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
// FIXME: document all interface functions.
|
|
|
|
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
int __msan_get_track_origins();
|
|
|
|
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
void __msan_init();
|
|
|
|
|
|
|
|
// Print a warning and maybe return.
|
|
|
|
// This function can die based on flags()->exit_code.
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
void __msan_warning();
|
|
|
|
|
|
|
|
// Print a warning and die.
|
|
|
|
// Intrumentation inserts calls to this function when building in "fast" mode
|
|
|
|
// (i.e. -mllvm -msan-keep-going)
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE __attribute__((noreturn))
|
|
|
|
void __msan_warning_noreturn();
|
|
|
|
|
2014-04-18 20:18:00 +08:00
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
void __msan_maybe_warning_1(u8 s, u32 o);
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
void __msan_maybe_warning_2(u16 s, u32 o);
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
void __msan_maybe_warning_4(u32 s, u32 o);
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
void __msan_maybe_warning_8(u64 s, u32 o);
|
|
|
|
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
void __msan_maybe_store_origin_1(u8 s, void *p, u32 o);
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
void __msan_maybe_store_origin_2(u16 s, void *p, u32 o);
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
void __msan_maybe_store_origin_4(u32 s, void *p, u32 o);
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
void __msan_maybe_store_origin_8(u64 s, void *p, u32 o);
|
|
|
|
|
2013-01-29 22:33:29 +08:00
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
2013-04-23 21:34:19 +08:00
|
|
|
void __msan_unpoison(const void *a, uptr size);
|
2013-01-29 22:33:29 +08:00
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
2014-03-21 18:12:17 +08:00
|
|
|
void __msan_unpoison_string(const char *s);
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
2013-01-29 22:33:29 +08:00
|
|
|
void __msan_clear_and_unpoison(void *a, uptr size);
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
void* __msan_memcpy(void *dst, const void *src, uptr size);
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
void* __msan_memset(void *s, int c, uptr n);
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
void* __msan_memmove(void* dest, const void* src, uptr n);
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
2013-04-23 21:34:19 +08:00
|
|
|
void __msan_poison(const void *a, uptr size);
|
2013-01-29 22:33:29 +08:00
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
void __msan_poison_stack(void *a, uptr size);
|
|
|
|
|
|
|
|
// Copy size bytes from src to dst and unpoison the result.
|
|
|
|
// Useful to implement unsafe loads.
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
void __msan_load_unpoisoned(void *src, uptr size, void *dst);
|
|
|
|
|
|
|
|
// Returns the offset of the first (at least partially) poisoned byte,
|
|
|
|
// or -1 if the whole range is good.
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
sptr __msan_test_shadow(const void *x, uptr size);
|
|
|
|
|
2014-04-02 19:50:42 +08:00
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
void __msan_check_mem_is_initialized(const void *x, uptr size);
|
|
|
|
|
2013-01-29 22:33:29 +08:00
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
2013-04-23 21:34:19 +08:00
|
|
|
void __msan_set_origin(const void *a, uptr size, u32 origin);
|
2013-01-29 22:33:29 +08:00
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
void __msan_set_alloca_origin(void *a, uptr size, const char *descr);
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
2013-09-13 20:49:13 +08:00
|
|
|
void __msan_set_alloca_origin4(void *a, uptr size, const char *descr, uptr pc);
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
2014-03-18 21:45:19 +08:00
|
|
|
u32 __msan_chain_origin(u32 id);
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
2013-04-23 21:34:19 +08:00
|
|
|
u32 __msan_get_origin(const void *a);
|
2013-01-29 22:33:29 +08:00
|
|
|
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
void __msan_clear_on_return();
|
|
|
|
|
|
|
|
// Default: -1 (don't exit on error).
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
void __msan_set_exit_code(int exit_code);
|
|
|
|
|
2013-06-21 20:37:58 +08:00
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
void __msan_set_keep_going(int keep_going);
|
|
|
|
|
2013-01-29 22:33:29 +08:00
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
int __msan_set_poison_in_malloc(int do_poison);
|
|
|
|
|
2013-08-13 19:42:45 +08:00
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
|
2013-02-13 15:19:47 +08:00
|
|
|
/* OPTIONAL */ const char* __msan_default_options();
|
|
|
|
|
2013-01-29 22:33:29 +08:00
|
|
|
// For testing.
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
void __msan_set_expect_umr(int expect_umr);
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
void __msan_print_shadow(const void *x, uptr size);
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
2014-04-30 17:50:30 +08:00
|
|
|
void __msan_dump_shadow(const void *x, uptr size);
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
2013-01-29 22:33:29 +08:00
|
|
|
int __msan_has_dynamic_component();
|
|
|
|
|
|
|
|
// Returns x such that %fs:x is the first byte of __msan_retval_tls.
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
int __msan_get_retval_tls_offset();
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
int __msan_get_param_tls_offset();
|
|
|
|
|
2013-03-12 02:07:42 +08:00
|
|
|
// For intercepting mmap from ld.so in msandr.
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
bool __msan_is_in_loader();
|
|
|
|
|
2013-01-29 22:33:29 +08:00
|
|
|
// For testing.
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
u32 __msan_get_umr_origin();
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
2013-04-23 21:34:19 +08:00
|
|
|
void __msan_partial_poison(const void* data, void* shadow, uptr size);
|
2013-01-29 22:33:29 +08:00
|
|
|
|
|
|
|
// Tell MSan about newly allocated memory (ex.: custom allocator).
|
|
|
|
// Memory will be marked uninitialized, with origin at the call site.
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
2013-04-23 21:34:19 +08:00
|
|
|
void __msan_allocated_memory(const void* data, uptr size);
|
2013-01-29 22:33:29 +08:00
|
|
|
|
2013-06-04 21:08:36 +08:00
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
2013-06-04 21:49:10 +08:00
|
|
|
u16 __sanitizer_unaligned_load16(const uu16 *p);
|
2013-06-04 21:08:36 +08:00
|
|
|
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
2013-06-04 21:49:10 +08:00
|
|
|
u32 __sanitizer_unaligned_load32(const uu32 *p);
|
2013-06-04 21:08:36 +08:00
|
|
|
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
2013-06-04 21:49:10 +08:00
|
|
|
u64 __sanitizer_unaligned_load64(const uu64 *p);
|
2013-06-04 21:08:36 +08:00
|
|
|
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
2013-06-04 21:49:10 +08:00
|
|
|
void __sanitizer_unaligned_store16(uu16 *p, u16 x);
|
2013-06-04 21:08:36 +08:00
|
|
|
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
2013-06-04 21:49:10 +08:00
|
|
|
void __sanitizer_unaligned_store32(uu32 *p, u32 x);
|
2013-06-04 21:08:36 +08:00
|
|
|
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
2013-06-04 21:49:10 +08:00
|
|
|
void __sanitizer_unaligned_store64(uu64 *p, u64 x);
|
2013-08-02 22:26:58 +08:00
|
|
|
|
2013-12-20 19:05:19 +08:00
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
void __msan_dr_is_initialized();
|
|
|
|
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
void *__msan_wrap_indirect_call(void *target);
|
|
|
|
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
void __msan_set_indirect_call_wrapper(uptr wrapper);
|
2014-03-27 22:04:58 +08:00
|
|
|
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
void __msan_set_death_callback(void (*callback)(void));
|
2013-06-04 21:08:36 +08:00
|
|
|
} // extern "C"
|
|
|
|
|
2013-01-29 22:33:29 +08:00
|
|
|
#endif // MSAN_INTERFACE_INTERNAL_H
|