linux-efi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Atish Patra <Atish.Patra@wdc.com>
To: "ardb@kernel.org" <ardb@kernel.org>
Cc: "linux-efi@vger.kernel.org" <linux-efi@vger.kernel.org>,
	"mingo@kernel.org" <mingo@kernel.org>,
	"nivedita@alum.mit.edu" <nivedita@alum.mit.edu>,
	"lukas@wunner.de" <lukas@wunner.de>
Subject: Re: [PATCH 03/19] efi/libstub: Use hidden visiblity for all source files
Date: Tue, 25 Feb 2020 19:18:32 +0000	[thread overview]
Message-ID: <8801a47f278447b284a06879b026fed76658cef9.camel@wdc.com> (raw)
In-Reply-To: <CAKv+Gu9bPsiJLQqsfXwDMNe-VCsVCqDNvZAiCnon18kYG4M9qA@mail.gmail.com>

On Tue, 2020-02-25 at 00:36 +0100, Ard Biesheuvel wrote:
> On Tue, 25 Feb 2020 at 00:15, Atish Patra <Atish.Patra@wdc.com>
> 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@kernel.org>
> > > ---
> > >  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@redhat.com>
> > >   */
> > > 
> > > -/*
> > > - * 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)

Thanks. That solves the problem. I should have looked in the efi-next
first :(.

-- 
Regards,
Atish

  reply	other threads:[~2020-02-25 19:18 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-10 16:02 [PATCH 00/19] EFI stub early spring cleaning part 2 Ard Biesheuvel
2020-02-10 16:02 ` [PATCH 01/19] efi/libstub/x86: Remove pointless zeroing of apm_bios_info Ard Biesheuvel
2020-02-10 16:02 ` [PATCH 02/19] efi/libstub/x86: Avoid overflowing code32_start on PE entry Ard Biesheuvel
2020-02-10 16:02 ` [PATCH 03/19] efi/libstub: Use hidden visiblity for all source files Ard Biesheuvel
2020-02-24 23:15   ` Atish Patra
2020-02-24 23:36     ` Ard Biesheuvel
2020-02-25 19:18       ` Atish Patra [this message]
2020-02-10 16:02 ` [PATCH 04/19] efi/libstub/arm: Relax FDT alignment requirement Ard Biesheuvel
2020-02-10 16:02 ` [PATCH 05/19] efi/libstub: Move memory map handling and allocation routines to mem.c Ard Biesheuvel
2020-02-10 16:02 ` [PATCH 06/19] efi/libstub: Simplify efi_high_alloc() and rename to efi_allocate_pages() Ard Biesheuvel
2020-02-10 16:02 ` [PATCH 07/19] efi/libstub/x86: Incorporate eboot.c into libstub Ard Biesheuvel
2020-02-10 16:02 ` [PATCH 08/19] efi/libstub: Use consistent type names for file I/O protocols Ard Biesheuvel
2020-02-10 16:02 ` [PATCH 09/19] efi/libstub: Move stub specific declarations into efistub.h Ard Biesheuvel
2020-02-10 16:02 ` [PATCH 10/19] efi/libstub/x86: Permit bootparams struct to be allocated above 4 GB Ard Biesheuvel
2020-02-10 16:02 ` [PATCH 11/19] efi/libstub/x86: Permit cmdline data " Ard Biesheuvel
2020-02-10 16:02 ` [PATCH 12/19] efi/libstub: Move efi_random_alloc() into separate source file Ard Biesheuvel
2020-02-10 16:02 ` [PATCH 13/19] efi/libstub: Move get_dram_base() into arm-stub.c Ard Biesheuvel
2020-02-17  1:17   ` Atish Patra
2020-02-17  8:37     ` Ard Biesheuvel
2020-02-26 23:34       ` Atish Patra
2020-02-27  7:38         ` Ard Biesheuvel
2020-02-27  7:48           ` Atish Patra
2020-02-27  7:50             ` Ard Biesheuvel
2020-02-10 16:02 ` [PATCH 14/19] efi/libstub: Move file I/O support code into separate file Ard Biesheuvel
2020-02-10 16:02 ` [PATCH 15/19] efi/libstub: Rewrite file I/O routine Ard Biesheuvel
2020-02-10 16:02 ` [PATCH 16/19] efi/libstub: Take soft and hard memory limits into account for initrd loading Ard Biesheuvel
2020-02-10 16:02 ` [PATCH 17/19] efi/libstub: Clean up command line parsing routine Ard Biesheuvel
2020-02-10 16:02 ` [PATCH 18/19] efi/libstub: Expose LocateDevicePath boot service Ard Biesheuvel
2020-02-10 16:02 ` [PATCH 19/19] efi/libstub: Make the LoadFile EFI protocol accessible Ard Biesheuvel

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-all 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=8801a47f278447b284a06879b026fed76658cef9.camel@wdc.com \
    --to=atish.patra@wdc.com \
    --cc=ardb@kernel.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=mingo@kernel.org \
    --cc=nivedita@alum.mit.edu \
    /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;
as well as URLs for NNTP newsgroup(s).