mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-27 12:57:53 +00:00
56769ba4b2
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>
78 lines
2.6 KiB
Makefile
78 lines
2.6 KiB
Makefile
# SPDX-License-Identifier: GPL-2.0-only
|
|
#
|
|
# Makefile for compat_vdso
|
|
#
|
|
|
|
# Symbols present in the compat_vdso
|
|
compat_vdso-syms = rt_sigreturn
|
|
compat_vdso-syms += getcpu
|
|
compat_vdso-syms += flush_icache
|
|
|
|
COMPAT_CC := $(CC)
|
|
COMPAT_LD := $(LD)
|
|
|
|
# binutils 2.35 does not support the zifencei extension, but in the ISA
|
|
# spec 20191213, G stands for IMAFD_ZICSR_ZIFENCEI.
|
|
ifdef CONFIG_TOOLCHAIN_NEEDS_EXPLICIT_ZICSR_ZIFENCEI
|
|
COMPAT_CC_FLAGS := -march=rv32g -mabi=ilp32
|
|
else
|
|
COMPAT_CC_FLAGS := -march=rv32imafd -mabi=ilp32
|
|
endif
|
|
COMPAT_LD_FLAGS := -melf32lriscv
|
|
|
|
# Disable attributes, as they're useless and break the build.
|
|
COMPAT_CC_FLAGS += $(call cc-option,-mno-riscv-attribute)
|
|
COMPAT_CC_FLAGS += $(call as-option,-Wa$(comma)-mno-arch-attr)
|
|
|
|
# Files to link into the compat_vdso
|
|
obj-compat_vdso = $(patsubst %, %.o, $(compat_vdso-syms)) note.o
|
|
|
|
# Build rules
|
|
targets := $(obj-compat_vdso) compat_vdso.so compat_vdso.so.dbg compat_vdso.lds
|
|
obj-compat_vdso := $(addprefix $(obj)/, $(obj-compat_vdso))
|
|
|
|
obj-y += compat_vdso.o
|
|
CPPFLAGS_compat_vdso.lds += -P -C -DCOMPAT_VDSO -U$(ARCH)
|
|
|
|
# Disable profiling and instrumentation for VDSO code
|
|
GCOV_PROFILE := n
|
|
KCOV_INSTRUMENT := n
|
|
KASAN_SANITIZE := n
|
|
UBSAN_SANITIZE := n
|
|
|
|
# Force dependency
|
|
$(obj)/compat_vdso.o: $(obj)/compat_vdso.so
|
|
|
|
# link rule for the .so file, .lds has to be first
|
|
$(obj)/compat_vdso.so.dbg: $(obj)/compat_vdso.lds $(obj-compat_vdso) FORCE
|
|
$(call if_changed,compat_vdsold)
|
|
LDFLAGS_compat_vdso.so.dbg = -shared -S -soname=linux-compat_vdso.so.1 \
|
|
--build-id=sha1 --hash-style=both --eh-frame-hdr
|
|
|
|
$(obj-compat_vdso): %.o: %.S FORCE
|
|
$(call if_changed_dep,compat_vdsoas)
|
|
|
|
# strip rule for the .so file
|
|
$(obj)/%.so: OBJCOPYFLAGS := -S
|
|
$(obj)/%.so: $(obj)/%.so.dbg FORCE
|
|
$(call if_changed,objcopy)
|
|
|
|
# Generate VDSO offsets using helper script
|
|
gen-compat_vdsosym := $(srctree)/$(src)/gen_compat_vdso_offsets.sh
|
|
quiet_cmd_compat_vdsosym = VDSOSYM $@
|
|
cmd_compat_vdsosym = $(NM) $< | $(gen-compat_vdsosym) | LC_ALL=C sort > $@
|
|
|
|
include/generated/compat_vdso-offsets.h: $(obj)/compat_vdso.so.dbg FORCE
|
|
$(call if_changed,compat_vdsosym)
|
|
|
|
# actual build commands
|
|
# The DSO images are built using a special linker script
|
|
# Make sure only to export the intended __compat_vdso_xxx symbol offsets.
|
|
quiet_cmd_compat_vdsold = VDSOLD $@
|
|
cmd_compat_vdsold = $(COMPAT_LD) $(ld_flags) $(COMPAT_LD_FLAGS) -T $(filter-out FORCE,$^) -o $@.tmp && \
|
|
$(OBJCOPY) $(patsubst %, -G __compat_vdso_%, $(compat_vdso-syms)) $@.tmp $@ && \
|
|
rm $@.tmp
|
|
|
|
# actual build commands
|
|
quiet_cmd_compat_vdsoas = VDSOAS $@
|
|
cmd_compat_vdsoas = $(COMPAT_CC) $(a_flags) $(COMPAT_CC_FLAGS) -c -o $@ $<
|