ANDROID: kbuild: re-add vmlinux.symvers for mixed building

The modpost build phase was refactored upstream in commit f73edc8951
("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 <willmcvicker@google.com>
Change-Id: I4b964434d02abbcdb694d3e03bfa4dc2d5a81f85
This commit is contained in:
Will McVicker 2022-10-14 22:35:15 -07:00
parent 558762106d
commit d624007eb1
2 changed files with 32 additions and 1 deletions

View File

@ -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

View File

@ -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 "\<vmlinux\s\+EXPORT" $< > $@
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