FROMGIT: kbuild: Add gendwarfksyms as an alternative to genksyms
When MODVERSIONS is enabled, allow selecting gendwarfksyms as the implementation, but default to genksyms. Signed-off-by: Sami Tolvanen <samitolvanen@google.com> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> (cherry picked from commit 9c3681f9b9fd12cdbc4a542df599f1837512f3d5 https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git kbuild) Bug: 347787665 Signed-off-by: Matthew Maurer <mmaurer@google.com> Change-Id: Id6279538db7fc1616dc6a1a4b980df271e8df087 Signed-off-by: Matthew Maurer <mmaurer@google.com>
This commit is contained in:
committed by
Giuliano Procida
parent
bbbb64a40f
commit
1e7815837f
@@ -169,6 +169,22 @@ config MODVERSIONS
|
||||
make them incompatible with the kernel you are running. If
|
||||
unsure, say N.
|
||||
|
||||
choice
|
||||
prompt "Module versioning implementation"
|
||||
depends on MODVERSIONS
|
||||
help
|
||||
Select the tool used to calculate symbol versions for modules.
|
||||
|
||||
If unsure, select GENKSYMS.
|
||||
|
||||
config GENKSYMS
|
||||
bool "genksyms (from source code)"
|
||||
help
|
||||
Calculate symbol versions from pre-processed source code using
|
||||
genksyms.
|
||||
|
||||
If unsure, say Y.
|
||||
|
||||
config GENDWARFKSYMS
|
||||
bool "gendwarfksyms (from debugging information)"
|
||||
depends on DEBUG_INFO
|
||||
@@ -176,6 +192,12 @@ config GENDWARFKSYMS
|
||||
depends on !DEBUG_INFO_REDUCED && !DEBUG_INFO_SPLIT
|
||||
# Requires ELF object files.
|
||||
depends on !LTO
|
||||
help
|
||||
Calculate symbol versions from DWARF debugging information using
|
||||
gendwarfksyms. Requires DEBUG_INFO to be enabled.
|
||||
|
||||
If unsure, say N.
|
||||
endchoice
|
||||
|
||||
config ASM_MODVERSIONS
|
||||
bool
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ hostprogs += unifdef
|
||||
targets += module.lds
|
||||
|
||||
subdir-$(CONFIG_GCC_PLUGINS) += gcc-plugins
|
||||
subdir-$(CONFIG_MODVERSIONS) += genksyms
|
||||
subdir-$(CONFIG_GENKSYMS) += genksyms
|
||||
subdir-$(CONFIG_GENDWARFKSYMS) += gendwarfksyms
|
||||
subdir-$(CONFIG_SECURITY_SELINUX) += selinux
|
||||
subdir-$(CONFIG_SECURITY_IPE) += ipe
|
||||
|
||||
+29
-6
@@ -107,13 +107,24 @@ cmd_cpp_i_c = $(CPP) $(c_flags) -o $@ $<
|
||||
$(obj)/%.i: $(obj)/%.c FORCE
|
||||
$(call if_changed_dep,cpp_i_c)
|
||||
|
||||
getexportsymbols = $(NM) $@ | sed -n 's/.* __export_symbol_\(.*\)/$(1)/p'
|
||||
|
||||
gendwarfksyms = $(objtree)/scripts/gendwarfksyms/gendwarfksyms \
|
||||
$(if $(KBUILD_SYMTYPES), --symtypes $(@:.o=.symtypes)) \
|
||||
$(if $(KBUILD_GENDWARFKSYMS_STABLE), --stable)
|
||||
|
||||
genksyms = $(objtree)/scripts/genksyms/genksyms \
|
||||
$(if $(1), -T $(2)) \
|
||||
$(if $(KBUILD_PRESERVE), -p) \
|
||||
-r $(or $(wildcard $(2:.symtypes=.symref)), /dev/null)
|
||||
|
||||
# These mirror gensymtypes_S and co below, keep them in synch.
|
||||
ifdef CONFIG_GENDWARFKSYMS
|
||||
cmd_gensymtypes_c = $(if $(skip_gendwarfksyms),, \
|
||||
$(call getexportsymbols,\1) | $(gendwarfksyms) $@)
|
||||
else
|
||||
cmd_gensymtypes_c = $(CPP) -D__GENKSYMS__ $(c_flags) $< | $(genksyms)
|
||||
endif # CONFIG_GENDWARFKSYMS
|
||||
|
||||
quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@
|
||||
cmd_cc_symtypes_c = $(call cmd_gensymtypes_c,true,$@) >/dev/null
|
||||
@@ -314,14 +325,26 @@ $(obj)/%.ll: $(obj)/%.rs FORCE
|
||||
# This is convoluted. The .S file must first be preprocessed to run guards and
|
||||
# expand names, then the resulting exports must be constructed into plain
|
||||
# EXPORT_SYMBOL(symbol); to build our dummy C file, and that gets preprocessed
|
||||
# to make the genksyms input.
|
||||
# to make the genksyms input or compiled into an object for gendwarfksyms.
|
||||
#
|
||||
# These mirror gensymtypes_c and co above, keep them in synch.
|
||||
cmd_gensymtypes_S = \
|
||||
{ echo "\#include <linux/kernel.h>" ; \
|
||||
echo "\#include <asm/asm-prototypes.h>" ; \
|
||||
$(NM) $@ | sed -n 's/.* __export_symbol_\(.*\)/EXPORT_SYMBOL(\1);/p' ; } | \
|
||||
$(CPP) -D__GENKSYMS__ $(c_flags) -xc - | $(genksyms)
|
||||
getasmexports = \
|
||||
{ echo "\#include <linux/kernel.h>" ; \
|
||||
echo "\#include <linux/string.h>" ; \
|
||||
echo "\#include <asm/asm-prototypes.h>" ; \
|
||||
$(call getexportsymbols,EXPORT_SYMBOL(\1);) ; }
|
||||
|
||||
ifdef CONFIG_GENDWARFKSYMS
|
||||
cmd_gensymtypes_S = \
|
||||
$(getasmexports) | \
|
||||
$(CC) $(c_flags) -c -o $(@:.o=.gendwarfksyms.o) -xc -; \
|
||||
$(call getexportsymbols,\1) | \
|
||||
$(gendwarfksyms) $(@:.o=.gendwarfksyms.o)
|
||||
else
|
||||
cmd_gensymtypes_S = \
|
||||
$(getasmexports) | \
|
||||
$(CPP) -D__GENKSYMS__ $(c_flags) -xc - | $(genksyms)
|
||||
endif # CONFIG_GENDWARFKSYMS
|
||||
|
||||
quiet_cmd_cc_symtypes_S = SYM $(quiet_modtag) $@
|
||||
cmd_cc_symtypes_S = $(call cmd_gensymtypes_S,true,$@) >/dev/null
|
||||
|
||||
Reference in New Issue
Block a user