From 01790fdc6928a34125f092bbf98e9217a2251fa5 Mon Sep 17 00:00:00 2001 From: Victor Khimenko Date: Tue, 12 May 2020 22:59:04 +0200 Subject: [PATCH] Allow native_bridge linker to use different APEX from native one Bug: http://b/156397945 Test: dlfcn.dlopen_system_libicuuc_android_api_level_28 with native_bridge Change-Id: I3ecd929a0c31dda8cd424795f21f6ef472776557 --- linker/linker.cpp | 41 +---------------------------------------- 1 file changed, 1 insertion(+), 40 deletions(-) diff --git a/linker/linker.cpp b/linker/linker.cpp index b368e9605..edf0329c9 100644 --- a/linker/linker.cpp +++ b/linker/linker.cpp @@ -65,6 +65,7 @@ #include "linker_phdr.h" #include "linker_relocate.h" #include "linker_tls.h" +#include "linker_translate_path.h" #include "linker_utils.h" #include "private/bionic_call_ifunc_resolver.h" @@ -103,7 +104,6 @@ static const char* const kVendorLibDir = "/vendor/lib64"; static const char* const kAsanSystemLibDir = "/data/asan/system/lib64"; static const char* const kAsanOdmLibDir = "/data/asan/odm/lib64"; static const char* const kAsanVendorLibDir = "/data/asan/vendor/lib64"; -static const char* const kI18nApexLibDir = "/apex/com.android.i18n/lib64"; #else static const char* const kSystemLibDir = "/system/lib"; static const char* const kOdmLibDir = "/odm/lib"; @@ -111,7 +111,6 @@ static const char* const kVendorLibDir = "/vendor/lib"; static const char* const kAsanSystemLibDir = "/data/asan/system/lib"; static const char* const kAsanOdmLibDir = "/data/asan/odm/lib"; static const char* const kAsanVendorLibDir = "/data/asan/vendor/lib"; -static const char* const kI18nApexLibDir = "/apex/com.android.i18n/lib"; #endif static const char* const kAsanLibDirPrefix = "/data/asan"; @@ -235,44 +234,6 @@ static bool is_greylisted(android_namespace_t* ns, const char* name, const soinf } // END OF WORKAROUND -// Workaround for dlopen(/system/lib(64)/) when .so is in /apex. http://b/121248172 -/** - * Translate /system path to /apex path if needed - * The workaround should work only when targetSdkVersion < Q. - * - * param out_name_to_apex pointing to /apex path - * return true if translation is needed - */ -static bool translateSystemPathToApexPath(const char* name, std::string* out_name_to_apex) { - static const char* const kSystemToArtApexLibs[] = { - "libicuuc.so", - "libicui18n.so", - }; - // New mapping for new apex should be added below - - // Nothing to do if target sdk version is Q or above - if (get_application_target_sdk_version() >= 29) { - return false; - } - - // If the path isn't /system/lib, there's nothing to do. - if (name == nullptr || dirname(name) != kSystemLibDir) { - return false; - } - - const char* base_name = basename(name); - - for (const char* soname : kSystemToArtApexLibs) { - if (strcmp(base_name, soname) == 0) { - *out_name_to_apex = std::string(kI18nApexLibDir) + "/" + base_name; - return true; - } - } - - return false; -} -// End Workaround for dlopen(/system/lib/) when .so is in /apex. - static std::vector g_ld_preload_names; static void notify_gdb_of_load(soinfo* info) {