diff options
author | Dmitriy Ivanov <dimitry@google.com> | 2015-06-16 15:38:21 -0700 |
---|---|---|
committer | Dmitriy Ivanov <dimitry@google.com> | 2015-06-16 16:52:21 -0700 |
commit | ea4ef52fa46602a5853df0e5b1ddd71b194d54ce (patch) | |
tree | 6a7cc40101796db2cf93eee07ab724e94738e56d /linker | |
parent | 420574690cc7096c3f894d5d88a65e8fd13de25c (diff) | |
download | bionic-ea4ef52fa46602a5853df0e5b1ddd71b194d54ce.zip bionic-ea4ef52fa46602a5853df0e5b1ddd71b194d54ce.tar.gz bionic-ea4ef52fa46602a5853df0e5b1ddd71b194d54ce.tar.bz2 |
Improve library lookup logic
Linker tries to open a library even if it can
be found by soname. This only happens if the
library was previously opened under different
target sdk version.
Bug: http://b/21876587
Bug: http://b/21153477
Bug: http://b/21171302
Bug: https://code.google.com/p/android/issues/detail?id=160921
Change-Id: I769a04b6b1368a107d43f399297be14050338bbc
Diffstat (limited to 'linker')
-rw-r--r-- | linker/linker.cpp | 12 | ||||
-rw-r--r-- | linker/linker_sdk_versions.cpp | 4 |
2 files changed, 16 insertions, 0 deletions
diff --git a/linker/linker.cpp b/linker/linker.cpp index bbdd1b0..9c8765d 100644 --- a/linker/linker.cpp +++ b/linker/linker.cpp @@ -1349,7 +1349,19 @@ static soinfo *find_loaded_library_by_soname(const char* name) { return nullptr; } + uint32_t target_sdk_version = get_application_target_sdk_version(); + for (soinfo* si = solist; si != nullptr; si = si->next) { + // If the library was opened under different target sdk version + // skip this step and try to reopen it. The exceptions are + // "libdl.so" and global group. There is no point in skipping + // them because relocation process is going to use them + // in any case. + if (si != solist && (si->get_dt_flags_1() & DF_1_GLOBAL) == 0 && + si->is_linked() && si->get_target_sdk_version() != target_sdk_version) { + continue; + } + const char* soname = si->get_soname(); if (soname != nullptr && (strcmp(name, soname) == 0)) { return si; diff --git a/linker/linker_sdk_versions.cpp b/linker/linker_sdk_versions.cpp index e9ad3dc..9aebb06 100644 --- a/linker/linker_sdk_versions.cpp +++ b/linker/linker_sdk_versions.cpp @@ -21,6 +21,10 @@ static std::atomic<uint32_t> g_target_sdk_version(__ANDROID_API__); void set_application_target_sdk_version(uint32_t target) { + // translate current sdk_version to platform sdk_version + if (target == 0) { + target = __ANDROID_API__; + } g_target_sdk_version = target; } |