mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-16 23:45:31 +08:00
aff69273af
The actual intention is that no dynamic relocation exists in the VDSO. For this the VDSO build validates that the resulting .so file does not have any relocations which are specified via $(ARCH_REL_TYPE_ABS) per architecture, which is fragile as e.g. ARM64 lacks an entry for R_AARCH64_RELATIVE. Aside of that ARCH_REL_TYPE_ABS is a misnomer as it checks for relative relocations too. However, some GNU ld ports produce unneeded R_*_NONE relocation entries. If a port fails to determine the exact .rel[a].dyn size, the trailing zeros become R_*_NONE relocations. E.g. ld's powerpc port recently fixed https://sourceware.org/bugzilla/show_bug.cgi?id=29540). R_*_NONE are generally a no-op in the dynamic loaders. So just ignore them. Remove the ARCH_REL_TYPE_ABS defines and just validate that the resulting .so file does not contain any R_* relocation entries except R_*_NONE. Signed-off-by: Fangrui Song <maskray@google.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com> # for aarch64 Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu> Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com> # for vDSO, aarch64 Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc) Link: https://lore.kernel.org/r/20230310190750.3323802-1-maskray@google.com
96 lines
2.6 KiB
Makefile
96 lines
2.6 KiB
Makefile
# SPDX-License-Identifier: GPL-2.0
|
|
# Objects to go into the VDSO.
|
|
|
|
# Include the generic Makefile to check the built vdso.
|
|
include $(srctree)/lib/vdso/Makefile
|
|
|
|
obj-vdso-y := elf.o vgetcpu.o vgettimeofday.o sigreturn.o
|
|
|
|
# Common compiler flags between ABIs.
|
|
ccflags-vdso := \
|
|
$(filter -I%,$(KBUILD_CFLAGS)) \
|
|
$(filter -E%,$(KBUILD_CFLAGS)) \
|
|
$(filter -march=%,$(KBUILD_CFLAGS)) \
|
|
$(filter -m%-float,$(KBUILD_CFLAGS)) \
|
|
-D__VDSO__
|
|
|
|
ifeq ($(cc-name),clang)
|
|
ccflags-vdso += $(filter --target=%,$(KBUILD_CFLAGS))
|
|
endif
|
|
|
|
cflags-vdso := $(ccflags-vdso) \
|
|
-isystem $(shell $(CC) -print-file-name=include) \
|
|
$(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \
|
|
-O2 -g -fno-strict-aliasing -fno-common -fno-builtin -G0 \
|
|
-fno-stack-protector -fno-jump-tables -DDISABLE_BRANCH_PROFILING \
|
|
$(call cc-option, -fno-asynchronous-unwind-tables) \
|
|
$(call cc-option, -fno-stack-protector)
|
|
aflags-vdso := $(ccflags-vdso) \
|
|
-D__ASSEMBLY__ -Wa,-gdwarf-2
|
|
|
|
ifneq ($(c-gettimeofday-y),)
|
|
CFLAGS_vgettimeofday.o += -include $(c-gettimeofday-y)
|
|
endif
|
|
|
|
# VDSO linker flags.
|
|
ldflags-y := -Bsymbolic --no-undefined -soname=linux-vdso.so.1 \
|
|
$(filter -E%,$(KBUILD_CFLAGS)) -nostdlib -shared \
|
|
--hash-style=sysv --build-id -T
|
|
|
|
GCOV_PROFILE := n
|
|
|
|
#
|
|
# Shared build commands.
|
|
#
|
|
|
|
quiet_cmd_vdsold_and_vdso_check = LD $@
|
|
cmd_vdsold_and_vdso_check = $(cmd_ld); $(cmd_vdso_check)
|
|
|
|
quiet_cmd_vdsoas_o_S = AS $@
|
|
cmd_vdsoas_o_S = $(CC) $(a_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/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE
|
|
$(call if_changed,vdsosym)
|
|
|
|
#
|
|
# Build native VDSO.
|
|
#
|
|
|
|
native-abi := $(filter -mabi=%,$(KBUILD_CFLAGS))
|
|
|
|
targets += $(obj-vdso-y)
|
|
targets += vdso.lds vdso.so.dbg vdso.so
|
|
|
|
obj-vdso := $(obj-vdso-y:%.o=$(obj)/%.o)
|
|
|
|
$(obj-vdso): KBUILD_CFLAGS := $(cflags-vdso) $(native-abi)
|
|
$(obj-vdso): KBUILD_AFLAGS := $(aflags-vdso) $(native-abi)
|
|
|
|
$(obj)/vdso.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) $(native-abi)
|
|
|
|
$(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE
|
|
$(call if_changed,vdsold_and_vdso_check)
|
|
|
|
$(obj)/vdso.so: OBJCOPYFLAGS := -S
|
|
$(obj)/vdso.so: $(obj)/vdso.so.dbg FORCE
|
|
$(call if_changed,objcopy)
|
|
|
|
obj-y += vdso.o
|
|
|
|
$(obj)/vdso.o : $(obj)/vdso.so
|
|
|
|
# install commands for the unstripped file
|
|
quiet_cmd_vdso_install = INSTALL $@
|
|
cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
|
|
|
|
vdso.so: $(obj)/vdso.so.dbg
|
|
@mkdir -p $(MODLIB)/vdso
|
|
$(call cmd,vdso_install)
|
|
|
|
vdso_install: vdso.so
|