44b81136e8
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>
56 lines
1.5 KiB
ArmAsm
56 lines
1.5 KiB
ArmAsm
/*
|
|
* Common module linker script, always used when linking a module.
|
|
* Archs are free to supply their own linker scripts. ld will
|
|
* combine them automatically.
|
|
*/
|
|
SECTIONS {
|
|
/DISCARD/ : {
|
|
*(.discard)
|
|
*(.discard.*)
|
|
}
|
|
|
|
__ksymtab 0 : { *(SORT(___ksymtab+*)) }
|
|
__ksymtab_gpl 0 : { *(SORT(___ksymtab_gpl+*)) }
|
|
__ksymtab_unused 0 : { *(SORT(___ksymtab_unused+*)) }
|
|
__ksymtab_unused_gpl 0 : { *(SORT(___ksymtab_unused_gpl+*)) }
|
|
__ksymtab_gpl_future 0 : { *(SORT(___ksymtab_gpl_future+*)) }
|
|
__kcrctab 0 : { *(SORT(___kcrctab+*)) }
|
|
__kcrctab_gpl 0 : { *(SORT(___kcrctab_gpl+*)) }
|
|
__kcrctab_unused 0 : { *(SORT(___kcrctab_unused+*)) }
|
|
__kcrctab_unused_gpl 0 : { *(SORT(___kcrctab_unused_gpl+*)) }
|
|
__kcrctab_gpl_future 0 : { *(SORT(___kcrctab_gpl_future+*)) }
|
|
|
|
.init_array 0 : ALIGN(8) { *(SORT(.init_array.*)) *(.init_array) }
|
|
|
|
__jump_table 0 : ALIGN(8) { KEEP(*(__jump_table)) }
|
|
|
|
__patchable_function_entries : { *(__patchable_function_entries) }
|
|
|
|
#ifdef CONFIG_LTO_CLANG
|
|
/*
|
|
* With CONFIG_LTO_CLANG, LLD always enables -fdata-sections and
|
|
* -ffunction-sections, which increases the size of the final module.
|
|
* Merge the split sections in the final binary.
|
|
*/
|
|
.bss : {
|
|
*(.bss .bss.[0-9a-zA-Z_]*)
|
|
*(.bss..L*)
|
|
}
|
|
|
|
.data : {
|
|
*(.data .data.[0-9a-zA-Z_]*)
|
|
*(.data..L*)
|
|
}
|
|
|
|
.rodata : {
|
|
*(.rodata .rodata.[0-9a-zA-Z_]*)
|
|
*(.rodata..L*)
|
|
}
|
|
|
|
.text : { *(.text .text.[0-9a-zA-Z_]*) }
|
|
#endif
|
|
}
|
|
|
|
/* bring in arch-specific sections */
|
|
#include <asm/module.lds.h>
|