Skip to contentSkip to conversation

efi/libstub/x86: Work around LLVM ELF quirk build regression

PATCH In review Ard Biesheuvel 2 participants 2 messages May 5, 2020 – May 7, 2020 EFI

lore
Share & tools
lore

Ard Biesheuvel

author maintainer
#0 lore raw

PATCH v2 1/1 efi/libstub/x86: Work around LLVM ELF quirk build regression

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 <[email protected]>
Cc Peter Collingbourne <[email protected]>
Cc Sami Tolvanen <[email protected]>
---
 drivers/firmware/efi/libstub/Makefile | 1 +
 1 file changed, 1 insertion(+)
drivers/firmware/efi/libstub/Makefile +1 -0
index 8d246b51bd49..e5a49dc8e9bc 100644
@@ -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
Signature · 1 line
2.17.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 15 lines · Ard Biesheuvel

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.

Quoted 8 lines

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

Cc Nick Desaulniers <[email protected]>
Cc Peter Collingbourne <[email protected]>
Cc Sami Tolvanen <[email protected]>

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.

Quoted 19 lines
---
 drivers/firmware/efi/libstub/Makefile | 1 +
 1 file changed, 1 insertion(+)
drivers/firmware/efi/libstub/Makefile +1 -1
index 8d246b51bd49..e5a49dc8e9bc 100644
@@ -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

Signature · 2 lines
Thanks,
~Nick Desaulniers