[sanitizer_common] Introduce SANITIZER_MMAP_BEGIN macro (#147645)

To prepare for other platforms, such as 64-bit AIX, that have a non-zero
mmap beginning address.

---------

Co-authored-by: David Justo <david.justo.1996@gmail.com>
This commit is contained in:
Jake Egan
2025-07-09 20:14:23 -04:00
committed by GitHub
parent 28aa5a64ef
commit d286540734
6 changed files with 8 additions and 5 deletions

View File

@@ -239,7 +239,7 @@ using PrimaryAllocator = PrimaryAllocatorASVT<LocalAddressSpaceView>;
typedef CompactSizeClassMap SizeClassMap;
template <typename AddressSpaceViewTy>
struct AP32 {
static const uptr kSpaceBeg = 0;
static const uptr kSpaceBeg = SANITIZER_MMAP_BEGIN;
static const u64 kSpaceSize = SANITIZER_MMAP_RANGE_SIZE;
static const uptr kMetadataSize = 0;
typedef __asan::SizeClassMap SizeClassMap;

View File

@@ -53,7 +53,7 @@ struct ChunkMetadata {
#if !SANITIZER_CAN_USE_ALLOCATOR64
template <typename AddressSpaceViewTy>
struct AP32 {
static const uptr kSpaceBeg = 0;
static const uptr kSpaceBeg = SANITIZER_MMAP_BEGIN;
static const u64 kSpaceSize = SANITIZER_MMAP_RANGE_SIZE;
static const uptr kMetadataSize = sizeof(ChunkMetadata);
typedef __sanitizer::CompactSizeClassMap SizeClassMap;

View File

@@ -56,7 +56,7 @@ struct MsanMapUnmapCallback {
const uptr kMaxAllowedMallocSize = 2UL << 30;
struct AP32 {
static const uptr kSpaceBeg = 0;
static const uptr kSpaceBeg = SANITIZER_MMAP_BEGIN;
static const u64 kSpaceSize = SANITIZER_MMAP_RANGE_SIZE;
static const uptr kMetadataSize = sizeof(Metadata);
using SizeClassMap = __sanitizer::CompactSizeClassMap;

View File

@@ -23,7 +23,7 @@ namespace __sanitizer {
typedef CompactSizeClassMap InternalSizeClassMap;
struct AP32 {
static const uptr kSpaceBeg = 0;
static const uptr kSpaceBeg = SANITIZER_MMAP_BEGIN;
static const u64 kSpaceSize = SANITIZER_MMAP_RANGE_SIZE;
static const uptr kMetadataSize = 0;
typedef InternalSizeClassMap SizeClassMap;

View File

@@ -318,6 +318,9 @@
# endif
#endif
// The first address that can be returned by mmap.
#define SANITIZER_MMAP_BEGIN 0
// The range of addresses which can be returned my mmap.
// FIXME: this value should be different on different platforms. Larger values
// will still work but will consume more memory for TwoLevelByteMap.

View File

@@ -62,7 +62,7 @@ struct MapUnmapCallback;
defined(__powerpc__) || SANITIZER_RISCV64
struct AP32 {
static const uptr kSpaceBeg = 0;
static const uptr kSpaceBeg = SANITIZER_MMAP_BEGIN;
static const u64 kSpaceSize = SANITIZER_MMAP_RANGE_SIZE;
static const uptr kMetadataSize = 0;
typedef __sanitizer::CompactSizeClassMap SizeClassMap;