From patchwork Mon Nov 3 12:02:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 40019 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f71.google.com (mail-ee0-f71.google.com [74.125.83.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CB50721894 for ; Mon, 3 Nov 2014 12:24:23 +0000 (UTC) Received: by mail-ee0-f71.google.com with SMTP id e51sf2763228eek.10 for ; Mon, 03 Nov 2014 04:24:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=vW5Ie/3wnCESRuIjIjGEQH9xCAWhGmGZxyHnX6+L78s=; b=Gtnog1KXDwPWyE/2Q3K38KShjKb+agBUqQmbx1sJB8IQfgM5NeHNs3vDVlNTL52Wy7 5UALJ1MlAz8S6hfwoKR8g3mDuSVd+rh0Gpt5fv/YvnQm26xBvM7sFWVnPnfpjoqBFvaG Sb6u/fGUwByed6xL70dcXaXTqP6Pq1eMBby1UAbfNYQTWfhqAKPWz9fwcmIq1o/SueVh zIETXAB8zMhJrNtsxbqz0FiKZrzw0FZptkYIQDYb10H+gWnwGS7mAgfecNJ2Fs7Z2Hgc gM8pmGFrUbtMnhPtWQXG990nl8ITRnPjmU0LRU8M4i6+5oVgIpdIBuaNFjQm6uzLXw5p 3EoQ== X-Gm-Message-State: ALoCoQmakyuhQM9QGAFFt/BoahUS7rElILTEai33bDY3t2QT2QtZp4M7qIqypQiylCczj92g9INK X-Received: by 10.112.217.102 with SMTP id ox6mr347039lbc.19.1415017462996; Mon, 03 Nov 2014 04:24:22 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.29.135 with SMTP id k7ls641975lah.78.gmail; Mon, 03 Nov 2014 04:24:22 -0800 (PST) X-Received: by 10.112.146.37 with SMTP id sz5mr50214365lbb.27.1415017462848; Mon, 03 Nov 2014 04:24:22 -0800 (PST) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id o10si32228180lae.87.2014.11.03.04.24.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 03 Nov 2014 04:24:22 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by mail-la0-f47.google.com with SMTP id gd6so8071067lab.6 for ; Mon, 03 Nov 2014 04:24:22 -0800 (PST) X-Received: by 10.152.6.228 with SMTP id e4mr50520275laa.71.1415017462464; Mon, 03 Nov 2014 04:24:22 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp225350lbz; Mon, 3 Nov 2014 04:24:21 -0800 (PST) X-Received: by 10.229.176.70 with SMTP id bd6mr64090733qcb.12.1415017461143; Mon, 03 Nov 2014 04:24:21 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id q8si29321785qcj.35.2014.11.03.04.24.20 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 03 Nov 2014 04:24:21 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:34062 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlGgG-0007zc-A0 for patch@linaro.org; Mon, 03 Nov 2014 07:24:20 -0500 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 Received: from afflict.kos.to (afflict [92.243.29.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by afflict.kos.to (Postfix) with ESMTPSA id 86924264F1; Mon, 3 Nov 2014 13:02:42 +0100 (CET) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Mon, 3 Nov 2014 14:02:41 +0200 Message-Id: X-Mailer: git-send-email 1.7.10.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 2001:4b98:dc0:45:216:3eff:fe3d:166f Cc: Peter Maydell , Jonas Maebe Subject: [Qemu-devel] [PULL 3/3] elf: take phdr offset into account when calculating the program load address X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: riku.voipio@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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; }