Replace TLS_SLOT_BIONIC_PREINIT w/ shared globals
Instead of passing the address of a KernelArgumentBlock to libc.so for
initialization, use __loader_shared_globals() to initialize globals.
Most of the work happened in the previous CLs. This CL switches a few
KernelArgumentBlock::getauxval calls to [__bionic_]getauxval and stops
routing the KernelArgumentBlock address through the libc init functions.
Bug: none
Test: bionic unit tests
Change-Id: I96c7b02c21d55c454558b7a5a9243c682782f2dd
Merged-In: I96c7b02c21d55c454558b7a5a9243c682782f2dd
(cherry picked from commit 746ad15912cfa82271424747e94d8125acc43d8c)
diff --git a/libc/bionic/libc_init_dynamic.cpp b/libc/bionic/libc_init_dynamic.cpp
index 2ec1556..af1b847 100644
--- a/libc/bionic/libc_init_dynamic.cpp
+++ b/libc/bionic/libc_init_dynamic.cpp
@@ -77,12 +77,12 @@
// after __stack_chk_guard is initialized and therefore can safely have a stack
// protector.
__attribute__((noinline))
-static void __libc_preinit_impl(KernelArgumentBlock& args) {
+static void __libc_preinit_impl() {
#if defined(__i386__)
- __libc_init_sysinfo(args);
+ __libc_init_sysinfo();
#endif
- __libc_init_globals(args);
+ __libc_init_globals();
__libc_init_common();
// Hooks for various libraries to let them know that we're starting up.
@@ -98,17 +98,11 @@
// to run before any others (such as the jemalloc constructor), and lower
// is better (http://b/68046352).
__attribute__((constructor(1))) static void __libc_preinit() {
- // Read the kernel argument block pointer from TLS, then clear the slot so no
- // other initializer sees its value.
- void** tls = __get_tls();
- KernelArgumentBlock* args = static_cast<KernelArgumentBlock*>(tls[TLS_SLOT_BIONIC_PREINIT]);
- tls[TLS_SLOT_BIONIC_PREINIT] = nullptr;
-
// The linker has initialized its copy of the global stack_chk_guard, and filled in the main
// thread's TLS slot with that value. Initialize the local global stack guard with its value.
- __stack_chk_guard = reinterpret_cast<uintptr_t>(tls[TLS_SLOT_STACK_GUARD]);
+ __stack_chk_guard = reinterpret_cast<uintptr_t>(__get_tls()[TLS_SLOT_STACK_GUARD]);
- __libc_preinit_impl(*args);
+ __libc_preinit_impl();
}
// This function is called from the executable's _start entry point