Skip to content

Commit 56769ba

Browse files
committed
kbuild: unify vdso_install rules
Currently, there is no standard implementation for vdso_install, leading to various issues: 1. Code duplication Many architectures duplicate similar code just for copying files to the install destination. Some architectures (arm, sparc, x86) create build-id symlinks, introducing more code duplication. 2. Unintended updates of in-tree build artifacts The vdso_install rule depends on the vdso files to install. It may update in-tree build artifacts. This can be problematic, as explained in commit 19514fc ("arm, kbuild: make "make install" not depend on vmlinux"). 3. Broken code in some architectures Makefile code is often copied from one architecture to another without proper adaptation. 'make vdso_install' for parisc does not work. 'make vdso_install' for s390 installs vdso64, but not vdso32. To address these problems, this commit introduces a generic vdso_install rule. Architectures that support vdso_install need to define vdso-install-y in arch/*/Makefile. vdso-install-y lists the files to install. For example, arch/x86/Makefile looks like this: vdso-install-$(CONFIG_X86_64) += arch/x86/entry/vdso/vdso64.so.dbg vdso-install-$(CONFIG_X86_X32_ABI) += arch/x86/entry/vdso/vdsox32.so.dbg vdso-install-$(CONFIG_X86_32) += arch/x86/entry/vdso/vdso32.so.dbg vdso-install-$(CONFIG_IA32_EMULATION) += arch/x86/entry/vdso/vdso32.so.dbg These files will be installed to $(MODLIB)/vdso/ with the .dbg suffix, if exists, stripped away. vdso-install-y can optionally take the second field after the colon separator. This is needed because some architectures install a vdso file as a different base name. The following is a snippet from arch/arm64/Makefile. vdso-install-$(CONFIG_COMPAT_VDSO) += arch/arm64/kernel/vdso32/vdso.so.dbg:vdso32.so This will rename vdso.so.dbg to vdso32.so during installation. If such architectures change their implementation so that the base names match, this workaround will go away. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Acked-by: Sven Schnelle <svens@linux.ibm.com> # s390 Reviewed-by: Nicolas Schier <nicolas@fjasle.eu> Reviewed-by: Guo Ren <guoren@kernel.org> Acked-by: Helge Deller <deller@gmx.de> # parisc Acked-by: Catalin Marinas <catalin.marinas@arm.com> Acked-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
1 parent 1b62728 commit 56769ba

20 files changed

Lines changed: 73 additions & 185 deletions

File tree

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,6 +1317,14 @@ scripts_unifdef: scripts_basic
13171317
quiet_cmd_install = INSTALL $(INSTALL_PATH)
13181318
cmd_install = unset sub_make_done; $(srctree)/scripts/install.sh
13191319

1320+
# ---------------------------------------------------------------------------
1321+
# vDSO install
1322+
1323+
PHONY += vdso_install
1324+
vdso_install: export INSTALL_FILES = $(vdso-install-y)
1325+
vdso_install:
1326+
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vdsoinst
1327+
13201328
# ---------------------------------------------------------------------------
13211329
# Tools
13221330

@@ -1560,6 +1568,7 @@ help:
15601568
@echo '* vmlinux - Build the bare kernel'
15611569
@echo '* modules - Build all modules'
15621570
@echo ' modules_install - Install all modules to INSTALL_MOD_PATH (default: /)'
1571+
@echo ' vdso_install - Install unstripped vdso to INSTALL_MOD_PATH (default: /)'
15631572
@echo ' dir/ - Build all files in dir and below'
15641573
@echo ' dir/file.[ois] - Build specified target only'
15651574
@echo ' dir/file.ll - Build the LLVM assembly file'

arch/arm/Makefile

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,7 @@ $(INSTALL_TARGETS): KBUILD_IMAGE = $(boot)/$(patsubst %install,%Image,$@)
304304
$(INSTALL_TARGETS):
305305
$(call cmd,install)
306306

307-
PHONY += vdso_install
308-
vdso_install:
309-
ifeq ($(CONFIG_VDSO),y)
310-
$(Q)$(MAKE) $(build)=arch/arm/vdso $@
311-
endif
307+
vdso-install-$(CONFIG_VDSO) += arch/arm/vdso/vdso.so.dbg
312308

313309
# My testing targets (bypasses dependencies)
314310
bp:; $(Q)$(MAKE) $(build)=$(boot) $(boot)/bootpImage
@@ -331,7 +327,6 @@ define archhelp
331327
echo ' Install using (your) ~/bin/$(INSTALLKERNEL) or'
332328
echo ' (distribution) /sbin/$(INSTALLKERNEL) or'
333329
echo ' install to $$(INSTALL_PATH) and run lilo'
334-
echo ' vdso_install - Install unstripped vdso.so to $$(INSTALL_MOD_PATH)/vdso'
335330
echo
336331
echo ' multi_v7_lpae_defconfig - multi_v7_defconfig with CONFIG_ARM_LPAE enabled'
337332
endef

arch/arm/vdso/Makefile

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -63,28 +63,3 @@ quiet_cmd_vdsold_and_vdso_check = LD $@
6363

6464
quiet_cmd_vdsomunge = MUNGE $@
6565
cmd_vdsomunge = $(objtree)/$(obj)/vdsomunge $< $@
66-
67-
#
68-
# Install the unstripped copy of vdso.so.dbg. If our toolchain
69-
# supports build-id, install .build-id links as well.
70-
#
71-
# Cribbed from arch/x86/vdso/Makefile.
72-
#
73-
quiet_cmd_vdso_install = INSTALL $<
74-
define cmd_vdso_install
75-
cp $< "$(MODLIB)/vdso/vdso.so"; \
76-
if readelf -n $< | grep -q 'Build ID'; then \
77-
buildid=`readelf -n $< |grep 'Build ID' |sed -e 's/^.*Build ID: \(.*\)$$/\1/'`; \
78-
first=`echo $$buildid | cut -b-2`; \
79-
last=`echo $$buildid | cut -b3-`; \
80-
mkdir -p "$(MODLIB)/vdso/.build-id/$$first"; \
81-
ln -sf "../../vdso.so" "$(MODLIB)/vdso/.build-id/$$first/$$last.debug"; \
82-
fi
83-
endef
84-
85-
$(MODLIB)/vdso: FORCE
86-
@mkdir -p $(MODLIB)/vdso
87-
88-
PHONY += vdso_install
89-
vdso_install: $(obj)/vdso.so.dbg $(MODLIB)/vdso
90-
$(call cmd,vdso_install)

arch/arm64/Makefile

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,6 @@ install: KBUILD_IMAGE := $(boot)/Image
169169
install zinstall:
170170
$(call cmd,install)
171171

172-
PHONY += vdso_install
173-
vdso_install:
174-
$(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso $@
175-
$(if $(CONFIG_COMPAT_VDSO), \
176-
$(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso32 $@)
177-
178172
archprepare:
179173
$(Q)$(MAKE) $(build)=arch/arm64/tools kapi
180174
ifeq ($(CONFIG_ARM64_ERRATUM_843419),y)
@@ -205,6 +199,9 @@ ifdef CONFIG_COMPAT_VDSO
205199
endif
206200
endif
207201

202+
vdso-install-y += arch/arm64/kernel/vdso/vdso.so.dbg
203+
vdso-install-$(CONFIG_COMPAT_VDSO) += arch/arm64/kernel/vdso32/vdso.so.dbg:vdso32.so
204+
208205
include $(srctree)/scripts/Makefile.defconf
209206

210207
PHONY += virtconfig

arch/arm64/kernel/vdso/Makefile

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,3 @@ include/generated/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE
7878
# Actual build commands
7979
quiet_cmd_vdsold_and_vdso_check = LD $@
8080
cmd_vdsold_and_vdso_check = $(cmd_ld); $(cmd_vdso_check)
81-
82-
# Install commands for the unstripped file
83-
quiet_cmd_vdso_install = INSTALL $@
84-
cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
85-
86-
vdso.so: $(obj)/vdso.so.dbg
87-
@mkdir -p $(MODLIB)/vdso
88-
$(call cmd,vdso_install)
89-
90-
vdso_install: vdso.so

arch/arm64/kernel/vdso32/Makefile

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,3 @@ gen-vdsosym := $(srctree)/$(src)/../vdso/gen_vdso_offsets.sh
172172
quiet_cmd_vdsosym = VDSOSYM $@
173173
# The AArch64 nm should be able to read an AArch32 binary
174174
cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@
175-
176-
# Install commands for the unstripped file
177-
quiet_cmd_vdso_install = INSTALL32 $@
178-
cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/vdso32.so
179-
180-
vdso.so: $(obj)/vdso.so.dbg
181-
@mkdir -p $(MODLIB)/vdso
182-
$(call cmd,vdso_install)
183-
184-
vdso_install: vdso.so

arch/loongarch/Makefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,7 @@ vdso_prepare: prepare0
136136
$(Q)$(MAKE) $(build)=arch/loongarch/vdso include/generated/vdso-offsets.h
137137
endif
138138

139-
PHONY += vdso_install
140-
vdso_install:
141-
$(Q)$(MAKE) $(build)=arch/loongarch/vdso $@
139+
vdso-install-y += arch/loongarch/vdso/vdso.so.dbg
142140

143141
all: $(notdir $(KBUILD_IMAGE))
144142

arch/loongarch/vdso/Makefile

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,3 @@ $(obj)/vdso.so: $(obj)/vdso.so.dbg FORCE
8383
obj-y += vdso.o
8484

8585
$(obj)/vdso.o : $(obj)/vdso.so
86-
87-
# install commands for the unstripped file
88-
quiet_cmd_vdso_install = INSTALL $@
89-
cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
90-
91-
vdso.so: $(obj)/vdso.so.dbg
92-
@mkdir -p $(MODLIB)/vdso
93-
$(call cmd,vdso_install)
94-
95-
vdso_install: vdso.so

arch/parisc/Makefile

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,8 @@ vdso_prepare: prepare0
177177
$(Q)$(MAKE) $(build)=arch/parisc/kernel/vdso32 include/generated/vdso32-offsets.h
178178
endif
179179

180-
PHONY += vdso_install
181-
182-
vdso_install:
183-
$(Q)$(MAKE) $(build)=arch/parisc/kernel/vdso $@
184-
$(if $(CONFIG_COMPAT_VDSO), \
185-
$(Q)$(MAKE) $(build)=arch/parisc/kernel/vdso32 $@)
180+
vdso-install-y += arch/parisc/kernel/vdso32/vdso32.so
181+
vdso-install-$(CONFIG_64BIT) += arch/parisc/kernel/vdso64/vdso64.so
186182

187183
install: KBUILD_IMAGE := vmlinux
188184
zinstall: KBUILD_IMAGE := vmlinuz

arch/riscv/Makefile

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,6 @@ endif
131131
libs-y += arch/riscv/lib/
132132
libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a
133133

134-
PHONY += vdso_install
135-
vdso_install:
136-
$(Q)$(MAKE) $(build)=arch/riscv/kernel/vdso $@
137-
$(if $(CONFIG_COMPAT),$(Q)$(MAKE) \
138-
$(build)=arch/riscv/kernel/compat_vdso compat_$@)
139-
140134
ifeq ($(KBUILD_EXTMOD),)
141135
ifeq ($(CONFIG_MMU),y)
142136
prepare: vdso_prepare
@@ -148,6 +142,9 @@ vdso_prepare: prepare0
148142
endif
149143
endif
150144

145+
vdso-install-y += arch/riscv/kernel/vdso/vdso.so.dbg
146+
vdso-install-$(CONFIG_COMPAT) += arch/riscv/kernel/compat_vdso/compat_vdso.so.dbg:../compat_vdso/compat_vdso.so
147+
151148
ifneq ($(CONFIG_XIP_KERNEL),y)
152149
ifeq ($(CONFIG_RISCV_M_MODE)$(CONFIG_ARCH_CANAAN),yy)
153150
KBUILD_IMAGE := $(boot)/loader.bin

0 commit comments

Comments
 (0)