Skip to content

Commit

Permalink
linux-user: Fix loaddr computation for some elf files
Browse files Browse the repository at this point in the history
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: a93934f ("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>
(cherry picked from commit 82d70a8)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
  • Loading branch information
rth7680 authored and Michael Tokarev committed Nov 29, 2023
1 parent 88e79a2 commit 983a4a8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion linux-user/elfload.c
Original file line number Diff line number Diff line change
Expand Up @@ -3093,7 +3093,7 @@ static void load_elf_image(const char *image_name, int image_fd,
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;
}
Expand Down

0 comments on commit 983a4a8

Please sign in to comment.