summaryrefslogtreecommitdiff
path: root/libnativebridge
diff options
context:
space:
mode:
authorCalin Juravle <calin@google.com>2021-05-07 22:44:29 +0000
committerTreehugger Robot <treehugger-gerrit@google.com>2021-05-09 00:37:05 +0000
commit91d2c5c1d1157f27e723d8ebee458913c6f0ed43 (patch)
tree61089b69928171706cf93d939bb068d115e92c5d /libnativebridge
parent6958df93f8cb3d82bddadbabb5ed94b3b63a7f14 (diff)
Revert "Avoid loading external libraries from ARTs internal linker namespace."
This reverts commit 582448f29f2f2529202bf868d00ba5d3d3776bb6. Reason for revert: breaks tests Change-Id: I2e0b2a28d4644b314887673d4aef4f1094aea289
Diffstat (limited to 'libnativebridge')
-rw-r--r--libnativebridge/Android.bp11
-rw-r--r--libnativebridge/include/nativebridge/native_bridge.h5
-rw-r--r--libnativebridge/native_bridge.cc34
3 files changed, 9 insertions, 41 deletions
diff --git a/libnativebridge/Android.bp b/libnativebridge/Android.bp
index 8e87997b00..cb07d35363 100644
--- a/libnativebridge/Android.bp
+++ b/libnativebridge/Android.bp
@@ -10,6 +10,9 @@ package {
cc_defaults {
name: "libnativebridge-defaults",
defaults: ["art_defaults"],
+ cppflags: [
+ "-fvisibility=protected",
+ ],
header_libs: [
"jni_headers",
"libnativebridge-headers",
@@ -61,10 +64,10 @@ art_cc_library {
target: {
android: {
- header_libs: [
- "libnativeloader-headers", // For dlext_namespaces.h
- ],
- shared_libs: ["libdl_android"],
+ version_script: "libnativebridge.map.txt",
+ },
+ linux: {
+ version_script: "libnativebridge.map.txt",
},
},
diff --git a/libnativebridge/include/nativebridge/native_bridge.h b/libnativebridge/include/nativebridge/native_bridge.h
index 2199bab552..e20b6270a1 100644
--- a/libnativebridge/include/nativebridge/native_bridge.h
+++ b/libnativebridge/include/nativebridge/native_bridge.h
@@ -29,11 +29,6 @@ namespace android {
extern "C" {
#endif // __cplusplus
-// Loads a shared library from the system linker namespace, suitable for
-// platform libraries in /system/lib(64). If linker namespaces don't exist (i.e.
-// on host), this simply calls dlopen().
-void* OpenSystemLibrary(const char* path, int flags);
-
struct NativeBridgeRuntimeCallbacks;
struct NativeBridgeRuntimeValues;
diff --git a/libnativebridge/native_bridge.cc b/libnativebridge/native_bridge.cc
index fb13d62be0..46a05a23bf 100644
--- a/libnativebridge/native_bridge.cc
+++ b/libnativebridge/native_bridge.cc
@@ -31,10 +31,6 @@
#include <android-base/macros.h>
#include <log/log.h>
-#ifdef ART_TARGET_ANDROID
-#include "nativeloader/dlext_namespaces.h"
-#endif
-
namespace android {
#ifdef __APPLE__
@@ -44,28 +40,6 @@ void UNUSED(const T&) {}
extern "C" {
-void* OpenSystemLibrary(const char* path, int flags) {
-#ifdef ART_TARGET_ANDROID
- // The system namespace is called "default" for binaries in /system and
- // "system" for those in the Runtime APEX. Try "system" first since
- // "default" always exists.
- // TODO(b/185587109): Get rid of this error prone logic.
- android_namespace_t* system_ns = android_get_exported_namespace("system");
- if (system_ns == nullptr) {
- system_ns = android_get_exported_namespace("default");
- LOG_ALWAYS_FATAL_IF(system_ns == nullptr,
- "Failed to get system namespace for loading %s", path);
- }
- const android_dlextinfo dlextinfo = {
- .flags = ANDROID_DLEXT_USE_NAMESPACE,
- .library_namespace = system_ns,
- };
- return android_dlopen_ext(path, flags, &dlextinfo);
-#else
- return dlopen(path, flags);
-#endif
-}
-
// Environment values required by the apps running with native bridge.
struct NativeBridgeRuntimeValues {
const char* os_arch;
@@ -249,12 +223,8 @@ bool LoadNativeBridge(const char* nb_library_filename,
if (!NativeBridgeNameAcceptable(nb_library_filename)) {
CloseNativeBridge(true);
} else {
- // Try to open the library. We assume this library is provided by the
- // platform rather than the ART APEX itself, so use the system namespace
- // to avoid requiring a static linker config link to it from the
- // com_android_art namespace.
- void* handle = OpenSystemLibrary(nb_library_filename, RTLD_LAZY);
-
+ // Try to open the library.
+ void* handle = dlopen(nb_library_filename, RTLD_LAZY);
if (handle != nullptr) {
callbacks = reinterpret_cast<NativeBridgeCallbacks*>(dlsym(handle,
kNativeBridgeInterfaceSymbol));