summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKuba Brecka <kuba.brecka@gmail.com>2015-08-03 14:48:59 +0000
committerKuba Brecka <kuba.brecka@gmail.com>2015-08-03 14:48:59 +0000
commitfe17cee960edc2f7446097f61a7e4e677444aeb1 (patch)
treee3723c7440aa8afab561896e1b0fb180adce60e1
parentf607111d95ed4ce3befadb0013be6808f79470be (diff)
downloadbcm5719-llvm-fe17cee960edc2f7446097f61a7e4e677444aeb1.tar.gz
bcm5719-llvm-fe17cee960edc2f7446097f61a7e4e677444aeb1.zip
[asan] Fix dyld version detection on OS X
We currently have a dyld check in DyldNeedsEnvVariable that detects whether we are on a new OS X (10.11+) where we don't need to re-exec. For iOS simulator, we have a dlsym() hack that checks for a specific symbol, but this turns out to be fragile and problematic, because dlsym can sometimes call malloc(), which is not a good idea this early in the process runtime. Let's instead of this do a direct comparison of dyld's version, which is exported in a public symbol `dyldVersionNumber`. Differential Revision: http://reviews.llvm.org/D11719 llvm-svn: 243879
-rw-r--r--compiler-rt/lib/asan/asan_mac.cc23
1 files changed, 9 insertions, 14 deletions
diff --git a/compiler-rt/lib/asan/asan_mac.cc b/compiler-rt/lib/asan/asan_mac.cc
index f8ee0366da9..0f0f9bb0875 100644
--- a/compiler-rt/lib/asan/asan_mac.cc
+++ b/compiler-rt/lib/asan/asan_mac.cc
@@ -99,21 +99,16 @@ void DisableReexec() {
reexec_disabled = true;
}
-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.
+extern "C" double dyldVersionNumber;
+static const double kMinDyldVersionWithAutoInterposition = 360.0;
- // 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
+bool DyldNeedsEnvVariable() {
+ // If running on OS X 10.11+ or iOS 9.0+, dyld will interpose even if
+ // DYLD_INSERT_LIBRARIES is not set. However, checking OS version via
+ // GetMacosVersion() doesn't work for the simulator. Let's instead check
+ // `dyldVersionNumber`, which is exported by dyld, against a known version
+ // number from the first OS release where this appeared.
+ return dyldVersionNumber < kMinDyldVersionWithAutoInterposition;
}
void MaybeReexec() {
OpenPOWER on IntegriCloud