Replace public library list with shared lib sonames (part 2/2)

This commit updates interface of libdl.c.

1. android_init_namespaces is replaces with android_init_anonymous_namespace
2. added 2 arguments to android_create_namespace to specify linked namespace
   and the list of shared libraries sonames.
3. symbol lookup does not get past boundary libraries (added check and test for it).

Bug: http://b/26833548
Bug: http://b/21879602
Test: bionic-unit-tests --gtest_filter=dl*:Dl*
Change-Id: I32921da487a02e5bd0d2fc528904d1228394bfb9
diff --git a/linker/linker_namespaces.cpp b/linker/linker_namespaces.cpp
index 675f324..a7e14cc 100644
--- a/linker/linker_namespaces.cpp
+++ b/linker/linker_namespaces.cpp
@@ -27,6 +27,7 @@
  */
 
 #include "linker_namespaces.h"
+#include "linker_soinfo.h"
 #include "linker_utils.h"
 
 #include <vector>
@@ -57,3 +58,23 @@
   return false;
 }
 
+bool android_namespace_t::is_accessible(soinfo* s) {
+  std::vector<soinfo*> soinfos;
+  soinfos.push_back(s);
+  s->get_parents().for_each([&](soinfo* parent_si) {
+    soinfos.push_back(parent_si);
+  });
+
+  return std::find_if(soinfos.begin(), soinfos.end(), [this](soinfo* si) {
+    if (si->get_primary_namespace() == this) {
+      return true;
+    }
+
+    const android_namespace_list_t& secondary_namespaces = si->get_secondary_namespaces();
+    if (secondary_namespaces.find(this) != secondary_namespaces.end()) {
+      return true;
+    }
+
+    return false;
+  }) != soinfos.end();
+}