@@ -294,25 +294,6 @@ void InstallAtExitHandler() { atexit(HwasanAtExit); }
294
294
295
295
// ---------------------- TSD ---------------- {{{1
296
296
297
- extern " C" void __hwasan_thread_enter () {
298
- hwasanThreadList ().CreateCurrentThread ()->EnsureRandomStateInited ();
299
- }
300
-
301
- extern " C" void __hwasan_thread_exit () {
302
- Thread *t = GetCurrentThread ();
303
- // Make sure that signal handler can not see a stale current thread pointer.
304
- atomic_signal_fence (memory_order_seq_cst);
305
- if (t) {
306
- // Block async signals on the thread as the handler can be instrumented.
307
- // After this point instrumented code can't access essential data from TLS
308
- // and will crash.
309
- // Bionic already calls __hwasan_thread_exit with blocked signals.
310
- if (SANITIZER_GLIBC)
311
- BlockSignals ();
312
- hwasanThreadList ().ReleaseThread (t);
313
- }
314
- }
315
-
316
297
# if HWASAN_WITH_INTERCEPTORS
317
298
static pthread_key_t tsd_key;
318
299
static bool tsd_key_inited = false ;
@@ -561,4 +542,25 @@ void InstallAtExitCheckLeaks() {
561
542
562
543
} // namespace __hwasan
563
544
545
+ using namespace __hwasan ;
546
+
547
+ extern " C" void __hwasan_thread_enter () {
548
+ hwasanThreadList ().CreateCurrentThread ()->EnsureRandomStateInited ();
549
+ }
550
+
551
+ extern " C" void __hwasan_thread_exit () {
552
+ Thread *t = GetCurrentThread ();
553
+ // Make sure that signal handler can not see a stale current thread pointer.
554
+ atomic_signal_fence (memory_order_seq_cst);
555
+ if (t) {
556
+ // Block async signals on the thread as the handler can be instrumented.
557
+ // After this point instrumented code can't access essential data from TLS
558
+ // and will crash.
559
+ // Bionic already calls __hwasan_thread_exit with blocked signals.
560
+ if (SANITIZER_GLIBC)
561
+ BlockSignals ();
562
+ hwasanThreadList ().ReleaseThread (t);
563
+ }
564
+ }
565
+
564
566
#endif // SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
0 commit comments