public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: edk2-devel@lists.01.org
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	Michael D Kinney <michael.d.kinney@intel.com>,
	Liming Gao <liming.gao@intel.com>, Ruiyu Ni <ruiyu.ni@intel.com>,
	Hao Wu <hao.a.wu@intel.com>,
	Leif Lindholm <leif.lindholm@linaro.org>,
	Jordan Justen <jordan.l.justen@intel.com>,
	Andrew Fish <afish@apple.com>, Star Zeng <star.zeng@intel.com>,
	Eric Dong <eric.dong@intel.com>, Laszlo Ersek <lersek@redhat.com>,
	Zenith432 <zenith432@users.sourceforge.net>,
	"Shi, Steven" <steven.shi@intel.com>
Subject: [RFC PATCH 11/11] MdePkg/ProcessorBind.h X64: drop non-LTO limitation on visiblity override
Date: Tue, 12 Jun 2018 17:23:06 +0200	[thread overview]
Message-ID: <20180612152306.25998-12-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <20180612152306.25998-1-ard.biesheuvel@linaro.org>

When LTO is in effect, overriding the symbol visibility to 'hidden'
using a GCC pragma used to result in module entry points being discarded,
and along with them all other code in the binary.

Now that we annotated all module entry points explicitly as having
'default' visibility, this is no longer the case, and we can drop this
restriction. This prevents GCC's LTO code generator from emitting GOT
based relocations that are non-trivial to deal with in GenFw.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 MdePkg/Include/X64/ProcessorBind.h | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/MdePkg/Include/X64/ProcessorBind.h b/MdePkg/Include/X64/ProcessorBind.h
index 38ef2665390f..7f78489bc2c4 100644
--- a/MdePkg/Include/X64/ProcessorBind.h
+++ b/MdePkg/Include/X64/ProcessorBind.h
@@ -27,18 +27,24 @@
 #pragma pack()
 #endif
 
-#if defined(__GNUC__) && defined(__pic__) && !defined(USING_LTO)
+#if defined(__GNUC__) && defined(__pic__)
 //
 // 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, which
 // contains absolute symbol addresses that are subject to runtime relocation.
 //
-// The LTO linker will not emit GOT based relocations when all symbol
-// references can be resolved locally, and so there is no need to set the
-// pragma in that case (and doing so will cause other issues).
-//
 #pragma GCC visibility push (hidden)
+
+//
+// When LTO is in effect, symbols with hidden visibility will get discarded,
+// since by definition, they cannot be referenced externally, even if they
+// are the entry point of the executable. So we will have to change the
+// visibility back to 'default' explicitly for all such entry points.
+//
+#ifdef USING_LTO
+#define EFI_ENTRYPOINT __attribute__((__visibility__("default")))
+#endif
 #endif
 
 #if defined(__INTEL_COMPILER)
-- 
2.17.1



  parent reply	other threads:[~2018-06-12 15:23 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-12 15:22 [RFC PATCH 00/11] GCC/X64: use hidden visibility for LTO PIE code Ard Biesheuvel
2018-06-12 15:22 ` [RFC PATCH 01/11] MdePkg/ProcessorBind.h: define macro to decorate module entry points Ard Biesheuvel
2018-06-12 15:22 ` [RFC PATCH 02/11] DuetPkg: annotate module entry points with EFI_ENTRYPOINT Ard Biesheuvel
2018-06-12 15:22 ` [RFC PATCH 03/11] EdkCompatibilityPkg: " Ard Biesheuvel
2018-06-12 15:22 ` [RFC PATCH 04/11] EmbeddedPkg: " Ard Biesheuvel
2018-06-12 15:23 ` [RFC PATCH 05/11] EmulatorPkg: " Ard Biesheuvel
2018-06-12 15:23 ` [RFC PATCH 06/11] IntelFrameWorkPkg: " Ard Biesheuvel
2018-06-12 15:23 ` [RFC PATCH 07/11] MdeModulePkg: " Ard Biesheuvel
2018-06-12 15:23 ` [RFC PATCH 08/11] MdePkg: " Ard Biesheuvel
2018-06-12 15:23 ` [RFC PATCH 09/11] Nt32Pkg: " Ard Biesheuvel
2018-06-12 15:23 ` [RFC PATCH 10/11] UefiCpuPkg: " Ard Biesheuvel
2018-06-12 15:23 ` Ard Biesheuvel [this message]
2018-06-12 18:33 ` [RFC PATCH 00/11] GCC/X64: use hidden visibility for LTO PIE code Laszlo Ersek
2018-06-12 18:58   ` Ard Biesheuvel
2018-06-13  2:08 ` Shi, Steven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180612152306.25998-12-ard.biesheuvel@linaro.org \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox