Expose libc_shared_globals to libc.so with symbol
Previously, the address of the global variable was communicated from the
dynamic linker to libc.so using a field of KernelArgumentBlock, which is
communicated using the TLS_SLOT_BIONIC_PREINIT slot.
As long as this function isn't called during relocations (i.e. while
executing an ifunc), it always return a non-NULL value. If it's called
before its PLT entry is relocated, I expect a crash.
I removed the __libc_init_shared_globals function. It's currently empty,
and I don't think there's one point in libc's initialization where
shared globals should be initialized.
Bug: http://b/25751302
Test: bionic unit tests
Change-Id: I614d25e7ef5e0d2ccc40d5c821dee10f1ec61c2e
diff --git a/libc/private/KernelArgumentBlock.h b/libc/private/KernelArgumentBlock.h
index 886dd32..1e053a1 100644
--- a/libc/private/KernelArgumentBlock.h
+++ b/libc/private/KernelArgumentBlock.h
@@ -24,7 +24,6 @@
#include "private/bionic_macros.h"
struct abort_msg_t;
-struct libc_shared_globals;
// When the kernel starts the dynamic linker, it passes a pointer to a block
// of memory containing argc, the argv array, the environment variable array,
@@ -67,7 +66,6 @@
// Other data that we want to pass from the dynamic linker to libc.so.
abort_msg_t** abort_message_ptr;
- libc_shared_globals* shared_globals;
private:
BIONIC_DISALLOW_COPY_AND_ASSIGN(KernelArgumentBlock);
diff --git a/libc/private/bionic_globals.h b/libc/private/bionic_globals.h
index 8c00551..44ec2e3 100644
--- a/libc/private/bionic_globals.h
+++ b/libc/private/bionic_globals.h
@@ -54,8 +54,7 @@
int initial_linker_arg_count;
};
-__LIBC_HIDDEN__ extern libc_shared_globals* __libc_shared_globals;
-__LIBC_HIDDEN__ void __libc_init_shared_globals(libc_shared_globals*);
+__LIBC_HIDDEN__ libc_shared_globals* __libc_shared_globals();
__LIBC_HIDDEN__ void __libc_init_fdsan();
class KernelArgumentBlock;