linker: check if needed_by is nullptr

Check if needed_by is nullptr in the grey-list warning
also print the name of the library making call to dlopen()

Bug: http://b/26749878
Change-Id: I4e16223a3e3d8d1539f855a0b3f199c5529027e0
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 72e7759..a9d8ec6 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -1788,9 +1788,13 @@
     if (is_greylisted(name, needed_by)) {
       // print warning only if needed by non-system library
       if (needed_by == nullptr || !is_system_library(needed_by->get_realpath())) {
-        DL_WARN("library \"%s\" (\"%s\") needed by \"%s\" is not accessible for the namespace \"%s\""
+        const soinfo* needed_or_dlopened_by = task->get_needed_by();
+        DL_WARN("library \"%s\" (\"%s\") needed or dlopened by \"%s\" is not accessible for the namespace \"%s\""
                 " - the access is temporarily granted as a workaround for http://b/26394120",
-                name, realpath.c_str(), needed_by->get_realpath(), ns->get_name());
+                name, realpath.c_str(),
+                needed_or_dlopened_by == nullptr ? "(unknown)" :
+                                         needed_or_dlopened_by->get_realpath(),
+                ns->get_name());
       }
     } else {
       // do not load libraries if they are not accessible for the specified namespace.