mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 20:07:46 +09:00
ANDROID: kbuild: merge module sections with LTO
LLD always splits sections with LTO, which increases module sizes. This change adds a linker script that merges the split sections in the final module. Bug: 145297228 Change-Id: I247e8bd029bd0f98a4fa1cd4db7f6398467b8e55 Suggested-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
This commit is contained in:
committed by
Alistair Delva
parent
f0723e3bd5
commit
6cea04778e
2
Makefile
2
Makefile
@@ -821,6 +821,8 @@ lto-clang-flags := -flto
|
|||||||
endif
|
endif
|
||||||
lto-clang-flags += -fvisibility=default $(call cc-option, -fsplit-lto-unit)
|
lto-clang-flags += -fvisibility=default $(call cc-option, -fsplit-lto-unit)
|
||||||
|
|
||||||
|
KBUILD_LDS_MODULE += $(srctree)/scripts/module-lto.lds
|
||||||
|
|
||||||
# allow disabling only clang LTO where needed
|
# allow disabling only clang LTO where needed
|
||||||
DISABLE_LTO_CLANG := -fno-lto
|
DISABLE_LTO_CLANG := -fno-lto
|
||||||
export DISABLE_LTO_CLANG
|
export DISABLE_LTO_CLANG
|
||||||
|
|||||||
22
scripts/module-lto.lds
Normal file
22
scripts/module-lto.lds
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
SECTIONS {
|
||||||
|
/*
|
||||||
|
* LLVM may emit .eh_frame with CONFIG_CFI_CLANG despite
|
||||||
|
* -fno-asynchronous-unwind-tables. Discard the section.
|
||||||
|
*/
|
||||||
|
/DISCARD/ : {
|
||||||
|
*(.eh_frame)
|
||||||
|
}
|
||||||
|
|
||||||
|
.bss : { *(.bss .bss[.0-9a-zA-Z_]*) }
|
||||||
|
.data : { *(.data .data[.0-9a-zA-Z_]*) }
|
||||||
|
.rela.data : { *(.rela.data .rela.data[.0-9a-zA-Z_]*) }
|
||||||
|
.rela.rodata : { *(.rela.rodata .rela.rodata[.0-9a-zA-Z_]*) }
|
||||||
|
.rela.text : { *(.rela.text .rela.text[.0-9a-zA-Z_]*) }
|
||||||
|
.rodata : { *(.rodata .rodata[.0-9a-zA-Z_]*) }
|
||||||
|
.text : { *(.text .text[.0-9a-zA-Z_]*) }
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user