Commit 8017ce50 authored by Masahiro Yamada's avatar Masahiro Yamada

kbuild: refactor cmd_modversions_c

cmd_modversions_c implements two parts; run genksyms to calculate CRCs
of exported symbols, run $(LD) to update the object with the CRCs. The
latter is not executed for CONFIG_LTO_CLANG=y since the object is not
ELF but LLVM bit code at this point.

The first part can be unified because we can always use $(NM) instead
of "$(OBJDUMP) -h" to dump the symbols.

Split the code into the two macros, cmd_gen_symversions_c and
cmd_modversions.
Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
parent 79f646e8
...@@ -168,29 +168,25 @@ ifdef CONFIG_MODVERSIONS ...@@ -168,29 +168,25 @@ ifdef CONFIG_MODVERSIONS
# the actual value of the checksum generated by genksyms # the actual value of the checksum generated by genksyms
# o remove .tmp_<file>.o to <file>.o # o remove .tmp_<file>.o to <file>.o
ifdef CONFIG_LTO_CLANG
# Generate .o.symversions files for each .o with exported symbols, and link these # Generate .o.symversions files for each .o with exported symbols, and link these
# to the kernel and/or modules at the end. # to the kernel and/or modules at the end.
cmd_modversions_c = \ gen_symversions = \
if $(NM) $@ 2>/dev/null | grep -q __ksymtab; then \ if $(NM) $@ 2>/dev/null | grep -q __ksymtab; then \
$(call cmd_gensymtypes_c,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \ $(call cmd_gensymtypes_$(1),$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \
> $@.symversions; \ > $@.symversions; \
else \ else \
rm -f $@.symversions; \ rm -f $@.symversions; \
fi; fi
else
cmd_modversions_c = \ cmd_gen_symversions_c = $(call gen_symversions,c)
if $(OBJDUMP) -h $@ | grep -q __ksymtab; then \
$(call cmd_gensymtypes_c,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \ cmd_modversions = \
> $(@D)/.tmp_$(@F:.o=.ver); \ if [ -r $@.symversions ]; then \
\
$(LD) $(KBUILD_LDFLAGS) -r -o $(@D)/.tmp_$(@F) $@ \ $(LD) $(KBUILD_LDFLAGS) -r -o $(@D)/.tmp_$(@F) $@ \
-T $(@D)/.tmp_$(@F:.o=.ver); \ -T $@.symversions; \
mv -f $(@D)/.tmp_$(@F) $@; \ mv -f $(@D)/.tmp_$(@F) $@; \
rm -f $(@D)/.tmp_$(@F:.o=.ver); \
fi fi
endif endif
endif
ifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT ifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
# compiler will not generate __mcount_loc use recordmcount or recordmcount.pl # compiler will not generate __mcount_loc use recordmcount or recordmcount.pl
...@@ -271,7 +267,8 @@ define rule_cc_o_c ...@@ -271,7 +267,8 @@ define rule_cc_o_c
$(call cmd,checksrc) $(call cmd,checksrc)
$(call cmd,checkdoc) $(call cmd,checkdoc)
$(call cmd,gen_objtooldep) $(call cmd,gen_objtooldep)
$(call cmd,modversions_c) $(call cmd,gen_symversions_c)
$(if $(CONFIG_LTO_CLANG),,$(call cmd,modversions))
$(call cmd,record_mcount) $(call cmd,record_mcount)
endef endef
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment