From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by ml01.01.org (Postfix) with ESMTP id 987691A1E24 for ; Mon, 1 Aug 2016 19:50:13 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP; 01 Aug 2016 19:50:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,458,1464678000"; d="scan'208";a="1017967950" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga001.fm.intel.com with ESMTP; 01 Aug 2016 19:50:13 -0700 Received: from fmsmsx154.amr.corp.intel.com (10.18.116.70) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 1 Aug 2016 19:50:12 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX154.amr.corp.intel.com (10.18.116.70) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 1 Aug 2016 19:50:12 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.147]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.107]) with mapi id 14.03.0248.002; Tue, 2 Aug 2016 10:49:40 +0800 From: "Gao, Liming" To: Ard Biesheuvel , "Shi, Steven" , "Zhu, Yonghong" , "Justen, Jordan L" , "edk2-devel@lists.01.org" Thread-Topic: [PATCH] MdePkg: move to 'hidden' visibility for all symbols under GCC/X64 Thread-Index: AQHR68H+HhV4I7kd3E+dEnPV7XH4LqA0+Weg Date: Tue, 2 Aug 2016 02:49:40 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A1155E3E3A@shsmsx102.ccr.corp.intel.com> References: <1470034640-3912-1-git-send-email-ard.biesheuvel@linaro.org> In-Reply-To: <1470034640-3912-1-git-send-email-ard.biesheuvel@linaro.org> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] MdePkg: move to 'hidden' visibility for all symbols under GCC/X64 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: Tue, 02 Aug 2016 02:50:13 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao > -----Original Message----- > From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org] > Sent: Monday, August 01, 2016 2:57 PM > To: Shi, Steven ; Zhu, Yonghong > ; Gao, Liming ; Justen, > Jordan L ; edk2-devel@lists.01.org > Cc: Ard Biesheuvel > Subject: [PATCH] MdePkg: move to 'hidden' visibility for all symbols unde= r > GCC/X64 >=20 > When using GCC to build for X64, we switched to the position independent > small code model, which is much more efficient in terms of code generatio= n > and runtime relocation footprint, and produces binaries that can execute > correctly from any offset. >=20 > However, the PIC routines are by default geared towards hosted binaries > containing symbol references that may resolve to definitions in other > dynamic objects, and for this reason, external symbol references are > indirected via a GOT entry by default (which also results in a .reloc fix= up > entry) unless we annotate them. >=20 > For this reason, we introduced the 'protected' visibility annotation for > all symbol definitions and references, by setting the GCC visibility > pragma. However, as it turns out, this is not sufficient for all versions > of GCC, and in some cases (GCC 5.x using the GCC49 toolchain tag), may > still result in GOT based relocations. >=20 > So switch to 'hidden' visibility instead, which is slightly stronger, and > fixes this issue for the versions of GCC that exhibit the problem. >=20 > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Ard Biesheuvel > --- > MdePkg/Include/X64/ProcessorBind.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/MdePkg/Include/X64/ProcessorBind.h > b/MdePkg/Include/X64/ProcessorBind.h > index a4aad3e524e8..666cc8e8bd16 100644 > --- a/MdePkg/Include/X64/ProcessorBind.h > +++ b/MdePkg/Include/X64/ProcessorBind.h > @@ -29,12 +29,12 @@ >=20 > #if defined(__GNUC__) && defined(__pic__) > // > -// Mark all symbol declarations and references as protected, meaning the= y > will > +// Mark all symbol declarations and references as hidden, meaning they w= ill > // not be subject to symbol preemption. This allows the compiler to refe= r to > // symbols directly using relative references rather than via the GOT, w= hich > // contains absolute symbol addresses that are subject to runtime reloca= tion. > // > -#pragma GCC visibility push (protected) > +#pragma GCC visibility push (hidden) > #endif >=20 > #if defined(__INTEL_COMPILER) > -- > 2.7.4