Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Commit 8652d44 ("kexec: support purgatories with .text.hot sections") added a warning when the purgatory has more than one .text section, which is unsupported. A couple of changes have been made to the x86 purgatory's Makefile to prevent the compiler from splitting the .text section as a result: 97b6b9c ("x86/purgatory: remove PGO flags") 75b2f7e ("x86/purgatory: Remove LTO flags") Unfortunately, there may be compiler optimizations that add other text sections that cannot be disabled. For example, starting with LLVM 18, large text is emitted in '.ltext', which happens for the purgatory due to commit e16c298 ("x86/purgatory: Change compiler flags from -mcmodel=kernel to -mcmodel=large to fix kexec relocation errors"), but there are out of line assembly files that use '.text'. $ llvm-readelf -S arch/x86/purgatory/purgatory.ro | rg ' .[a-z]?text' [ 1] .text PROGBITS 0000000000000000 000040 0000d0 00 AX 0 0 16 [ 2] .ltext PROGBITS 0000000000000000 000110 0015a6 00 AXl 0 0 16 To avoid the runtime warning when the purgatory has been built with LLVM 18, add a linker script that explicitly describes the sections of the purgatory.ro and use it to merge '.ltext' and '.lrodata' back into '.text' and '.rodata' to match the behavior of GCC and LLVM prior to the optimization, as the distinction between small and large text is not important in this case. This results in no warnings with '--orphan-handling=warn' with either GNU or LLVM toolchains and the resulting kernels can properly kexec other kernels. This linker script is based on arch/s390/purgatory/purgatory.lds.S and Ricardo Ribalda's prior attempt to add one for arch/x86 [1]. As a consequence of this change, the aforementioned flag changes can be reverted because the '.text.*' sections generated by those options will be combined properly by the linker script, which avoids the only reason they were added in the first place. kexec continues to work with LTO enabled. [1]: https://lore.kernel.org/20230321-kexec_clang16-v5-2-5563bf7c4173@chromium.org/ Reported-by: ns <0n-s@users.noreply.github.com> Closes: ClangBuiltLinux#2016 Signed-off-by: Nathan Chancellor <nathan@kernel.org>
- Loading branch information