1# SPDX-License-Identifier: GPL-2.0-only 2 3# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before 4# the inclusion of generic Makefile. 5ARCH_REL_TYPE_ABS := R_CKCORE_ADDR32|R_CKCORE_JUMP_SLOT 6include $(srctree)/lib/vdso/Makefile 7 8# Symbols present in the vdso 9vdso-syms = rt_sigreturn 10 11# Files to link into the vdso 12obj-vdso = $(patsubst %, %.o, $(vdso-syms)) note.o 13 14ccflags-y := -fno-stack-protector 15 16# Build rules 17targets := $(obj-vdso) vdso.so vdso.so.dbg vdso.lds vdso-dummy.o 18obj-vdso := $(addprefix $(obj)/, $(obj-vdso)) 19 20obj-y += vdso.o vdso-syms.o 21CPPFLAGS_vdso.lds += -P -C -U$(ARCH) 22 23# Disable gcov profiling for VDSO code 24GCOV_PROFILE := n 25KCOV_INSTRUMENT := n 26 27# Force dependency 28$(obj)/vdso.o: $(obj)/vdso.so 29 30SYSCFLAGS_vdso.so.dbg = $(c_flags) 31$(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso) FORCE 32 $(call if_changed,vdsold) 33SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \ 34 -Wl,--build-id=sha1 -Wl,--hash-style=both 35 36$(obj)/vdso-syms.S: $(obj)/vdso.so FORCE 37 $(call if_changed,so2s) 38 39# strip rule for the .so file 40$(obj)/%.so: OBJCOPYFLAGS := -S 41$(obj)/%.so: $(obj)/%.so.dbg FORCE 42 $(call if_changed,objcopy) 43 44# actual build commands 45# The DSO images are built using a special linker script 46# Make sure only to export the intended __vdso_xxx symbol offsets. 47quiet_cmd_vdsold = VDSOLD $@ 48 cmd_vdsold = $(CC) $(KBUILD_CFLAGS) $(call cc-option, -no-pie) -nostdlib -nostartfiles $(SYSCFLAGS_$(@F)) \ 49 -Wl,-T,$(filter-out FORCE,$^) -o $@.tmp && \ 50 $(CROSS_COMPILE)objcopy \ 51 $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \ 52 rm $@.tmp 53 54# Extracts symbol offsets from the VDSO, converting them into an assembly file 55# that contains the same symbols at the same offsets. 56quiet_cmd_so2s = SO2S $@ 57 cmd_so2s = $(NM) -D $< | $(srctree)/$(src)/so2s.sh > $@ 58 59# install commands for the unstripped file 60quiet_cmd_vdso_install = INSTALL $@ 61 cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@ 62 63vdso.so: $(obj)/vdso.so.dbg 64 @mkdir -p $(MODLIB)/vdso 65 $(call cmd,vdso_install) 66 67vdso_install: vdso.so 68