summaryrefslogtreecommitdiff
path: root/libnativeloader/native_loader_namespace.cpp
diff options
context:
space:
mode:
authorJiyong Park <jiyong@google.com>2019-05-16 21:03:30 +0900
committerJiyong Park <jiyong@google.com>2019-08-12 16:56:18 +0900
commitb37c4818da5f3f40036ae56ccffb670c9ff2cb97 (patch)
treeb930e5457ea89edd536debef4f5ae06b3d69e8be /libnativeloader/native_loader_namespace.cpp
parente2adc148037d323feceffb02b30b1d6861be9619 (diff)
Don't create anonymous namespace
Don't create anonymous namespace separately, use the first namespace that is created for app classloader as the anonymous namespace. Note that the anonymous namespace is set via the new ANDROID_NAMESPACE_TYPE_ALSO_USED_AS_ANONYMOUS. I didn't creat a new function like android_set_anonymous_namespace as it requires uprev of the libnativebridge interface and makes it harder to delete the old android_init_anonymous_namespace as we have to keep it until all proprietary bridged loaders are updated. Bug: 130388701 Test: CtsBionicTestCases Test: run games on http://www.monogame.net/showcase/?Android Change-Id: I0fdd614365eaa56c4ab47538bf3772d94bd9ae55
Diffstat (limited to 'libnativeloader/native_loader_namespace.cpp')
-rw-r--r--libnativeloader/native_loader_namespace.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/libnativeloader/native_loader_namespace.cpp b/libnativeloader/native_loader_namespace.cpp
index 4add6e690..a81fddf0f 100644
--- a/libnativeloader/native_loader_namespace.cpp
+++ b/libnativeloader/native_loader_namespace.cpp
@@ -85,7 +85,8 @@ Result<NativeLoaderNamespace> NativeLoaderNamespace::GetPlatformNamespace(bool i
Result<NativeLoaderNamespace> NativeLoaderNamespace::Create(
const std::string& name, const std::string& search_paths, const std::string& permitted_paths,
- const NativeLoaderNamespace* parent, bool is_shared, bool is_greylist_enabled) {
+ const NativeLoaderNamespace* parent, bool is_shared, bool is_greylist_enabled,
+ bool also_used_as_anonymous) {
bool is_bridged = false;
if (parent != nullptr) {
is_bridged = parent->IsBridged();
@@ -100,7 +101,17 @@ Result<NativeLoaderNamespace> NativeLoaderNamespace::Create(
}
const NativeLoaderNamespace& effective_parent = parent != nullptr ? *parent : *platform_ns;
+ // All namespaces for apps are isolated
uint64_t type = ANDROID_NAMESPACE_TYPE_ISOLATED;
+
+ // The namespace is also used as the anonymous namespace
+ // which is used when the linker fails to determine the caller address
+ if (also_used_as_anonymous) {
+ type |= ANDROID_NAMESPACE_TYPE_ALSO_USED_AS_ANONYMOUS;
+ }
+
+ // Bundled apps have access to all system libraries that are currently loaded
+ // in the default namespace
if (is_shared) {
type |= ANDROID_NAMESPACE_TYPE_SHARED;
}