Load libraries in breadth-first order
This patch fixes the problem with symbol search order
for dlsym(RTLD_DEFAULT/RTLD_NEXT, .) by loading libraries
and ld_preloads in correct order.
Bug: https://code.google.com/p/android/issues/detail?id=74255
Attempt: 2
(cherry picked from commit 14669a939d
)
Change-Id: Id87540c96a2242220967b6fa5d84ddcd829e2b97
This commit is contained in:
@@ -702,34 +702,17 @@ int phdr_table_get_arm_exidx(const ElfW(Phdr)* phdr_table, size_t phdr_count,
|
||||
* load_bias -> load bias
|
||||
* Output:
|
||||
* dynamic -> address of table in memory (null on failure).
|
||||
* dynamic_count -> number of items in table (0 on failure).
|
||||
* dynamic_flags -> protection flags for section (unset on failure)
|
||||
* Return:
|
||||
* void
|
||||
*/
|
||||
void phdr_table_get_dynamic_section(const ElfW(Phdr)* phdr_table, size_t phdr_count,
|
||||
ElfW(Addr) load_bias,
|
||||
ElfW(Dyn)** dynamic, size_t* dynamic_count, ElfW(Word)* dynamic_flags) {
|
||||
const ElfW(Phdr)* phdr = phdr_table;
|
||||
const ElfW(Phdr)* phdr_limit = phdr + phdr_count;
|
||||
|
||||
for (phdr = phdr_table; phdr < phdr_limit; phdr++) {
|
||||
if (phdr->p_type != PT_DYNAMIC) {
|
||||
continue;
|
||||
}
|
||||
|
||||
*dynamic = reinterpret_cast<ElfW(Dyn)*>(load_bias + phdr->p_vaddr);
|
||||
if (dynamic_count) {
|
||||
*dynamic_count = (unsigned)(phdr->p_memsz / 8);
|
||||
}
|
||||
if (dynamic_flags) {
|
||||
*dynamic_flags = phdr->p_flags;
|
||||
}
|
||||
return;
|
||||
}
|
||||
ElfW(Addr) load_bias, ElfW(Dyn)** dynamic) {
|
||||
*dynamic = nullptr;
|
||||
if (dynamic_count) {
|
||||
*dynamic_count = 0;
|
||||
for (const ElfW(Phdr)* phdr = phdr_table, *phdr_limit = phdr + phdr_count; phdr < phdr_limit; phdr++) {
|
||||
if (phdr->p_type == PT_DYNAMIC) {
|
||||
*dynamic = reinterpret_cast<ElfW(Dyn)*>(load_bias + phdr->p_vaddr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user