From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it0-x229.google.com (mail-it0-x229.google.com [IPv6:2607:f8b0:4001:c0b::229]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B2DCD1A1DF8 for ; Mon, 22 Aug 2016 00:25:55 -0700 (PDT) Received: by mail-it0-x229.google.com with SMTP id f6so74931507ith.0 for ; Mon, 22 Aug 2016 00:25:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=9EYo2rxWs4RO3poh6kablbAF3jZtQhf6SGy9ixXQTXY=; b=E4+lED9x0VGb2omsBUAxGk4fqyS+PPYxEnYU3uP3OmZFVf+SimuPPAKp+51dCVhdtK I4v0gxR3vpDk+AfjGOnDJFQQT0/is2xuOUmQQbBOB+WBKutKsttfY3TqBXsP8QRmtoUL kQUeuYGRsYfQUpE902oVaN2VMIss03F4W15Pw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=9EYo2rxWs4RO3poh6kablbAF3jZtQhf6SGy9ixXQTXY=; b=bMBxQ8FOq6KdmO1wo8LTSB+bxAn8qoZUnAQW8PwfywxEdmo1dFkTHKocG/CmpzMf/q eEuY5uy55rBoaW75NdwfqYekeakQ2uySmgX3UTyYdAopK3WuKTnzv6PXW8MNieAsr1jA 1kWXUiDa2goilbJ35/uPQaOTQrP+oBh71y0zJqJHDzd7KFHL/54V24hUtIKSBm1c9iFs mGI81GPbUOfyv1oBni6/eyypXziNufJzVWg3wdOwqebQAv/hlCL9zyflcSKrBjy8iWTL VOPXUFE2LCajzT5kuAFB/e8RC50kIcRW8qr82Fuf8PpKbzBc2HrIvYCWWRRwe0+Gnggf Xinw== X-Gm-Message-State: AEkoouu9h2jB0m0sRnO/A1aVvGRWryrMeivIEKz06oNcgjx0VLi2eKIxqyBaBDn/zI5sBKzCmqA0hpu/RyoumBS+ X-Received: by 10.36.57.215 with SMTP id l206mr20125045ita.5.1471850754944; Mon, 22 Aug 2016 00:25:54 -0700 (PDT) MIME-Version: 1.0 Received: by 10.36.204.195 with HTTP; Mon, 22 Aug 2016 00:25:54 -0700 (PDT) In-Reply-To: <4A89E2EF3DFEDB4C8BFDE51014F606A1155ED770@shsmsx102.ccr.corp.intel.com> References: <1470819330-7363-1-git-send-email-ard.biesheuvel@linaro.org> <4A89E2EF3DFEDB4C8BFDE51014F606A1155ED770@shsmsx102.ccr.corp.intel.com> From: Ard Biesheuvel Date: Mon, 22 Aug 2016 09:25:54 +0200 Message-ID: To: "Gao, Liming" Cc: "Shi, Steven" , "Zhu, Yonghong" , edk2-devel-01 Subject: Re: [PATCH] BaseTools/GccBase.lds: don't copy RELA section to PE/COFF X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Aug 2016 07:25:56 -0000 Content-Type: text/plain; charset=UTF-8 On 22 August 2016 at 09:22, Gao, Liming wrote: > Ard: > Sorry. I miss this patch. GccBase.lds is used by GCC44~GCC5. GCC44~GCC49 doesn't enable LTO, GCC5 enables LTO. That means RELA section is not used with LTO or without LTO. Right? The allocatable RELA section is only emitted when linking a PIE binary (i.e., the -pie linker switch, not the -fpie compiler switch). It contains ELF relocations that the PE/COFF loader does not understand. CLANG38LTO is the first toolchain to use the -pie linker switch, GCC5 does use PIE objects but does not create a PIE binary at link time. In some cases, (i.e., when we add support for GOT based relocations), the contents of this RELA section must be taken into account by GenFw, but currently, it can only contain relocations that are duplicates of the relocations we encounter in the non-allocatable RELA sections (.rela.text, .rela.data etc etc) So it never makes sense to copy it into the PE/COFF binary, regardless of whether we inspect its contents or not. -- Ard. > > Thanks > Liming >> -----Original Message----- >> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org] >> Sent: Monday, August 22, 2016 3:11 PM >> To: Shi, Steven ; Zhu, Yonghong >> ; Gao, Liming ; edk2- >> devel-01 >> Cc: Ard Biesheuvel >> Subject: Re: [PATCH] BaseTools/GccBase.lds: don't copy RELA section to >> PE/COFF >> >> On 10 August 2016 at 10:55, Ard Biesheuvel >> wrote: >> > The CLANG38 toolchain creates a PIE binary at link time. This is >> > necessary since the LTO code generation may otherwise result in >> > code that cannot execute correctly when loaded above 2 GB. >> > >> > PIE executables contain a RELA section consisting of dynamic >> > relocation entries that are intended for consumption by the loader >> > at runtime. For this reason, it has the SHF_ALLOC attribute set by >> > default, and will be identified by GenFw as a section that needs to >> > be copied into the PE/COFF binary, resulting in waste of space since >> > the PE/COFF loader does not use this data at all. >> > >> > So mark the RELA section as informational: this will prevent the >> > linker from setting the SHF_ALLOC attribute, causing GenFw to >> > ignore it. >> > >> > DxeCore.efi before: >> > >> > Detected 'X64' type PE/COFF image consisting of 3 sections >> > Section alignment: 0x40 >> > File alignment: 0x40 >> > Section '.text' @ 0x00000240 >> > File offset: 0x240 >> > Virtual size: 0x21000 >> > Raw size: 0x21000 >> > Section '.data' @ 0x00021240 >> > File offset: 0x21240 >> > Virtual size: 0x3640 >> > Raw size: 0x3640 >> > Section '.reloc' @ 0x00024880 >> > File offset: 0x24880 >> > Virtual size: 0x280 >> > Raw size: 0x280 >> > >> > DxeCore.efi after: >> > >> > Detected 'X64' type PE/COFF image consisting of 3 sections >> > Section alignment: 0x40 >> > File alignment: 0x40 >> > Section '.text' @ 0x00000240 >> > File offset: 0x240 >> > Virtual size: 0x1f440 >> > Raw size: 0x1f440 >> > Section '.data' @ 0x0001f680 >> > File offset: 0x1f680 >> > Virtual size: 0x3640 >> > Raw size: 0x3640 >> > Section '.reloc' @ 0x00022cc0 >> > File offset: 0x22cc0 >> > Virtual size: 0x280 >> > Raw size: 0x280 >> > >> > Contributed-under: TianoCore Contribution Agreement 1.0 >> > Signed-off-by: Ard Biesheuvel >> >> Steven, Liming: any comments? >> >> > --- >> > BaseTools/Scripts/GccBase.lds | 2 +- >> > 1 file changed, 1 insertion(+), 1 deletion(-) >> > >> > diff --git a/BaseTools/Scripts/GccBase.lds b/BaseTools/Scripts/GccBase.lds >> > index 281af8a9bd33..900848747144 100644 >> > --- a/BaseTools/Scripts/GccBase.lds >> > +++ b/BaseTools/Scripts/GccBase.lds >> > @@ -54,7 +54,7 @@ SECTIONS { >> > KEEP (*(.eh_frame)) >> > } >> > >> > - .rela ALIGN(CONSTANT(COMMONPAGESIZE)) : { >> > + .rela (INFO) : { >> > *(.rela .rela.*) >> > } >> > >> > -- >> > 2.7.4 >> >