* [PATCH v2] x86/boot/compressed: Disable jump tables
@ 2026-07-23 0:09 Nathan Chancellor
2026-07-23 6:32 ` Ard Biesheuvel
2026-07-23 8:11 ` [tip: x86/urgent] " tip-bot2 for Nathan Chancellor
0 siblings, 2 replies; 3+ messages in thread
From: Nathan Chancellor @ 2026-07-23 0:09 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
Ard Biesheuvel
Cc: Nick Desaulniers, Bill Wendling, Justin Stitt, linux-kernel,
llvm, stable, Nathan Chancellor
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.
Cc: stable@vger.kernel.org
Closes: https://github.com/ClangBuiltLinux/linux/issues/2165
Link: https://github.com/llvm/llvm-project/commit/fa02a6ed66b1700c996b49c96c6bc0eb014c9518 [1]
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
Changes in v2:
- Disable jump tables for GCC as well to mirror arch/x86/boot/startup
and adjust commit message to match (Ingo). I kept the rest of the
message for future 'git log' travelers to see the original issue.
- Link to v1: https://patch.msgid.link/20260623-x86-boot-compressed-disable-jt-clang-v1-1-575fccd58107@kernel.org
---
arch/x86/boot/compressed/Makefile | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
index 07e0e64b9a98..06934f9691d6 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -27,6 +27,7 @@ targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \
KBUILD_CFLAGS := -m$(BITS) -O2 $(CLANG_FLAGS)
KBUILD_CFLAGS += $(CC_FLAGS_DIALECT)
KBUILD_CFLAGS += -fno-strict-aliasing -fPIE
+KBUILD_CFLAGS += -fno-jump-tables
KBUILD_CFLAGS += -Wundef
KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
cflags-$(CONFIG_X86_32) := -march=i386
---
base-commit: 1590cf0329716306e948a8fc29f1d3ee87d3989f
change-id: 20260622-x86-boot-compressed-disable-jt-clang-ef1dfca25098
Best regards,
--
Cheers,
Nathan
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] x86/boot/compressed: Disable jump tables
2026-07-23 0:09 [PATCH v2] x86/boot/compressed: Disable jump tables Nathan Chancellor
@ 2026-07-23 6:32 ` Ard Biesheuvel
2026-07-23 8:11 ` [tip: x86/urgent] " tip-bot2 for Nathan Chancellor
1 sibling, 0 replies; 3+ messages in thread
From: Ard Biesheuvel @ 2026-07-23 6:32 UTC (permalink / raw)
To: Nathan Chancellor, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, x86
Cc: Nick Desaulniers, Bill Wendling, Justin Stitt, linux-kernel,
llvm, stable
On Thu, 23 Jul 2026, at 02:09, Nathan Chancellor wrote:
> 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.
>
> Cc: stable@vger.kernel.org
> Closes: https://github.com/ClangBuiltLinux/linux/issues/2165
> Link:
> https://github.com/llvm/llvm-project/commit/fa02a6ed66b1700c996b49c96c6bc0eb014c9518
> [1]
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [tip: x86/urgent] x86/boot/compressed: Disable jump tables
2026-07-23 0:09 [PATCH v2] x86/boot/compressed: Disable jump tables Nathan Chancellor
2026-07-23 6:32 ` Ard Biesheuvel
@ 2026-07-23 8:11 ` tip-bot2 for Nathan Chancellor
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Nathan Chancellor @ 2026-07-23 8:11 UTC (permalink / raw)
To: linux-tip-commits
Cc: Nathan Chancellor, Ingo Molnar, Ard Biesheuvel, Bill Wendling,
Justin Stitt, Nick Desaulniers, H. Peter Anvin, Peter Zijlstra,
stable, x86, linux-kernel
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: 4a9ec5ec9555ad62dc5b81a37ac946025c2ea002
Gitweb: https://git.kernel.org/tip/4a9ec5ec9555ad62dc5b81a37ac946025c2ea002
Author: Nathan Chancellor <nathan@kernel.org>
AuthorDate: Wed, 22 Jul 2026 17:09:43 -07:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Thu, 23 Jul 2026 10:06:58 +02:00
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: https://github.com/llvm/llvm-project/commit/fa02a6ed66b1700c996b49c96c6bc0eb014c9518 [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
---
arch/x86/boot/compressed/Makefile | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
index 07e0e64..06934f9 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -27,6 +27,7 @@ targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \
KBUILD_CFLAGS := -m$(BITS) -O2 $(CLANG_FLAGS)
KBUILD_CFLAGS += $(CC_FLAGS_DIALECT)
KBUILD_CFLAGS += -fno-strict-aliasing -fPIE
+KBUILD_CFLAGS += -fno-jump-tables
KBUILD_CFLAGS += -Wundef
KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
cflags-$(CONFIG_X86_32) := -march=i386
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-23 8:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-23 0:09 [PATCH v2] x86/boot/compressed: Disable jump tables Nathan Chancellor
2026-07-23 6:32 ` Ard Biesheuvel
2026-07-23 8:11 ` [tip: x86/urgent] " tip-bot2 for Nathan Chancellor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®