diff options
author | Kuba Brecka <kuba.brecka@gmail.com> | 2015-02-10 20:37:57 +0000 |
---|---|---|
committer | Kuba Brecka <kuba.brecka@gmail.com> | 2015-02-10 20:37:57 +0000 |
commit | 13c7a45cf38f63e2c67560c945ca26d995bea740 (patch) | |
tree | 7eb3576290ee541ea926c94efbcefcd3be797fda | |
parent | feafeaf22a3ad581bfa0d1d1a4c1f692affb04a0 (diff) |
Fix ASan's Noinst unit tests
We currently skip all "Noinst" unit tests on OS X, which was probably caused when we removed the "allow_reexec" flag. The MaybeReexec function fails to re-execute when the runtime is linked statically, because there is no dylib to use. This patch adds an explicit DisableReexec function that is used from asan_noinst_test.cc and the runtime then doesn't try to re-execute.
Reviewed at http://reviews.llvm.org/D7493
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@228740 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/asan/asan_internal.h | 1 | ||||
-rw-r--r-- | lib/asan/asan_linux.cc | 4 | ||||
-rw-r--r-- | lib/asan/asan_mac.cc | 8 | ||||
-rw-r--r-- | lib/asan/asan_win.cc | 4 | ||||
-rw-r--r-- | lib/asan/tests/asan_noinst_test.cc | 5 |
5 files changed, 21 insertions, 1 deletions
diff --git a/lib/asan/asan_internal.h b/lib/asan/asan_internal.h index a8e23ce77..ffd3ff82d 100644 --- a/lib/asan/asan_internal.h +++ b/lib/asan/asan_internal.h @@ -93,6 +93,7 @@ void AsanCheckIncompatibleRT(); void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp); void AsanOnSIGSEGV(int, void *siginfo, void *context); +void DisableReexec(); void MaybeReexec(); void ReadContextStack(void *context, uptr *stack, uptr *ssize); void AsanPlatformThreadInit(); diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc index 656050090..8e8bafd47 100644 --- a/lib/asan/asan_linux.cc +++ b/lib/asan/asan_linux.cc @@ -68,6 +68,10 @@ asan_rt_version_t __asan_rt_version; namespace __asan { +void DisableReexec() { + // No need to re-exec on Linux. +} + void MaybeReexec() { // No need to re-exec on Linux. } diff --git a/lib/asan/asan_mac.cc b/lib/asan/asan_mac.cc index 5c2caeae4..b35368617 100644 --- a/lib/asan/asan_mac.cc +++ b/lib/asan/asan_mac.cc @@ -101,7 +101,15 @@ void LeakyResetEnv(const char *name, const char *name_value) { } } +static bool reexec_disabled = false; + +void DisableReexec() { + reexec_disabled = true; +} + void MaybeReexec() { + if (reexec_disabled) return; + // Make sure the dynamic ASan runtime library is preloaded so that the // wrappers work. If it is not, set DYLD_INSERT_LIBRARIES and re-exec // ourselves. diff --git a/lib/asan/asan_win.cc b/lib/asan/asan_win.cc index 4f02b022f..693f0bcde 100644 --- a/lib/asan/asan_win.cc +++ b/lib/asan/asan_win.cc @@ -60,6 +60,10 @@ void PlatformTSDDtor(void *tsd) { AsanThread::TSDDtor(tsd); } // ---------------------- Various stuff ---------------- {{{1 +void DisableReexec() { + // No need to re-exec on Windows. +} + void MaybeReexec() { // No need to re-exec on Windows. } diff --git a/lib/asan/tests/asan_noinst_test.cc b/lib/asan/tests/asan_noinst_test.cc index c469d62a6..6a428fbbc 100644 --- a/lib/asan/tests/asan_noinst_test.cc +++ b/lib/asan/tests/asan_noinst_test.cc @@ -33,7 +33,10 @@ // Make sure __asan_init is called before any test case is run. struct AsanInitCaller { - AsanInitCaller() { __asan_init(); } + AsanInitCaller() { + __asan::DisableReexec(); + __asan_init(); + } }; static AsanInitCaller asan_init_caller; |