On Thu, Feb 12, 2026 at 11:21:53AM -0800, Song Liu wrote:
> Add support for LTO in klp-build toolchain. The key changes are to the
> symbol correlation logic.Basically, we want to:
>
> 1. Match symbols with differerent .llvm.<hash> suffixes, e.g., foo.llvm.123
> to foo.llvm.456.
> 2. Match local symbols with promoted global symbols, e.g., local foo
> with global foo.llvm.123.
>
> 1/8 and 2/8 are small cleanup/fix for existing code.
> 3/8 through 7/8 contains the core logic changes to correlate_symbols().
> 8/8 contains tests for klp-build toolchain.
>
> Song Liu (8):
> objtool/klp: Remove redundent strcmp in correlate_symbols
> objtool/klp: Remove trailing '_' in demangle_name()
> objtool/klp: Use sym->demangled_name for symbol_name hash
> objtool/klp: Also demangle global objects
> objtool/klp: Remove .llvm suffix in demangle_name()
> objtool/klp: Match symbols based on demangled_name for global
> variables
> objtool/klp: Correlate locals to globals
> livepatch: Add tests for klp-build toolchain
>
Hi Song,
One of the tests that Josh had suggested running to validate "no
changes" and git apply --recount / recountdiff was to touch most of the
.c files in the tree like so:
$ find . -type f -name '*.c' ! -path "./lib/*" -print0 | xargs -0 sed -i
'1iasm("nop");'
$ git checkout tools arch/x86/lib/inat.c arch/x86/lib/insn.c kernel/configs.c
$ git diff > /tmp/oneline.patch
which results in "klp-build: no changes detected" using gcc, but with
this patchset+llvm thin-LTO results in a few c_start/c_stop/c_next
uncorrelated variables.
Here is a minimal version of a reproducer:
$ grep LTO .config
CONFIG_LTO=y
CONFIG_LTO_CLANG=y
CONFIG_ARCH_SUPPORTS_LTO_CLANG=y
CONFIG_ARCH_SUPPORTS_LTO_CLANG_THIN=y
CONFIG_HAS_LTO_CLANG=y
# CONFIG_LTO_NONE is not set
# CONFIG_LTO_CLANG_FULL is not set
CONFIG_LTO_CLANG_THIN=y
$ cat ~/min.patch
diff --git a/arch/x86/kernel/cpu/proc.c b/arch/x86/kernel/cpu/proc.c
index 6571d432cbe3..96c6c8bb7228 100644
--- a/arch/x86/kernel/cpu/proc.c
+++ b/arch/x86/kernel/cpu/proc.c
@@ -1,3 +1,4 @@
+asm("nop");
// SPDX-License-Identifier: GPL-2.0
#include <linux/smp.h>
#include <linux/timex.h>
diff --git a/crypto/proc.c b/crypto/proc.c
index 82f15b967e85..1474800162bf 100644
--- a/crypto/proc.c
+++ b/crypto/proc.c
@@ -1,3 +1,4 @@
+asm("nop");
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Scatterlist Cryptographic API.
diff --git a/fs/proc/consoles.c b/fs/proc/consoles.c
index b7cab1ad990d..066e625ae14e 100644
--- a/fs/proc/consoles.c
+++ b/fs/proc/consoles.c
@@ -1,3 +1,4 @@
+asm("nop");
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2010 Werner Fink, Jiri Slaby
$ LLVM=1 ./scripts/livepatch/klp-build -T ~/min.patch
Validating patch(es)
Building original kernel
Copying original object files
Fixing patch(es)
Building patched kernel
Copying patched object files
Diffing objects
vmlinux.o: warning: objtool: correlate c_start.llvm.15251198824366928061
(origial) to c_start.llvm.14107081093236395767 (patched)
vmlinux.o: warning: objtool: correlate c_stop.llvm.15251198824366928061
(origial) to c_stop.llvm.14107081093236395767 (patched)
vmlinux.o: warning: objtool: correlate c_next.llvm.15251198824366928061
(origial) to c_next.llvm.14107081093236395767 (patched)
vmlinux.o: warning: objtool: correlate show_cpuinfo.llvm.15251198824366928061
(origial) to show_cpuinfo.llvm.10047843810948474008 (patched)
vmlinux.o: warning: objtool: correlate .str.llvm.1768504738091882651 (origial)
to .str.llvm.7814622528726587167 (patched)
vmlinux.o: warning: objtool: correlate crypto_seq_ops.llvm.1768504738091882651
(origial) to crypto_seq_ops.llvm.14107081093236395767 (patched)
vmlinux.o: warning: objtool: correlate c_start.llvm.1768504738091882651
(origial) to c_start.llvm.14107081093236395767 (patched)
vmlinux.o: warning: objtool: correlate c_stop.llvm.1768504738091882651
(origial) to c_stop.llvm.14107081093236395767 (patched)
vmlinux.o: warning: objtool: correlate c_next.llvm.1768504738091882651
(origial) to c_next.llvm.14107081093236395767 (patched)
vmlinux.o: warning: objtool: correlate c_show.llvm.1768504738091882651
(origial) to c_show.llvm.14107081093236395767 (patched)
vmlinux.o: warning: objtool: correlate __pfx_c_start.llvm.15251198824366928061
(origial) to __pfx_c_start.llvm.14107081093236395767 (patched)
vmlinux.o: warning: objtool: correlate __pfx_c_stop.llvm.15251198824366928061
(origial) to __pfx_c_stop.llvm.14107081093236395767 (patched)
vmlinux.o: warning: objtool: correlate __pfx_c_next.llvm.15251198824366928061
(origial) to __pfx_c_next.llvm.14107081093236395767 (patched)
vmlinux.o: warning: objtool: correlate
__pfx_show_cpuinfo.llvm.15251198824366928061 (origial) to
__pfx_show_cpuinfo.llvm.10047843810948474008 (patched)
vmlinux.o: warning: objtool: correlate __pfx_c_start.llvm.1768504738091882651
(origial) to __pfx_c_start.llvm.14107081093236395767 (patched)
vmlinux.o: warning: objtool: correlate __pfx_c_stop.llvm.1768504738091882651
(origial) to __pfx_c_stop.llvm.14107081093236395767 (patched)
vmlinux.o: warning: objtool: correlate __pfx_c_next.llvm.1768504738091882651
(origial) to __pfx_c_next.llvm.14107081093236395767 (patched)
vmlinux.o: warning: objtool: correlate __pfx_c_show.llvm.1768504738091882651
(origial) to __pfx_c_show.llvm.14107081093236395767 (patched)
vmlinux.o: warning: objtool: no correlation: c_start.llvm.1768504738091882651
vmlinux.o: warning: objtool: no correlation: c_stop.llvm.1768504738091882651
vmlinux.o: warning: objtool: no correlation: c_next.llvm.1768504738091882651
vmlinux.o: new function: c_start.llvm.10047843810948474008
vmlinux.o: new function: c_stop.llvm.10047843810948474008
vmlinux.o: new function: c_next.llvm.10047843810948474008
vmlinux.o: changed function: c_start.llvm.14107081093236395767
vmlinux.o: changed function: c_stop.llvm.14107081093236395767
vmlinux.o: changed function: c_next.llvm.14107081093236395767
Building patch module: livepatch-min.ko
SUCCESS
And since we're here, it looks like there's a type:
s/origial/original/g.
--
Joe