x86/purgatory: Remove LTO flags
Subsystems (3)
PATCH 1/1 x86/purgatory: Remove LTO flags
With LTO enabled, ld.lld generates multiple .text sections for purgatory.ro:
$ readelf -S purgatory.ro | grep " .text" [ 1] .text PROGBITS 0000000000000000 00000040 [ 7] .text.purgatory PROGBITS 0000000000000000 000020e0 [ 9] .text.warn PROGBITS 0000000000000000 000021c0 [13] .text.sha256_upda PROGBITS 0000000000000000 000022f0 [15] .text.sha224_upda PROGBITS 0000000000000000 00002be0 [17] .text.sha256_fina PROGBITS 0000000000000000 00002bf0 [19] .text.sha224_fina PROGBITS 0000000000000000 00002cc0
This cause WARNING from kexec_purgatory_setup_sechdrs():
WARNING: CPU: 26 PID: 110894 at kernel/kexec_file.c:919 kexec_load_purgatory+0x37f/0x390
Fix this by disabling LTO for purgatory.
---
AFAICT, x86 is the only arch that supports LTO and purgatory.
--- arch/x86/purgatory/Makefile | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/purgatory/Makefile +4 -0
@@ -19,6 +19,10 @@ CFLAGS_sha256.o := -D__DISABLE_EXPORTS -D__NO_FORTIFY # optimization flags. KBUILD_CFLAGS := $(filter-out -fprofile-sample-use=% -fprofile-use=%,$(KBUILD_CFLAGS)) +# When LTO is enabled, llvm emits many text sections, which is not supported +# by kexec. Remove -flto=* flags. +KBUILD_CFLAGS := $(filter-out -flto=%,$(KBUILD_CFLAGS)) + # When linking purgatory.ro with -r unresolved symbols are not checked, # also link a purgatory.chk binary without -r to check for unresolved symbols. PURGATORY_LDFLAGS := -e purgatory_start -z nodefaultlib
Signature · 1 line
2.34.1
Quoted 37 lines · Song Liu
With LTO enabled, ld.lld generates multiple .text sections for purgatory.ro:
$ readelf -S purgatory.ro | grep " .text" [ 1] .text PROGBITS 0000000000000000 00000040 [ 7] .text.purgatory PROGBITS 0000000000000000 000020e0 [ 9] .text.warn PROGBITS 0000000000000000 000021c0 [13] .text.sha256_upda PROGBITS 0000000000000000 000022f0 [15] .text.sha224_upda PROGBITS 0000000000000000 00002be0 [17] .text.sha256_fina PROGBITS 0000000000000000 00002bf0 [19] .text.sha224_fina PROGBITS 0000000000000000 00002cc0This cause WARNING from
kexec_purgatory_setup_sechdrs():WARNING: CPU: 26 PID: 110894 at kernel/kexec_file.c:919 kexec_load_purgatory+0x37f/0x390Fix this by disabling LTO for purgatory.
Fixes 8652d44f466a ("kexec: support purgatories with .text.hot sections")Cc Ricardo Ribalda <[email protected]>Signed-off-by Song Liu <[email protected]>---
AFAICT, x86 is the only arch that supports LTO and purgatory.--- arch/x86/purgatory/Makefile | 4 ++++ 1 file changed, 4 insertions(+)arch/x86/purgatory/Makefile +0
-0
arch/x86/purgatory/Makefile CFLAGS_sha256.o := -D__DISABLE_EXPORTS -D__NO_FORTIFY · line 24
Quoted 6 lines
arch/x86/purgatory/Makefile +3
-0@@ -19,6 +19,10 @@ CFLAGS_sha256.o := -D__DISABLE_EXPORTS -D__NO_FORTIFY # optimization flags. KBUILD_CFLAGS := $(filter-out -fprofile-sample-use=% -fprofile-use=%,$(KBUILD_CFLAGS)) +# When LTO is enabled, llvm emits many text sections, which is not supported +# by kexec. Remove -flto=* flags. +KBUILD_CFLAGS := $(filter-out -flto=%,$(KBUILD_CFLAGS))
Thanks for the patch!
Please prefer something akin to:
commit 6e20f18579c5 ("efi/libstub: disable LTO")
Please also CC Sami and [email protected] for v2.
Pretty sure we use a linker script to rejoin .text.* elsewhere in the kernel, but it doesn't look like x86 purgatory has one.
Quoted 7 lines
arch/x86/purgatory/Makefile +1
-0+ # When linking purgatory.ro with -r unresolved symbols are not checked, # also link a purgatory.chk binary without -r to check for unresolved symbols. PURGATORY_LDFLAGS := -e purgatory_start -z nodefaultlibSignature · 1 line
2.34.1
Quoted 42 lines · Nick Desaulniers
Quoted 40 lines · Song Liu
With LTO enabled, ld.lld generates multiple .text sections for purgatory.ro:
$ readelf -S purgatory.ro | grep " .text" [ 1] .text PROGBITS 0000000000000000 00000040 [ 7] .text.purgatory PROGBITS 0000000000000000 000020e0 [ 9] .text.warn PROGBITS 0000000000000000 000021c0 [13] .text.sha256_upda PROGBITS 0000000000000000 000022f0 [15] .text.sha224_upda PROGBITS 0000000000000000 00002be0 [17] .text.sha256_fina PROGBITS 0000000000000000 00002bf0 [19] .text.sha224_fina PROGBITS 0000000000000000 00002cc0This cause WARNING from
kexec_purgatory_setup_sechdrs():WARNING: CPU: 26 PID: 110894 at kernel/kexec_file.c:919 kexec_load_purgatory+0x37f/0x390Fix this by disabling LTO for purgatory.
Fixes 8652d44f466a ("kexec: support purgatories with .text.hot sections")Cc Ricardo Ribalda <[email protected]>Signed-off-by Song Liu <[email protected]>---
AFAICT, x86 is the only arch that supports LTO and purgatory.--- arch/x86/purgatory/Makefile | 4 ++++ 1 file changed, 4 insertions(+)arch/x86/purgatory/Makefile +0
-0@@ -19,6 +19,10 @@ CFLAGS_sha256.o := -D__DISABLE_EXPORTS -D__NO_FORTIFY # optimization flags. KBUILD_CFLAGS := $(filter-out -fprofile-sample-use=% -fprofile-use=%,$(KBUILD_CFLAGS))
Quoted 8 lines
arch/x86/purgatory/Makefile CFLAGS_sha256.o := -D__DISABLE_EXPORTS -D__NO_FORTIFY · line 24
Quoted 3 lines
arch/x86/purgatory/Makefile +3
-0+# When LTO is enabled, llvm emits many text sections, which is not supported +# by kexec. Remove -flto=* flags. +KBUILD_CFLAGS := $(filter-out -flto=%,$(KBUILD_CFLAGS))Thanks for the patch!
Please prefer something akin to:
commit6e20f18579c5("efi/libstub: disable LTO")
Thanks for the pointer! This does look better.
Thanks,
Song
Quoted 13 lines
Please also CC Sami and [email protected] for v2.
Pretty sure we use a linker script to rejoin .text.* elsewhere in the kernel, but it doesn't look like x86 purgatory has one.
Quoted 7 lines
arch/x86/purgatory/Makefile +1
-1+ # When linking purgatory.ro with -r unresolved symbols are not checked, # also link a purgatory.chk binary without -r to check for unresolved symbols. PURGATORY_LDFLAGS := -e purgatory_start -z nodefaultlib --2.34.1