linker: unload RTLD_NODELETE libraries when loading fails
Linker was not unloading libraries marked with RTLD_NODELETE
even when there was a error on load. For example when one of
dt_needed libraries was not found.
Bug: http://b/27911891
Change-Id: Ibc0bf110aa41fbfdc9f327ad8c364f2e3600af71
(cherry picked from commit 79abce42146b27d523f309e0a1bc9f50175191cb)
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 855b32b..bda713e 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -3220,7 +3220,7 @@
}
bool soinfo::can_unload() const {
- return (get_rtld_flags() & (RTLD_NODELETE | RTLD_GLOBAL)) == 0;
+ return !is_linked() || ((get_rtld_flags() & (RTLD_NODELETE | RTLD_GLOBAL)) == 0);
}
bool soinfo::is_linked() const {