From patchwork Wed Sep 28 22:51:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Kiper X-Patchwork-Id: 9355099 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 1748F60756 for ; Wed, 28 Sep 2016 22:54:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A6E629529 for ; Wed, 28 Sep 2016 22:54:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F34382964E; Wed, 28 Sep 2016 22:54:13 +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 9F43B29529 for ; Wed, 28 Sep 2016 22:54:13 +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 1bpNi6-0004Ix-N3; Wed, 28 Sep 2016 22:52:18 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpNi5-0004Hx-AV for xen-devel@lists.xenproject.org; Wed, 28 Sep 2016 22:52:17 +0000 Received: from [85.158.143.35] by server-11.bemta-6.messagelabs.com id 92/E3-08498-0A94CE75; Wed, 28 Sep 2016 22:52:16 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrFLMWRWlGSWpSXmKPExsUyZ7p8oO4Czzf hBvfusVt83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBn/58UXHOGvWHNkBlsD4weeLkYuDiGByUwS 71f9ZIZwvjBKzF8/jwnC2cgoMf3UCcYuRg4gZwKjRCNvFyMnB5uAjsTFLw/ZQWwRASWJe6smg 9UzC+xikjh1eSNYvbCAn8TemYkgNSwCqhLta3aygdi8Au4Sh6etYwWxJQQUJbqfTQCLcwp4SP x4+IERxBYCqrm96DsjRI2xRPvbi2wTGPkWMDKsYtQoTi0qSy3SNbTQSyrKTM8oyU3MzNE1NDD Ty00tLk5MT81JTCrWS87P3cQIDBMGINjBeHNjwCFGSQ4mJVHeqcZvwoX4kvJTKjMSizPii0pz UosPMcpwcChJ8F72AMoJFqWmp1akZeYAAxYmLcHBoyQCkeYtLkjMLc5Mh0idYlSUEuddAJIQA ElklObBtcGi5BKjrJQwLyPQIUI8BalFuZklqPKvGMU5GJWEeW+ATOHJzCuBm/4KaDET0OKlJ1 6ALC5JREhJNTAyaJ2dwKMv8mie2yuTt4dmfJ26+18t563npjnmp/xei5q33FXYkx9/etFuhwt yW3/ttxBVE7e6eadHzOq1R+oz6y3nzmw40fZnnkeHmKW8bE2ndvr3xqwc9ftLijtuR0hG/mFm Kb8b2H7wcF25b72Ru/4iPfn7uROPcZ89zn3yTeXbVLuVi5YpsRRnJBpqMRcVJwIAll7tY40CA AA= X-Env-Sender: daniel.kiper@oracle.com X-Msg-Ref: server-10.tower-21.messagelabs.com!1475103134!28917822!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 26310 invoked from network); 28 Sep 2016 22:52:15 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by server-10.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 28 Sep 2016 22:52:15 -0000 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u8SMq2QY012004 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Sep 2016 22:52:02 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id u8SMq1ll014543 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 28 Sep 2016 22:52:02 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u8SMq0Hf021197; Wed, 28 Sep 2016 22:52:01 GMT Received: from olila.local.net-space.pl (/10.175.227.27) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 28 Sep 2016 15:52:00 -0700 From: Daniel Kiper To: xen-devel@lists.xenproject.org Date: Thu, 29 Sep 2016 00:51:23 +0200 Message-Id: <1475103092-27893-5-git-send-email-daniel.kiper@oracle.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1475103092-27893-1-git-send-email-daniel.kiper@oracle.com> References: <1475103092-27893-1-git-send-email-daniel.kiper@oracle.com> X-Source-IP: aserv0022.oracle.com [141.146.126.234] 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 v8 04/13] 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, potentially it may contain 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 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 symbol address from nm output. This way xen ELF image build process is not prone to changes in order of nm output. This patch is prereq for "efi: build xen.gz with EFI code" patch which adds, among others, xen/arch/x86/efi/relocs-dummy.S to xen.gz output. Signed-off-by: Daniel Kiper --- v8 - suggestions/fixes: - use spaces instead of tab in indentation (suggested by Jan Beulich and Konrad Rzeszutek Wilk), - improve commit message (suggested by Jan Beulich). 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 931917d..8e003ff 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$$/0x\1/p'` ALL_OBJS := $(BASEDIR)/arch/x86/boot/built_in.o $(BASEDIR)/arch/x86/efi/built_in.o $(ALL_OBJS)