diff options
-rw-r--r-- | linker/linker.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/linker/linker.c b/linker/linker.c index a71986d..1e35f87 100644 --- a/linker/linker.c +++ b/linker/linker.c @@ -2078,7 +2078,18 @@ sanitize: 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; |