mirror of
https://github.com/SerenityOS/serenity
synced 2024-07-09 01:50:46 +00:00
AK: Add platform macros to detect presence of AddressSanitizer
The ASAN_[UN]POISON_MEMORY_REGION macros can be used to manually notify the AddressSanitizer runtime about the reachability of instrumented code accessing a memory region. This is most useful for manually managed heaps and arenas that do not go directly to malloc or alligned_alloc.
This commit is contained in:
parent
5e1c1eb840
commit
212365130d
|
@ -45,6 +45,20 @@
|
|||
#endif
|
||||
#define NO_SANITIZE_ADDRESS [[gnu::no_sanitize_address]]
|
||||
|
||||
// GCC doesn't have __has_feature but clang does
|
||||
#ifndef __has_feature
|
||||
# define __has_feature(...) 0
|
||||
#endif
|
||||
|
||||
#if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
|
||||
# define HAS_ADDRESS_SANITIZER
|
||||
# define ASAN_POISON_MEMORY_REGION(addr, size) __asan_poison_memory_region(addr, size)
|
||||
# define ASAN_UNPOISON_MEMORY_REGION(addr, size) __asan_unpoison_memory_region(addr, size)
|
||||
#else
|
||||
# define ASAN_POISON_MEMORY_REGION(addr, size)
|
||||
# define ASAN_UNPOISON_MEMORY_REGION(addr, size)
|
||||
#endif
|
||||
|
||||
#ifndef __serenity__
|
||||
# include <unistd.h>
|
||||
# undef PAGE_SIZE
|
||||
|
|
Loading…
Reference in New Issue
Block a user