linux/arch/x86/boot
Nathan Chancellor 4a9ec5ec95 x86/boot/compressed: Disable jump tables
After a recent upstream LLVM change to start generating jump and lookup
tables in switch statements in more instances [1], linking the
compressed x86 boot image when CONFIG_KERNEL_ZSTD is enabled fails with:

  ld.lld: error: Unexpected run-time relocations (.rela) detected!

Dumping the relocations in misc.o, which is the only file influenced by
CONFIG_KERNEL_ZSTD in the decompressor, shows dynamic relocations to
some string constants, which correspond to the string literals in the
switch statement in handle_zstd_error():

  Relocation section '.rela.data.rel.ro' at offset 0x277b0 contains 31 entries:
      Offset             Info             Type               Symbol's Value  Symbol's Name + Addend
  0000000000000000  0000006600000001 R_X86_64_64            0000000000000000 .rodata.str1.1 + 73a
  0000000000000008  0000006600000001 R_X86_64_64            0000000000000000 .rodata.str1.1 + 78e
  0000000000000010  0000006600000001 R_X86_64_64            0000000000000000 .rodata.str1.1 + 78e
  0000000000000018  0000006600000001 R_X86_64_64            0000000000000000 .rodata.str1.1 + 78e
  ...

This optimization is problematic for the decompressor environment, as it
is built as -fPIE without any explicit absolute references (as described
at the top of misc.c) while not applying any dynamic relocations, hence
the linker assertion. To opt out of this optimization, which is of
little value in this special early boot code, and to mirror the other
x86 startup code in arch/x86/boot/startup, disable jump tables in the
decompressor.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Cc: Bill Wendling <morbo@google.com>
Cc: Justin Stitt <justinstitt@google.com>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: stable@vger.kernel.org
Link: fa02a6ed66 [1]
Link: https://patch.msgid.link/20260722-x86-boot-compressed-disable-jt-clang-v2-1-7373d38482fb@kernel.org
Closes: https://github.com/ClangBuiltLinux/linux/issues/2165
2026-07-23 10:06:58 +02:00
..
compressed x86/boot/compressed: Disable jump tables 2026-07-23 10:06:58 +02:00
startup treewide: Explicitly include the x86 CPUID headers 2026-05-06 14:29:59 +02:00
.gitignore x86 boot build: make git ignore stale 'tools' directory 2025-03-24 23:09:14 -07:00
a20.c x86/boot: Clean up whitespace in a20.c 2025-11-28 20:29:52 +01:00
apm.c
bioscall.S x86/boot: Remove semicolon from "rep" prefixes 2025-04-18 09:32:57 +02:00
bitops.h x86/asm: Remove code depending on __GCC_ASM_FLAG_OUTPUTS__ 2025-09-08 15:38:06 +02:00
boot.h x86/{boot,mtrr}: Remove unused function declarations 2025-11-22 21:26:36 +01:00
cmdline.c
copy.S x86/boot: Remove semicolon from "rep" prefixes 2025-04-18 09:32:57 +02:00
cpu.c x86/cpu: Remove X86_FEATURE_NAMES 2023-05-15 20:03:08 +02:00
cpucheck.c x86/boot: Move boot_*msr helpers to asm/shared/msr.h 2025-10-30 16:29:53 +01:00
cpuflags.c x86/sev: Move GHCB page based HV communication out of startup code 2025-09-03 17:55:25 +02:00
cpuflags.h x86/boot: Do not test if AC and ID eflags are changeable on x86_64 2025-03-08 20:36:26 +01:00
ctype.h
early_serial_console.c x86/boot: Validate console=uart8250 baud rate to fix early boot hang 2026-07-14 11:01:33 +02:00
edd.c
genimage.sh x86/build: Fix broken copy command in genimage.sh when making isoimage 2025-02-25 21:13:33 +01:00
header.S x86/efi: Implement support for embedding SBAT data for x86 2025-06-21 13:53:44 +02:00
install.sh kbuild: Abort make on install failures 2024-07-20 13:34:54 +09:00
io.h x86/boot: Port I/O: Allow to hook up alternative helpers 2022-04-07 08:27:52 -07:00
main.c x86/boot: Clean up the arch/x86/boot/main.c code a bit 2024-05-22 09:36:49 +02:00
Makefile x86/efi: Implement support for embedding SBAT data for x86 2025-06-21 13:53:44 +02:00
memory.c
mkcpustr.c x86/cpufeatures: Generate the <asm/cpufeaturemasks.h> header based on build config 2025-03-19 11:15:11 +01:00
mtools.conf.in x86/boot: Fix make hdimage with older versions of mtools 2021-09-29 11:06:47 +02:00
pm.c x86/asm: Always set A (accessed) flag in GDT descriptors 2023-12-20 10:57:51 +01:00
pmjump.S
printf.c x86/boot: Address clang -Wimplicit-fallthrough in vsprintf() 2024-05-17 09:22:56 +02:00
regs.c
setup.ld x86/boot: Drop CRC-32 checksum and the build tool that generates it 2025-03-07 23:59:10 +01:00
string.c x86/boot: Get rid of kstrtoull() 2026-05-04 14:26:13 +02:00
string.h x86/boot: Get rid of kstrtoull() 2026-05-04 14:26:13 +02:00
tty.c treewide: Convert macro and uses of __section(foo) to __section("foo") 2020-10-25 14:51:49 -07:00
version.c kbuild: build init/built-in.a just once 2022-09-29 04:40:15 +09:00
vesa.h
video-bios.c
video-mode.c
video-vesa.c sysfb: Enable boot time VESA graphic mode selection 2022-03-04 20:55:33 +01:00
video-vga.c
video.c x86/boot: Remove semicolon from "rep" prefixes 2025-04-18 09:32:57 +02:00
video.h treewide: Convert macro and uses of __section(foo) to __section("foo") 2020-10-25 14:51:49 -07:00