Support symbol versioning

Bug: http://b/20139821
Change-Id: I64122a0fb0960c20b2ce614161b7ab048456b681
This commit is contained in:
Dmitriy Ivanov
2015-04-09 13:42:33 -07:00
parent c6ccdfaf1f
commit 2a81536144
19 changed files with 895 additions and 43 deletions

View File

@@ -50,6 +50,12 @@ template <typename ElfRelIteratorT>
bool soinfo::relocate(ElfRelIteratorT&& rel_iterator,
const soinfo_list_t& global_group,
const soinfo_list_t& local_group) {
VersionTracker version_tracker;
if (!version_tracker.init(this)) {
return false;
}
for (size_t idx = 0; rel_iterator.has_next(); ++idx) {
const auto rel = rel_iterator.next();
@@ -69,12 +75,33 @@ bool soinfo::relocate(ElfRelIteratorT&& rel_iterator,
continue;
}
ElfW(Sym)* s = nullptr;
const ElfW(Sym)* s = nullptr;
soinfo* lsi = nullptr;
if (sym != 0) {
sym_name = get_string(symtab_[sym].st_name);
s = soinfo_do_lookup(this, sym_name, &lsi, global_group,local_group);
const ElfW(Versym)* sym_ver_ptr = get_versym(sym);
ElfW(Versym) sym_ver = sym_ver_ptr == nullptr ? 0 : *sym_ver_ptr;
if (sym_ver == VER_NDX_LOCAL || sym_ver == VER_NDX_GLOBAL) {
// there is no version info for this one
if (!soinfo_do_lookup(this, sym_name, nullptr, &lsi, global_group, local_group, &s)) {
return false;
}
} else {
const version_info* vi = version_tracker.get_version_info(sym_ver);
if (vi == nullptr) {
DL_ERR("cannot find verneed/verdef for version index=%d "
"referenced by symbol \"%s\" at \"%s\"", sym_ver, sym_name, get_soname());
return false;
}
if (!soinfo_do_lookup(this, sym_name, vi, &lsi, global_group, local_group, &s)) {
return false;
}
}
if (s == nullptr) {
// mips does not support relocation with weak-undefined symbols
DL_ERR("cannot locate symbol \"%s\" referenced by \"%s\"...", sym_name, get_soname());
@@ -147,7 +174,11 @@ bool soinfo::mips_relocate_got(const soinfo_list_t& global_group,
// This is an undefined reference... try to locate it.
const char* sym_name = get_string(sym->st_name);
soinfo* lsi = nullptr;
ElfW(Sym)* s = soinfo_do_lookup(this, sym_name, &lsi, global_group, local_group);
const ElfW(Sym)* s = nullptr;
if (!soinfo_do_lookup(this, sym_name, nullptr, &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];