Ignore symbols of imported libs' dependencies
When a library is present in a namespace via the secondary_namespaces
list (i.e. the executable, LD_PRELOAD, DF_1_GLOBAL, or
android_create_namespace inheritance), then we want to search that
library's symbols, but not the symbols of its dependencies. Otherwise,
we want to search the dependencies to handle cross-NS dependency.
Bug: http://b/148569846
Test: bionic unit tests
Change-Id: If798d69de28ed5c0f1a155e4ff85c7e08934e531
diff --git a/tests/dlext_test.cpp b/tests/dlext_test.cpp
index a2b5b3c..293c17b 100644
--- a/tests/dlext_test.cpp
+++ b/tests/dlext_test.cpp
@@ -39,6 +39,7 @@
#include <procinfo/process_map.h>
#include <ziparchive/zip_archive.h>
+#include "core_shared_libs.h"
#include "gtest_globals.h"
#include "utils.h"
#include "dlext_private.h"
@@ -713,7 +714,7 @@
static const char* g_public_lib = "libnstest_public.so";
// These are libs shared with default namespace
-static const std::string g_core_shared_libs = "libc.so:libc++.so:libdl.so:libm.so";
+static const std::string g_core_shared_libs = kCoreSharedLibs;
TEST(dlext, ns_smoke) {
static const char* root_lib = "libnstest_root.so";
@@ -2055,6 +2056,23 @@
ASSERT_TRUE(ns_get_dlopened_string_anon() != ns_get_dlopened_string_private());
}
+TEST(dlext, ns_hidden_child) {
+ ExecTestHelper eth;
+
+ std::string helper = GetTestlibRoot() + "/ns_hidden_child_helper/ns_hidden_child_helper";
+ chmod(helper.c_str(), 0755); // TODO: "x" lost in CTS, b/34945607
+ std::string app_ns_dir = GetTestlibRoot() + "/ns_hidden_child_app";
+ eth.SetArgs({ helper.c_str(), app_ns_dir.c_str(), nullptr });
+
+ // Add the main libns_hidden_child_*.so libraries to the search path of the default namespace.
+ std::string env = "LD_LIBRARY_PATH=" + GetTestlibRoot();
+ eth.SetEnv({ env.c_str(), nullptr });
+
+ eth.Run([&]() { execve(helper.c_str(), eth.GetArgs(), eth.GetEnv()); }, 0,
+ "public_function is non-null\n"
+ "internal_function is null\n");
+}
+
TEST(dlext, dlopen_handle_value_platform) {
void* handle = dlopen("libtest_dlsym_from_this.so", RTLD_NOW | RTLD_LOCAL);
ASSERT_TRUE((reinterpret_cast<uintptr_t>(handle) & 1) != 0)