From patchwork Fri Sep 23 21:47:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Kiper X-Patchwork-Id: 9348907 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C772260B16 for ; Fri, 23 Sep 2016 21:51:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA1DC2AE49 for ; Fri, 23 Sep 2016 21:51:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A5DE32AE56; Fri, 23 Sep 2016 21:51:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D58E52AE49 for ; Fri, 23 Sep 2016 21:51:03 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bnYKX-0003nH-Jq; Fri, 23 Sep 2016 21:48:25 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bnYKV-0003mV-VJ for xen-devel@lists.xenproject.org; Fri, 23 Sep 2016 21:48:24 +0000 Received: from [193.109.254.147] by server-9.bemta-6.messagelabs.com id 3E/EF-28857-723A5E75; Fri, 23 Sep 2016 21:48:23 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrLLMWRWlGSWpSXmKPExsUyZ7p8oK7a4qf hBgf2WFh83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBnTj+5iLjjHU3H75QW2BsYjXF2MXBxCAm1M EpfeP2eGcL4wSryfcZEJwtnAKPHyXj9rFyMnkDORUeLJRlkQm01AR+Lil4fsILaIgJLEvVWTw RqYBXYxSZy6vJERJCEs4Ccxv6+fGcRmEVCVmPRxGguIzSvgLvHxXyuYLSGgKNH9bAIbiM0p4C Fx/cl6Fohl7hJbm5cxQtQYSpx+uI1xAiPfAkaGVYwaxalFZalFukZmeklFmekZJbmJmTm6hgZ mermpxcWJ6ak5iUnFesn5uZsYgcHCAAQ7GM8sCDzEKMnBpCTKy1/3NFyILyk/pTIjsTgjvqg0 J7X4EKMMB4eSBK/pIqCcYFFqempFWmYOMGxh0hIcPEoivPsXAqV5iwsSc4sz0yFSpxgVpcR5T 4EkBEASGaV5cG2wWLnEKCslzMsIdIgQT0FqUW5mCar8K0ZxDkYlYV6fuUBTeDLzSuCmvwJazA S0+NudJyCLSxIRUlINjAqc1d/1rq1t5n0mVLPjIC9DDH/8iku+tlqPG+bM/nfcN/iho9SXc+t 2d7/+MHn9+ovnwyff9WEJujn7sPqWpTn3H13mlDt+8YU+r8T3hEvPpb5Grdi2aOUDP+79rsaN rJk3Oxf4tfPN/P6w3CB2nXJBFd+XpMn7mAN750XHTG5tmM/V5L9zylclluKMREMt5qLiRACRc JqokAIAAA== X-Env-Sender: daniel.kiper@oracle.com X-Msg-Ref: server-2.tower-27.messagelabs.com!1474667301!8524957!1 X-Originating-IP: [156.151.31.81] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTU2LjE1MS4zMS44MSA9PiAyODgzMzk=\n X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 52023 invoked from network); 23 Sep 2016 21:48:22 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by server-2.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 23 Sep 2016 21:48:22 -0000 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u8NLmBO3023621 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 23 Sep 2016 21:48:12 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u8NLmBNN032682 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 23 Sep 2016 21:48:11 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u8NLmA9u015735; Fri, 23 Sep 2016 21:48:11 GMT Received: from olila.local.net-space.pl (/10.175.174.211) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 23 Sep 2016 14:48:10 -0700 From: Daniel Kiper To: xen-devel@lists.xenproject.org Date: Fri, 23 Sep 2016 23:47:27 +0200 Message-Id: <1474667259-27290-3-git-send-email-daniel.kiper@oracle.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1474667259-27290-1-git-send-email-daniel.kiper@oracle.com> References: <1474667259-27290-1-git-send-email-daniel.kiper@oracle.com> X-Source-IP: userv0021.oracle.com [156.151.31.71] Cc: jgross@suse.com, sstabellini@kernel.org, andrew.cooper3@citrix.com, cardoe@cardoe.com, pgnet.dev@gmail.com, ning.sun@intel.com, julien.grall@arm.com, david.vrabel@citrix.com, jbeulich@suse.com, qiaowei.ren@intel.com, gang.wei@intel.com, fu.wei@linaro.org Subject: [Xen-devel] [PATCH v7 02/14] x86: properly calculate xen ELF end of image address X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Currently xen ELF end of image address is calculated using first line from "nm -nr xen/xen-syms" output. However, sometimes it may contain random symbol address not related to the end of image in any way. It can happen if a symbol is introduced with address larger than __end_of_image__ symbol address. Such situation encountered when I linked xen ELF binary with xen/arch/x86/efi/relocs-dummy.S. Then first line from "nm -nr xen/xen-syms" contained "ffff82d0c0000000 A ALT_START" and xen ELF image memory size was silently set to 1023 MiB. This issue happened because there is no check which symbol address is used to calculate end of image address. So, let's fix it and take ELF end of image address by reading __end_of_image__ symbol address from nm output. This way xen ELF image build process is not prone to changes in order of nm output. Signed-off-by: Daniel Kiper --- v7 - suggestions/fixes: - use sed instead of awk (suggested by Jan Beulich), - improve commit message (suggested by Jan Beulich). --- xen/arch/x86/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index d3875c5..c3a8920 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -91,7 +91,7 @@ endif $(TARGET): $(TARGET)-syms $(efi-y) boot/mkelf32 ./boot/mkelf32 $(notes_phdrs) $(TARGET)-syms $(TARGET) 0x100000 \ - `$(NM) -nr $(TARGET)-syms | head -n 1 | sed -e 's/^\([^ ]*\).*/0x\1/'` + `$(NM) $(TARGET)-syms | sed -ne 's/^\([^ ]*\) . __end_of_image__$$/0x\1/p'` .PHONY: tests tests: