From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41058) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlGLV-0007ND-CA for qemu-devel@nongnu.org; Mon, 03 Nov 2014 07:02:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XlGLM-00046u-AY for qemu-devel@nongnu.org; Mon, 03 Nov 2014 07:02:53 -0500 Received: from [2001:4b98:dc0:45:216:3eff:fe3d:166f] (port=35606 helo=afflict.kos.to) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlGLM-00046S-4Y for qemu-devel@nongnu.org; Mon, 03 Nov 2014 07:02:44 -0500 From: riku.voipio@linaro.org Date: Mon, 3 Nov 2014 14:02:41 +0200 Message-Id: In-Reply-To: References: Subject: [Qemu-devel] [PULL 3/3] elf: take phdr offset into account when calculating the program load address List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonas Maebe From: Jonas Maebe 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 Signed-off-by: Riku Voipio --- 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