From patchwork Tue Jun 16 11:55:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 49957 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 08D86228F8 for ; Tue, 16 Jun 2015 11:56:21 +0000 (UTC) Received: by lbcak1 with SMTP id ak1sf3889984lbc.2 for ; Tue, 16 Jun 2015 04:56:20 -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=aTgOqWDmUWuEYlSIPJOfHWvAz5EaSNh4HRlzqqQaiJY=; b=NQIWvQc1BVhKHI1IDnel/npSaMT4tWA1XrPhT3J4WUSJyjMv4wyBo/ApFp8CfJDc83 VfVlQkh9M/EneZhAF+yTRLb7tHpIAzknU5rDfPJWiTTobkuAogCSrlq/ELzZBkikXsNz e2zaxyYGuJSzcPviy2bRL82K1fZyeyN4WkDNfLMnfSb59dg0ExGIrr0Zr2OvZHPhKpEp +1AwwkW4A003gKeaAN6P/oioiu/crVbDCeEDDasLOk0VTLzUpfIE4yIQVKU3WxOcIhuv 7Gv0gnchRlXLq+3OIuZE/X/DPE7Jl/fWeoT5K4niP4UOK6hV50wcdK10YboNJ0cKQir7 St+g== X-Gm-Message-State: ALoCoQnbnhKgtMijZABYO11l0EVNhZuJAiA8EgXnyB9q4xbw/O+o+oQe492uivx7jWzu5EkEYL/i X-Received: by 10.180.73.137 with SMTP id l9mr2808455wiv.5.1434455779989; Tue, 16 Jun 2015 04:56:19 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.170.201 with SMTP id ao9ls94655lac.9.gmail; Tue, 16 Jun 2015 04:56:19 -0700 (PDT) X-Received: by 10.152.6.132 with SMTP id b4mr20594389laa.53.1434455779824; Tue, 16 Jun 2015 04:56:19 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id yi7si621006lbb.14.2015.06.16.04.56.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jun 2015 04:56:19 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by labbc20 with SMTP id bc20so9511962lab.1 for ; Tue, 16 Jun 2015 04:56:19 -0700 (PDT) X-Received: by 10.112.222.133 with SMTP id qm5mr6813496lbc.86.1434455779378; Tue, 16 Jun 2015 04:56:19 -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 hn6csp2064140lbb; Tue, 16 Jun 2015 04:56:18 -0700 (PDT) X-Received: by 10.107.170.65 with SMTP id t62mr35298090ioe.71.1434455777762; Tue, 16 Jun 2015 04:56:17 -0700 (PDT) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id q142si554104ioe.75.2015.06.16.04.56.16 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 16 Jun 2015 04:56:17 -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-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1Z4pTI-0004FC-Kv; Tue, 16 Jun 2015 11:56:04 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1Z4pTH-0004F1-Pq for edk2-devel@lists.sourceforge.net; Tue, 16 Jun 2015 11:56:03 +0000 Received-SPF: pass (sog-mx-3.v43.ch3.sourceforge.com: domain of linaro.org designates 209.85.223.177 as permitted sender) client-ip=209.85.223.177; envelope-from=ard.biesheuvel@linaro.org; helo=mail-ie0-f177.google.com; Received: from mail-ie0-f177.google.com ([209.85.223.177]) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1Z4pTG-00020v-TC for edk2-devel@lists.sourceforge.net; Tue, 16 Jun 2015 11:56:03 +0000 Received: by iecrd14 with SMTP id rd14so10965258iec.3 for ; Tue, 16 Jun 2015 04:55:57 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.107.163.146 with SMTP id m140mr41168370ioe.85.1434455757603; Tue, 16 Jun 2015 04:55:57 -0700 (PDT) Received: by 10.36.138.69 with HTTP; Tue, 16 Jun 2015 04:55:57 -0700 (PDT) In-Reply-To: References: Date: Tue, 16 Jun 2015 13:55:57 +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: 1Z4pTG-00020v-TC Subject: Re: [edk2] [PATCH] BaseTools for AArch64 GCC: Ensure that the correlation .text and .data is consistent between ELF and PE-COFF so the debugger sees global variables correctly 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.215.52 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 4 June 2015 at 21:48, Cohen, Eugene wrote: > Oops, left off the contribution agreement line, trying again > > Dear ArmPkg maintainers (and later BaseTools maintainer), > > This is a fix for debugger correlation of global variables for AArch64 built on GCC. > > Before this change looking at global variables with a debugger showed bogus memory locations. This is because the offset of the .data section in the ELF file did not reflect where it was placed in the PE-COFF (.efi) output. > > This change passes a linker control script so that the data section is packed next to .text so the ELF accurately reflects the relationship between the sections when converted to PE-COFF by GenFw. > > I have tested this with the Lauterbach debugger. I don't know how well it will work with other debuggers and debug scripts. > > If you would rather view the change as a github pull request: > https://github.com/tianocore/edk2/pull/12 > > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Eugene Cohen > Could you please send patches inline? Attachments are a pain to review. Also, since the patch introduces a completely new linker script, it is hard to review how yours deviates from the default. Git is actually quite helpful since it can figure out if your newly introduced file resembles an existing file, and only shows the diff with respect to the original. Applying your patch and doing 'git show --find-copies-harder' gives me (tools_def.tempate omitted): """ + . = 0; .text ALIGN(0x20) : { *(.text .stub .text.* .gnu.linkonce.t.*) """ So are you saying that the resulting PE/COFF is identical (for all intents and purposes), and only the ELF intermediate file deviates? How does this affect ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.inf, which outputs lines like add-symbol-file /home/ard/build/uefi-next/Build/ArmVirtQemu-AARCH64/DEBUG_GCC48/AARCH64/MdeModulePkg/Core/Dxe/DxeMain/DEBUG/DxeCore.dll 0x5F2C7260 where the .dll is and ELF file, and the line seems to incorporate the header offset that you are removing. Regards, Ard. ------------------------------------------------------------------------------ diff --git a/BaseTools/Scripts/gcc4.4-ld-script b/BaseTools/Scripts/gcc-arm-ld-script similarity index 59% copy from BaseTools/Scripts/gcc4.4-ld-script copy to BaseTools/Scripts/gcc-arm-ld-script index 68b2767590ac..e1589a4d03bf 100644 --- a/BaseTools/Scripts/gcc4.4-ld-script +++ b/BaseTools/Scripts/gcc-arm-ld-script @@ -1,8 +1,10 @@ -/* OUTPUT_FORMAT(efi-bsdrv-x86_64) */ SECTIONS { - /* . = 0 + SIZEOF_HEADERS; */ - . = 0x280; + /* Start at 0 so we can meet more aggressive alignment requires after the PE-COFF conversion + like those for ARM exception vectors. This requires debugger scripts to offset past + the PE-COFF header (typically 0x260). When the PE-COFF conversion occurs we will + get proper alignment since the ELF section alignment is applied in the conversion process. */