[compiler-rt][hwasan] Move Thread::Init into hwasan_linux.cpp
authorLeonard Chan <leonardchan@google.com>
Wed, 16 Jun 2021 17:24:51 +0000 (10:24 -0700)
committerLeonard Chan <leonardchan@google.com>
Fri, 18 Jun 2021 17:32:41 +0000 (10:32 -0700)
commit88d93923e6653f02f5ece1faf9f49a7e309989a0
treef3580d2c2e3bb52a173aed88deb4b775cc1d02e2
parent79caf69cc08a72022f968020eab486b698fd4178
[compiler-rt][hwasan] Move Thread::Init into hwasan_linux.cpp

This allows for other implementations to define their own version of `Thread::Init`.
This will be the case for Fuchsia where much of the thread initialization can be
broken up between different thread hooks (`__sanitizer_before_thread_create_hook`,
`__sanitizer_thread_create_hook`, `__sanitizer_thread_start_hook`). Namely, setting
up the heap ring buffer and stack info and can be setup before thread creation.
The stack ring buffer can also be setup before thread creation, but storing it into
`__hwasan_tls` can only be done on the thread start hook since it's only then we
can access `__hwasan_tls` for that thread correctly.

Differential Revision: https://reviews.llvm.org/D104248
compiler-rt/lib/hwasan/hwasan_linux.cpp
compiler-rt/lib/hwasan/hwasan_thread.cpp
compiler-rt/lib/hwasan/hwasan_thread.h