qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: riku.voipio@linaro.org
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Jonas Maebe <jonas.maebe@elis.ugent.be>
Subject: [Qemu-devel] [PULL 3/3] elf: take phdr offset into account when calculating the program load address
Date: Mon,  3 Nov 2014 14:02:41 +0200	[thread overview]
Message-ID: <a93934fecd4dffc9d4b452b670c9506be5dea30d.1415015510.git.riku.voipio@linaro.org> (raw)
In-Reply-To: <cover.1415015510.git.riku.voipio@linaro.org>

From: Jonas Maebe <jonas.maebe@elis.ugent.be>

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>
---
 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 f2e2197..84123ba 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -1820,7 +1820,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

  parent reply	other threads:[~2014-11-03 12:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-03 12:02 [Qemu-devel] [PULL 0/3] linux-user changes for 2.2 riku.voipio
2014-11-03 12:02 ` [Qemu-devel] [PULL 1/3] linux-user: Let user specify random seed riku.voipio
2014-11-03 12:02 ` [Qemu-devel] [PULL 2/3] linux-user: Fix fault address truncation AArch64 riku.voipio
2014-11-03 12:02 ` riku.voipio [this message]
2014-11-03 22:50 ` [Qemu-devel] [PULL 0/3] linux-user changes for 2.2 Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a93934fecd4dffc9d4b452b670c9506be5dea30d.1415015510.git.riku.voipio@linaro.org \
    --to=riku.voipio@linaro.org \
    --cc=jonas.maebe@elis.ugent.be \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).