Add the FreeBSD AArch64 memory layout

Use the FreeBSD AArch64 memory layout values when building for it.
These are based on the x86_64 values, scaled to take into account the
larger address space on AArch64.

Reviewed by: vitalybuka

Differential Revision: https://reviews.llvm.org/D125758
This commit is contained in:
Andrew Turner 2022-05-16 17:36:40 +01:00 committed by Ed Maste
parent 6d1f86095d
commit 1b2fa907d7
1 changed files with 21 additions and 0 deletions

View File

@ -195,6 +195,27 @@ const MappingDesc kMemoryLayout[] = {
((((uptr)(mem)) & ~0xC00000000000ULL) + 0x080000000000ULL) ((((uptr)(mem)) & ~0xC00000000000ULL) + 0x080000000000ULL)
#define SHADOW_TO_ORIGIN(shadow) (((uptr)(shadow)) + 0x140000000000ULL) #define SHADOW_TO_ORIGIN(shadow) (((uptr)(shadow)) + 0x140000000000ULL)
#elif SANITIZER_FREEBSD && defined(__aarch64__)
// Low memory: main binary, MAP_32BIT mappings and modules
// High memory: heap, modules and main thread stack
const MappingDesc kMemoryLayout[] = {
{0x000000000000ULL, 0x020000000000ULL, MappingDesc::APP, "low memory"},
{0x020000000000ULL, 0x200000000000ULL, MappingDesc::INVALID, "invalid"},
{0x200000000000ULL, 0x620000000000ULL, MappingDesc::SHADOW, "shadow"},
{0x620000000000ULL, 0x700000000000ULL, MappingDesc::INVALID, "invalid"},
{0x700000000000ULL, 0xb20000000000ULL, MappingDesc::ORIGIN, "origin"},
{0xb20000000000ULL, 0xc00000000000ULL, MappingDesc::INVALID, "invalid"},
{0xc00000000000ULL, 0x1000000000000ULL, MappingDesc::APP, "high memory"}};
// Maps low and high app ranges to contiguous space with zero base:
// Low: 0000 0000 0000 - 01ff ffff ffff -> 4000 0000 0000 - 41ff ffff ffff
// High: c000 0000 0000 - ffff ffff ffff -> 0000 0000 0000 - 3fff ffff ffff
#define LINEARIZE_MEM(mem) \
(((uptr)(mem) & ~0x1800000000000ULL) ^ 0x400000000000ULL)
#define MEM_TO_SHADOW(mem) (LINEARIZE_MEM((mem)) + 0x200000000000ULL)
#define SHADOW_TO_ORIGIN(shadow) (((uptr)(shadow)) + 0x500000000000)
#elif SANITIZER_FREEBSD && SANITIZER_WORDSIZE == 64 #elif SANITIZER_FREEBSD && SANITIZER_WORDSIZE == 64
// Low memory: main binary, MAP_32BIT mappings and modules // Low memory: main binary, MAP_32BIT mappings and modules