summary refs log tree commit diff stats
path: root/linux-user/elfload.c
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2023-11-14 12:13:29 -0800
committerRichard Henderson <richard.henderson@linaro.org>2023-11-21 09:23:27 -0600
commit82d70a84c8ee42ef969a9cfddc0f5b30b16165f5 (patch)
treeb4e6293c73b74f015cf85188caa43319f2366260 /linux-user/elfload.c
parentc14ae763d548842c6abd1afaf5dc7ce7322ed901 (diff)
downloadfocaccia-qemu-82d70a84c8ee42ef969a9cfddc0f5b30b16165f5.tar.gz
focaccia-qemu-82d70a84c8ee42ef969a9cfddc0f5b30b16165f5.zip
linux-user: Fix loaddr computation for some elf files
The file offset of the load segment is not relevant to the
low address, only the beginning of the virtual address page.

Cc: qemu-stable@nongnu.org
Fixes: a93934fecd4 ("elf: take phdr offset into account when calculating the program load address")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1952
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Diffstat (limited to 'linux-user/elfload.c')
-rw-r--r--linux-user/elfload.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 4cd6891d7b..cf9e74468b 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -3308,7 +3308,7 @@ static void load_elf_image(const char *image_name, const ImageSource *src,
     for (i = 0; i < ehdr->e_phnum; ++i) {
         struct elf_phdr *eppnt = phdr + i;
         if (eppnt->p_type == PT_LOAD) {
-            abi_ulong a = eppnt->p_vaddr - eppnt->p_offset;
+            abi_ulong a = eppnt->p_vaddr & TARGET_PAGE_MASK;
             if (a < loaddr) {
                 loaddr = a;
             }