diff options
author | vichang <vichang@google.com> | 2019-02-06 17:03:41 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2019-02-06 17:03:41 +0000 |
commit | 73ee7a6320024c8f390d954a01b7a067c919bfc4 (patch) | |
tree | a701642ffc9e75a87cc5153a373942fc0df91abb /linker | |
parent | 3f8bdb216cf3c1faab805917efed74119971f84d (diff) | |
parent | 1906e77665758c61b0d97c35f3d64225f296504a (diff) | |
download | android_bionic-73ee7a6320024c8f390d954a01b7a067c919bfc4.tar.gz android_bionic-73ee7a6320024c8f390d954a01b7a067c919bfc4.tar.bz2 android_bionic-73ee7a6320024c8f390d954a01b7a067c919bfc4.zip |
Merge "Revert "Allow dlopen("/system/lib/<soname>") for pre-Q""
Diffstat (limited to 'linker')
-rw-r--r-- | linker/linker.cpp | 91 |
1 files changed, 14 insertions, 77 deletions
diff --git a/linker/linker.cpp b/linker/linker.cpp index e759d76f1..428dd25de 100644 --- a/linker/linker.cpp +++ b/linker/linker.cpp @@ -91,21 +91,19 @@ static const char* const kLdConfigFilePath = "/system/etc/ld.config.txt"; static const char* const kLdConfigVndkLiteFilePath = "/system/etc/ld.config.vndk_lite.txt"; #if defined(__LP64__) -static const char* const kSystemLibDir = "/system/lib64"; -static const char* const kOdmLibDir = "/odm/lib64"; -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 kRuntimeApexLibDir = "/apex/com.android.runtime/lib64"; +static const char* const kSystemLibDir = "/system/lib64"; +static const char* const kOdmLibDir = "/odm/lib64"; +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"; #else -static const char* const kSystemLibDir = "/system/lib"; -static const char* const kOdmLibDir = "/odm/lib"; -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 kRuntimeApexLibDir = "/apex/com.android.runtime/lib"; +static const char* const kSystemLibDir = "/system/lib"; +static const char* const kOdmLibDir = "/odm/lib"; +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"; #endif static const char* const kAsanLibDirPrefix = "/data/asan"; @@ -230,44 +228,6 @@ static bool is_greylisted(android_namespace_t* ns, const char* name, const soinf } // END OF WORKAROUND -// Workaround for dlopen(/system/lib(64)/<soname>) 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 kSystemToRuntimeApexLibs[] = { - "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() >= __ANDROID_API_Q__) { - return false; - } - - // If the path is not absolute, or isn't /system/lib, there's nothing to do. - if (name[0] != '/' || dirname(name).compare(kSystemLibDir) != 0) { - return false; - } - - const char* base_name = basename(name); - - for (const char* soname : kSystemToRuntimeApexLibs) { - if (strcmp(base_name, soname) == 0) { - *out_name_to_apex = std::string(kRuntimeApexLibDir) + "/" + base_name; - return true; - } - } - - return false; -} -// End Workaround for dlopen(/system/lib/<soname>) when .so is in /apex. - static std::vector<std::string> g_ld_preload_names; static bool g_anonymous_namespace_initialized; @@ -2114,14 +2074,13 @@ void* do_dlopen(const char* name, int flags, android_namespace_t* ns = get_caller_namespace(caller); LD_LOG(kLogDlopen, - "dlopen(name=\"%s\", flags=0x%x, extinfo=%s, caller=\"%s\", caller_ns=%s@%p, targetSdkVersion=%i) ...", + "dlopen(name=\"%s\", flags=0x%x, extinfo=%s, caller=\"%s\", caller_ns=%s@%p) ...", name, flags, android_dlextinfo_to_string(extinfo).c_str(), caller == nullptr ? "(null)" : caller->get_realpath(), ns == nullptr ? "(null)" : ns->get_name(), - ns, - get_application_target_sdk_version()); + ns); auto purge_guard = android::base::make_scope_guard([&]() { purge_unused_memory(); }); @@ -2155,28 +2114,6 @@ void* do_dlopen(const char* name, int flags, } } - // Workaround for dlopen(/system/lib/<soname>) when .so is in /apex. http://b/121248172 - // The workaround works only when targetSdkVersion < Q. - std::string name_to_apex; - if (translateSystemPathToApexPath(name, &name_to_apex)) { - const char* new_name = name_to_apex.c_str(); - LD_LOG(kLogDlopen, "dlopen translating path to /apex: name=%s newName=%s", - name, - new_name); - // Some APEXs could be optionally disabled. Only translate the path - // when the old file is absent and the new file exists. - if (file_exists(name)) { - LD_LOG(kLogDlopen, "dlopen failed to translate path to /apex: /system file exists. %s", name); - } else if (!file_exists(new_name)) { - LD_LOG(kLogDlopen, "dlopen failed to translate path to /apex: /apex file does not exist. %s", - new_name); - } else { - LD_LOG(kLogDlopen, "dlopen new path to /apex: newName=%s", new_name); - name = new_name; - } - } - // End Workaround for dlopen(/system/lib/<soname>) when .so is in /apex. - std::string asan_name_holder; const char* translated_name = name; |