Index: lib/asan/asan_mac.cc =================================================================== --- lib/asan/asan_mac.cc +++ lib/asan/asan_mac.cc @@ -24,7 +24,15 @@ #include "sanitizer_common/sanitizer_libc.h" #include "sanitizer_common/sanitizer_mac.h" -#include // for _NSGetArgv +#if !TARGET_OS_IPHONE +#include // for _NSGetArgv and _NSGetEnviron +#else +extern char **environ; +extern "C" { + extern char ***_NSGetArgv(void); +} +#endif + #include // for dladdr() #include #include @@ -62,9 +70,11 @@ // otherwise the corresponding "NAME=value" string is replaced with // |name_value|. void LeakyResetEnv(const char *name, const char *name_value) { +#if !TARGET_OS_IPHONE char ***env_ptr = _NSGetEnviron(); CHECK(env_ptr); char **environ = *env_ptr; +#endif CHECK(environ); uptr name_len = internal_strlen(name); while (*environ != 0) { Index: lib/asan/asan_mapping.h =================================================================== --- lib/asan/asan_mapping.h +++ lib/asan/asan_mapping.h @@ -100,6 +100,9 @@ static const u64 kDefaultShadowOffset32 = 1ULL << 29; // 0x20000000 static const u64 kIosShadowOffset32 = 1ULL << 30; // 0x40000000 static const u64 kDefaultShadowOffset64 = 1ULL << 44; +static const u64 kIosShadowOffset64 = 0x130000000; +static const u64 kIosSimShadowOffset32 = 1ULL << 30; +static const u64 kIosSimShadowOffset64 = kDefaultShadowOffset64; static const u64 kDefaultShort64bitShadowOffset = 0x7FFF8000; // < 2G. static const u64 kAArch64_ShadowOffset64 = 1ULL << 36; static const u64 kMIPS32_ShadowOffset32 = 0x0aaa0000; @@ -112,6 +115,20 @@ #define SHADOW_SCALE kDefaultShadowScale #if SANITIZER_ANDROID # define SHADOW_OFFSET (0) +#elif SANITIZER_IOS +# if SANITIZER_WORDSIZE == 32 +# if SANITIZER_IOSSIM +# define SHADOW_OFFSET kIosSimShadowOffset32 +# else +# define SHADOW_OFFSET kIosShadowOffset32 +# endif +# else +# if SANITIZER_IOSSIM +# define SHADOW_OFFSET kIosSimShadowOffset64 +# else +# define SHADOW_OFFSET kIosShadowOffset64 +# endif +# endif #else # if SANITIZER_WORDSIZE == 32 # if defined(__mips__)