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

Configure Feed

Select the types of activity you want to include in your feed.

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 19514fc665ff ("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>

+73 -185
+9
Makefile
··· 1318 1318 cmd_install = unset sub_make_done; $(srctree)/scripts/install.sh 1319 1319 1320 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 + 1328 + # --------------------------------------------------------------------------- 1321 1329 # Tools 1322 1330 1323 1331 ifdef CONFIG_OBJTOOL ··· 1568 1560 @echo '* vmlinux - Build the bare kernel' 1569 1561 @echo '* modules - Build all modules' 1570 1562 @echo ' modules_install - Install all modules to INSTALL_MOD_PATH (default: /)' 1563 + @echo ' vdso_install - Install unstripped vdso to INSTALL_MOD_PATH (default: /)' 1571 1564 @echo ' dir/ - Build all files in dir and below' 1572 1565 @echo ' dir/file.[ois] - Build specified target only' 1573 1566 @echo ' dir/file.ll - Build the LLVM assembly file'
+1 -6
arch/arm/Makefile
··· 304 304 $(INSTALL_TARGETS): 305 305 $(call cmd,install) 306 306 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 312 308 313 309 # My testing targets (bypasses dependencies) 314 310 bp:; $(Q)$(MAKE) $(build)=$(boot) $(boot)/bootpImage ··· 327 331 echo ' Install using (your) ~/bin/$(INSTALLKERNEL) or' 328 332 echo ' (distribution) /sbin/$(INSTALLKERNEL) or' 329 333 echo ' install to $$(INSTALL_PATH) and run lilo' 330 - echo ' vdso_install - Install unstripped vdso.so to $$(INSTALL_MOD_PATH)/vdso' 331 334 echo 332 335 echo ' multi_v7_lpae_defconfig - multi_v7_defconfig with CONFIG_ARM_LPAE enabled' 333 336 endef
-25
arch/arm/vdso/Makefile
··· 63 63 64 64 quiet_cmd_vdsomunge = MUNGE $@ 65 65 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)
+3 -6
arch/arm64/Makefile
··· 169 169 install zinstall: 170 170 $(call cmd,install) 171 171 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 - 178 172 archprepare: 179 173 $(Q)$(MAKE) $(build)=arch/arm64/tools kapi 180 174 ifeq ($(CONFIG_ARM64_ERRATUM_843419),y) ··· 198 204 include/generated/vdso32-offsets.h arch/arm64/kernel/vdso32/vdso.so 199 205 endif 200 206 endif 207 + 208 + vdso-install-y += arch/arm64/kernel/vdso/vdso.so.dbg 209 + vdso-install-$(CONFIG_COMPAT_VDSO) += arch/arm64/kernel/vdso32/vdso.so.dbg:vdso32.so 201 210 202 211 include $(srctree)/scripts/Makefile.defconf 203 212
-10
arch/arm64/kernel/vdso/Makefile
··· 78 78 # Actual build commands 79 79 quiet_cmd_vdsold_and_vdso_check = LD $@ 80 80 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
-10
arch/arm64/kernel/vdso32/Makefile
··· 172 172 quiet_cmd_vdsosym = VDSOSYM $@ 173 173 # The AArch64 nm should be able to read an AArch32 binary 174 174 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
+1 -3
arch/loongarch/Makefile
··· 136 136 $(Q)$(MAKE) $(build)=arch/loongarch/vdso include/generated/vdso-offsets.h 137 137 endif 138 138 139 - PHONY += vdso_install 140 - vdso_install: 141 - $(Q)$(MAKE) $(build)=arch/loongarch/vdso $@ 139 + vdso-install-y += arch/loongarch/vdso/vdso.so.dbg 142 140 143 141 all: $(notdir $(KBUILD_IMAGE)) 144 142
-10
arch/loongarch/vdso/Makefile
··· 83 83 obj-y += vdso.o 84 84 85 85 $(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
+2 -6
arch/parisc/Makefile
··· 177 177 $(Q)$(MAKE) $(build)=arch/parisc/kernel/vdso32 include/generated/vdso32-offsets.h 178 178 endif 179 179 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 186 182 187 183 install: KBUILD_IMAGE := vmlinux 188 184 zinstall: KBUILD_IMAGE := vmlinuz
+3 -6
arch/riscv/Makefile
··· 131 131 libs-y += arch/riscv/lib/ 132 132 libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a 133 133 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 - 140 134 ifeq ($(KBUILD_EXTMOD),) 141 135 ifeq ($(CONFIG_MMU),y) 142 136 prepare: vdso_prepare ··· 141 147 142 148 endif 143 149 endif 150 + 151 + vdso-install-y += arch/riscv/kernel/vdso/vdso.so.dbg 152 + vdso-install-$(CONFIG_COMPAT) += arch/riscv/kernel/compat_vdso/compat_vdso.so.dbg:../compat_vdso/compat_vdso.so 144 153 145 154 ifneq ($(CONFIG_XIP_KERNEL),y) 146 155 ifeq ($(CONFIG_RISCV_M_MODE)$(CONFIG_ARCH_CANAAN),yy)
-10
arch/riscv/kernel/compat_vdso/Makefile
··· 76 76 # actual build commands 77 77 quiet_cmd_compat_vdsoas = VDSOAS $@ 78 78 cmd_compat_vdsoas = $(COMPAT_CC) $(a_flags) $(COMPAT_CC_FLAGS) -c -o $@ $< 79 - 80 - # install commands for the unstripped file 81 - quiet_cmd_compat_vdso_install = INSTALL $@ 82 - cmd_compat_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/compat_vdso/$@ 83 - 84 - compat_vdso.so: $(obj)/compat_vdso.so.dbg 85 - @mkdir -p $(MODLIB)/compat_vdso 86 - $(call cmd,compat_vdso_install) 87 - 88 - compat_vdso_install: compat_vdso.so
-10
arch/riscv/kernel/vdso/Makefile
··· 73 73 cmd_vdsold = $(LD) $(ld_flags) -T $(filter-out FORCE,$^) -o $@.tmp && \ 74 74 $(OBJCOPY) $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \ 75 75 rm $@.tmp 76 - 77 - # install commands for the unstripped file 78 - quiet_cmd_vdso_install = INSTALL $@ 79 - cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@ 80 - 81 - vdso.so: $(obj)/vdso.so.dbg 82 - @mkdir -p $(MODLIB)/vdso 83 - $(call cmd,vdso_install) 84 - 85 - vdso_install: vdso.so
+3 -3
arch/s390/Makefile
··· 138 138 zfcpdump: 139 139 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ 140 140 141 - vdso_install: 142 - $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@ 143 - 144 141 archheaders: 145 142 $(Q)$(MAKE) $(build)=$(syscalls) uapi 146 143 ··· 156 159 $(Q)$(MAKE) $(build)=arch/s390/kernel/vdso64 include/generated/vdso64-offsets.h 157 160 $(if $(CONFIG_COMPAT),$(Q)$(MAKE) \ 158 161 $(build)=arch/s390/kernel/vdso32 include/generated/vdso32-offsets.h) 162 + 163 + vdso-install-y += arch/s390/kernel/vdso64/vdso64.so.dbg 164 + vdso-install-$(CONFIG_COMPAT) += arch/s390/kernel/vdso32/vdso32.so.dbg 159 165 160 166 ifdef CONFIG_EXPOLINE_EXTERN 161 167 modules_prepare: expoline_prepare
-10
arch/s390/kernel/vdso32/Makefile
··· 61 61 quiet_cmd_vdso32cc = VDSO32C $@ 62 62 cmd_vdso32cc = $(CC) $(c_flags) -c -o $@ $< 63 63 64 - # install commands for the unstripped file 65 - quiet_cmd_vdso_install = INSTALL $@ 66 - cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@ 67 - 68 - vdso32.so: $(obj)/vdso32.so.dbg 69 - @mkdir -p $(MODLIB)/vdso 70 - $(call cmd,vdso_install) 71 - 72 - vdso_install: vdso32.so 73 - 74 64 # Generate VDSO offsets using helper script 75 65 gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh 76 66 quiet_cmd_vdsosym = VDSOSYM $@
-10
arch/s390/kernel/vdso64/Makefile
··· 70 70 quiet_cmd_vdso64cc = VDSO64C $@ 71 71 cmd_vdso64cc = $(CC) $(c_flags) -c -o $@ $< 72 72 73 - # install commands for the unstripped file 74 - quiet_cmd_vdso_install = INSTALL $@ 75 - cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@ 76 - 77 - vdso64.so: $(obj)/vdso64.so.dbg 78 - @mkdir -p $(MODLIB)/vdso 79 - $(call cmd,vdso_install) 80 - 81 - vdso_install: vdso64.so 82 - 83 73 # Generate VDSO offsets using helper script 84 74 gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh 85 75 quiet_cmd_vdsosym = VDSOSYM $@
+2 -3
arch/sparc/Makefile
··· 76 76 archheaders: 77 77 $(Q)$(MAKE) $(build)=arch/sparc/kernel/syscalls all 78 78 79 - PHONY += vdso_install 80 - vdso_install: 81 - $(Q)$(MAKE) $(build)=arch/sparc/vdso $@ 79 + vdso-install-$(CONFIG_SPARC64) += arch/sparc/vdso/vdso64.so.dbg 80 + vdso-install-$(CONFIG_COMPAT) += arch/sparc/vdso/vdso32.so.dbg 82 81 83 82 # This is the image used for packaging 84 83 KBUILD_IMAGE := $(boot)/zImage
-27
arch/sparc/vdso/Makefile
··· 116 116 117 117 VDSO_LDFLAGS = -shared --hash-style=both --build-id=sha1 -Bsymbolic 118 118 GCOV_PROFILE := n 119 - 120 - # 121 - # Install the unstripped copies of vdso*.so. If our toolchain supports 122 - # build-id, install .build-id links as well. 123 - # 124 - quiet_cmd_vdso_install = INSTALL $(@:install_%=%) 125 - define cmd_vdso_install 126 - cp $< "$(MODLIB)/vdso/$(@:install_%=%)"; \ 127 - if readelf -n $< |grep -q 'Build ID'; then \ 128 - buildid=`readelf -n $< |grep 'Build ID' |sed -e 's/^.*Build ID: \(.*\)$$/\1/'`; \ 129 - first=`echo $$buildid | cut -b-2`; \ 130 - last=`echo $$buildid | cut -b3-`; \ 131 - mkdir -p "$(MODLIB)/vdso/.build-id/$$first"; \ 132 - ln -sf "../../$(@:install_%=%)" "$(MODLIB)/vdso/.build-id/$$first/$$last.debug"; \ 133 - fi 134 - endef 135 - 136 - vdso_img_insttargets := $(vdso_img_sodbg:%.dbg=install_%) 137 - 138 - $(MODLIB)/vdso: FORCE 139 - @mkdir -p $(MODLIB)/vdso 140 - 141 - $(vdso_img_insttargets): install_%: $(obj)/%.dbg $(MODLIB)/vdso FORCE 142 - $(call cmd,vdso_install) 143 - 144 - PHONY += vdso_install $(vdso_img_insttargets) 145 - vdso_install: $(vdso_img_insttargets) FORCE
+4 -3
arch/x86/Makefile
··· 291 291 install: 292 292 $(call cmd,install) 293 293 294 - PHONY += vdso_install 295 - vdso_install: 296 - $(Q)$(MAKE) $(build)=arch/x86/entry/vdso $@ 294 + vdso-install-$(CONFIG_X86_64) += arch/x86/entry/vdso/vdso64.so.dbg 295 + vdso-install-$(CONFIG_X86_X32_ABI) += arch/x86/entry/vdso/vdsox32.so.dbg 296 + vdso-install-$(CONFIG_X86_32) += arch/x86/entry/vdso/vdso32.so.dbg 297 + vdso-install-$(CONFIG_IA32_EMULATION) += arch/x86/entry/vdso/vdso32.so.dbg 297 298 298 299 archprepare: checkbin 299 300 checkbin:
-27
arch/x86/entry/vdso/Makefile
··· 190 190 quiet_cmd_vdso_and_check = VDSO $@ 191 191 cmd_vdso_and_check = $(cmd_vdso); $(cmd_vdso_check) 192 192 193 - # 194 - # Install the unstripped copies of vdso*.so. If our toolchain supports 195 - # build-id, install .build-id links as well. 196 - # 197 - quiet_cmd_vdso_install = INSTALL $(@:install_%=%) 198 - define cmd_vdso_install 199 - cp $< "$(MODLIB)/vdso/$(@:install_%=%)"; \ 200 - if readelf -n $< |grep -q 'Build ID'; then \ 201 - buildid=`readelf -n $< |grep 'Build ID' |sed -e 's/^.*Build ID: \(.*\)$$/\1/'`; \ 202 - first=`echo $$buildid | cut -b-2`; \ 203 - last=`echo $$buildid | cut -b3-`; \ 204 - mkdir -p "$(MODLIB)/vdso/.build-id/$$first"; \ 205 - ln -sf "../../$(@:install_%=%)" "$(MODLIB)/vdso/.build-id/$$first/$$last.debug"; \ 206 - fi 207 - endef 208 - 209 - vdso_img_insttargets := $(vdso_img_sodbg:%.dbg=install_%) 210 - 211 - $(MODLIB)/vdso: FORCE 212 - @mkdir -p $(MODLIB)/vdso 213 - 214 - $(vdso_img_insttargets): install_%: $(obj)/%.dbg $(MODLIB)/vdso 215 - $(call cmd,vdso_install) 216 - 217 - PHONY += vdso_install $(vdso_img_insttargets) 218 - vdso_install: $(vdso_img_insttargets) 219 - 220 193 clean-files := vdso32.so vdso32.so.dbg vdso64* vdso-image-*.c vdsox32.so*
+45
scripts/Makefile.vdsoinst
··· 1 + # SPDX-License-Identifier: GPL-2.0-only 2 + # ========================================================================== 3 + # Install unstripped copies of vDSO 4 + # ========================================================================== 5 + 6 + PHONY := __default 7 + __default: 8 + @: 9 + 10 + include $(srctree)/scripts/Kbuild.include 11 + 12 + install-dir := $(MODLIB)/vdso 13 + 14 + define gen_install_rules 15 + 16 + src := $$(firstword $$(subst :,$(space),$(1))) 17 + dest := $(install-dir)/$$(or $$(word 2,$$(subst :,$(space),$(1))),$$(patsubst %.dbg,%,$$(notdir $(1)))) 18 + 19 + __default: $$(dest) 20 + $$(dest): $$(src) FORCE 21 + $$(call cmd,install) 22 + 23 + # Some architectures create .build-id symlinks 24 + ifneq ($(filter arm sparc x86, $(SRCARCH)),) 25 + link := $(install-dir)/.build-id/$$(shell $(READELF) -n $$(src) | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p') 26 + 27 + __default: $$(link) 28 + $$(link): $$(dest) FORCE 29 + $$(call cmd,symlink) 30 + endif 31 + 32 + endef 33 + 34 + $(foreach x, $(sort $(INSTALL_FILES)), $(eval $(call gen_install_rules,$(x)))) 35 + 36 + quiet_cmd_install = INSTALL $@ 37 + cmd_install = mkdir -p $(dir $@); cp $< $@ 38 + 39 + quiet_cmd_symlink = SYMLINK $@ 40 + cmd_symlink = mkdir -p $(dir $@); ln -sf --relative $< $@ 41 + 42 + PHONY += FORCE 43 + FORCE: 44 + 45 + .PHONY: $(PHONY)