Fix some unused DT_ warnings
* DT_PLTGOT - ignored for non-mips
* DT_RELCOUNT/RELACOUNT - ignored
* DT_RELENT/RELAENT - sanity checks
* DT_SYMENT - sanity check
* DT_SONAME - ignore for now.
Bug: 18186310
(cherry picked from commit 4a6e9a835a
)
Change-Id: Ib40095f0770d65628fc7abac5a471378de35ebe7
This commit is contained in:
@@ -1875,6 +1875,10 @@ bool soinfo::PrelinkImage() {
|
|||||||
DEBUG("d = %p, d[0](tag) = %p d[1](val) = %p",
|
DEBUG("d = %p, d[0](tag) = %p d[1](val) = %p",
|
||||||
d, reinterpret_cast<void*>(d->d_tag), reinterpret_cast<void*>(d->d_un.d_val));
|
d, reinterpret_cast<void*>(d->d_tag), reinterpret_cast<void*>(d->d_un.d_val));
|
||||||
switch (d->d_tag) {
|
switch (d->d_tag) {
|
||||||
|
case DT_SONAME:
|
||||||
|
// TODO: glibc dynamic linker uses this name for
|
||||||
|
// initial library lookup; consider doing the same here.
|
||||||
|
break;
|
||||||
case DT_HASH:
|
case DT_HASH:
|
||||||
nbucket = reinterpret_cast<uint32_t*>(load_bias + d->d_un.d_ptr)[0];
|
nbucket = reinterpret_cast<uint32_t*>(load_bias + d->d_un.d_ptr)[0];
|
||||||
nchain = reinterpret_cast<uint32_t*>(load_bias + d->d_un.d_ptr)[1];
|
nchain = reinterpret_cast<uint32_t*>(load_bias + d->d_un.d_ptr)[1];
|
||||||
@@ -1887,6 +1891,12 @@ bool soinfo::PrelinkImage() {
|
|||||||
case DT_SYMTAB:
|
case DT_SYMTAB:
|
||||||
symtab = reinterpret_cast<ElfW(Sym)*>(load_bias + d->d_un.d_ptr);
|
symtab = reinterpret_cast<ElfW(Sym)*>(load_bias + d->d_un.d_ptr);
|
||||||
break;
|
break;
|
||||||
|
case DT_SYMENT:
|
||||||
|
if (d->d_un.d_val != sizeof(ElfW(Sym))) {
|
||||||
|
DL_ERR("invalid DT_SYMENT: %d", d->d_un.d_val);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
#if !defined(__LP64__)
|
#if !defined(__LP64__)
|
||||||
case DT_PLTREL:
|
case DT_PLTREL:
|
||||||
if (d->d_un.d_val != DT_REL) {
|
if (d->d_un.d_val != DT_REL) {
|
||||||
@@ -1909,12 +1919,13 @@ bool soinfo::PrelinkImage() {
|
|||||||
plt_rel_count = d->d_un.d_val / sizeof(ElfW(Rel));
|
plt_rel_count = d->d_un.d_val / sizeof(ElfW(Rel));
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
#if defined(__mips__)
|
|
||||||
case DT_PLTGOT:
|
case DT_PLTGOT:
|
||||||
|
#if defined(__mips__)
|
||||||
// Used by mips and mips64.
|
// Used by mips and mips64.
|
||||||
plt_got = reinterpret_cast<ElfW(Addr)**>(load_bias + d->d_un.d_ptr);
|
plt_got = reinterpret_cast<ElfW(Addr)**>(load_bias + d->d_un.d_ptr);
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
|
// Ignore for other platforms... (because RTLD_LAZY is not supported)
|
||||||
|
break;
|
||||||
case DT_DEBUG:
|
case DT_DEBUG:
|
||||||
// Set the DT_DEBUG entry to the address of _r_debug for GDB
|
// Set the DT_DEBUG entry to the address of _r_debug for GDB
|
||||||
// if the dynamic table is writable
|
// if the dynamic table is writable
|
||||||
@@ -1935,6 +1946,15 @@ bool soinfo::PrelinkImage() {
|
|||||||
case DT_RELASZ:
|
case DT_RELASZ:
|
||||||
rela_count = d->d_un.d_val / sizeof(ElfW(Rela));
|
rela_count = d->d_un.d_val / sizeof(ElfW(Rela));
|
||||||
break;
|
break;
|
||||||
|
case DT_RELAENT:
|
||||||
|
if (d->d_un.d_val != sizeof(ElfW(Rela))) {
|
||||||
|
DL_ERR("invalid DT_RELAENT: %d", d->d_un.d_val);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case DT_RELACOUNT:
|
||||||
|
// ignored (see DT_RELCOUNT comments for details)
|
||||||
|
break;
|
||||||
case DT_REL:
|
case DT_REL:
|
||||||
DL_ERR("unsupported DT_REL in \"%s\"", name);
|
DL_ERR("unsupported DT_REL in \"%s\"", name);
|
||||||
return false;
|
return false;
|
||||||
@@ -1948,6 +1968,19 @@ bool soinfo::PrelinkImage() {
|
|||||||
case DT_RELSZ:
|
case DT_RELSZ:
|
||||||
rel_count = d->d_un.d_val / sizeof(ElfW(Rel));
|
rel_count = d->d_un.d_val / sizeof(ElfW(Rel));
|
||||||
break;
|
break;
|
||||||
|
case DT_RELENT:
|
||||||
|
if (d->d_un.d_val != sizeof(ElfW(Rel))) {
|
||||||
|
DL_ERR("invalid DT_RELENT: %d", d->d_un.d_val);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case DT_RELCOUNT:
|
||||||
|
// "Indicates that all RELATIVE relocations have been concatenated together,
|
||||||
|
// and specifies the RELATIVE relocation count."
|
||||||
|
//
|
||||||
|
// TODO: Spec also mentions that this can be used to optimize relocation process;
|
||||||
|
// Not currently used by bionic linker - ignored.
|
||||||
|
break;
|
||||||
case DT_RELA:
|
case DT_RELA:
|
||||||
DL_ERR("unsupported DT_RELA in \"%s\"", name);
|
DL_ERR("unsupported DT_RELA in \"%s\"", name);
|
||||||
return false;
|
return false;
|
||||||
@@ -2007,8 +2040,6 @@ bool soinfo::PrelinkImage() {
|
|||||||
break;
|
break;
|
||||||
#if defined(__mips__)
|
#if defined(__mips__)
|
||||||
case DT_STRSZ:
|
case DT_STRSZ:
|
||||||
case DT_SYMENT:
|
|
||||||
case DT_RELENT:
|
|
||||||
break;
|
break;
|
||||||
case DT_MIPS_RLD_MAP:
|
case DT_MIPS_RLD_MAP:
|
||||||
// Set the DT_MIPS_RLD_MAP entry to the address of _r_debug for GDB.
|
// Set the DT_MIPS_RLD_MAP entry to the address of _r_debug for GDB.
|
||||||
|
Reference in New Issue
Block a user