Skip to content

Commit

Permalink
kbuild: move .vmlinux.objs rule to Makefile.modpost
Browse files Browse the repository at this point in the history
.vmlinux.objs is used by modpost, so scripts/Makefile.modpost is
a better place to generate it.

It is used only when CONFIG_MODVERSIONS=y. It should be guarded
by "ifdef CONFIG_MODVERSIONS".

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
  • Loading branch information
Masahiro Yamada committed Sep 28, 2022
1 parent 5750121 commit 26ef40d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1477,7 +1477,7 @@ endif # CONFIG_MODULES
# Directories & files removed with 'make clean'
CLEAN_FILES += include/ksym vmlinux.symvers modules-only.symvers \
modules.builtin modules.builtin.modinfo modules.nsdeps \
compile_commands.json .thinlto-cache
compile_commands.json .thinlto-cache .vmlinux.objs

# Directories & files removed with 'make mrproper'
MRPROPER_FILES += include/config include/generated \
Expand Down
30 changes: 28 additions & 2 deletions scripts/Makefile.modpost
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,32 @@ vmlinux.symvers: vmlinux.o

__modpost: vmlinux.symvers

# Generate the list of in-tree objects in vmlinux
# ---------------------------------------------------------------------------

# This is used to retrieve symbol versions generated by genksyms.
ifdef CONFIG_MODVERSIONS
vmlinux.symvers: .vmlinux.objs
endif

# Ignore libgcc.a
# Some architectures do '$(CC) --print-libgcc-file-name' to borrow libgcc.a
# from the toolchain, but there is no EXPORT_SYMBOL in it.

quiet_cmd_vmlinux_objs = GEN $@
cmd_vmlinux_objs = \
for f in $(real-prereqs); do \
case $${f} in \
*libgcc.a) ;; \
*.a) $(AR) t $${f} ;; \
*) echo $${f} ;; \
esac \
done > $@

targets += .vmlinux.objs
.vmlinux.objs: $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) FORCE
$(call if_changed,vmlinux_objs)

else

ifeq ($(KBUILD_EXTMOD),)
Expand Down Expand Up @@ -134,13 +160,13 @@ ifneq ($(KBUILD_MODPOST_NOFINAL),1)
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal
endif

endif

PHONY += FORCE
FORCE:

existing-targets := $(wildcard $(sort $(targets)))

-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)

endif

.PHONY: $(PHONY)
18 changes: 0 additions & 18 deletions scripts/link-vmlinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ cleanup()
rm -f System.map
rm -f vmlinux
rm -f vmlinux.map
rm -f .vmlinux.objs
rm -f .vmlinux.export.c
}

Expand All @@ -218,23 +217,6 @@ fi
#link vmlinux.o
${MAKE} -f "${srctree}/scripts/Makefile.vmlinux_o"

# Generate the list of in-tree objects in vmlinux
#
# This is used to retrieve symbol versions generated by genksyms.
for f in ${KBUILD_VMLINUX_OBJS} ${KBUILD_VMLINUX_LIBS}; do
case ${f} in
*libgcc.a)
# Some architectures do '$(CC) --print-libgcc-file-name' to
# borrow libgcc.a from the toolchain.
# There is no EXPORT_SYMBOL in external objects. Ignore this.
;;
*.a)
${AR} t ${f} ;;
*)
echo ${f} ;;
esac
done > .vmlinux.objs

# modpost vmlinux.o to check for section mismatches
${MAKE} -f "${srctree}/scripts/Makefile.modpost" MODPOST_VMLINUX=1

Expand Down

0 comments on commit 26ef40d

Please sign in to comment.