summaryrefslogtreecommitdiff
path: root/linker/linker_main.cpp
diff options
context:
space:
mode:
authordimitry <dimitry@google.com>2017-11-28 16:03:07 +0100
committerdimitry <dimitry@google.com>2017-12-10 22:04:55 +0100
commit965d06da1ed957c349dbdfcc7831b462b757bf85 (patch)
treee07845fb90aa116761abf3699c114a156fb02650 /linker/linker_main.cpp
parentd351581aa9ba1fbce227db35500471fe59c45f08 (diff)
Fix logic in loading dependencies crossing namespace boundaries
This change addresses multiple problems introduced by 02586a2a34e6acfccf359b94db840f422b6c0231 1. In the case of unsuccessful dlopen the failure guard is triggered for two namespaces which leads to double unload. 2. In the case where load_tasks includes libraries from 3 and more namespaces it results in incorrect linking of libraries shared between second and third/forth and so on namespaces. The root cause of these problems was recursive call to find_libraries. It does not do what it is expected to do. It does not form new load_tasks list and immediately jumps to linking local_group. Not only this skips reference counting it also will include unlinked but accessible library from third (and fourth and fifth) namespaces in invalid local group. The best case scenario here is that for 3 or more namesapces this will fail to link. The worse case scenario it will link the library incorrectly with will lead to very hard to catch bugs. This change removes recursive call and replaces it with explicit list of local_groups which should be linked. It also revisits the way we do reference counting - with this change the reference counts are updated after after libraries are successfully loaded. Also update soinfo_free to abort in case when linker tries to free same soinfo for the second time - this makes linker behavior less undefined. Test: bionic-unit-tests Bug: http://b/69787209 Change-Id: Iea25ced181a98c6503cce6e2b832c91d697342d5
Diffstat (limited to 'linker/linker_main.cpp')
-rw-r--r--linker/linker_main.cpp4
1 files changed, 0 insertions, 4 deletions
diff --git a/linker/linker_main.cpp b/linker/linker_main.cpp
index 317f0d29b..dc1fa7550 100644
--- a/linker/linker_main.cpp
+++ b/linker/linker_main.cpp
@@ -384,9 +384,6 @@ static ElfW(Addr) __linker_init_post_relocation(KernelArgumentBlock& args) {
const char** needed_library_names = &needed_library_name_list[0];
size_t needed_libraries_count = needed_library_name_list.size();
- // readers_map is shared across recursive calls to find_libraries so that we
- // don't need to re-load elf headers.
- std::unordered_map<const soinfo*, ElfReader> readers_map;
if (needed_libraries_count > 0 &&
!find_libraries(&g_default_namespace,
si,
@@ -399,7 +396,6 @@ static ElfW(Addr) __linker_init_post_relocation(KernelArgumentBlock& args) {
nullptr,
true /* add_as_children */,
true /* search_linked_namespaces */,
- readers_map,
&namespaces)) {
__linker_cannot_link(g_argv[0]);
} else if (needed_libraries_count == 0) {