diff options
-rw-r--r-- | compiler-rt/lib/asan/asan_rtems.cc | 33 | ||||
-rw-r--r-- | compiler-rt/lib/sanitizer_common/sanitizer_rtems.cc | 10 | ||||
-rw-r--r-- | compiler-rt/lib/sanitizer_common/sanitizer_rtems.h | 7 |
3 files changed, 10 insertions, 40 deletions
diff --git a/compiler-rt/lib/asan/asan_rtems.cc b/compiler-rt/lib/asan/asan_rtems.cc index 4ad9a4a66cc..a4af940057e 100644 --- a/compiler-rt/lib/asan/asan_rtems.cc +++ b/compiler-rt/lib/asan/asan_rtems.cc @@ -72,11 +72,6 @@ void EarlyInit() { ResetShadowMemory(); } -// Main thread information. Initialized in CreateMainThread() and -// used by ThreadStartHook(). -static uptr MainThreadSelf; -static AsanThread *MainThread; - // We can use a plain thread_local variable for TSD. static thread_local void *per_thread; @@ -134,18 +129,12 @@ void AsanThread::SetThreadStackAndTls(const AsanThread::InitOptions *options) { tls_end_ = options->tls_bottom + options->tls_size; } -// Called by __asan::AsanInitInternal (asan_rtl.c). +// Called by __asan::AsanInitInternal (asan_rtl.c). Unlike other ports, the +// main thread on RTEMS does not require special treatment; its AsanThread is +// already created by the provided hooks. This function simply looks up and +// returns the created thread. AsanThread *CreateMainThread() { - CHECK_NE(__sanitizer::MainThreadStackBase, 0); - CHECK_GT(__sanitizer::MainThreadStackSize, 0); - AsanThread *t = CreateAsanThread( - nullptr, 0, GetThreadSelf(), true, - __sanitizer::MainThreadStackBase, __sanitizer::MainThreadStackSize, - __sanitizer::MainThreadTlsBase, __sanitizer::MainThreadTlsSize); - SetCurrentThread(t); - MainThreadSelf = pthread_self(); - MainThread = t; - return t; + return GetThreadContextByTidLocked(0)->thread; } // This is called before each thread creation is attempted. So, in @@ -179,16 +168,14 @@ static void ThreadCreateHook(void *hook, bool aborted) { } } -// This is called (1) in the newly-created thread before it runs -// anything else, with the pointer returned by BeforeThreadCreateHook -// (above). cf. asan_interceptors.cc:asan_thread_start. (2) before -// a thread restart. +// This is called (1) in the newly-created thread before it runs anything else, +// with the pointer returned by BeforeThreadCreateHook (above). (2) before a +// thread restart. static void ThreadStartHook(void *hook, uptr os_id) { - if (!hook && !MainThreadSelf) + if (!hook) return; - DCHECK(hook || os_id == MainThreadSelf); - AsanThread *thread = hook ? static_cast<AsanThread *>(hook) : MainThread; + AsanThread *thread = static_cast<AsanThread *>(hook); SetCurrentThread(thread); ThreadStatus status = diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_rtems.cc b/compiler-rt/lib/sanitizer_common/sanitizer_rtems.cc index 56bc9b04037..2a8fb21ddf4 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_rtems.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_rtems.cc @@ -275,14 +275,4 @@ uptr MainThreadTlsBase, MainThreadTlsSize; } // namespace __sanitizer -extern "C" { -void __sanitizer_startup_hook(void *stack_base, size_t stack_size, - void *tls_base, size_t tls_size) { - __sanitizer::MainThreadStackBase = reinterpret_cast<uintptr_t>(stack_base); - __sanitizer::MainThreadStackSize = stack_size; - __sanitizer::MainThreadTlsBase = reinterpret_cast<uintptr_t>(tls_base); - __sanitizer::MainThreadTlsSize = tls_size; -} -} // extern "C" - #endif // SANITIZER_RTEMS diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_rtems.h b/compiler-rt/lib/sanitizer_common/sanitizer_rtems.h index e2f668ff9e8..968fa66e1be 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_rtems.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_rtems.h @@ -17,12 +17,5 @@ #if SANITIZER_RTEMS #include "sanitizer_common.h" -namespace __sanitizer { - -extern uptr MainThreadStackBase, MainThreadStackSize; -extern uptr MainThreadTlsBase, MainThreadTlsSize; - -} // namespace __sanitizer - #endif // SANITIZER_RTEMS #endif // SANITIZER_RTEMS_H |