[PATCH] D11719: [asan] Fix dyld version detection on OS X

Phabricator reviews at reviews.llvm.org
Mon Aug 3 07:49:33 PDT 2015


This revision was automatically updated to reflect the committed changes.
Closed by commit rL243879: [asan] Fix dyld version detection on OS X (authored by kuba.brecka).

Changed prior to commit:
  http://reviews.llvm.org/D11719?vs=31228&id=31231#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D11719

Files:
  compiler-rt/trunk/lib/asan/asan_mac.cc

Index: compiler-rt/trunk/lib/asan/asan_mac.cc
===================================================================
--- compiler-rt/trunk/lib/asan/asan_mac.cc
+++ compiler-rt/trunk/lib/asan/asan_mac.cc
@@ -99,21 +99,16 @@
   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() {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11719.31231.patch
Type: text/x-patch
Size: 1461 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150803/8daa1169/attachment.bin>


More information about the llvm-commits mailing list