mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-11-01 09:13:37 +00:00
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 19514fc665 ("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>
79 lines
2.5 KiB
Makefile
79 lines
2.5 KiB
Makefile
# SPDX-License-Identifier: GPL-2.0
|
|
# List of files in the vdso
|
|
|
|
KCOV_INSTRUMENT := n
|
|
|
|
# Include the generic Makefile to check the built vdso.
|
|
include $(srctree)/lib/vdso/Makefile
|
|
obj-vdso64 = vdso_user_wrapper.o note.o
|
|
obj-cvdso64 = vdso64_generic.o getcpu.o
|
|
VDSO_CFLAGS_REMOVE := -pg $(CC_FLAGS_FTRACE) $(CC_FLAGS_EXPOLINE) $(CC_FLAGS_CHECK_STACK)
|
|
CFLAGS_REMOVE_getcpu.o = $(VDSO_CFLAGS_REMOVE)
|
|
CFLAGS_REMOVE_vdso64_generic.o = $(VDSO_CFLAGS_REMOVE)
|
|
|
|
# Build rules
|
|
|
|
targets := $(obj-vdso64) $(obj-cvdso64) vdso64.so vdso64.so.dbg
|
|
obj-vdso64 := $(addprefix $(obj)/, $(obj-vdso64))
|
|
obj-cvdso64 := $(addprefix $(obj)/, $(obj-cvdso64))
|
|
|
|
KBUILD_AFLAGS += -DBUILD_VDSO
|
|
KBUILD_CFLAGS += -DBUILD_VDSO -DDISABLE_BRANCH_PROFILING
|
|
|
|
KBUILD_AFLAGS_64 := $(filter-out -m64,$(KBUILD_AFLAGS))
|
|
KBUILD_AFLAGS_64 += -m64
|
|
|
|
KBUILD_CFLAGS_64 := $(filter-out -m64,$(KBUILD_CFLAGS))
|
|
KBUILD_CFLAGS_64 := $(filter-out -mno-pic-data-is-text-relative,$(KBUILD_CFLAGS_64))
|
|
KBUILD_CFLAGS_64 += -m64 -fPIC -fno-common -fno-builtin
|
|
ldflags-y := -fPIC -shared -soname=linux-vdso64.so.1 \
|
|
--hash-style=both --build-id=sha1 -T
|
|
|
|
$(targets:%=$(obj)/%.dbg): KBUILD_CFLAGS = $(KBUILD_CFLAGS_64)
|
|
$(targets:%=$(obj)/%.dbg): KBUILD_AFLAGS = $(KBUILD_AFLAGS_64)
|
|
|
|
obj-y += vdso64_wrapper.o
|
|
targets += vdso64.lds
|
|
CPPFLAGS_vdso64.lds += -P -C -U$(ARCH)
|
|
|
|
# Disable gcov profiling, ubsan and kasan for VDSO code
|
|
GCOV_PROFILE := n
|
|
UBSAN_SANITIZE := n
|
|
KASAN_SANITIZE := n
|
|
KCSAN_SANITIZE := n
|
|
|
|
# Force dependency (incbin is bad)
|
|
$(obj)/vdso64_wrapper.o : $(obj)/vdso64.so
|
|
|
|
quiet_cmd_vdso_and_check = VDSO $@
|
|
cmd_vdso_and_check = $(cmd_ld); $(cmd_vdso_check)
|
|
|
|
# link rule for the .so file, .lds has to be first
|
|
$(obj)/vdso64.so.dbg: $(src)/vdso64.lds $(obj-vdso64) $(obj-cvdso64) FORCE
|
|
$(call if_changed,vdso_and_check)
|
|
|
|
# strip rule for the .so file
|
|
$(obj)/%.so: OBJCOPYFLAGS := -S
|
|
$(obj)/%.so: $(obj)/%.so.dbg FORCE
|
|
$(call if_changed,objcopy)
|
|
|
|
# assembly rules for the .S files
|
|
$(obj-vdso64): %.o: %.S FORCE
|
|
$(call if_changed_dep,vdso64as)
|
|
|
|
$(obj-cvdso64): %.o: %.c FORCE
|
|
$(call if_changed_dep,vdso64cc)
|
|
|
|
# actual build commands
|
|
quiet_cmd_vdso64as = VDSO64A $@
|
|
cmd_vdso64as = $(CC) $(a_flags) -c -o $@ $<
|
|
quiet_cmd_vdso64cc = VDSO64C $@
|
|
cmd_vdso64cc = $(CC) $(c_flags) -c -o $@ $<
|
|
|
|
# Generate VDSO offsets using helper script
|
|
gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh
|
|
quiet_cmd_vdsosym = VDSOSYM $@
|
|
cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@
|
|
|
|
include/generated/vdso64-offsets.h: $(obj)/vdso64.so.dbg FORCE
|
|
$(call if_changed,vdsosym)
|