kbuild: merge module sections under CONFIG_LD_DEAD_CODE_DATA_ELIMINATION too
Subsystems (2)
PATCH 1/1 kbuild: merge module sections under CONFIG_LD_DEAD_CODE_DATA_ELIMINATION too
When building with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION, -fdata-sections and -ffunction-sections are being enabled by the top-level Makefile, and module section merging is also needed. Expand the ifdef (and the comment block) to cover that case too.
--- scripts/module.lds.S | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
scripts/module.lds.S +6 -3
@@ -20,11 +20,14 @@ SECTIONS { __patchable_function_entries : { *(__patchable_function_entries) } -#ifdef CONFIG_LTO_CLANG +#if defined(CONFIG_LD_DEAD_CODE_DATA_ELIMINATION) || defined(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. + * -ffunction-sections. With CONFIG_LD_DEAD_CODE_DATA_ELIMINATION, + * -fdata-sections and -ffunction-sections are being enabled by + * the top-level Makefile. + * This increases the size of the final module. Merge the split + * sections in the final binary. */ .bss : { *(.bss .bss.[0-9a-zA-Z_]*)
--
2.31.1
Sami Tolvanen
maintainerQuoted 7 lines · Alexander Lobakin
When building with
CONFIG_LD_DEAD_CODE_DATA_ELIMINATION, -fdata-sections and -ffunction-sections are being enabled by the top-levelMakefile, and module section merging is also needed. Expand the ifdef (and the comment block) to cover that case too.Fixes 6a3193cdd5e5 ("kbuild: lto: Merge module sections if and only if CONFIG_LTO_CLANG is enabled")
Wouldn't this trigger the ld.bfd bug described in the commit message when LD_DEAD_CODE_DATA_ELIMINATION is enabled? LTO_CLANG always uses LLD, so it won't have this issue.
Sami
Quoted 11 lines · Sami Tolvanen
Quoted 5 lines · On Fri, Apr 2, 2021 at 5:40 AM Alexander Lobakin [email protected] wrote:
When building with
CONFIG_LD_DEAD_CODE_DATA_ELIMINATION, -fdata-sections and -ffunction-sections are being enabled by the top-levelMakefile, and module section merging is also needed. Expand the ifdef (and the comment block) to cover that case too.Fixes 6a3193cdd5e5 ("kbuild: lto: Merge module sections if and only if CONFIG_LTO_CLANG is enabled")Wouldn't this trigger the ld.bfd bug described in the commit message when
LD_DEAD_CODE_DATA_ELIMINATIONis enabled?LTO_CLANGalways uses LLD, so it won't have this issue.
LD_DEAD_CODE_DATA_ELIMINATION is marked
“EXPERIMENTAL“ in the config prompt, and
arches have to opt-inHAS_LD_DEAD_CODE_DATA_ELIMINATION to give
an access to it (only a few does). This
should be relatively safe.
Quoted 1 line
Sami
Thanks,
Al
Quoted 11 lines · Alexander Lobakin
Quoted 7 lines · Sami Tolvanen
Quoted 5 lines · On Fri, Apr 2, 2021 at 5:40 AM Alexander Lobakin [email protected] wrote:
When building with
CONFIG_LD_DEAD_CODE_DATA_ELIMINATION, -fdata-sections and -ffunction-sections are being enabled by the top-levelMakefile, and module section merging is also needed. Expand the ifdef (and the comment block) to cover that case too.Fixes 6a3193cdd5e5 ("kbuild: lto: Merge module sections if and only if CONFIG_LTO_CLANG is enabled")
Did you test this patch before submission?
See the top Makefile closely:
ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION KBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections LDFLAGS_vmlinux += --gc-sections
endif
-ffunction-sections -fdata-sections are passed to only built-in objects, but not to module objects in the first place.
KBUILD_CFLAGS_KERNEL is only passed to built-in objects.
The situation you claimed never happens.
Quoted 15 lines
Quoted 3 lines
Wouldn't this trigger the ld.bfd bug described in the commit message when
LD_DEAD_CODE_DATA_ELIMINATIONis enabled?LTO_CLANGalways uses LLD, so it won't have this issue.
LD_DEAD_CODE_DATA_ELIMINATIONis marked
“EXPERIMENTAL“ in the config prompt, and
arches have to opt-inHAS_LD_DEAD_CODE_DATA_ELIMINATIONto give
an access to it (only a few does). This
should be relatively safe.Quoted 1 line
Sami
Thanks,
Al
Signature · 2 lines
Best Regards Masahiro Yamada