From patchwork Wed Jun 24 08:18:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 50254 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 05CE8228FC for ; Wed, 24 Jun 2015 08:19:15 +0000 (UTC) Received: by lbcak1 with SMTP id ak1sf8929266lbc.2 for ; Wed, 24 Jun 2015 01:19:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mime-version:in-reply-to:references :date:message-id:from:to:subject:precedence:reply-to:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :content-type:content-transfer-encoding:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=IZ9ynBwO8Htmixi5M0L/JL15Ff1MwMlJcpvjNXL1nj8=; b=A2NnMORDSHlgLTQZfx0NHfo+BXG9CToR1PlfI9p3UrHbg/82GZp2w3xIuH7J3rCx4a 6xoA3PJ1DaAayDPRJ0n1jrhC1//nqDqrAMouAhSpyGCdOpTdhBZtaMypANeCBq8hB3t1 LuWNRCw52oOiY6lPbqfYKHgf0wf8wiZ5fs+/+QlGTm+sdhK23lr1dUMqlgAyXXGqAdAD Oehz4PO1R+J9xzg7zK+LaudBxqhXb/txGskHrn/svqAgfJ5sdiU8KpGBsi2AhryYLwRF f8Lqte6nmJbkfrKefXeowJUS5fB2vjyugTZxC+jxW46pDLLrzzIW8YQ2W25a/p3CYS/B 9BbA== X-Gm-Message-State: ALoCoQkCapdHuMSudhJ2+q1Q9/wK9HzGde6PtN85dJXaYq7YnO/6fga2aOrFakiVdJa8vpckosBE X-Received: by 10.152.88.70 with SMTP id be6mr15804677lab.9.1435133953963; Wed, 24 Jun 2015 01:19:13 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.120.71 with SMTP id la7ls157220lab.25.gmail; Wed, 24 Jun 2015 01:19:13 -0700 (PDT) X-Received: by 10.112.47.73 with SMTP id b9mr38702049lbn.46.1435133953813; Wed, 24 Jun 2015 01:19:13 -0700 (PDT) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com. [209.85.217.181]) by mx.google.com with ESMTPS id cy4si21401160lac.57.2015.06.24.01.19.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Jun 2015 01:19:13 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) client-ip=209.85.217.181; Received: by lbnk3 with SMTP id k3so21658309lbn.1 for ; Wed, 24 Jun 2015 01:19:13 -0700 (PDT) X-Received: by 10.112.209.106 with SMTP id ml10mr38385605lbc.112.1435133953516; Wed, 24 Jun 2015 01:19:13 -0700 (PDT) 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.108.230 with SMTP id hn6csp3622392lbb; Wed, 24 Jun 2015 01:19:12 -0700 (PDT) X-Received: by 10.50.30.105 with SMTP id r9mr1590113igh.11.1435133951846; Wed, 24 Jun 2015 01:19:11 -0700 (PDT) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id c101si14195897ioj.30.2015.06.24.01.19.11 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 24 Jun 2015 01:19:11 -0700 (PDT) Received-SPF: pass (google.com: domain of edk2-devel-bounces@lists.sourceforge.net designates 216.34.181.88 as permitted sender) client-ip=216.34.181.88; Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1Z7ftd-0003SN-AY; Wed, 24 Jun 2015 08:19:01 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1Z7ftb-0003SH-Qx for edk2-devel@lists.sourceforge.net; Wed, 24 Jun 2015 08:18:59 +0000 Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of linaro.org designates 209.85.223.169 as permitted sender) client-ip=209.85.223.169; envelope-from=ard.biesheuvel@linaro.org; helo=mail-ie0-f169.google.com; Received: from mail-ie0-f169.google.com ([209.85.223.169]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1Z7ftZ-0003vz-Hj for edk2-devel@lists.sourceforge.net; Wed, 24 Jun 2015 08:18:59 +0000 Received: by iebmu5 with SMTP id mu5so28349852ieb.1 for ; Wed, 24 Jun 2015 01:18:52 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.107.163.146 with SMTP id m140mr51777292ioe.85.1435133932012; Wed, 24 Jun 2015 01:18:52 -0700 (PDT) Received: by 10.36.138.69 with HTTP; Wed, 24 Jun 2015 01:18:51 -0700 (PDT) In-Reply-To: <4A89E2EF3DFEDB4C8BFDE51014F606A111A85168@shsmsx102.ccr.corp.intel.com> References: <1435047559-58044-1-git-send-email-yingke.d.liu@intel.com> <4A89E2EF3DFEDB4C8BFDE51014F606A111A85168@shsmsx102.ccr.corp.intel.com> Date: Wed, 24 Jun 2015 10:18:51 +0200 Message-ID: From: Ard Biesheuvel To: "edk2-devel@lists.sourceforge.net" X-Spam-Score: -1.5 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1Z7ftZ-0003vz-Hj Subject: Re: [edk2] [Patch 2/3] BaseTools: Update GenFw to support 4K alignment. X-BeenThere: edk2-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list Reply-To: edk2-devel@lists.sourceforge.net List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: edk2-devel-bounces@lists.sourceforge.net X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@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.217.181 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 On 24 June 2015 at 10:15, Gao, Liming wrote: > Ard: > Good suggestion. How about go through every Shdr and choose the max Shdr->sh_addralign? The alignment should be power of 2. > Indeed. Something like this seems to work fine: """ """ Note that we may want to use 64 KB instead of 4 KB on AArch64, since the OS may use 64 KB pages. So we should avoid hardcoding 4 KB values for section alignment. diff --git a/BaseTools/Source/C/GenFw/Elf64Convert.c b/BaseTools/Source/C/GenFw/Elf64Convert.c index 2266e487cec7..4025191e868e 100644 --- a/BaseTools/Source/C/GenFw/Elf64Convert.c +++ b/BaseTools/Source/C/GenFw/Elf64Convert.c @@ -97,7 +97,7 @@ STATIC Elf_Phdr *mPhdrBase; // // Coff information // -STATIC const UINT32 mCoffAlignment = 0x20; +STATIC UINT32 mCoffAlignment = 0x20; // // PE section alignment. @@ -286,6 +286,20 @@ ScanSections64 ( mCoffOffset += mCoffNbrSections * sizeof(EFI_IMAGE_SECTION_HEADER); // + // Set mCoffAlignment to the maximum alignment of the input sections + // we care about + // + for (i = 0; i < mEhdr->e_shnum; i++) { + Elf_Shdr *shdr = GetShdrByIndex(i); + if (shdr->sh_addralign <= mCoffAlignment) { + continue; + } + if (IsTextShdr(shdr) || IsDataShdr(shdr) || IsHiiRsrcShdr(shdr)) { + mCoffAlignment = shdr->sh_addralign; + } + } + + // // First text sections. // mCoffOffset = CoffAlign(mCoffOffset);