This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][PR sanitizer/70624] Fix 'dyld: Symbol not found: _dyldVersionNumber' link error on old Darwin systems.
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Maxim Ostapenko <m dot ostapenko at samsung dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Dominique Dhumieres <dominiq at lps dot ens dot fr>, Yury Gribov <y dot gribov at samsung dot com>, Slava Garbuzov <v dot garbuzov at samsung dot com>
- Date: Thu, 21 Apr 2016 13:54:15 +0200
- Subject: Re: [PATCH][PR sanitizer/70624] Fix 'dyld: Symbol not found: _dyldVersionNumber' link error on old Darwin systems.
- Authentication-results: sourceware.org; auth=none
- References: <5718BEEC dot 9090605 at samsung dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Thu, Apr 21, 2016 at 02:52:12PM +0300, Maxim Ostapenko wrote:
> Hi,
>
> On older Darwin systems (in particular, Darwin 10), dyld doesn't export
> '_dyldVersionNumber' symbol so we would have 'undefined reference' error in
> sanitizer library. We can mitigate this by introducing weak reference to
> '_dyldVersionNumber' and bailing out if &dyldVersionNumber == 0.
>
> Tested by Dominique on x86_64-apple-darwin10 and x86_64-apple-darwin15 (see
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70624#c8).
> Ok for mainline? If yes, should I back port this patch to gcc-{4.9, 5,
> 6}-branch?
>
> -Maxim
> libsanitizer/ChangeLog:
>
> 2016-04-21 Maxim Ostapenko <m.ostapenko@samsung.com>
>
> PR sanitizer/70624
> * asan/asan_mac.cc: Cherry pick upstream r266868.
Ok, for all branches, including 6.1 (if you commit it today).
Thanks.
> diff --git a/libsanitizer/asan/asan_mac.cc b/libsanitizer/asan/asan_mac.cc
> index 20e37ff..ab3c656 100644
> --- a/libsanitizer/asan/asan_mac.cc
> +++ b/libsanitizer/asan/asan_mac.cc
> @@ -97,10 +97,14 @@ void DisableReexec() {
> reexec_disabled = true;
> }
>
> -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
Jakub