diff options
author | Dimitry Ivanov <dimitry@google.com> | 2016-05-05 17:30:24 -0700 |
---|---|---|
committer | Dimitry Ivanov <dimitry@google.com> | 2016-05-06 11:39:47 -0700 |
commit | 4ddabd01bf361cadb33baa7213e2ca5129b938f0 (patch) | |
tree | bb26ecba4d0041eb43053dc83ef868f5caa19e8f /libnativeloader | |
parent | 830561bb2b34ca8c09be4860380e9032202c3112 (diff) | |
download | system_core-4ddabd01bf361cadb33baa7213e2ca5129b938f0.tar.gz system_core-4ddabd01bf361cadb33baa7213e2ca5129b938f0.tar.bz2 system_core-4ddabd01bf361cadb33baa7213e2ca5129b938f0.zip |
Add public libs from an environment variable
This is enabled only for builds with ro.debuggable=1
It is intended for use only in tests using dalvikvm
and needing access to platform libraries.
Bug: http://b/28449304
Change-Id: I402457d0da542996ccf265aeaa305f09881e4333
Diffstat (limited to 'libnativeloader')
-rw-r--r-- | libnativeloader/Android.mk | 16 | ||||
-rw-r--r-- | libnativeloader/native_loader.cpp | 19 |
2 files changed, 28 insertions, 7 deletions
diff --git a/libnativeloader/Android.mk b/libnativeloader/Android.mk index 6c064c706..632c6c8dc 100644 --- a/libnativeloader/Android.mk +++ b/libnativeloader/Android.mk @@ -1,19 +1,21 @@ LOCAL_PATH:= $(call my-dir) -NATIVE_LOADER_COMMON_SRC_FILES := \ +native_loader_common_src_files := \ native_loader.cpp +native_loader_common_cflags := -Werror -Wall + # Shared library for target # ======================================================== include $(CLEAR_VARS) LOCAL_MODULE:= libnativeloader -LOCAL_SRC_FILES:= $(NATIVE_LOADER_COMMON_SRC_FILES) +LOCAL_SRC_FILES:= $(native_loader_common_src_files) LOCAL_SHARED_LIBRARIES := libnativehelper liblog libcutils LOCAL_STATIC_LIBRARIES := libbase LOCAL_CLANG := true -LOCAL_CFLAGS += -Werror -Wall +LOCAL_CFLAGS := $(native_loader_common_cflags) LOCAL_CPPFLAGS := -std=gnu++14 -fvisibility=hidden LOCAL_LDFLAGS := -ldl LOCAL_MULTILIB := both @@ -27,11 +29,11 @@ include $(CLEAR_VARS) LOCAL_MODULE:= libnativeloader -LOCAL_SRC_FILES:= $(NATIVE_LOADER_COMMON_SRC_FILES) +LOCAL_SRC_FILES:= $(native_loader_common_src_files) LOCAL_SHARED_LIBRARIES := libnativehelper liblog libcutils LOCAL_STATIC_LIBRARIES := libbase LOCAL_CLANG := true -LOCAL_CFLAGS += -Werror -Wall +LOCAL_CFLAGS := $(native_loader_common_cflags) LOCAL_CPPFLAGS := -std=gnu++14 -fvisibility=hidden LOCAL_LDFLAGS := -ldl LOCAL_MULTILIB := both @@ -45,10 +47,10 @@ include $(CLEAR_VARS) LOCAL_MODULE:= libnativeloader -LOCAL_SRC_FILES:= $(NATIVE_LOADER_COMMON_SRC_FILES) +LOCAL_SRC_FILES:= $(native_loader_common_src_files) LOCAL_STATIC_LIBRARIES := libnativehelper libcutils liblog libbase LOCAL_CLANG := true -LOCAL_CFLAGS += -Werror -Wall +LOCAL_CFLAGS := $(native_loader_common_cflags) LOCAL_CPPFLAGS := -std=gnu++14 -fvisibility=hidden LOCAL_LDFLAGS := -ldl LOCAL_MULTILIB := both diff --git a/libnativeloader/native_loader.cpp b/libnativeloader/native_loader.cpp index 7d9bb567f..7f21375bd 100644 --- a/libnativeloader/native_loader.cpp +++ b/libnativeloader/native_loader.cpp @@ -39,6 +39,12 @@ namespace android { static constexpr const char* kPublicNativeLibrariesSystemConfigPathFromRoot = "/etc/public.libraries.txt"; static constexpr const char* kPublicNativeLibrariesVendorConfig = "/vendor/etc/public.libraries.txt"; +static bool is_debuggable() { + char debuggable[PROP_VALUE_MAX]; + property_get("ro.debuggable", debuggable, "0"); + return std::string(debuggable) == "1"; +} + class LibraryNamespaces { public: LibraryNamespaces() : initialized_(false) { } @@ -103,6 +109,19 @@ class LibraryNamespaces { LOG_ALWAYS_FATAL_IF(!ReadConfig(public_native_libraries_system_config, &sonames), "Error reading public native library list from \"%s\": %s", public_native_libraries_system_config.c_str(), strerror(errno)); + + // For debuggable platform builds use ANDROID_ADDITIONAL_PUBLIC_LIBRARIES environment + // variable to add libraries to the list. This is intended for platform tests only. + if (is_debuggable()) { + const char* additional_libs = getenv("ANDROID_ADDITIONAL_PUBLIC_LIBRARIES"); + if (additional_libs != nullptr && additional_libs[0] != '\0') { + std::vector<std::string> additional_libs_vector = base::Split(additional_libs, ":"); + std::copy(additional_libs_vector.begin(), + additional_libs_vector.end(), + std::back_inserter(sonames)); + } + } + // This file is optional, quietly ignore if the file does not exist. ReadConfig(kPublicNativeLibrariesVendorConfig, &sonames); |