mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 04:33:26 +02:00
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
86 lines
2.5 KiB
Makefile
86 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 += -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
|
|
|
|
# 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,ld)
|
|
|
|
# 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 $@ $<
|
|
|
|
# install commands for the unstripped file
|
|
quiet_cmd_vdso_install = INSTALL $@
|
|
cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
|
|
|
|
vdso64.so: $(obj)/vdso64.so.dbg
|
|
@mkdir -p $(MODLIB)/vdso
|
|
$(call cmd,vdso_install)
|
|
|
|
vdso_install: vdso64.so
|
|
|
|
# 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)
|