linker: Allow link namespaces without name filters

This commit allows users to create a link without soname filters between
two linker namespaces.

The motivation is to establish one-way shared library isolation.  For
example, assume that there are two linker namespaces `default` and
`vndk`.  We would like to limit the shared libraries that can be used by
the `default` namespace.  In the meanwhile, we would like to allow the
`vndk` namespace to use shared libs from the `default` namespace if the
soname cannot be find in the search path or loaded sonames of the `vndk`
namespace.

          shared_libs  = %VNDK_CORE_LIBRARIES%
          shared_libs += %VNDK_SAMEPROCESS_LIBRARIES%
    vndk <-------------------------------------------- default
       \_______________________________________________/^
                allow_all_shared_libs = true

android_link_namespaces_all_libs() is added to libdl, but it is
versioned as LIBC_PRIVATE.  android_link_namespaces_all_libs() is only
for unit tests.

Bug: 69824336

Test: adb shell /data/nativetest/linker-unit-tests/linker-unit-tests32
Test: adb shell /data/nativetest64/linker-unit-tests/linker-unit-tests64

Test: adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests
Test: adb shell /data/nativetest64/bionic-unit-tests/bionic-unit-tests

Test: Update /system/etc/ld.config*.txt and check whether the vndk
linker namespace of the vendor process can access the shared libs from
the default linker namespace.

Change-Id: I2879f0c5f5af60c7e56f8f743ebd2872e552286b
diff --git a/linker/linker_namespaces.h b/linker/linker_namespaces.h
index 16906d6..a7fe0d5 100644
--- a/linker/linker_namespaces.h
+++ b/linker/linker_namespaces.h
@@ -40,8 +40,10 @@
 struct android_namespace_link_t {
  public:
   android_namespace_link_t(android_namespace_t* linked_namespace,
-                           const std::unordered_set<std::string>& shared_lib_sonames)
-      : linked_namespace_(linked_namespace), shared_lib_sonames_(shared_lib_sonames)
+                           const std::unordered_set<std::string>& shared_lib_sonames,
+                           bool allow_all_shared_libs)
+      : linked_namespace_(linked_namespace), shared_lib_sonames_(shared_lib_sonames),
+        allow_all_shared_libs_(allow_all_shared_libs)
   {}
 
   android_namespace_t* linked_namespace() const {
@@ -53,12 +55,17 @@
   }
 
   bool is_accessible(const char* soname) const {
-    return shared_lib_sonames_.find(soname) != shared_lib_sonames_.end();
+    return allow_all_shared_libs_ || shared_lib_sonames_.find(soname) != shared_lib_sonames_.end();
+  }
+
+  bool allow_all_shared_libs() const {
+    return allow_all_shared_libs_;
   }
 
  private:
   android_namespace_t* const linked_namespace_;
   const std::unordered_set<std::string> shared_lib_sonames_;
+  bool allow_all_shared_libs_;
 };
 
 struct android_namespace_t {
@@ -105,8 +112,10 @@
     return linked_namespaces_;
   }
   void add_linked_namespace(android_namespace_t* linked_namespace,
-                            const std::unordered_set<std::string>& shared_lib_sonames) {
-    linked_namespaces_.push_back(android_namespace_link_t(linked_namespace, shared_lib_sonames));
+                            const std::unordered_set<std::string>& shared_lib_sonames,
+                            bool allow_all_shared_libs) {
+    linked_namespaces_.push_back(
+        android_namespace_link_t(linked_namespace, shared_lib_sonames, allow_all_shared_libs));
   }
 
   void add_soinfo(soinfo* si) {