Merge "Rename the runtime linker namespace following ART/Runtime APEX split."

This commit is contained in:
Treehugger Robot 2019-10-08 03:33:29 +00:00 committed by Gerrit Code Review
commit b7dee5d148
7 changed files with 105 additions and 113 deletions

View File

@ -44,7 +44,7 @@ namespace {
// vendor and system namespaces.
constexpr const char* kVendorNamespaceName = "sphal";
constexpr const char* kVndkNamespaceName = "vndk";
constexpr const char* kRuntimeNamespaceName = "runtime";
constexpr const char* kArtNamespaceName = "art";
constexpr const char* kNeuralNetworksNamespaceName = "neuralnetworks";
// classloader-namespace is a linker namespace that is created for the loaded
@ -237,10 +237,10 @@ Result<NativeLoaderNamespace*> LibraryNamespaces::Create(JNIEnv* env, uint32_t t
return linked.error();
}
auto runtime_ns = NativeLoaderNamespace::GetExportedNamespace(kRuntimeNamespaceName, is_bridged);
// Runtime apex does not exist in host, and under certain build conditions.
if (runtime_ns) {
linked = app_ns->Link(*runtime_ns, runtime_public_libraries());
auto art_ns = NativeLoaderNamespace::GetExportedNamespace(kArtNamespaceName, is_bridged);
// ART APEX does not exist on host, and under certain build conditions.
if (art_ns) {
linked = app_ns->Link(*art_ns, art_public_libraries());
if (!linked) {
return linked.error();
}

View File

@ -63,10 +63,6 @@ android_namespace_t* FindExportedNamespace(const char* caller_location) {
LOG_ALWAYS_FATAL_IF((dot_index == std::string::npos),
"Error finding namespace of apex: no dot in apex name %s", caller_location);
std::string name = location.substr(dot_index + 1, slash_index - dot_index - 1);
// TODO(b/139408016): Rename the runtime namespace to "art".
if (name == "art") {
name = "runtime";
}
android_namespace_t* boot_namespace = android_get_exported_namespace(name.c_str());
LOG_ALWAYS_FATAL_IF((boot_namespace == nullptr),
"Error finding namespace of apex: no namespace called %s", name.c_str());

View File

@ -83,7 +83,7 @@ class Platform {
static std::unordered_map<std::string, Platform::mock_namespace_handle> namespaces = {
{"platform", TO_MOCK_NAMESPACE(TO_ANDROID_NAMESPACE("platform"))},
{"default", TO_MOCK_NAMESPACE(TO_ANDROID_NAMESPACE("default"))},
{"runtime", TO_MOCK_NAMESPACE(TO_ANDROID_NAMESPACE("runtime"))},
{"art", TO_MOCK_NAMESPACE(TO_ANDROID_NAMESPACE("art"))},
{"sphal", TO_MOCK_NAMESPACE(TO_ANDROID_NAMESPACE("sphal"))},
{"vndk", TO_MOCK_NAMESPACE(TO_ANDROID_NAMESPACE("vndk"))},
{"neuralnetworks", TO_MOCK_NAMESPACE(TO_ANDROID_NAMESPACE("neuralnetworks"))},
@ -338,13 +338,13 @@ class NativeLoaderTest_Create : public NativeLoaderTest {
std::string expected_permitted_path = std::string("/data:/mnt/expand:") + permitted_path;
std::string expected_parent_namespace = "platform";
bool expected_link_with_platform_ns = true;
bool expected_link_with_runtime_ns = true;
bool expected_link_with_art_ns = true;
bool expected_link_with_sphal_ns = !vendor_public_libraries().empty();
bool expected_link_with_vndk_ns = false;
bool expected_link_with_default_ns = false;
bool expected_link_with_neuralnetworks_ns = true;
std::string expected_shared_libs_to_platform_ns = default_public_libraries();
std::string expected_shared_libs_to_runtime_ns = runtime_public_libraries();
std::string expected_shared_libs_to_art_ns = art_public_libraries();
std::string expected_shared_libs_to_sphal_ns = vendor_public_libraries();
std::string expected_shared_libs_to_vndk_ns = vndksp_libraries();
std::string expected_shared_libs_to_default_ns = default_public_libraries();
@ -368,9 +368,9 @@ class NativeLoaderTest_Create : public NativeLoaderTest {
StrEq(expected_shared_libs_to_platform_ns)))
.WillOnce(Return(true));
}
if (expected_link_with_runtime_ns) {
EXPECT_CALL(*mock, mock_link_namespaces(Eq(IsBridged()), _, NsEq("runtime"),
StrEq(expected_shared_libs_to_runtime_ns)))
if (expected_link_with_art_ns) {
EXPECT_CALL(*mock, mock_link_namespaces(Eq(IsBridged()), _, NsEq("art"),
StrEq(expected_shared_libs_to_art_ns)))
.WillOnce(Return(true));
}
if (expected_link_with_sphal_ns) {

View File

@ -181,10 +181,10 @@ static std::string InitDefaultPublicLibraries(bool for_preload) {
return android::base::Join(*sonames, ':');
}
// Remove the public libs in the runtime namespace.
// Remove the public libs in the art namespace.
// These libs are listed in public.android.txt, but we don't want the rest of android
// in default namespace to dlopen the libs.
// For example, libicuuc.so is exposed to classloader namespace from runtime namespace.
// For example, libicuuc.so is exposed to classloader namespace from art namespace.
// Unfortunately, it does not have stable C symbols, and default namespace should only use
// stable symbols in libandroidicu.so. http://b/120786417
for (const std::string& lib_name : kArtApexPublicLibraries) {
@ -281,7 +281,7 @@ const std::string& default_public_libraries() {
return list;
}
const std::string& runtime_public_libraries() {
const std::string& art_public_libraries() {
static std::string list = InitArtPublicLibraries();
return list;
}

View File

@ -29,7 +29,7 @@ using android::base::Result;
// e.g., if it is a vendor app or not, different set of libraries are made available.
const std::string& preloadable_public_libraries();
const std::string& default_public_libraries();
const std::string& runtime_public_libraries();
const std::string& art_public_libraries();
const std::string& vendor_public_libraries();
const std::string& extended_public_libraries();
const std::string& neuralnetworks_public_libraries();

View File

@ -42,29 +42,29 @@ namespace.default.asan.search.paths += /odm/${LIB}
# APEX related namespaces.
###############################################################################
additional.namespaces = runtime,conscrypt,media,neuralnetworks,resolv
additional.namespaces = art,conscrypt,media,neuralnetworks,resolv
# Keep in sync with the "platform" namespace in art/build/apex/ld.config.txt.
# If a shared library or an executable requests a shared library that
# cannot be loaded into the default namespace, the dynamic linker tries
# to load the shared library from the runtime namespace. And then, if the
# shared library cannot be loaded from the runtime namespace either, the
# to load the shared library from the art namespace. And then, if the
# shared library cannot be loaded from the art namespace either, the
# dynamic linker tries to load the shared library from the resolv namespace.
# Finally, if all attempts fail, the dynamic linker returns an error.
namespace.default.links = runtime,resolv,neuralnetworks
namespace.default.asan.links = runtime,resolv,neuralnetworks
namespace.default.link.runtime.shared_libs = libandroidicu.so
namespace.default.link.runtime.shared_libs += libdexfile_external.so
namespace.default.link.runtime.shared_libs += libdexfiled_external.so
namespace.default.links = art,resolv,neuralnetworks
namespace.default.asan.links = art,resolv,neuralnetworks
namespace.default.link.art.shared_libs = libandroidicu.so
namespace.default.link.art.shared_libs += libdexfile_external.so
namespace.default.link.art.shared_libs += libdexfiled_external.so
# TODO(b/120786417 or b/134659294): libicuuc.so and libicui18n.so are kept for app compat.
namespace.default.link.runtime.shared_libs += libicui18n.so
namespace.default.link.runtime.shared_libs += libicuuc.so
namespace.default.link.runtime.shared_libs += libnativebridge.so
namespace.default.link.runtime.shared_libs += libnativehelper.so
namespace.default.link.runtime.shared_libs += libnativeloader.so
namespace.default.link.art.shared_libs += libicui18n.so
namespace.default.link.art.shared_libs += libicuuc.so
namespace.default.link.art.shared_libs += libnativebridge.so
namespace.default.link.art.shared_libs += libnativehelper.so
namespace.default.link.art.shared_libs += libnativeloader.so
# TODO(b/122876336): Remove libpac.so once it's migrated to Webview
namespace.default.link.runtime.shared_libs += libpac.so
namespace.default.link.art.shared_libs += libpac.so
# When libnetd_resolv.so can't be found in the default namespace, search for it
# in the resolv namespace. Don't allow any other libraries from the resolv namespace
@ -75,25 +75,24 @@ namespace.default.link.resolv.shared_libs = libnetd_resolv.so
namespace.default.link.neuralnetworks.shared_libs = libneuralnetworks.so
###############################################################################
# "runtime" APEX namespace
# "art" APEX namespace
#
# This namespace exposes externally accessible libraries from the Runtime APEX.
# Keep in sync with the "runtime" namespace in art/build/apex/ld.config.txt.
# This namespace exposes externally accessible libraries from the ART APEX.
# Keep in sync with the "art" namespace in art/build/apex/ld.config.txt.
###############################################################################
# TODO(b/139408016): Rename this namespace to "art".
namespace.runtime.isolated = true
namespace.art.isolated = true
# Visible to allow links to be created at runtime, e.g. through
# android_link_namespaces in libnativeloader.
namespace.runtime.visible = true
namespace.art.visible = true
namespace.runtime.search.paths = /apex/com.android.art/${LIB}
namespace.runtime.asan.search.paths = /apex/com.android.art/${LIB}
namespace.runtime.links = default
namespace.art.search.paths = /apex/com.android.art/${LIB}
namespace.art.asan.search.paths = /apex/com.android.art/${LIB}
namespace.art.links = default
# Need allow_all_shared_libs because libart.so can dlopen oat files in
# /system/framework and /data.
# TODO(b/130340935): Use a dynamically created linker namespace similar to
# classloader-namespace for oat files, and tighten this up.
namespace.runtime.link.default.allow_all_shared_libs = true
namespace.art.link.default.allow_all_shared_libs = true
###############################################################################
# "media" APEX namespace
@ -136,8 +135,8 @@ namespace.conscrypt.visible = true
namespace.conscrypt.search.paths = /apex/com.android.conscrypt/${LIB}
namespace.conscrypt.asan.search.paths = /apex/com.android.conscrypt/${LIB}
namespace.conscrypt.links = runtime,default
namespace.conscrypt.link.runtime.shared_libs = libandroidio.so
namespace.conscrypt.links = art,default
namespace.conscrypt.link.art.shared_libs = libandroidio.so
namespace.conscrypt.link.default.shared_libs = libc.so
namespace.conscrypt.link.default.shared_libs += libm.so
namespace.conscrypt.link.default.shared_libs += libdl.so

View File

@ -35,7 +35,7 @@ dir.postinstall = /postinstall
dir.system = /data
[system]
additional.namespaces = runtime,conscrypt,media,neuralnetworks,resolv,sphal,vndk,rs
additional.namespaces = art,conscrypt,media,neuralnetworks,resolv,sphal,vndk,rs
###############################################################################
# "default" namespace
@ -68,23 +68,23 @@ namespace.default.asan.search.paths += /vendor/${LIB}
# Keep in sync with the "platform" namespace in art/build/apex/ld.config.txt.
# If a shared library or an executable requests a shared library that
# cannot be loaded into the default namespace, the dynamic linker tries
# to load the shared library from the runtime namespace. And then, if the
# shared library cannot be loaded from the runtime namespace either, the
# to load the shared library from the art namespace. And then, if the
# shared library cannot be loaded from the art namespace either, the
# dynamic linker tries to load the shared library from the resolv namespace.
# Finally, if all attempts fail, the dynamic linker returns an error.
namespace.default.links = runtime,resolv,neuralnetworks
namespace.default.link.runtime.shared_libs = libandroidicu.so
namespace.default.link.runtime.shared_libs += libdexfile_external.so
namespace.default.link.runtime.shared_libs += libdexfiled_external.so
namespace.default.links = art,resolv,neuralnetworks
namespace.default.link.art.shared_libs = libandroidicu.so
namespace.default.link.art.shared_libs += libdexfile_external.so
namespace.default.link.art.shared_libs += libdexfiled_external.so
# TODO(b/120786417 or b/134659294): libicuuc.so and libicui18n.so are kept for app compat.
namespace.default.link.runtime.shared_libs += libicui18n.so
namespace.default.link.runtime.shared_libs += libicuuc.so
namespace.default.link.runtime.shared_libs += libnativebridge.so
namespace.default.link.runtime.shared_libs += libnativehelper.so
namespace.default.link.runtime.shared_libs += libnativeloader.so
namespace.default.link.art.shared_libs += libicui18n.so
namespace.default.link.art.shared_libs += libicuuc.so
namespace.default.link.art.shared_libs += libnativebridge.so
namespace.default.link.art.shared_libs += libnativehelper.so
namespace.default.link.art.shared_libs += libnativeloader.so
# TODO(b/122876336): Remove libpac.so once it's migrated to Webview
namespace.default.link.runtime.shared_libs += libpac.so
namespace.default.link.art.shared_libs += libpac.so
# When libnetd_resolv.so can't be found in the default namespace, search for it
# in the resolv namespace. Don't allow any other libraries from the resolv namespace
@ -95,26 +95,25 @@ namespace.default.link.resolv.shared_libs = libnetd_resolv.so
namespace.default.link.neuralnetworks.shared_libs = libneuralnetworks.so
###############################################################################
# "runtime" APEX namespace
# "art" APEX namespace
#
# This namespace pulls in externally accessible libs from the Runtime APEX.
# Keep in sync with the "runtime" namespace in art/build/apex/ld.config.txt.
# This namespace pulls in externally accessible libs from the ART APEX.
# Keep in sync with the "art" namespace in art/build/apex/ld.config.txt.
###############################################################################
# TODO(b/139408016): Rename this namespace to "art".
namespace.runtime.isolated = true
namespace.art.isolated = true
# Visible to allow links to be created at runtime, e.g. through
# android_link_namespaces in libnativeloader.
namespace.runtime.visible = true
namespace.art.visible = true
namespace.runtime.search.paths = /apex/com.android.art/${LIB}
namespace.runtime.asan.search.paths = /apex/com.android.art/${LIB}
namespace.runtime.links = default,neuralnetworks
namespace.art.search.paths = /apex/com.android.art/${LIB}
namespace.art.asan.search.paths = /apex/com.android.art/${LIB}
namespace.art.links = default,neuralnetworks
# Need allow_all_shared_libs because libart.so can dlopen oat files in
# /system/framework and /data.
# TODO(b/130340935): Use a dynamically created linker namespace similar to
# classloader-namespace for oat files, and tighten this up.
namespace.runtime.link.default.allow_all_shared_libs = true
namespace.runtime.link.neuralnetworks.shared_libs = libneuralnetworks.so
namespace.art.link.default.allow_all_shared_libs = true
namespace.art.link.neuralnetworks.shared_libs = libneuralnetworks.so
###############################################################################
# "media" APEX namespace
@ -149,8 +148,8 @@ namespace.conscrypt.visible = true
namespace.conscrypt.search.paths = /apex/com.android.conscrypt/${LIB}
namespace.conscrypt.asan.search.paths = /apex/com.android.conscrypt/${LIB}
namespace.conscrypt.links = runtime,default
namespace.conscrypt.link.runtime.shared_libs = libandroidio.so
namespace.conscrypt.links = art,default
namespace.conscrypt.link.art.shared_libs = libandroidio.so
namespace.conscrypt.link.default.shared_libs = libc.so
namespace.conscrypt.link.default.shared_libs += libm.so
namespace.conscrypt.link.default.shared_libs += libdl.so
@ -357,7 +356,7 @@ namespace.neuralnetworks.link.default.shared_libs += libvndksupport.so
# (LL-NDK only) access.
###############################################################################
[vendor]
additional.namespaces = runtime,neuralnetworks
additional.namespaces = art,neuralnetworks
namespace.default.isolated = false
@ -399,36 +398,35 @@ namespace.default.asan.search.paths += /%PRODUCT%/${LIB}
namespace.default.asan.search.paths += /data/asan/system/${LIB}/vndk%VNDK_VER%
namespace.default.asan.search.paths += /system/${LIB}/vndk%VNDK_VER%
namespace.default.links = runtime,neuralnetworks
namespace.default.link.runtime.shared_libs = libdexfile_external.so
namespace.default.link.runtime.shared_libs += libdexfiled_external.so
namespace.default.links = art,neuralnetworks
namespace.default.link.art.shared_libs = libdexfile_external.so
namespace.default.link.art.shared_libs += libdexfiled_external.so
# TODO(b/120786417 or b/134659294): libicuuc.so and libicui18n.so are kept for app compat.
namespace.default.link.runtime.shared_libs += libicui18n.so
namespace.default.link.runtime.shared_libs += libicuuc.so
namespace.default.link.runtime.shared_libs += libnativebridge.so
namespace.default.link.runtime.shared_libs += libnativehelper.so
namespace.default.link.runtime.shared_libs += libnativeloader.so
namespace.default.link.art.shared_libs += libicui18n.so
namespace.default.link.art.shared_libs += libicuuc.so
namespace.default.link.art.shared_libs += libnativebridge.so
namespace.default.link.art.shared_libs += libnativehelper.so
namespace.default.link.art.shared_libs += libnativeloader.so
# Workaround for b/124772622
namespace.default.link.runtime.shared_libs += libandroidicu.so
namespace.default.link.art.shared_libs += libandroidicu.so
# LLNDK library moved into apex
namespace.default.link.neuralnetworks.shared_libs = libneuralnetworks.so
###############################################################################
# "runtime" APEX namespace
# "art" APEX namespace
#
# This namespace exposes externally accessible libraries from the Runtime APEX.
# Keep in sync with the "runtime" namespace in art/build/apex/ld.config.txt.
# This namespace exposes externally accessible libraries from the ART APEX.
# Keep in sync with the "art" namespace in art/build/apex/ld.config.txt.
###############################################################################
# TODO(b/139408016): Rename this namespace to "art".
namespace.runtime.isolated = true
namespace.art.isolated = true
namespace.runtime.search.paths = /apex/com.android.art/${LIB}
namespace.runtime.asan.search.paths = /apex/com.android.art/${LIB}
namespace.runtime.links = default
namespace.art.search.paths = /apex/com.android.art/${LIB}
namespace.art.asan.search.paths = /apex/com.android.art/${LIB}
namespace.art.links = default
# TODO(b/130340935): Use a dynamically created linker namespace similar to
# classloader-namespace for oat files, and tighten this up.
namespace.runtime.link.default.allow_all_shared_libs = true
namespace.art.link.default.allow_all_shared_libs = true
###############################################################################
# "neuralnetworks" APEX namespace
@ -459,7 +457,7 @@ namespace.neuralnetworks.link.default.shared_libs += libvndksupport.so
# includes the requisite namespace setup for APEXes.
###############################################################################
[unrestricted]
additional.namespaces = runtime,media,conscrypt,resolv,neuralnetworks
additional.namespaces = art,media,conscrypt,resolv,neuralnetworks
# Visible to allow links to be created at runtime, e.g. through
# android_link_namespaces in libnativeloader.
@ -477,20 +475,20 @@ namespace.default.asan.search.paths += /data/asan/vendor/${LIB}
namespace.default.asan.search.paths += /vendor/${LIB}
# Keep in sync with the "platform" namespace in art/build/apex/ld.config.txt.
namespace.default.links = runtime,resolv,neuralnetworks
namespace.default.link.runtime.shared_libs = libandroidicu.so
namespace.default.link.runtime.shared_libs += libdexfile_external.so
namespace.default.link.runtime.shared_libs += libdexfiled_external.so
namespace.default.links = art,resolv,neuralnetworks
namespace.default.link.art.shared_libs = libandroidicu.so
namespace.default.link.art.shared_libs += libdexfile_external.so
namespace.default.link.art.shared_libs += libdexfiled_external.so
# TODO(b/120786417 or b/134659294): libicuuc.so and libicui18n.so are kept for app compat.
namespace.default.link.runtime.shared_libs += libicui18n.so
namespace.default.link.runtime.shared_libs += libicuuc.so
namespace.default.link.runtime.shared_libs += libnativebridge.so
namespace.default.link.runtime.shared_libs += libnativehelper.so
namespace.default.link.runtime.shared_libs += libnativeloader.so
namespace.default.link.art.shared_libs += libicui18n.so
namespace.default.link.art.shared_libs += libicuuc.so
namespace.default.link.art.shared_libs += libnativebridge.so
namespace.default.link.art.shared_libs += libnativehelper.so
namespace.default.link.art.shared_libs += libnativeloader.so
# TODO(b/122876336): Remove libpac.so once it's migrated to Webview
namespace.default.link.runtime.shared_libs += libpac.so
namespace.default.link.runtime.shared_libs += %SANITIZER_RUNTIME_LIBRARIES%
namespace.default.link.art.shared_libs += libpac.so
namespace.default.link.art.shared_libs += %SANITIZER_RUNTIME_LIBRARIES%
namespace.default.link.resolv.shared_libs = libnetd_resolv.so
@ -498,20 +496,19 @@ namespace.default.link.resolv.shared_libs = libnetd_resolv.so
namespace.default.link.neuralnetworks.shared_libs = libneuralnetworks.so
###############################################################################
# "runtime" APEX namespace
# "art" APEX namespace
#
# This namespace exposes externally accessible libraries from the Runtime APEX.
# Keep in sync with the "runtime" namespace in art/build/apex/ld.config.txt.
# This namespace exposes externally accessible libraries from the ART APEX.
# Keep in sync with the "art" namespace in art/build/apex/ld.config.txt.
###############################################################################
# TODO(b/139408016): Rename this namespace to "art".
namespace.runtime.isolated = true
namespace.art.isolated = true
# Visible to allow links to be created at runtime, e.g. through
# android_link_namespaces in libnativeloader.
namespace.runtime.visible = true
namespace.art.visible = true
namespace.runtime.search.paths = /apex/com.android.art/${LIB}
namespace.runtime.asan.search.paths = /apex/com.android.art/${LIB}
namespace.runtime.links = default
namespace.art.search.paths = /apex/com.android.art/${LIB}
namespace.art.asan.search.paths = /apex/com.android.art/${LIB}
namespace.art.links = default
# TODO(b/130340935): Use a dynamically created linker namespace similar to
# classloader-namespace for oat files, and tighten this up.
@ -548,8 +545,8 @@ namespace.conscrypt.visible = true
namespace.conscrypt.search.paths = /apex/com.android.conscrypt/${LIB}
namespace.conscrypt.asan.search.paths = /apex/com.android.conscrypt/${LIB}
namespace.conscrypt.links = runtime,default
namespace.conscrypt.link.runtime.shared_libs = libandroidio.so
namespace.conscrypt.links = art,default
namespace.conscrypt.link.art.shared_libs = libandroidio.so
namespace.conscrypt.link.default.shared_libs = libc.so
namespace.conscrypt.link.default.shared_libs += libm.so
namespace.conscrypt.link.default.shared_libs += libdl.so