[ASan] Don't call __asan_init() from certain interceptors on Darwin.

Fixes http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58994, which hadn't
manifested in LLVM because libclang_rt.asan_osx_dynamic.dylib used to depend on
the Foundation framework.
Without that dependency some interceptors may be called from the system
libraries before libSystem_initializer() is called, which lead to assertion
failures in sanitizer_mac.cc (_NSGetEnviron() returns NULL).

To fix the problem we fall back to the original functions in the common
libsanitizer interceptors and the __cxa_atexit() interceptor on Darwin.

This patch also prints a better error message in the case _NSGetEnviron()
returns NULL.



git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@194573 91177308-0d34-0410-b5e6-96231b3b80d8
2 files changed