summaryrefslogtreecommitdiff
path: root/libnativeloader/native_loader.cpp
diff options
context:
space:
mode:
authorDimitry Ivanov <dimitry@google.com>2016-11-02 18:03:10 -0700
committerDimitry Ivanov <dimitry@google.com>2016-11-04 15:21:13 -0700
commitd836ab005a3fd70e477a01d4200483131a285c9a (patch)
treebed575ec93b56e95650318697219c1daa75e43d8 /libnativeloader/native_loader.cpp
parent8d339e940fb6aab288287139cdc3617c52d7ae00 (diff)
Allow different namespace types for different classloaders
An app should be able to make cross-arch calls to different apps via other app's Context.getClassLoader() Bug: 32542970 Test: Boot fugu. Check that there are no linker-namespace related errors in the log. Change-Id: I1593f4688bcde0121a5e24a707441a4935fa7dc4
Diffstat (limited to 'libnativeloader/native_loader.cpp')
-rw-r--r--libnativeloader/native_loader.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/libnativeloader/native_loader.cpp b/libnativeloader/native_loader.cpp
index e09cce3e3..15fe0540e 100644
--- a/libnativeloader/native_loader.cpp
+++ b/libnativeloader/native_loader.cpp
@@ -308,13 +308,17 @@ class LibraryNamespaces {
// code is one example) unknown to linker in which case linker uses anonymous
// namespace. The second argument specifies the search path for the anonymous
// namespace which is the library_path of the classloader.
- if (!is_native_bridge) {
- initialized_ = android_init_namespaces(public_libraries_.c_str(), library_path);
- if (!initialized_) {
- *error_msg = dlerror();
- }
- } else {
- initialized_ = NativeBridgeInitNamespace(public_libraries_.c_str(), library_path);
+ initialized_ = android_init_namespaces(public_libraries_.c_str(),
+ is_native_bridge ? nullptr : library_path);
+ if (!initialized_) {
+ *error_msg = dlerror();
+ return false;
+ }
+
+ // and now initialize native bridge namespaces if necessary.
+ if (NativeBridgeInitialized()) {
+ initialized_ = NativeBridgeInitNamespace(public_libraries_.c_str(),
+ is_native_bridge ? library_path : nullptr);
if (!initialized_) {
*error_msg = NativeBridgeGetError();
}