qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] elf: take phdr offset into account when calculating


From: Jonas Maebe
Subject: [Qemu-devel] [PATCH] elf: take phdr offset into account when calculating the program load address
Date: Fri, 24 Oct 2014 16:07:15 +0200

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 <address@hidden>
---
 linux-user/elfload.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 1c04fcf..0e141a7 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -1821,7 +1821,7 @@ static void load_elf_image(const char *image_name, int 
image_fd,
     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;
             }
-- 
2.1.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]