From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 104B91A1DEF for ; Mon, 22 Aug 2016 01:56:06 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP; 22 Aug 2016 01:56:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,559,1464678000"; d="scan'208";a="159254022" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga004.fm.intel.com with ESMTP; 22 Aug 2016 01:56:05 -0700 Received: from fmsmsx102.amr.corp.intel.com (10.18.124.200) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 22 Aug 2016 01:56:05 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX102.amr.corp.intel.com (10.18.124.200) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 22 Aug 2016 01:56:04 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.147]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.8]) with mapi id 14.03.0248.002; Mon, 22 Aug 2016 16:56:03 +0800 From: "Shi, Steven" To: "Gao, Liming" , Ard Biesheuvel CC: edk2-devel-01 Thread-Topic: [edk2] [PATCH] BaseTools/GccBase.lds: don't copy RELA section to PE/COFF Thread-Index: AQHR8uUYug416i7sXkW9+rDfsDieoaBUHLIAgAADKACAAAEVAIAAFsGAgACGWfA= Date: Mon, 22 Aug 2016 08:56:02 +0000 Message-ID: <06C8AB66E78EE34A949939824ABE2B3103390788@shsmsx102.ccr.corp.intel.com> References: <1470819330-7363-1-git-send-email-ard.biesheuvel@linaro.org> <4A89E2EF3DFEDB4C8BFDE51014F606A1155ED770@shsmsx102.ccr.corp.intel.com> <4A89E2EF3DFEDB4C8BFDE51014F606A1155ED825@shsmsx102.ccr.corp.intel.com> In-Reply-To: <4A89E2EF3DFEDB4C8BFDE51014F606A1155ED825@shsmsx102.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYzBiNmVkNzctMTcwYS00NjFmLTg0MTQtNWMzYWI0ODk2NjZiIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IndCZ0xoc20xVmNjZ2pxbEZLaEkrdDdmWUZVejNrV3FVR2ZTcTh5SjNjVms9In0= x-ctpclassification: CTP_IC x-originating-ip: [10.239.127.40] MIME-Version: 1.0 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 08:56:06 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Ard, Your patch rock! Thank you let us know and contribute this optimization.=20 Steven Shi Intel\SSG\STO\UEFI Firmware Tel: +86 021-61166522 iNet: 821-6522 > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > Gao, Liming > Sent: Monday, August 22, 2016 4:47 PM > To: Ard Biesheuvel > Cc: edk2-devel-01 > Subject: Re: [edk2] [PATCH] BaseTools/GccBase.lds: don't copy RELA sectio= n > to PE/COFF >=20 > Ard: > Thanks for the detail information. Your patch makes sense. Reviewed-b= y: > Liming Gao >=20 > > -----Original Message----- > > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > > Ard Biesheuvel > > Sent: Monday, August 22, 2016 3:26 PM > > To: Gao, Liming > > Cc: edk2-devel-01 > > Subject: Re: [edk2] [PATCH] BaseTools/GccBase.lds: don't copy RELA > section > > to PE/COFF > > > > 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 t= o > > >> > be copied into the PE/COFF binary, resulting in waste of space sin= ce > > >> > 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 > > >> > > > _______________________________________________ > > edk2-devel mailing list > > edk2-devel@lists.01.org > > https://lists.01.org/mailman/listinfo/edk2-devel > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel