summaryrefslogtreecommitdiff
path: root/linker/linker_main.cpp
diff options
context:
space:
mode:
authorTorne (Richard Coles) <torne@google.com>2018-10-17 15:59:38 -0400
committerTorne (Richard Coles) <torne@google.com>2019-02-20 17:29:36 -0500
commitefbe9a5eefce28db6d1dbba18c212eb45915cf78 (patch)
tree0e35795b7b52bc65af89143af0662b5b0f4ce3e1 /linker/linker_main.cpp
parent73ee7a6320024c8f390d954a01b7a067c919bfc4 (diff)
linker: allow using reserved space for multiple libraries.
Introduce a new flag ANDROID_DLEXT_RESERVED_ADDRESS_RECURSIVE which instructs the linker to use the reserved address space to load all of the newly-loaded libraries required by a dlopen() call instead of only the main library. They will be loaded consecutively into that region if they fit. The RELRO sections of all the loaded libraries will also be considered for reading/writing shared RELRO data. This will allow the WebView implementation to potentially consist of more than one .so file while still benefiting from the RELRO sharing optimisation, which would otherwise only apply to the "root" .so file. Test: bionic-unit-tests (existing and newly added) Bug: 110790153 Change-Id: I61da775c29fd5017d9a1e2b6b3757c3d20a355b3
Diffstat (limited to 'linker/linker_main.cpp')
-rw-r--r--linker/linker_main.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/linker/linker_main.cpp b/linker/linker_main.cpp
index 7486cd79b..763b15c4b 100644
--- a/linker/linker_main.cpp
+++ b/linker/linker_main.cpp
@@ -165,7 +165,7 @@ static void add_vdso() {
si->load_bias = get_elf_exec_load_bias(ehdr_vdso);
si->prelink_image();
- si->link_image(g_empty_list, soinfo_list_t::make_list(si), nullptr);
+ si->link_image(g_empty_list, soinfo_list_t::make_list(si), nullptr, nullptr);
// prevents accidental unloads...
si->set_dt_flags_1(si->get_dt_flags_1() | DF_1_NODELETE);
si->set_linked();
@@ -281,7 +281,8 @@ static ExecutableInfo load_executable(const char* orig_path) {
if (!elf_reader.Read(result.path.c_str(), fd.get(), file_offset, result.file_stat.st_size)) {
__linker_error("error: %s\n", linker_get_error_buffer());
}
- if (!elf_reader.Load(nullptr)) {
+ address_space_params address_space;
+ if (!elf_reader.Load(&address_space)) {
__linker_error("error: %s\n", linker_get_error_buffer());
}
@@ -448,7 +449,7 @@ static ElfW(Addr) linker_main(KernelArgumentBlock& args, const char* exe_to_load
&namespaces)) {
__linker_cannot_link(g_argv[0]);
} else if (needed_libraries_count == 0) {
- if (!si->link_image(g_empty_list, soinfo_list_t::make_list(si), nullptr)) {
+ if (!si->link_image(g_empty_list, soinfo_list_t::make_list(si), nullptr, nullptr)) {
__linker_cannot_link(g_argv[0]);
}
si->increment_ref_count();
@@ -615,7 +616,7 @@ extern "C" ElfW(Addr) __linker_init(void* raw_args) {
// itself without having to look into local_group and (2) allocators
// are not yet initialized, and therefore we cannot use linked_list.push_*
// functions at this point.
- if (!tmp_linker_so.link_image(g_empty_list, g_empty_list, nullptr)) __linker_cannot_link(args.argv[0]);
+ if (!tmp_linker_so.link_image(g_empty_list, g_empty_list, nullptr, nullptr)) __linker_cannot_link(args.argv[0]);
return __linker_init_post_relocation(args, tmp_linker_so);
}