diff --git a/linker/linker.cpp b/linker/linker.cpp index 0e6fa450d..2669a5637 100644 --- a/linker/linker.cpp +++ b/linker/linker.cpp @@ -2941,7 +2941,7 @@ bool soinfo::link_image(const soinfo_list_t& global_group, const soinfo_list_t& #endif #if defined(__mips__) - if (!mips_relocate_got(global_group, local_group)) { + if (!mips_relocate_got(version_tracker, global_group, local_group)) { return false; } #endif diff --git a/linker/linker.h b/linker/linker.h index 109aeb720..dc8c6e08a 100644 --- a/linker/linker.h +++ b/linker/linker.h @@ -247,7 +247,9 @@ struct soinfo { uint32_t mips_symtabno_; uint32_t mips_local_gotno_; uint32_t mips_gotsym_; - bool mips_relocate_got(const soinfo_list_t& global_group, const soinfo_list_t& local_group); + bool mips_relocate_got(const VersionTracker& version_tracker, + const soinfo_list_t& global_group, + const soinfo_list_t& local_group); #endif size_t ref_count_; diff --git a/linker/linker_mips.cpp b/linker/linker_mips.cpp index 3402afe68..7436180c3 100644 --- a/linker/linker_mips.cpp +++ b/linker/linker_mips.cpp @@ -124,7 +124,8 @@ bool soinfo::relocate(const VersionTracker& version_tracker, return true; } -bool soinfo::mips_relocate_got(const soinfo_list_t& global_group, +bool soinfo::mips_relocate_got(const VersionTracker& version_tracker, + const soinfo_list_t& global_group, const soinfo_list_t& local_group) { ElfW(Addr)** got = plt_got_; if (got == nullptr) { @@ -148,21 +149,27 @@ bool soinfo::mips_relocate_got(const soinfo_list_t& global_group, } // Now for the global GOT entries... - ElfW(Sym)* sym = symtab_ + mips_gotsym_; got = plt_got_ + mips_local_gotno_; - for (size_t g = mips_gotsym_; g < mips_symtabno_; g++, sym++, got++) { + for (ElfW(Word) sym = mips_gotsym_; sym < mips_symtabno_; sym++, got++) { // This is an undefined reference... try to locate it. - const char* sym_name = get_string(sym->st_name); + const ElfW(Sym)* local_sym = symtab_ + sym; + const char* sym_name = get_string(local_sym->st_name); soinfo* lsi = nullptr; const ElfW(Sym)* s = nullptr; - if (!soinfo_do_lookup(this, sym_name, nullptr, &lsi, global_group, local_group, &s)) { + + const version_info* vi = nullptr; + + if (!lookup_version_info(version_tracker, sym, sym_name, &vi)) { + return false; + } + + if (!soinfo_do_lookup(this, sym_name, vi, &lsi, global_group, local_group, &s)) { return false; } if (s == nullptr) { // We only allow an undefined symbol if this is a weak reference. - s = &symtab_[g]; - if (ELF_ST_BIND(s->st_info) != STB_WEAK) { + if (ELF_ST_BIND(local_sym->st_info) != STB_WEAK) { DL_ERR("cannot locate \"%s\"...", sym_name); return false; }