From 10c0350fb5f2dfff4e71db47c92ba89d195e89b4 Mon Sep 17 00:00:00 2001 From: Kuba Mracek Date: Thu, 6 Jul 2017 17:13:40 +0000 Subject: [sanitizer] Split GetMaxVirtualAddress into separate Linux version and Mac version [NFC] The logic in GetMaxVirtualAddress is already pretty complex, and I want to get rid of the hardcoded value for iOS/AArch64, which would need adding more Darwin-specific code, so let's split the implementation into sanitizer_linux.cc and sanitizer_mac.cc files. NFC. Differential Revision: https://reviews.llvm.org/D35031 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@307281 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/sanitizer_common/sanitizer_mac.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib/sanitizer_common/sanitizer_mac.cc') diff --git a/lib/sanitizer_common/sanitizer_mac.cc b/lib/sanitizer_common/sanitizer_mac.cc index 2a13fee05..7d027130d 100644 --- a/lib/sanitizer_common/sanitizer_mac.cc +++ b/lib/sanitizer_common/sanitizer_mac.cc @@ -800,6 +800,20 @@ char **GetArgv() { return *_NSGetArgv(); } +uptr GetMaxVirtualAddress() { +#if SANITIZER_WORDSIZE == 64 +# if defined(__aarch64__) && SANITIZER_IOS && !SANITIZER_IOSSIM + // Ideally, we would derive the upper bound from MACH_VM_MAX_ADDRESS. The + // upper bound can change depending on the device. + return 0x200000000 - 1; +# else + return (1ULL << 47) - 1; // 0x00007fffffffffffUL; +# endif +#else // SANITIZER_WORDSIZE == 32 + return (1ULL << 32) - 1; // 0xffffffff; +#endif // SANITIZER_WORDSIZE +} + uptr FindAvailableMemoryRange(uptr shadow_size, uptr alignment, uptr left_padding) { -- cgit v1.2.3