Merge "Allow native_bridge linker to use different APEX from native one"

This commit is contained in:
Victor Khimenko 2020-05-16 01:05:55 +00:00 committed by Gerrit Code Review
commit 57a1c3908f

View file

@ -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)/<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 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/<soname>) when .so is in /apex.
static std::vector<std::string> g_ld_preload_names;
static void notify_gdb_of_load(soinfo* info) {