Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arm64: Fix vdso-offsets.h dependency

arch/arm64/kernel/{vdso,signal}.c include generated/vdso-offsets.h, and
therefore the symbol offsets must be generated before these files are
compiled.

The current rules in arm64/kernel/Makefile do not actually enforce
this, because even though $(obj)/vdso is listed as a prerequisite for
vdso-offsets.h, this does not result in the intended effect of
building the vdso subdirectory (before all the other objects). As a
consequence, depending on the order in which the rules are followed,
vdso-offsets.h is updated or not before arm64/kernel/{vdso,signal}.o
are built. The current rules also impose an unnecessary dependency on
vdso-offsets.h for all arm64/kernel/*.o, resulting in unnecessary
rebuilds.

This patch removes the arch/arm64/kernel/vdso/vdso-offsets.h file
generation, leaving only the include/generated/vdso-offsets.h one. It
adds a forced dependency check of the vdso-offsets.h file in
arch/arm64/kernel/Makefile which, if not up to date according to the
arch/arm64/kernel/vdso/Makefile rules (depending on vdso.so.dbg), will
trigger the vdso/ subdirectory build and vdso-offsets.h re-generation.
Automatic kbuild dependency rules between kernel/{vdso,signal}.c rules
and vdso-offsets.h will guarantee that the vDSO object is built first,
followed by the generated symbol offsets header file.

Reported-by: Kevin Brodsky <kevin.brodsky@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

+7 -7
+4 -3
arch/arm64/kernel/Makefile
··· 54 54 head-y := head.o 55 55 extra-y += $(head-y) vmlinux.lds 56 56 57 - # vDSO - this must be built first to generate the symbol offsets 58 - $(call objectify,$(arm64-obj-y)): $(obj)/vdso/vdso-offsets.h 59 - $(obj)/vdso/vdso-offsets.h: $(obj)/vdso 57 + # Check that the vDSO symbol offsets header file is up to date and re-generate 58 + # it if necessary. 59 + $(objtree)/include/generated/vdso-offsets.h: FORCE 60 + $(Q)$(MAKE) $(build)=$(obj)/vdso $@
+3 -4
arch/arm64/kernel/vdso/Makefile
··· 23 23 ccflags-y += -Wl,-shared 24 24 25 25 obj-y += vdso.o 26 - extra-y += vdso.lds vdso-offsets.h 26 + extra-y += vdso.lds 27 27 CPPFLAGS_vdso.lds += -P -C -U$(ARCH) 28 28 29 29 # Force dependency (incbin is bad) ··· 42 42 gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh 43 43 quiet_cmd_vdsosym = VDSOSYM $@ 44 44 define cmd_vdsosym 45 - $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@ && \ 46 - cp $@ include/generated/ 45 + $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@ 47 46 endef 48 47 49 - $(obj)/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE 48 + $(objtree)/include/generated/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE 50 49 $(call if_changed,vdsosym) 51 50 52 51 # Assembly rules for the .S files