[compiler-rt] r266868 - [sanitizer] Fix 'dyld: Symbol not found: _dyldVersionNumber' link error on old Darwin systems.

Maxim Ostapenko via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 20 03:22:37 PDT 2016


Author: chefmax
Date: Wed Apr 20 05:22:37 2016
New Revision: 266868

URL: http://llvm.org/viewvc/llvm-project?rev=266868&view=rev
Log:
[sanitizer] Fix 'dyld: Symbol not found: _dyldVersionNumber' link error on old Darwin systems.

This patch fixes https://github.com/google/sanitizers/issues/669. On older Darwin systems (in particular, Darwin 10),
dyld doesn't export '_dyldVersionNumber' symbol so we would have 'undefined reference' error in sanitzer library. Although
sanitizers support was added to LLVM on OS X 10.7+ where '_dyldVersionNumber' symbol is already exported, GCC users still
may want use them on older systems.

Differential Revision: http://reviews.llvm.org/D19218

Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc?rev=266868&r1=266867&r2=266868&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc Wed Apr 20 05:22:37 2016
@@ -564,10 +564,14 @@ bool ReexecDisabled() {
   return false;
 }
 
-extern "C" double dyldVersionNumber;
+extern "C" SANITIZER_WEAK_ATTRIBUTE double dyldVersionNumber;
 static const double kMinDyldVersionWithAutoInterposition = 360.0;
 
 bool DyldNeedsEnvVariable() {
+  // Although sanitizer support was added to LLVM on OS X 10.7+, GCC users
+  // still may want use them on older systems. On older Darwin platforms, dyld
+  // doesn't export dyldVersionNumber symbol and we simply return true.
+  if (!&dyldVersionNumber) return true;
   // 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




More information about the llvm-commits mailing list