ANDROID: modpost: filter function/data section ldflags
The previous addition of -plugin-opt=-function-sections and -plugin-opt=-data-sections to LDFLAGS when performing LTO with gold was causing kernel modules to have individual sections for functions and data. This means that rather than having multiple symbols in the standard .text, .bss, and .data sections, there were now tens of thousands of sections, each with one symbol. This was problematic for third party tools used for parsing ramdumps that expect to find symbols in the standard object layout. This patch filters out these flags from LDFLAGS when constructing modules. Modules are linked in two phases with LTO. 1. produces <module>.lto.o 2. produces <module>.ko We must not use these flags during BOTH links otherwise these objects will have individual function and data sections. Running `readelf -S` on the above two files should show a number of sections in the order of tens (vs. tens of thousands) for the tooling to work properly. A more robust solution may be to look into is fixing the tooling to work with function and data section object layouts, but this should fix the tooling to work with the previous object layout for now. Bug: 116819139 Bug: 119467548 Bug: 120503084 Change-Id: I2a388f42d5e460654de9cbd0b37dae4463bbb73e Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Rapherion Rollerscaperers <rapherion@raphielgang.org>
This commit is contained in:
parent
3caa54b873
commit
2c6dc3d015
1 changed files with 7 additions and 3 deletions
|
@ -88,8 +88,10 @@ modpost-ext = $(if $(CONFIG_LTO_CLANG),.lto,)
|
|||
|
||||
ifdef CONFIG_LTO_CLANG
|
||||
quiet_cmd_cc_lto_link_modules = LD [M] $@
|
||||
bad_ld_flags = -plugin-opt=-function-sections -plugin-opt=-data-sections
|
||||
filtered_ld_flags = $(filter-out $(bad_ld_flags),$(ld_flags))
|
||||
cmd_cc_lto_link_modules = \
|
||||
$(LD) $(ld_flags) -r -o $(@) \
|
||||
$(LD) $(filtered_ld_flags) -r -o $(@) \
|
||||
$(shell [ -s $(@:$(modpost-ext).o=.o.symversions) ] && \
|
||||
echo -T $(@:$(modpost-ext).o=.o.symversions)) \
|
||||
--whole-archive $(filter-out FORCE,$^)
|
||||
|
@ -136,8 +138,10 @@ ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink)
|
|||
quiet_cmd_ld_ko_o = LD [M] $@
|
||||
|
||||
ifdef CONFIG_LTO_CLANG
|
||||
cmd_ld_ko_o = \
|
||||
$(LD) -r $(LDFLAGS) \
|
||||
bad_ld_flags = -plugin-opt=-function-sections -plugin-opt=-data-sections
|
||||
filtered_ldflags = $(filter-out $(bad_ld_flags),$(LDFLAGS))
|
||||
cmd_ld_ko_o = \
|
||||
$(LD) -r $(filtered_ld_flags) \
|
||||
$(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \
|
||||
$(shell [ -s $(@:.ko=.o.symversions) ] && \
|
||||
echo -T $(@:.ko=.o.symversions)) \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue