mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:47:45 +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
1 changed files with 14 additions and 0 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue