diff options
author | Ryan Prichard <rprichard@google.com> | 2018-11-22 02:41:04 -0800 |
---|---|---|
committer | Ryan Prichard <rprichard@google.com> | 2018-11-28 14:26:14 -0800 |
commit | 7752bcb234a9960d2e9e89766d143b7ac0c5f332 (patch) | |
tree | e7bcae45f66a0682f07d242f18b33681fc9e4cfa /linker/linker_main.cpp | |
parent | abf736a7803f4acc8b70a2dab0d43b931aa9c5c0 (diff) |
Move the abort message to libc_shared_globals
__libc_shared_globals() is available in dynamic modules as soon as
relocation has finished (i.e. after ifuncs run). Before ifuncs have run,
the android_set_abort_message() function already doesn't work because it
calls public APIs via the PLT. (If this matters, we can use a static
bool variable to enable android_set_abort_message after libc
initialization).
__libc_shared_globals() is hidden, so it's available in the linker
immediately (i.e. before relocation). TLS memory (e.g. errno) currently
isn't accessible until after relocation, but a later patch fixes that.
Bug: none
Test: bionic unit tests
Change-Id: Ied4433758ed2da9ee404c6158e319cf502d05a53
Diffstat (limited to 'linker/linker_main.cpp')
-rw-r--r-- | linker/linker_main.cpp | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/linker/linker_main.cpp b/linker/linker_main.cpp index 963e82c86..442ecd909 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; @@ -300,7 +299,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, }; @@ -664,7 +663,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)); |