mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 09:36:06 +00:00
[msan] Add __msan_check_mem_is_initialized.
An assert()-like function that checks that a memory range is fully initialized. llvm-svn: 205413
This commit is contained in:
parent
a55fcd35e9
commit
80cb930c09
@ -54,6 +54,10 @@ extern "C" {
|
||||
memory range, or -1 if the whole range is good. */
|
||||
intptr_t __msan_test_shadow(const volatile void *x, size_t size);
|
||||
|
||||
/* Checks that memory range is fully initialized, and reports an error if it
|
||||
* is not. */
|
||||
void __msan_check_mem_is_initialized(const volatile void *x, size_t size);
|
||||
|
||||
/* Set exit code when error(s) were detected.
|
||||
Value of 0 means don't change the program exit code. */
|
||||
void __msan_set_exit_code(int exit_code);
|
||||
|
@ -383,6 +383,22 @@ sptr __msan_test_shadow(const void *x, uptr size) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
void __msan_check_mem_is_initialized(const void *x, uptr size) {
|
||||
if (!__msan::flags()->report_umrs) return;
|
||||
sptr offset = __msan_test_shadow(x, size) < 0;
|
||||
if (offset < 0)
|
||||
return;
|
||||
|
||||
GET_CALLER_PC_BP_SP;
|
||||
(void)sp;
|
||||
__msan::PrintWarningWithOrigin(pc, bp,
|
||||
__msan_get_origin(((char *)x) + offset));
|
||||
if (__msan::flags()->halt_on_error) {
|
||||
Printf("Exiting\n");
|
||||
Die();
|
||||
}
|
||||
}
|
||||
|
||||
int __msan_set_poison_in_malloc(int do_poison) {
|
||||
int old = flags()->poison_in_malloc;
|
||||
flags()->poison_in_malloc = do_poison;
|
||||
|
@ -64,6 +64,9 @@ void __msan_load_unpoisoned(void *src, uptr size, void *dst);
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
sptr __msan_test_shadow(const void *x, uptr size);
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
void __msan_check_mem_is_initialized(const void *x, uptr size);
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
void __msan_set_origin(const void *a, uptr size, u32 origin);
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
|
Loading…
x
Reference in New Issue
Block a user