[ASan] Move the shadow range on 32-bit iOS (and iOS Simulator)

to 0x40000000-0x60000000 to avoid address space clash with system libraries.
The solution has been proposed by tahabekireren@gmail.com in https://code.google.com/p/address-sanitizer/issues/detail?id=210
This is also known to fix some Chromium iOS tests.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207002 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Alexander Potapenko 2014-04-23 17:14:45 +00:00
parent e0f15f8b7a
commit 2820f739b2

View File

@ -55,6 +55,7 @@ using namespace llvm;
static const uint64_t kDefaultShadowScale = 3; static const uint64_t kDefaultShadowScale = 3;
static const uint64_t kDefaultShadowOffset32 = 1ULL << 29; static const uint64_t kDefaultShadowOffset32 = 1ULL << 29;
static const uint64_t kIOSShadowOffset32 = 1ULL << 30;
static const uint64_t kDefaultShadowOffset64 = 1ULL << 44; static const uint64_t kDefaultShadowOffset64 = 1ULL << 44;
static const uint64_t kSmallX86_64ShadowOffset = 0x7FFF8000; // < 2G. static const uint64_t kSmallX86_64ShadowOffset = 0x7FFF8000; // < 2G.
static const uint64_t kPPC64_ShadowOffset64 = 1ULL << 41; static const uint64_t kPPC64_ShadowOffset64 = 1ULL << 41;
@ -250,7 +251,7 @@ struct ShadowMapping {
static ShadowMapping getShadowMapping(const Module &M, int LongSize) { static ShadowMapping getShadowMapping(const Module &M, int LongSize) {
llvm::Triple TargetTriple(M.getTargetTriple()); llvm::Triple TargetTriple(M.getTargetTriple());
bool IsAndroid = TargetTriple.getEnvironment() == llvm::Triple::Android; bool IsAndroid = TargetTriple.getEnvironment() == llvm::Triple::Android;
// bool IsMacOSX = TargetTriple.getOS() == llvm::Triple::MacOSX; bool IsIOS = TargetTriple.getOS() == llvm::Triple::IOS;
bool IsFreeBSD = TargetTriple.getOS() == llvm::Triple::FreeBSD; bool IsFreeBSD = TargetTriple.getOS() == llvm::Triple::FreeBSD;
bool IsLinux = TargetTriple.getOS() == llvm::Triple::Linux; bool IsLinux = TargetTriple.getOS() == llvm::Triple::Linux;
bool IsPPC64 = TargetTriple.getArch() == llvm::Triple::ppc64 || bool IsPPC64 = TargetTriple.getArch() == llvm::Triple::ppc64 ||
@ -268,6 +269,8 @@ static ShadowMapping getShadowMapping(const Module &M, int LongSize) {
Mapping.Offset = kMIPS32_ShadowOffset32; Mapping.Offset = kMIPS32_ShadowOffset32;
else if (IsFreeBSD) else if (IsFreeBSD)
Mapping.Offset = kFreeBSD_ShadowOffset32; Mapping.Offset = kFreeBSD_ShadowOffset32;
else if (IsIOS)
Mapping.Offset = kIOSShadowOffset32;
else else
Mapping.Offset = kDefaultShadowOffset32; Mapping.Offset = kDefaultShadowOffset32;
} else { // LongSize == 64 } else { // LongSize == 64