diff options
author | Ryan Prichard <rprichard@google.com> | 2018-11-30 02:06:52 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-11-30 02:06:52 +0000 |
commit | 6b70fda682419b1cb41b33bfd84c66c037b7390e (patch) | |
tree | bfa841808df6ed69eef493dfda2eb4e94812bce0 /linker/linker_main.cpp | |
parent | c7cbef4f2dca7de4fb6186df05e0208d7d7fbfa5 (diff) | |
parent | 48b1159bb82b12bdd75be9228bd43db45168bdba (diff) |
Merge changes I376d7695,Ied443375,I614d25e7
* changes:
Use shared globals to init __progname + environ
Move the abort message to libc_shared_globals
Expose libc_shared_globals to libc.so with symbol
Diffstat (limited to 'linker/linker_main.cpp')
-rw-r--r-- | linker/linker_main.cpp | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/linker/linker_main.cpp b/linker/linker_main.cpp index 82b10b74b..aa12b6ef1 100644 --- a/linker/linker_main.cpp +++ b/linker/linker_main.cpp @@ -116,7 +116,6 @@ soinfo* solist_get_vdso() { } int g_ld_debug_verbosity; -abort_msg_t* g_abort_message = nullptr; // For debuggerd. static std::vector<std::string> g_ld_preload_names; @@ -299,7 +298,7 @@ static ElfW(Addr) linker_main(KernelArgumentBlock& args, const char* exe_to_load #endif // Sanitize the environment. - __libc_init_AT_SECURE(args); + __libc_init_AT_SECURE(args.envp); // Initialize system properties __system_properties_init(); // may use 'environ' @@ -308,7 +307,7 @@ static ElfW(Addr) linker_main(KernelArgumentBlock& args, const char* exe_to_load #ifdef __ANDROID__ debuggerd_callbacks_t callbacks = { .get_abort_message = []() { - return g_abort_message; + return __libc_shared_globals()->abort_msg; }, .post_dump = ¬ify_gdb_of_libraries, }; @@ -630,12 +629,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); @@ -663,13 +656,14 @@ __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; + __libc_shared_globals()->init_progname = g_argv[0]; // Initialize static variables. Note that in order to // get correct libdl_info we need to call constructors @@ -678,7 +672,6 @@ __linker_init_post_relocation(KernelArgumentBlock& args, soinfo& tmp_linker_so) g_default_namespace.add_soinfo(solinker); init_link_map_head(*solinker, kLinkerPath); - args.abort_message_ptr = &g_abort_message; ElfW(Addr) start_address = linker_main(args, exe_to_load); INFO("[ Jumping to _start (%p)... ]", reinterpret_cast<void*>(start_address)); |