On Tue, 25 Feb 2020 at 00:15, Atish Patra <Atish.Patra@xxxxxxx> wrote: > > On Mon, 2020-02-10 at 17:02 +0100, Ard Biesheuvel wrote: > > Instead of setting the visibility pragma for a small set of symbol > > declarations that could result in absolute references that we cannot > > support in the stub, declare hidden visibility for all code in the > > EFI stub, which is more robust and future proof. > > > > To ensure that the #pragma is taken into account before any other > > includes are processed, put it in a header file of its own and > > include it via the compiler command line using the -include option. > > > > Signed-off-by: Ard Biesheuvel <ardb@xxxxxxxxxx> > > --- > > arch/arm64/include/asm/efi.h | 3 --- > > drivers/firmware/efi/libstub/Makefile | 2 +- > > drivers/firmware/efi/libstub/arm64-stub.c | 8 +------- > > drivers/firmware/efi/libstub/hidden.h | 6 ++++++ > > 4 files changed, 8 insertions(+), 11 deletions(-) > > > > diff --git a/arch/arm64/include/asm/efi.h > > b/arch/arm64/include/asm/efi.h > > index 44531a69d32b..56ae87401a26 100644 > > --- a/arch/arm64/include/asm/efi.h > > +++ b/arch/arm64/include/asm/efi.h > > @@ -107,9 +107,6 @@ static inline void free_screen_info(struct > > screen_info *si) > > { > > } > > > > -/* redeclare as 'hidden' so the compiler will generate relative > > references */ > > -extern struct screen_info screen_info > > __attribute__((__visibility__("hidden"))); > > - > > static inline void efifb_setup_from_dmi(struct screen_info *si, > > const char *opt) > > { > > } > > diff --git a/drivers/firmware/efi/libstub/Makefile > > b/drivers/firmware/efi/libstub/Makefile > > index f14b7636323a..4efdbd711e8e 100644 > > --- a/drivers/firmware/efi/libstub/Makefile > > +++ b/drivers/firmware/efi/libstub/Makefile > > @@ -25,7 +25,7 @@ cflags-$(CONFIG_ARM) := $(subst > > $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \ > > cflags-$(CONFIG_EFI_ARMSTUB) += -I$(srctree)/scripts/dtc/libfdt > > > > KBUILD_CFLAGS := $(cflags-y) > > -DDISABLE_BRANCH_PROFILING \ > > - -D__NO_FORTIFY \ > > + -include hidden.h -D__NO_FORTIFY \ > > $(call cc-option,-ffreestanding) \ > > $(call cc-option,-fno-stack- > > protector) \ > > -D__DISABLE_EXPORTS > > diff --git a/drivers/firmware/efi/libstub/arm64-stub.c > > b/drivers/firmware/efi/libstub/arm64-stub.c > > index 2915b44132e6..719d03a64329 100644 > > --- a/drivers/firmware/efi/libstub/arm64-stub.c > > +++ b/drivers/firmware/efi/libstub/arm64-stub.c > > @@ -6,17 +6,11 @@ > > * Adapted from ARM version by Mark Salter <msalter@xxxxxxxxxx> > > */ > > > > -/* > > - * To prevent the compiler from emitting GOT-indirected (and thus > > absolute) > > - * references to the section markers, override their visibility as > > 'hidden' > > - */ > > -#pragma GCC visibility push(hidden) > > -#include <asm/sections.h> > > -#pragma GCC visibility pop > > > > #include <linux/efi.h> > > #include <asm/efi.h> > > #include <asm/memory.h> > > +#include <asm/sections.h> > > #include <asm/sysreg.h> > > > > #include "efistub.h" > > diff --git a/drivers/firmware/efi/libstub/hidden.h > > b/drivers/firmware/efi/libstub/hidden.h > > new file mode 100644 > > index 000000000000..3493b041f419 > > --- /dev/null > > +++ b/drivers/firmware/efi/libstub/hidden.h > > @@ -0,0 +1,6 @@ > > +/* SPDX-License-Identifier: GPL-2.0 */ > > +/* > > + * To prevent the compiler from emitting GOT-indirected (and thus > > absolute) > > + * references to any global symbols, override their visibility as > > 'hidden' > > + */ > > +#pragma GCC visibility push(hidden) > > I am getting following compiler errors because of this patch while > cross compiling for ARM, ARM64 and RISC-V. > > cc1: fatal error: hidden.h: No such file or directory > > Adding the following line to cflags solves the issue which indicates > that gcc is not looking at the source file directory for this > particularly include file. > > -I$(srctree)/drivers/firmware/efi/libstub > > I might have some trick in my build setup. Just posting here to see if > anybody else also seeing the same problem. > Thanks Atish. Heinrich reported the same issue. It didn't affect me or any of the bots because it only hits if you build in-tree (i.e., $srctree == $objtree) My latest efi/next branch carries a fix for this (similar to your suggestion, but using -include)