瀏覽代碼

ARM: hide 'hidden' pragma for hosted build

The hidden visibility #pragma in inc/arm/efibind.h was meant to inform
the compiler that symbols with external linkage are never exported from
shared libraries [and thus never preempted] when executing in UEFI context
(since UEFI does not support shared libraries). This allows the compiler to
generate relative symbol references instead of GOT entries, which is much more
efficient since the latter need to be relocated before invoking the entry
point of the UEFI app.

However, as it turns out, this pragma is leaking into other code that does
not run in UEFI context, but simply needs to access data structures that
UEFI defines. So make the pragma dependent on whether we are building with
-ffreestanding, which is only used for bare metal code such as UEFI.

Last-Update: 2018-08-24

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Elder versions of sbsigntool failed to build on armhf without the patch,
cf. https://launchpad.net/ubuntu/+source/gnu-efi/3.0.8-0ubuntu1~16.04.1
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Ard Biesheuvel 8 年之前
父節點
當前提交
fa506bd242
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      inc/arm/efibind.h

+ 1 - 1
inc/arm/efibind.h

@@ -38,7 +38,7 @@ typedef int32_t             intptr_t;
  * This prevents GCC from emitting GOT based relocations, and use R_ARM_REL32
  * relative relocations instead, which are more suitable for static binaries.
  */
-#ifdef __GNUC__
+#if defined(__GNUC__) && !__STDC_HOSTED__
 #pragma GCC visibility push (hidden)
 #endif