summaryrefslogtreecommitdiff
path: root/linker/linker.cpp
diff options
context:
space:
mode:
authorPeter Collingbourne <pcc@google.com>2019-08-16 17:26:05 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2019-08-16 17:26:05 +0000
commit3952113d90dd91adc67ce60899d4997bb5f63d0d (patch)
tree2aa8942bfbeb0f2283fb7552f6fad3a647335753 /linker/linker.cpp
parent5f112cd7564f092c93c877e526d269ec68d47922 (diff)
parent191ecdc49ba18fc07d62d419fd51cc7dee4190f8 (diff)
Merge "Fix a few bionic test failures caused by hwasan global instrumentation."
Diffstat (limited to 'linker/linker.cpp')
-rw-r--r--linker/linker.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/linker/linker.cpp b/linker/linker.cpp
index dc819c18d..d581dd8ce 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -952,7 +952,9 @@ static const ElfW(Sym)* dlsym_linear_lookup(android_namespace_t* ns,
}
soinfo* find_containing_library(const void* p) {
- ElfW(Addr) address = reinterpret_cast<ElfW(Addr)>(p);
+ // Addresses within a library may be tagged if they point to globals. Untag
+ // them so that the bounds check succeeds.
+ ElfW(Addr) address = reinterpret_cast<ElfW(Addr)>(untag_address(p));
for (soinfo* si = solist_get_head(); si != nullptr; si = si->next) {
if (address < si->base || address - si->base >= si->size) {
continue;
@@ -1902,13 +1904,13 @@ bool find_libraries(android_namespace_t* ns,
// flag is set.
link_extinfo = extinfo;
}
+ if (__libc_shared_globals()->load_hook) {
+ __libc_shared_globals()->load_hook(si->load_bias, si->phdr, si->phnum);
+ }
if (!si->link_image(global_group, local_group, link_extinfo, &relro_fd_offset) ||
!get_cfi_shadow()->AfterLoad(si, solist_get_head())) {
return false;
}
- if (__libc_shared_globals()->load_hook) {
- __libc_shared_globals()->load_hook(si->load_bias, si->phdr, si->phnum);
- }
}
return true;