kbuild: record needed exported symbols for modules
Kernel modules are partially linked object files with some undefined symbols that are expected to be matched with EXPORT_SYMBOL() entries from elsewhere. Each .tmp_versions/*.mod file currently contains two line of text separated by a newline character. The first line has the actual module file name while the second line has a list of object files constituting that module. Those files are parsed by modpost (scripts/mod/sumversion.c), scripts/Makefile.modpost, scripts/Makefile.modsign, etc. Only the modpost utility cares about the second line while the others retrieve only the first line. Therefore we can add a third line to record the list of undefined symbols aka required EXPORT_SYMBOL() entries for each module into that file without breaking anything. Like for the second line, symbols are separated by a blank and the list is terminated with a newline character. To avoid needless build overhead, the undefined symbols extraction is performed only when CONFIG_TRIM_UNUSED_KSYMS is selected. Signed-off-by: Nicolas Pitre <nico@linaro.org> Acked-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
f55532a0c0
commit
9895c03d48
@ -286,6 +286,13 @@ define rule_as_o_S
|
|||||||
mv -f $(dot-target).tmp $(dot-target).cmd
|
mv -f $(dot-target).tmp $(dot-target).cmd
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
# List module undefined symbols (or empty line if not enabled)
|
||||||
|
ifdef CONFIG_TRIM_UNUSED_KSYMS
|
||||||
|
cmd_undef_syms = $(NM) $@ | sed -n 's/^ \+U //p' | xargs echo
|
||||||
|
else
|
||||||
|
cmd_undef_syms = echo
|
||||||
|
endif
|
||||||
|
|
||||||
# Built-in and composite module parts
|
# Built-in and composite module parts
|
||||||
$(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_obj) FORCE
|
$(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_obj) FORCE
|
||||||
$(call cmd,force_checksrc)
|
$(call cmd,force_checksrc)
|
||||||
@ -296,7 +303,8 @@ $(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_obj) FORCE
|
|||||||
$(single-used-m): $(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_obj) FORCE
|
$(single-used-m): $(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_obj) FORCE
|
||||||
$(call cmd,force_checksrc)
|
$(call cmd,force_checksrc)
|
||||||
$(call if_changed_rule,cc_o_c)
|
$(call if_changed_rule,cc_o_c)
|
||||||
@{ echo $(@:.o=.ko); echo $@; } > $(MODVERDIR)/$(@F:.o=.mod)
|
@{ echo $(@:.o=.ko); echo $@; \
|
||||||
|
$(cmd_undef_syms); } > $(MODVERDIR)/$(@F:.o=.mod)
|
||||||
|
|
||||||
quiet_cmd_cc_lst_c = MKLST $@
|
quiet_cmd_cc_lst_c = MKLST $@
|
||||||
cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \
|
cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \
|
||||||
@ -426,7 +434,8 @@ $(call multi_depend, $(multi-used-y), .o, -objs -y)
|
|||||||
|
|
||||||
$(multi-used-m): FORCE
|
$(multi-used-m): FORCE
|
||||||
$(call if_changed,link_multi-m)
|
$(call if_changed,link_multi-m)
|
||||||
@{ echo $(@:.o=.ko); echo $(link_multi_deps); } > $(MODVERDIR)/$(@F:.o=.mod)
|
@{ echo $(@:.o=.ko); echo $(link_multi_deps); \
|
||||||
|
$(cmd_undef_syms); } > $(MODVERDIR)/$(@F:.o=.mod)
|
||||||
$(call multi_depend, $(multi-used-m), .o, -objs -y -m)
|
$(call multi_depend, $(multi-used-m), .o, -objs -y -m)
|
||||||
|
|
||||||
targets += $(multi-used-y) $(multi-used-m)
|
targets += $(multi-used-y) $(multi-used-m)
|
||||||
|
Loading…
Reference in New Issue
Block a user