From eae09772558016836f1356816f4d1d0be498d74c Mon Sep 17 00:00:00 2001 From: Dmitriy Ivanov Date: Mon, 3 Nov 2014 21:15:15 -0800 Subject: [PATCH] Revert "Remove unnecessary lookups during relocations" This reverts commit 6442dbd3bcadbd5e522465743a8d8cf56338ae1c. Bug: 18222321 Bug: 18211780 Change-Id: I87b18a32238a1f75afe56149221b6691f50d9f56 --- linker/linker.cpp | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/linker/linker.cpp b/linker/linker.cpp index c63ac35bb..eb1a483ae 100644 --- a/linker/linker.cpp +++ b/linker/linker.cpp @@ -530,11 +530,6 @@ static ElfW(Sym)* soinfo_do_lookup(soinfo* si, const char* name, soinfo** lsi, c // 3. Look for it in the local group if (s == nullptr) { local_group.visit([&](soinfo* local_si) { - if (local_si == si && si->has_DT_SYMBOLIC) { - // we already did this - skip - return true; - } - DEBUG("%s: looking up %s in %s (from local group)", si->name, name, local_si->name); s = soinfo_elf_lookup(local_si, elf_hash, name); if (s != nullptr) { @@ -546,6 +541,28 @@ static ElfW(Sym)* soinfo_do_lookup(soinfo* si, const char* name, soinfo** lsi, c }); } + // 4. Look for it in this library (unless we already did it because of DT_SYMBOLIC) + if (s == nullptr && !si->has_DT_SYMBOLIC) { + DEBUG("%s: looking up %s in local scope", si->name, name); + s = soinfo_elf_lookup(si, elf_hash, name); + if (s != nullptr) { + *lsi = si; + } + } + + // 5. Dependencies + if (s == nullptr) { + si->get_children().visit([&](soinfo* child) { + DEBUG("%s: looking up %s in %s", si->name, name, child->name); + s = soinfo_elf_lookup(child, elf_hash, name); + if (s != nullptr) { + *lsi = child; + return false; + } + return true; + }); + } + if (s != nullptr) { TRACE_TYPE(LOOKUP, "si %s sym %s s->st_value = %p, " "found in %s, base = %p, load bias = %p",