kbuild: lto: Merge module sections if and only if CONFIG_LTO_CLANG is enabled
authorSean Christopherson <seanjc@google.com>
Mon, 22 Mar 2021 23:44:38 +0000 (16:44 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 23 Feb 2022 11:01:00 +0000 (12:01 +0100)
commit44b81136e86849117f34a083c359e4860662b3be
treea3ec70acbe76ff09d2fc3ffc01216020a64ce750
parent8b53e5f737bcf64226298c16c3920e7f0807ab94
kbuild: lto: Merge module sections if and only if CONFIG_LTO_CLANG is enabled

commit 6a3193cdd5e5b96ac65f04ee42555c216da332af upstream.

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 <ndesaulniers@google.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Reviewed-by: Sami Tolvanen <samitolvanen@google.com>
Tested-by: Sami Tolvanen <samitolvanen@google.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20210322234438.502582-1-seanjc@google.com
Cc: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
scripts/module.lds.S