diff options
author | Torne (Richard Coles) <torne@google.com> | 2019-04-11 12:25:06 -0400 |
---|---|---|
committer | Torne (Richard Coles) <torne@google.com> | 2019-04-11 13:57:31 -0400 |
commit | 5d10374947824c60d524e812172ae60f30a51fde (patch) | |
tree | d6ae67a2d04a626afdabbe546d01378bd0636eca /linker/linker.cpp | |
parent | e6fd53b751c253ce9315875bed838a6d549132f3 (diff) |
Only write main library's RELRO by default.
ANDROID_DLEXT_WRITE_RELRO was inadvertently writing out the RELRO
section of all libraries loaded during a given dlopen() call instead of
only the main library; since the other libraries are loaded at
unpredictable addresses this additional data is rarely useful.
Fix this to only happen when the
ANDROID_DLEXT_RESERVED_ADDRESS_RECURSIVE flag is being used.
Bug: 128623590
Test: DlExtRelroSharingTest.CheckRelroSizes
Change-Id: I05e8651d06ce2de77b8c85fe2b6238f9c09691ad
Diffstat (limited to 'linker/linker.cpp')
-rw-r--r-- | linker/linker.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/linker/linker.cpp b/linker/linker.cpp index c60ab6a50..219ae7914 100644 --- a/linker/linker.cpp +++ b/linker/linker.cpp @@ -1865,11 +1865,17 @@ bool find_libraries(android_namespace_t* ns, soinfo_list_t global_group = local_group_ns->get_global_group(); bool linked = local_group.visit([&](soinfo* si) { - // Even though local group may contain accessible soinfos from other namesapces + // Even though local group may contain accessible soinfos from other namespaces // we should avoid linking them (because if they are not linked -> they // are in the local_group_roots and will be linked later). if (!si->is_linked() && si->get_primary_namespace() == local_group_ns) { - if (!si->link_image(global_group, local_group, extinfo, &relro_fd_offset) || + const android_dlextinfo* link_extinfo = nullptr; + if (si == soinfos[0] || reserved_address_recursive) { + // Only forward extinfo for the first library unless the recursive + // flag is set. + link_extinfo = extinfo; + } + if (!si->link_image(global_group, local_group, link_extinfo, &relro_fd_offset) || !get_cfi_shadow()->AfterLoad(si, solist_get_head())) { return false; } |