diff options
author | Martin Stjernholm <mast@google.com> | 2021-05-05 13:10:42 +0100 |
---|---|---|
committer | Treehugger Robot <treehugger-gerrit@google.com> | 2021-05-13 15:42:46 +0000 |
commit | 7e363b8a078ccc68a5666461c455cfc1d192b7b5 (patch) | |
tree | 6ca23e3efb66f73e8a8ad4cfa5aaa65e51ffd4e0 /libnativeloader/native_loader.cpp | |
parent | b94401e6e15903b64de709fd69863b6880cedd7c (diff) |
Drop ro.debuggable restriction for NATIVELOADER_DEFAULT_NAMESPACE_LIBS.
To allow running tests on user builds. The (non)existence of the
environment variable itself serves fine as a toggle, and it is hard to
inject into the zygote environment on a user build anyway.
Also a few other cleanups from comments on
https://r.android.com/1689792.
Test: art/test/testrunner/testrunner.py --target --64 --optimizing
Bug: 130340935
Change-Id: I1843a8bbfb5dadc560919022d1f2123eb652be5a
Diffstat (limited to 'libnativeloader/native_loader.cpp')
-rw-r--r-- | libnativeloader/native_loader.cpp | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/libnativeloader/native_loader.cpp b/libnativeloader/native_loader.cpp index 545d04b5c8..2deb5ef3d0 100644 --- a/libnativeloader/native_loader.cpp +++ b/libnativeloader/native_loader.cpp @@ -29,7 +29,6 @@ #include <android-base/file.h> #include <android-base/macros.h> -#include <android-base/properties.h> #include <android-base/strings.h> #include <android-base/thread_annotations.h> #include <nativebridge/native_bridge.h> @@ -48,12 +47,11 @@ namespace { #if defined(ART_TARGET_ANDROID) // NATIVELOADER_DEFAULT_NAMESPACE_LIBS is an environment variable that can be -// used when ro.debuggable is true to list extra libraries (separated by ":") -// that libnativeloader will load from the default namespace. The libraries -// must be listed without paths, and then LD_LIBRARY_PATH is typically set to the -// directories to load them from. The libraries will be available in all -// classloader namespaces, and also in the fallback namespace used when no -// classloader is given. +// used to list extra libraries (separated by ":") that libnativeloader will +// load from the default namespace. The libraries must be listed without paths, +// and then LD_LIBRARY_PATH is typically set to the directories to load them +// from. The libraries will be available in all classloader namespaces, and also +// in the fallback namespace used when no classloader is given. // // kNativeloaderExtraLibs is the name of that fallback namespace. // @@ -64,11 +62,6 @@ namespace { // test libraries that depend on ART internal libraries. constexpr const char* kNativeloaderExtraLibs = "nativeloader-extra-libs"; -bool Debuggable() { - static bool debuggable = android::base::GetBoolProperty("ro.debuggable", false); - return debuggable; -} - using android::nativeloader::LibraryNamespaces; std::mutex g_namespaces_mutex; @@ -124,11 +117,8 @@ Result<NativeLoaderNamespace*> GetNativeloaderExtraLibsNamespace() REQUIRES(g_na // If the given path matches a library in NATIVELOADER_DEFAULT_NAMESPACE_LIBS // then load it in the nativeloader-extra-libs namespace, otherwise return -// nullptr without error. This is only enabled if the ro.debuggable is true. +// nullptr without error. Result<void*> TryLoadNativeloaderExtraLib(const char* path) { - if (!Debuggable()) { - return nullptr; - } const char* links = getenv("NATIVELOADER_DEFAULT_NAMESPACE_LIBS"); if (links == nullptr || *links == 0) { return nullptr; @@ -166,11 +156,9 @@ Result<NativeLoaderNamespace*> CreateClassLoaderNamespaceLocked(JNIEnv* env, if (!ns.ok()) { return ns; } - if (Debuggable()) { - Result<void> linked = CreateNativeloaderDefaultNamespaceLibsLink(*ns.value()); - if (!linked.ok()) { - return linked.error(); - } + Result<void> linked = CreateNativeloaderDefaultNamespaceLibsLink(*ns.value()); + if (!linked.ok()) { + return linked.error(); } return ns; } @@ -190,7 +178,7 @@ void ResetNativeLoader() { #if defined(ART_TARGET_ANDROID) std::lock_guard<std::mutex> guard(g_namespaces_mutex); g_namespaces->Reset(); - delete(g_nativeloader_extra_libs_namespace); + delete g_nativeloader_extra_libs_namespace; g_nativeloader_extra_libs_namespace = nullptr; #endif } |