From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by ml01.01.org (Postfix) with ESMTP id 975401A1E27 for ; Mon, 1 Aug 2016 07:18:05 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP; 01 Aug 2016 07:18:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,455,1464678000"; d="scan'208,217";a="1032961159" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga002.fm.intel.com with ESMTP; 01 Aug 2016 07:18:04 -0700 Received: from fmsmsx118.amr.corp.intel.com (10.18.116.18) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 1 Aug 2016 07:18:04 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx118.amr.corp.intel.com (10.18.116.18) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 1 Aug 2016 07:18:04 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.147]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.150]) with mapi id 14.03.0248.002; Mon, 1 Aug 2016 22:18:02 +0800 From: "Gao, Liming" To: 'Ard Biesheuvel' , "Shi, Steven" , "Zhu, Yonghong" , "Justen, Jordan L" , "edk2-devel@lists.01.org" CC: "lersek@redhat.com" , "leif.lindholm@linaro.org" Thread-Topic: [edk2] [PATCH v5 7/8] MdePkg GCC/X64: avoid 'hidden' visibility for module entry points Thread-Index: AQHR68sX1YXE81CPpEGCgS3W14qzHaAz3ajA Date: Mon, 1 Aug 2016 14:18:02 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A1155E30DE@shsmsx102.ccr.corp.intel.com> References: <1470038497-2536-1-git-send-email-ard.biesheuvel@linaro.org> <1470038497-2536-8-git-send-email-ard.biesheuvel@linaro.org> In-Reply-To: <1470038497-2536-8-git-send-email-ard.biesheuvel@linaro.org> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_PUBLIC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiN2NjZmJjMjMtOTE0OC00NzllLTllOGMtZmVlYTU5MjNjYjQzIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX1BVQkxJQyJ9XX1dfSwiU3ViamVjdExhYmVscyI6W10sIlRNQ1ZlcnNpb24iOiIxNS45LjYuNiIsIlRydXN0ZWRMYWJlbEhhc2giOiJxSmZ4bW9YbXc3WUVVTTF0R2c4Uzl3UHl3UW03NFZvSUJzd3QxTzQyWGZnPSJ9 x-originating-ip: [10.239.127.40] MIME-Version: 1.0 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 Subject: Re: [PATCH v5 7/8] MdePkg GCC/X64: avoid 'hidden' visibility for module entry points 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, 01 Aug 2016 14:18:05 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Ard: I don't think it is good way to define GCC_VISIBILITY_PROTECTED and apply= it in EntryPointLib. We only need to expose _ModuleEntryPoint. It has been= specified in LINK_FLAGS in tools_def.txt. Could we also specify its attrib= ute in CC_FLAGS or LINK_FLAGS in tools_def.txt? Thanks Liming > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > Ard Biesheuvel > Sent: Monday, August 01, 2016 4:02 PM > To: Shi, Steven ; Zhu, Yonghong > ; Gao, Liming ; Justen, > Jordan L ; edk2-devel@lists.01.org > Cc: lersek@redhat.com; leif.lindholm@linaro.org; Ard Biesheuvel > > Subject: [edk2] [PATCH v5 7/8] MdePkg GCC/X64: avoid 'hidden' visibility = for > module entry points > > When building with LTO enabled, the LTO routines infer from the 'hidden' > visibility of the _ModuleEntryPoint symbol that its code only needs to be > retained if it is referenced internally, and disregards the fact that > it is referenced by the entry point field in the ELF metadata. > > This is arguably a bug in LTO, but we can work around it by ensuring that > the _ModuleEntryPoint symbol is emitted with protected visibility instead= . > > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Ard Biesheuvel > --- > MdePkg/Include/X64/ProcessorBind.h | 9 ++++++++- > MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf | 2 ++ > MdePkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoint.inf | 2 ++ > MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf | 2 ++ > MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf | = 2 > ++ > MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf | 2 ++ > 6 files changed, 18 insertions(+), 1 deletion(-) > > diff --git a/MdePkg/Include/X64/ProcessorBind.h > b/MdePkg/Include/X64/ProcessorBind.h > index 666cc8e8bd16..e45b9cba2bb3 100644 > --- a/MdePkg/Include/X64/ProcessorBind.h > +++ b/MdePkg/Include/X64/ProcessorBind.h > @@ -29,13 +29,20 @@ > > #if defined(__GNUC__) && defined(__pic__) > // > -// Mark all symbol declarations and references as hidden, meaning they w= ill > +// Mark all symbol declarations and references as hidden*, meaning they > will > // not be subject to symbol preemption. This allows the compiler to refer= to > // symbols directly using relative references rather than via the GOT, wh= ich > // contains absolute symbol addresses that are subject to runtime relocat= ion. > // > +// * Under LTO, the entry point of a module must have protected or defau= lt > +// visibility to prevent it from being pruned. > +// > +#ifdef GCC_VISIBILITY_PROTECTED > +#pragma GCC visibility push (protected) > +#else > #pragma GCC visibility push (hidden) > #endif > +#endif > > #if defined(__INTEL_COMPILER) > // > diff --git a/MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf > b/MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf > index 01f64c34c7a1..2d6f87ed062e 100644 > --- a/MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf > +++ b/MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf > @@ -39,3 +39,5 @@ [LibraryClasses] > BaseLib > DebugLib > > +[BuildOptions] > + GCC:*_*_X64_CC_FLAGS =3D -DGCC_VISIBILITY_PROTECTED > diff --git a/MdePkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoint.inf > b/MdePkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoint.inf > index d920306713c5..4e61783b3bd5 100644 > --- a/MdePkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoint.inf > +++ b/MdePkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoint.inf > @@ -37,3 +37,5 @@ [LibraryClasses] > BaseLib > DebugLib > > +[BuildOptions] > + GCC:*_*_X64_CC_FLAGS =3D -DGCC_VISIBILITY_PROTECTED > diff --git a/MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf > b/MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf > index a2db9e058bbe..adfd91bdc57e 100644 > --- a/MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf > +++ b/MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf > @@ -37,3 +37,5 @@ [Packages] > [LibraryClasses] > DebugLib > > +[BuildOptions] > + GCC:*_*_X64_CC_FLAGS =3D -DGCC_VISIBILITY_PROTECTED > diff --git > a/MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf > b/MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf > index be92b3dc0760..9525c55c2051 100644 > --- > a/MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf > +++ > b/MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf > @@ -38,3 +38,5 @@ [LibraryClasses] > DebugLib > BaseLib > > +[BuildOptions] > + GCC:*_*_X64_CC_FLAGS =3D -DGCC_VISIBILITY_PROTECTED > diff --git a/MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf > b/MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf > index 7a9dcbcd4df2..8d30b1197850 100644 > --- a/MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf > +++ b/MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf > @@ -65,3 +65,5 @@ [Depex.common.UEFI_DRIVER] > gEfiVariableArchProtocolGuid AND > gEfiWatchdogTimerArchProtocolGuid > > +[BuildOptions] > + GCC:*_*_X64_CC_FLAGS =3D -DGCC_VISIBILITY_PROTECTED > -- > 2.7.4 > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel