+2016-04-05 Maxim Ostapenko <m.ostapenko@samsung.com>
+
+ PR sanitizer/70474
+ * asan/asan_mac.cc (GetMacosVersionInternal): Cherry pick
+ upstream r241487, 221379 and r224315.
+ (void MaybeReexec): Cherry pick upstream r241487.
+ * asan/asan_mac.h (enum MacosVersion): Cherry pick upstream r224315.
+
2015-06-26 Release Manager
* GCC 4.9.3 released.
case '1': return MACOS_VERSION_LION;
case '2': return MACOS_VERSION_MOUNTAIN_LION;
case '3': return MACOS_VERSION_MAVERICKS;
- default: return MACOS_VERSION_UNKNOWN;
+ case '4': return MACOS_VERSION_YOSEMITE;
+ default:
+ if (IsDigit(version[1]))
+ return MACOS_VERSION_UNKNOWN_NEWER;
+ else
+ return MACOS_VERSION_UNKNOWN;
}
}
default: return MACOS_VERSION_UNKNOWN;
}
}
+bool DyldNeedsEnvVariable() {
+// If running on OS X 10.11+ or iOS 9.0+, dyld will interpose even if
+// DYLD_INSERT_LIBRARIES is not set.
+
+#if SANITIZER_IOSSIM
+ // GetMacosVersion will not work for the simulator, whose kernel version
+ // is tied to the host. Use a weak linking hack for the simulator.
+ // This API was introduced in the same version of the OS as the dyld
+ // optimization.
+
+ // Check for presence of a symbol that is available on OS X 10.11+, iOS 9.0+.
+ return (dlsym(RTLD_NEXT, "mach_memory_info") == nullptr);
+#else
+ return (GetMacosVersion() <= MACOS_VERSION_YOSEMITE);
+#endif
+}
+
void MaybeReexec() {
if (!flags()->allow_reexec) return;
// Make sure the dynamic ASan runtime library is preloaded so that the
uptr old_env_len = dyld_insert_libraries ?
internal_strlen(dyld_insert_libraries) : 0;
uptr fname_len = internal_strlen(info.dli_fname);
- if (!dyld_insert_libraries ||
- !REAL(strstr)(dyld_insert_libraries, info.dli_fname)) {
+ bool lib_is_in_env =
+ dyld_insert_libraries && REAL(strstr)(dyld_insert_libraries, info.dli_fname);
+ if (DyldNeedsEnvVariable() && !lib_is_in_env) {
// DYLD_INSERT_LIBRARIES is not set or does not contain the runtime
// library.
char program_name[1024];
}
execv(program_name, *_NSGetArgv());
} else {
+
+ if (!lib_is_in_env)
+ return;
+
// DYLD_INSERT_LIBRARIES is set and contains the runtime library.
if (old_env_len == fname_len) {
// It's just the runtime library name - fine to unset the variable.
MACOS_VERSION_SNOW_LEOPARD,
MACOS_VERSION_LION,
MACOS_VERSION_MOUNTAIN_LION,
- MACOS_VERSION_MAVERICKS
+ MACOS_VERSION_MAVERICKS,
+ MACOS_VERSION_YOSEMITE,
+ MACOS_VERSION_UNKNOWN_NEWER
};
// Used by asan_malloc_mac.cc and asan_mac.cc