]> git.proxmox.com Git - mirror_qemu.git/commitdiff
linux-user: Fix loaddr computation for some elf files
authorRichard Henderson <richard.henderson@linaro.org>
Tue, 14 Nov 2023 20:13:29 +0000 (12:13 -0800)
committerRichard Henderson <richard.henderson@linaro.org>
Tue, 21 Nov 2023 15:23:27 +0000 (09:23 -0600)
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>
linux-user/elfload.c

index 4cd6891d7b6a0eec8f47d79fb5f93b8f7a119f04..cf9e74468b11c7dd35dc6e6c3c57ef9d6336d01d 100644 (file)
@@ -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;
             }