linker: Fix the computation of si->base
The computation of si->base assumed that the first entry in the program header table is a PT_PHDR. This results in the dynamic linker crashing with a SIGSEGV/MAPERR when trying to load some of the NDK unit test programs, which happen to have an EXIDX header first, followed byu a PHDR one. This patch fixes the computation by parsing the program header table, looking explicitely for the PHDR entry. This fixes the load of the NDK unit test programs, and doesn't affect system libraries. Change-Id: Id18ea6037dbe950b5abbbce816c2960321f0b81d
This commit is contained in:
parent
4b469eae40
commit
8180b08fb2
1 changed files with 12 additions and 1 deletions
|
@ -2192,7 +2192,18 @@ unsigned __linker_init(unsigned **elfdata)
|
|||
vecs += 2;
|
||||
}
|
||||
|
||||
si->base = (Elf32_Addr) si->phdr - si->phdr->p_vaddr;
|
||||
/* Compute the value of si->base. We can't rely on the fact that
|
||||
* the first entry is the PHDR because this will not be true
|
||||
* for certain executables (e.g. some in the NDK unit test suite)
|
||||
*/
|
||||
int nn;
|
||||
si->base = 0;
|
||||
for ( nn = 0; nn < si->phnum; nn++ ) {
|
||||
if (si->phdr[nn].p_type == PT_PHDR) {
|
||||
si->base = (Elf32_Addr) si->phdr - si->phdr[nn].p_vaddr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
si->dynamic = (unsigned *)-1;
|
||||
si->wrprotect_start = 0xffffffff;
|
||||
si->wrprotect_end = 0;
|
||||
|
|
Loading…
Reference in a new issue