diff options
author | Ryan Prichard <rprichard@google.com> | 2018-04-30 18:29:32 -0700 |
---|---|---|
committer | Ryan Prichard <rprichard@google.com> | 2018-05-30 15:43:43 -0700 |
commit | 6631f9b03dd032519be4b1971c2399a6e5e59357 (patch) | |
tree | 5e08b395a93f4a1cf4ec0fc83b7a09b4e864e51d /libc/bionic/libc_init_static.cpp | |
parent | aa922bbaf38d896ecb46ae08c675c2ef0df811db (diff) | |
download | bionic-6631f9b03dd032519be4b1971c2399a6e5e59357.tar.gz |
Clean up TLS_SLOT_BIONIC_PREINIT usage a bit
- It is only needed for dynamic executables, so move the initialization
out of __libc_init_main_thread and just before the solib constructor
calls. For static executables, the slot was initialized, then never
used or cleared. Instead, leave it clear.
- For static executables, __libc_init_main_thread already initialized the
stack guard, so remove the redundant __init_thread_stack_guard call.
- Simplify the slot access/clearing a bit in __libc_preinit.
- Remove the "__libc_init_common() will change the TLS area so the old one
won't be accessible anyway." comment. AFAICT, it's incorrect -- the
main thread's TLS area in a dynamic executable is initialized to a
static pthread_internal_t object in the linker, then reused by libc.so.
Test: adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests
Test: adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static
Change-Id: Ie2da6f5be3ad563fa65b38eaadf8ba6ecc6a64b6
Diffstat (limited to 'libc/bionic/libc_init_static.cpp')
-rw-r--r-- | libc/bionic/libc_init_static.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/libc/bionic/libc_init_static.cpp b/libc/bionic/libc_init_static.cpp index d19dd2882..4d62efe8d 100644 --- a/libc/bionic/libc_init_static.cpp +++ b/libc/bionic/libc_init_static.cpp @@ -86,10 +86,9 @@ __noreturn void __libc_init(void* raw_args, BIONIC_STOP_UNWIND; KernelArgumentBlock args(raw_args); - __libc_init_main_thread(args); // Initializing the globals requires TLS to be available for errno. - __init_thread_stack_guard(__get_thread()); + __libc_init_main_thread(args); __libc_init_globals(args); __libc_init_AT_SECURE(args); |