Skip to content

Commit 26ef40d

Browse files
committed
kbuild: move .vmlinux.objs rule to Makefile.modpost
.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 <[email protected]> Tested-by: Nick Desaulniers <[email protected]> Reviewed-by: Nicolas Schier <[email protected]>
1 parent 5750121 commit 26ef40d

File tree

3 files changed

+29
-21
lines changed

3 files changed

+29
-21
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1477,7 +1477,7 @@ endif # CONFIG_MODULES
14771477
# Directories & files removed with 'make clean'
14781478
CLEAN_FILES += include/ksym vmlinux.symvers modules-only.symvers \
14791479
modules.builtin modules.builtin.modinfo modules.nsdeps \
1480-
compile_commands.json .thinlto-cache
1480+
compile_commands.json .thinlto-cache .vmlinux.objs
14811481

14821482
# Directories & files removed with 'make mrproper'
14831483
MRPROPER_FILES += include/config include/generated \

scripts/Makefile.modpost

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,32 @@ vmlinux.symvers: vmlinux.o
5757

5858
__modpost: vmlinux.symvers
5959

60+
# Generate the list of in-tree objects in vmlinux
61+
# ---------------------------------------------------------------------------
62+
63+
# This is used to retrieve symbol versions generated by genksyms.
64+
ifdef CONFIG_MODVERSIONS
65+
vmlinux.symvers: .vmlinux.objs
66+
endif
67+
68+
# Ignore libgcc.a
69+
# Some architectures do '$(CC) --print-libgcc-file-name' to borrow libgcc.a
70+
# from the toolchain, but there is no EXPORT_SYMBOL in it.
71+
72+
quiet_cmd_vmlinux_objs = GEN $@
73+
cmd_vmlinux_objs = \
74+
for f in $(real-prereqs); do \
75+
case $${f} in \
76+
*libgcc.a) ;; \
77+
*.a) $(AR) t $${f} ;; \
78+
*) echo $${f} ;; \
79+
esac \
80+
done > $@
81+
82+
targets += .vmlinux.objs
83+
.vmlinux.objs: $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) FORCE
84+
$(call if_changed,vmlinux_objs)
85+
6086
else
6187

6288
ifeq ($(KBUILD_EXTMOD),)
@@ -134,13 +160,13 @@ ifneq ($(KBUILD_MODPOST_NOFINAL),1)
134160
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal
135161
endif
136162

163+
endif
164+
137165
PHONY += FORCE
138166
FORCE:
139167

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

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

144-
endif
145-
146172
.PHONY: $(PHONY)

scripts/link-vmlinux.sh

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ cleanup()
199199
rm -f System.map
200200
rm -f vmlinux
201201
rm -f vmlinux.map
202-
rm -f .vmlinux.objs
203202
rm -f .vmlinux.export.c
204203
}
205204

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

221-
# Generate the list of in-tree objects in vmlinux
222-
#
223-
# This is used to retrieve symbol versions generated by genksyms.
224-
for f in ${KBUILD_VMLINUX_OBJS} ${KBUILD_VMLINUX_LIBS}; do
225-
case ${f} in
226-
*libgcc.a)
227-
# Some architectures do '$(CC) --print-libgcc-file-name' to
228-
# borrow libgcc.a from the toolchain.
229-
# There is no EXPORT_SYMBOL in external objects. Ignore this.
230-
;;
231-
*.a)
232-
${AR} t ${f} ;;
233-
*)
234-
echo ${f} ;;
235-
esac
236-
done > .vmlinux.objs
237-
238220
# modpost vmlinux.o to check for section mismatches
239221
${MAKE} -f "${srctree}/scripts/Makefile.modpost" MODPOST_VMLINUX=1
240222

0 commit comments

Comments
 (0)