All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] efi/libstub/x86: Work around LLVM ELF quirk build regression
@ 2020-05-05  7:30 Ard Biesheuvel
  2020-05-07 19:07 ` Nick Desaulniers
  0 siblings, 1 reply; 2+ messages in thread
From: Ard Biesheuvel @ 2020-05-05  7:30 UTC (permalink / raw)
  To: linux-efi
  Cc: arnd, clang-built-linux, maskray, Ard Biesheuvel,
	Nick Desaulniers, Peter Collingbourne, Sami Tolvanen

When building the x86 EFI stub with Clang, the libstub Makefile rules
that manipulate the ELF object files may throw an error like:

    STUBCPY drivers/firmware/efi/libstub/efi-stub-helper.stub.o
  strip: drivers/firmware/efi/libstub/efi-stub-helper.stub.o: Failed to find link section for section 10
  objcopy: drivers/firmware/efi/libstub/efi-stub-helper.stub.o: Failed to find link section for section 10

This is the result of a LLVM feature [0] where symbol references are
stored in a LLVM specific .llvm_addrsig section in a non-transparent way,
causing generic ELF tools such as strip or objcopy to choke on them.

So force the compiler not to emit these sections, by passing the
appropriate command line option.

[0] https://sourceware.org/bugzilla/show_bug.cgi?id=23817

Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Collingbourne <pcc@google.com>
Cc: Sami Tolvanen <samitolvanen@google.com>
Reported-by: Arnd Bergmann <arnd@arndb.de>
Suggested-by: Fangrui Song <maskray@google.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 drivers/firmware/efi/libstub/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
index 8d246b51bd49..e5a49dc8e9bc 100644
--- a/drivers/firmware/efi/libstub/Makefile
+++ b/drivers/firmware/efi/libstub/Makefile
@@ -30,6 +30,7 @@ KBUILD_CFLAGS			:= $(cflags-y) -DDISABLE_BRANCH_PROFILING \
 				   -D__NO_FORTIFY \
 				   $(call cc-option,-ffreestanding) \
 				   $(call cc-option,-fno-stack-protector) \
+				   $(call cc-option,-fno-addrsig) \
 				   -D__DISABLE_EXPORTS
 
 GCOV_PROFILE			:= n
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] efi/libstub/x86: Work around LLVM ELF quirk build regression
  2020-05-05  7:30 [PATCH v2] efi/libstub/x86: Work around LLVM ELF quirk build regression Ard Biesheuvel
@ 2020-05-07 19:07 ` Nick Desaulniers
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Desaulniers @ 2020-05-07 19:07 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: linux-efi, Arnd Bergmann, clang-built-linux, Fangrui Song,
	Peter Collingbourne, Sami Tolvanen

On Tue, May 5, 2020 at 12:31 AM Ard Biesheuvel <ardb@kernel.org> wrote:
>
> When building the x86 EFI stub with Clang, the libstub Makefile rules
> that manipulate the ELF object files may throw an error like:
>
>     STUBCPY drivers/firmware/efi/libstub/efi-stub-helper.stub.o
>   strip: drivers/firmware/efi/libstub/efi-stub-helper.stub.o: Failed to find link section for section 10
>   objcopy: drivers/firmware/efi/libstub/efi-stub-helper.stub.o: Failed to find link section for section 10
>
> This is the result of a LLVM feature [0] where symbol references are
> stored in a LLVM specific .llvm_addrsig section in a non-transparent way,
> causing generic ELF tools such as strip or objcopy to choke on them.
>
> So force the compiler not to emit these sections, by passing the
> appropriate command line option.
>
> [0] https://sourceware.org/bugzilla/show_bug.cgi?id=23817
>
> Cc: Nick Desaulniers <ndesaulniers@google.com>
> Cc: Peter Collingbourne <pcc@google.com>
> Cc: Sami Tolvanen <samitolvanen@google.com>
> Reported-by: Arnd Bergmann <arnd@arndb.de>
> Suggested-by: Fangrui Song <maskray@google.com>
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>

I wonder if it's more appropriate to enable this globally for the
kernel, or why we don't see the failure for other object files outside
of libstub?  We might need to revisit that if we see such failures
again, but this patch LGTM. Thanks Ard.
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

> ---
>  drivers/firmware/efi/libstub/Makefile | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
> index 8d246b51bd49..e5a49dc8e9bc 100644
> --- a/drivers/firmware/efi/libstub/Makefile
> +++ b/drivers/firmware/efi/libstub/Makefile
> @@ -30,6 +30,7 @@ KBUILD_CFLAGS                 := $(cflags-y) -DDISABLE_BRANCH_PROFILING \
>                                    -D__NO_FORTIFY \
>                                    $(call cc-option,-ffreestanding) \
>                                    $(call cc-option,-fno-stack-protector) \
> +                                  $(call cc-option,-fno-addrsig) \
>                                    -D__DISABLE_EXPORTS
>
>  GCOV_PROFILE                   := n
> --
> 2.17.1
>


-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-07 19:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-05  7:30 [PATCH v2] efi/libstub/x86: Work around LLVM ELF quirk build regression Ard Biesheuvel
2020-05-07 19:07 ` Nick Desaulniers

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.