elf: take phdr offset into account when calculating the program load address
The first program header does not necessarily start at offset 0. This change
corresponds to what the Linux kernel does in load_elf_binary().
Signed-off-by: Jonas Maebe <jonas.maebe@elis.ugent.be>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index f2e2197..84123ba 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -1820,7 +1820,7 @@
loaddr = -1, hiaddr = 0;
for (i = 0; i < ehdr->e_phnum; ++i) {
if (phdr[i].p_type == PT_LOAD) {
- abi_ulong a = phdr[i].p_vaddr;
+ abi_ulong a = phdr[i].p_vaddr - phdr[i].p_offset;
if (a < loaddr) {
loaddr = a;
}