diff options
author | Ryan Prichard <rprichard@google.com> | 2018-11-22 02:40:17 -0800 |
---|---|---|
committer | Ryan Prichard <rprichard@google.com> | 2018-11-28 14:26:14 -0800 |
commit | abf736a7803f4acc8b70a2dab0d43b931aa9c5c0 (patch) | |
tree | 72009b4f3acbd65415b4c1ed2244d1c560269349 /linker/linker_main.cpp | |
parent | 12ed389ca5ea756f664de6f76118c886f7bac865 (diff) |
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
Diffstat (limited to 'linker/linker_main.cpp')
-rw-r--r-- | linker/linker_main.cpp | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/linker/linker_main.cpp b/linker/linker_main.cpp index 66766fe56..963e82c86 100644 --- a/linker/linker_main.cpp +++ b/linker/linker_main.cpp @@ -622,12 +622,6 @@ __linker_init_post_relocation(KernelArgumentBlock& args, soinfo& tmp_linker_so) // couldn't make system calls on x86 at that point, but we can now... if (!tmp_linker_so.protect_relro()) __linker_cannot_link(args.argv[0]); - // Initialize the linker/libc.so shared global inside the linker. - static libc_shared_globals shared_globals; - __libc_shared_globals = &shared_globals; - __libc_init_shared_globals(&shared_globals); - args.shared_globals = __libc_shared_globals; - // Initialize the linker's static libc's globals __libc_init_globals(args); @@ -655,12 +649,12 @@ __linker_init_post_relocation(KernelArgumentBlock& args, soinfo& tmp_linker_so) exit(0); } exe_to_load = args.argv[1]; - __libc_shared_globals->initial_linker_arg_count = 1; + __libc_shared_globals()->initial_linker_arg_count = 1; } // store argc/argv/envp to use them for calling constructors - g_argc = args.argc - __libc_shared_globals->initial_linker_arg_count; - g_argv = args.argv + __libc_shared_globals->initial_linker_arg_count; + g_argc = args.argc - __libc_shared_globals()->initial_linker_arg_count; + g_argv = args.argv + __libc_shared_globals()->initial_linker_arg_count; g_envp = args.envp; // Initialize static variables. Note that in order to |