Check if strtab exists before using it

Bug: http://b/21696087
Change-Id: I1e22d5fd6fe2faead332249493123c9a085081e9
This commit is contained in:
Dmitriy Ivanov 2015-06-08 10:41:33 -07:00
parent d9dc13d417
commit 624b8f17a1

View File

@ -2842,17 +2842,6 @@ bool soinfo::prelink_image() {
}
}
// second pass - parse entries relying on strtab
for (ElfW(Dyn)* d = dynamic; d->d_tag != DT_NULL; ++d) {
if (d->d_tag == DT_SONAME) {
soname_ = get_string(d->d_un.d_val);
#if defined(__work_around_b_19059885__)
strlcpy(old_name_, soname_, sizeof(old_name_));
#endif
break;
}
}
DEBUG("si->base = %p, si->strtab = %p, si->symtab = %p",
reinterpret_cast<void*>(base), strtab_, symtab_);
@ -2875,6 +2864,17 @@ bool soinfo::prelink_image() {
return false;
}
// second pass - parse entries relying on strtab
for (ElfW(Dyn)* d = dynamic; d->d_tag != DT_NULL; ++d) {
if (d->d_tag == DT_SONAME) {
soname_ = get_string(d->d_un.d_val);
#if defined(__work_around_b_19059885__)
strlcpy(old_name_, soname_, sizeof(old_name_));
#endif
break;
}
}
// Before M release linker was using basename in place of soname.
// In the case when dt_soname is absent some apps stop working
// because they can't find dt_needed library by soname.