Ignore DT_BIND_NOW (0x18)

Bug: 17552334
Change-Id: Ibe93fd3d6580f369f9a6ef8d235bf0df00fe7607
This commit is contained in:
Dmitriy Ivanov 2014-10-15 14:59:01 -07:00
parent 71cbcdcf94
commit ea6eae182a

View File

@ -1915,27 +1915,33 @@ bool soinfo::PrelinkImage() {
// TODO: glibc dynamic linker uses this name for // TODO: glibc dynamic linker uses this name for
// initial library lookup; consider doing the same here. // initial library lookup; consider doing the same here.
break; 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];
bucket = reinterpret_cast<uint32_t*>(load_bias + d->d_un.d_ptr + 8); bucket = reinterpret_cast<uint32_t*>(load_bias + d->d_un.d_ptr + 8);
chain = reinterpret_cast<uint32_t*>(load_bias + d->d_un.d_ptr + 8 + nbucket * 4); chain = reinterpret_cast<uint32_t*>(load_bias + d->d_un.d_ptr + 8 + nbucket * 4);
break; break;
case DT_STRTAB: case DT_STRTAB:
strtab = reinterpret_cast<const char*>(load_bias + d->d_un.d_ptr); strtab = reinterpret_cast<const char*>(load_bias + d->d_un.d_ptr);
break; break;
case DT_STRSZ: case DT_STRSZ:
strtab_size = d->d_un.d_val; strtab_size = d->d_un.d_val;
break; break;
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: case DT_SYMENT:
if (d->d_un.d_val != sizeof(ElfW(Sym))) { if (d->d_un.d_val != sizeof(ElfW(Sym))) {
DL_ERR("invalid DT_SYMENT: %zd", static_cast<size_t>(d->d_un.d_val)); DL_ERR("invalid DT_SYMENT: %zd", static_cast<size_t>(d->d_un.d_val));
return false; return false;
} }
break; break;
case DT_PLTREL: case DT_PLTREL:
#if defined(USE_RELA) #if defined(USE_RELA)
if (d->d_un.d_val != DT_RELA) { if (d->d_un.d_val != DT_RELA) {
@ -1949,6 +1955,7 @@ bool soinfo::PrelinkImage() {
} }
#endif #endif
break; break;
case DT_JMPREL: case DT_JMPREL:
#if defined(USE_RELA) #if defined(USE_RELA)
plt_rela = reinterpret_cast<ElfW(Rela)*>(load_bias + d->d_un.d_ptr); plt_rela = reinterpret_cast<ElfW(Rela)*>(load_bias + d->d_un.d_ptr);
@ -1956,6 +1963,7 @@ bool soinfo::PrelinkImage() {
plt_rel = reinterpret_cast<ElfW(Rel)*>(load_bias + d->d_un.d_ptr); plt_rel = reinterpret_cast<ElfW(Rel)*>(load_bias + d->d_un.d_ptr);
#endif #endif
break; break;
case DT_PLTRELSZ: case DT_PLTRELSZ:
#if defined(USE_RELA) #if defined(USE_RELA)
plt_rela_count = d->d_un.d_val / sizeof(ElfW(Rela)); plt_rela_count = d->d_un.d_val / sizeof(ElfW(Rela));
@ -1963,6 +1971,7 @@ 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;
case DT_PLTGOT: case DT_PLTGOT:
#if defined(__mips__) #if defined(__mips__)
// Used by mips and mips64. // Used by mips and mips64.
@ -1970,6 +1979,7 @@ bool soinfo::PrelinkImage() {
#endif #endif
// Ignore for other platforms... (because RTLD_LAZY is not supported) // Ignore for other platforms... (because RTLD_LAZY is not supported)
break; 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
@ -1987,21 +1997,26 @@ bool soinfo::PrelinkImage() {
case DT_RELA: case DT_RELA:
rela = reinterpret_cast<ElfW(Rela)*>(load_bias + d->d_un.d_ptr); rela = reinterpret_cast<ElfW(Rela)*>(load_bias + d->d_un.d_ptr);
break; break;
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: case DT_RELAENT:
if (d->d_un.d_val != sizeof(ElfW(Rela))) { if (d->d_un.d_val != sizeof(ElfW(Rela))) {
DL_ERR("invalid DT_RELAENT: %zd", static_cast<size_t>(d->d_un.d_val)); DL_ERR("invalid DT_RELAENT: %zd", static_cast<size_t>(d->d_un.d_val));
return false; return false;
} }
break; break;
// ignored (see DT_RELCOUNT comments for details)
case DT_RELACOUNT: case DT_RELACOUNT:
// ignored (see DT_RELCOUNT comments for details)
break; 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;
case DT_RELSZ: case DT_RELSZ:
DL_ERR("unsupported DT_RELSZ in \"%s\"", name); DL_ERR("unsupported DT_RELSZ in \"%s\"", name);
return false; return false;
@ -2009,21 +2024,24 @@ bool soinfo::PrelinkImage() {
case DT_REL: case DT_REL:
rel = reinterpret_cast<ElfW(Rel)*>(load_bias + d->d_un.d_ptr); rel = reinterpret_cast<ElfW(Rel)*>(load_bias + d->d_un.d_ptr);
break; break;
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: case DT_RELENT:
if (d->d_un.d_val != sizeof(ElfW(Rel))) { if (d->d_un.d_val != sizeof(ElfW(Rel))) {
DL_ERR("invalid DT_RELENT: %zd", static_cast<size_t>(d->d_un.d_val)); DL_ERR("invalid DT_RELENT: %zd", static_cast<size_t>(d->d_un.d_val));
return false; return false;
} }
break; break;
// "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.
case DT_RELCOUNT: 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; break;
case DT_RELA: case DT_RELA:
DL_ERR("unsupported DT_RELA in \"%s\"", name); DL_ERR("unsupported DT_RELA in \"%s\"", name);
@ -2033,31 +2051,39 @@ bool soinfo::PrelinkImage() {
init_func = reinterpret_cast<linker_function_t>(load_bias + d->d_un.d_ptr); init_func = reinterpret_cast<linker_function_t>(load_bias + d->d_un.d_ptr);
DEBUG("%s constructors (DT_INIT) found at %p", name, init_func); DEBUG("%s constructors (DT_INIT) found at %p", name, init_func);
break; break;
case DT_FINI: case DT_FINI:
fini_func = reinterpret_cast<linker_function_t>(load_bias + d->d_un.d_ptr); fini_func = reinterpret_cast<linker_function_t>(load_bias + d->d_un.d_ptr);
DEBUG("%s destructors (DT_FINI) found at %p", name, fini_func); DEBUG("%s destructors (DT_FINI) found at %p", name, fini_func);
break; break;
case DT_INIT_ARRAY: case DT_INIT_ARRAY:
init_array = reinterpret_cast<linker_function_t*>(load_bias + d->d_un.d_ptr); init_array = reinterpret_cast<linker_function_t*>(load_bias + d->d_un.d_ptr);
DEBUG("%s constructors (DT_INIT_ARRAY) found at %p", name, init_array); DEBUG("%s constructors (DT_INIT_ARRAY) found at %p", name, init_array);
break; break;
case DT_INIT_ARRAYSZ: case DT_INIT_ARRAYSZ:
init_array_count = ((unsigned)d->d_un.d_val) / sizeof(ElfW(Addr)); init_array_count = ((unsigned)d->d_un.d_val) / sizeof(ElfW(Addr));
break; break;
case DT_FINI_ARRAY: case DT_FINI_ARRAY:
fini_array = reinterpret_cast<linker_function_t*>(load_bias + d->d_un.d_ptr); fini_array = reinterpret_cast<linker_function_t*>(load_bias + d->d_un.d_ptr);
DEBUG("%s destructors (DT_FINI_ARRAY) found at %p", name, fini_array); DEBUG("%s destructors (DT_FINI_ARRAY) found at %p", name, fini_array);
break; break;
case DT_FINI_ARRAYSZ: case DT_FINI_ARRAYSZ:
fini_array_count = ((unsigned)d->d_un.d_val) / sizeof(ElfW(Addr)); fini_array_count = ((unsigned)d->d_un.d_val) / sizeof(ElfW(Addr));
break; break;
case DT_PREINIT_ARRAY: case DT_PREINIT_ARRAY:
preinit_array = reinterpret_cast<linker_function_t*>(load_bias + d->d_un.d_ptr); preinit_array = reinterpret_cast<linker_function_t*>(load_bias + d->d_un.d_ptr);
DEBUG("%s constructors (DT_PREINIT_ARRAY) found at %p", name, preinit_array); DEBUG("%s constructors (DT_PREINIT_ARRAY) found at %p", name, preinit_array);
break; break;
case DT_PREINIT_ARRAYSZ: case DT_PREINIT_ARRAYSZ:
preinit_array_count = ((unsigned)d->d_un.d_val) / sizeof(ElfW(Addr)); preinit_array_count = ((unsigned)d->d_un.d_val) / sizeof(ElfW(Addr));
break; break;
case DT_TEXTREL: case DT_TEXTREL:
#if defined(__LP64__) #if defined(__LP64__)
DL_ERR("text relocations (DT_TEXTREL) found in 64-bit ELF file \"%s\"", name); DL_ERR("text relocations (DT_TEXTREL) found in 64-bit ELF file \"%s\"", name);
@ -2066,12 +2092,15 @@ bool soinfo::PrelinkImage() {
has_text_relocations = true; has_text_relocations = true;
break; break;
#endif #endif
case DT_SYMBOLIC: case DT_SYMBOLIC:
has_DT_SYMBOLIC = true; has_DT_SYMBOLIC = true;
break; break;
case DT_NEEDED: case DT_NEEDED:
++needed_count; ++needed_count;
break; break;
case DT_FLAGS: case DT_FLAGS:
if (d->d_un.d_val & DF_TEXTREL) { if (d->d_un.d_val & DF_TEXTREL) {
#if defined(__LP64__) #if defined(__LP64__)
@ -2085,6 +2114,7 @@ bool soinfo::PrelinkImage() {
has_DT_SYMBOLIC = true; has_DT_SYMBOLIC = true;
} }
break; break;
case DT_FLAGS_1: case DT_FLAGS_1:
if ((d->d_un.d_val & DF_1_GLOBAL) != 0) { if ((d->d_un.d_val & DF_1_GLOBAL) != 0) {
rtld_flags |= RTLD_GLOBAL; rtld_flags |= RTLD_GLOBAL;
@ -2107,6 +2137,7 @@ bool soinfo::PrelinkImage() {
*dp = &_r_debug; *dp = &_r_debug;
} }
break; break;
case DT_MIPS_RLD_VERSION: case DT_MIPS_RLD_VERSION:
case DT_MIPS_FLAGS: case DT_MIPS_FLAGS:
case DT_MIPS_BASE_ADDRESS: case DT_MIPS_BASE_ADDRESS:
@ -2125,10 +2156,14 @@ bool soinfo::PrelinkImage() {
mips_gotsym = d->d_un.d_val; mips_gotsym = d->d_un.d_val;
break; break;
#endif #endif
// Ignored: "Its use has been superseded by the DF_BIND_NOW flag"
case DT_BIND_NOW:
break;
// Ignore: bionic does not support symbol versioning...
case DT_VERSYM: case DT_VERSYM:
case DT_VERDEF: case DT_VERDEF:
case DT_VERDEFNUM: case DT_VERDEFNUM:
// Ignore: bionic does not support symbol versioning...
break; break;
default: default: