From d624007eb12b7707bf360346160b27fdd84785aa Mon Sep 17 00:00:00 2001 From: Will McVicker Date: Fri, 14 Oct 2022 22:35:15 -0700 Subject: [PATCH] ANDROID: kbuild: re-add vmlinux.symvers for mixed building The modpost build phase was refactored upstream in commit f73edc8951b2 ("kbuild: unify two modpost invocations"). The new implementation does not generate a vmlinux.symvers which our existing mixed build implementation depends upon to match the KMI between the modules and GKI kernel (via depmod). Since the Module.symvers is equal to the vmlinux.symvers + modules-only.symvers, this patch adds support to generate the vmlinux.symvers in order to continue using the existing mixed build implementation. Just a couple of notes: 1) This allows us to use the same mixed build implementation for android14-6.1 and android14-5.15 without making any build tooling changes. 2) This implementation won't catch build-time vendor changes to GKI Module CRCs during modpost. This is due to the fact that we are only using the vmlinux.symvers from the GKI kernel pass and not including the CRCs for the GKI modules. Bug: 253726452 Signed-off-by: Will McVicker Change-Id: I4b964434d02abbcdb694d3e03bfa4dc2d5a81f85 --- Makefile | 2 +- scripts/Makefile.modpost | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d708bfa0c004..8e42be0655cc 100644 --- a/Makefile +++ b/Makefile @@ -1975,7 +1975,7 @@ KBUILD_MODULES := endif # CONFIG_MODULES PHONY += modpost -modpost: $(if $(single-build),, $(if $(KBUILD_BUILTIN), vmlinux.o)) \ +modpost: $(if $(single-build),, $(if $(KBUILD_MIXED_TREE),,$(if $(KBUILD_BUILTIN), vmlinux.o))) \ $(if $(KBUILD_MODULES), modules_check) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index b315a410d729..1e11f6f582c3 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -60,8 +60,10 @@ ifeq ($(KBUILD_EXTMOD),) # This is used to retrieve symbol versions generated by genksyms. ifdef CONFIG_MODVERSIONS +ifndef KBUILD_MIXED_TREE vmlinux.symvers Module.symvers: .vmlinux.objs endif +endif # Ignore libgcc.a # Some architectures do '$(CC) --print-libgcc-file-name' to borrow libgcc.a @@ -76,9 +78,17 @@ quiet_cmd_vmlinux_objs = GEN $@ esac \ done > $@ +quiet_cmd_vmlinux_symvers = GEN $@ + cmd_vmlinux_symvers = grep "\ $@ + +quiet_cmd_cat_symvers = GEN $@ + cmd_cat_symvers = cat $(real-prereqs) > $@ + +ifndef KBUILD_MIXED_TREE targets += .vmlinux.objs .vmlinux.objs: vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE $(call if_changed,vmlinux_objs) +endif vmlinux.o-if-present := $(wildcard vmlinux.o) output-symdump := vmlinux.symvers @@ -86,6 +96,27 @@ output-symdump := vmlinux.symvers ifdef KBUILD_MODULES output-symdump := $(if $(vmlinux.o-if-present), Module.symvers, modules-only.symvers) missing-input := $(filter-out $(vmlinux.o-if-present),vmlinux.o) + +targets += vmlinux.symvers +vmlinux.symvers: Module.symvers FORCE + $(call if_changed,vmlinux_symvers) + +__modpost: $(if $(vmlinux.o-if-present),vmlinux.symvers,) +endif + +# Overwrite values for mixed building (overwritting makes merges easier) +ifdef KBUILD_MIXED_TREE +targets += Module.symvers +Module.symvers: $(mixed-build-prefix)vmlinux.symvers modules-only.symvers FORCE + $(call if_changed,cat_symvers) + +__modpost: Module.symvers + +vmlinux.o-if-present := +vmlinux.symvers-if-present := $(wildcard $(mixed-build-prefix)vmlinux.symvers) +modpost-args += $(addprefix -i ,$(vmlinux.symvers-if-present)) +output-symdump := modules-only.symvers +missing-input := $(filter-out $(vmlinux.symvers-if-present),$(mixed-build-prefix)vmlinux.symvers) endif else