LTO fix for v5.12-rc6

- Only perform explicit module section merges under LTO (Sean Christopherson)
kbuild: lto: Merge module sections if and only if CONFIG_LTO_CLANG is enabled

Merge module sections only when using Clang LTO. With ld.bfd, merging
sections does not appear to update the symbol tables for the module,
e.g. 'readelf -s' shows the value that a symbol would have had, if
sections were not merged. ld.lld does not show this problem.

The stale symbol table breaks gdb's function disassembler, and presumably
other things, e.g.

  gdb -batch -ex "file arch/x86/kvm/kvm.ko" -ex "disassemble kvm_init"

reads the wrong bytes and dumps garbage.

Fixes: dd2776222abb ("kbuild: lto: merge module sections")
Cc: Nick Desaulniers <>
Signed-off-by: Sean Christopherson <>
Reviewed-by: Sami Tolvanen <>
Tested-by: Sami Tolvanen <>
Signed-off-by: Kees Cook <>
1 file changed