linker: print "not accessible" error message to the log
Print properties of the namespace on "library is not accessible"
error to better diagnose problems with native library accessiblity
Bug: http://b/27406143
Change-Id: Icf3d6c604f09dfa015de863fdb1267d343930d2a
(cherry picked from commit 350bdad61cc6551db649fcaeb8642f4a1d6b139a)
diff --git a/linker/linker.cpp b/linker/linker.cpp
index b5b76b6..a43630b 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -93,6 +93,9 @@
default_library_paths_ = library_paths;
}
+ const std::vector<std::string>& get_permitted_paths() const {
+ return permitted_paths_;
+ }
void set_permitted_paths(std::vector<std::string>&& permitted_paths) {
permitted_paths_ = permitted_paths;
}
@@ -1651,8 +1654,23 @@
if (!ns->is_accessible(realpath)) {
// do not load libraries if they are not accessible for the specified namespace.
- DL_ERR("library \"%s\" is not accessible for the namespace \"%s\"",
- name, ns->get_name());
+ const char* needed_or_dlopened_by = task->get_needed_by() == nullptr ?
+ "(unknown)" :
+ task->get_needed_by()->get_realpath();
+
+ DL_ERR("library \"%s\" needed or dlopened by \"%s\" is not accessible for the namespace \"%s\"",
+ name, needed_or_dlopened_by, ns->get_name());
+
+ PRINT("library \"%s\" (\"%s\") needed or dlopened by \"%s\" is not accessible for the"
+ " namespace: [name=\"%s\", ld_library_paths=\"%s\", default_library_paths=\"%s\","
+ " permitted_paths=\"%s\"]",
+ name, realpath.c_str(),
+ needed_or_dlopened_by,
+ ns->get_name(),
+ android::base::Join(ns->get_ld_library_paths(), ':').c_str(),
+ android::base::Join(ns->get_default_library_paths(), ':').c_str(),
+ android::base::Join(ns->get_permitted_paths(), ':').c_str());
+
return false;
}