187f3248cSGuo Ren# SPDX-License-Identifier: GPL-2.0-only 287f3248cSGuo Ren 3aff69273SFangrui Song# Include the generic Makefile to check the built vdso. 4*127b0e05SThomas Weißschuhinclude $(srctree)/lib/vdso/Makefile.include 587f3248cSGuo Ren 687f3248cSGuo Ren# Symbols present in the vdso 70d3b051aSGuo Renvdso-syms += rt_sigreturn 887f3248cSGuo Ren 987f3248cSGuo Ren# Files to link into the vdso 1087f3248cSGuo Renobj-vdso = $(patsubst %, %.o, $(vdso-syms)) note.o 1187f3248cSGuo Ren 120d3b051aSGuo Renifneq ($(c-gettimeofday-y),) 130d3b051aSGuo Ren CFLAGS_vgettimeofday.o += -include $(c-gettimeofday-y) 140d3b051aSGuo Renendif 150d3b051aSGuo Ren 160d3b051aSGuo Renccflags-y := -fno-stack-protector -DBUILD_VDSO32 1787f3248cSGuo Ren 1887f3248cSGuo Ren# Build rules 1987f3248cSGuo Rentargets := $(obj-vdso) vdso.so vdso.so.dbg vdso.lds vdso-dummy.o 2087f3248cSGuo Renobj-vdso := $(addprefix $(obj)/, $(obj-vdso)) 2187f3248cSGuo Ren 2287f3248cSGuo Renobj-y += vdso.o vdso-syms.o 2387f3248cSGuo RenCPPFLAGS_vdso.lds += -P -C -U$(ARCH) 2487f3248cSGuo Ren 2587f3248cSGuo Ren# Force dependency 2687f3248cSGuo Ren$(obj)/vdso.o: $(obj)/vdso.so 2787f3248cSGuo Ren 2887f3248cSGuo RenSYSCFLAGS_vdso.so.dbg = $(c_flags) 29b957df3bSMasahiro Yamada$(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE 3087f3248cSGuo Ren $(call if_changed,vdsold) 3187f3248cSGuo RenSYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \ 3287f3248cSGuo Ren -Wl,--build-id=sha1 -Wl,--hash-style=both 3387f3248cSGuo Ren 3487f3248cSGuo Ren$(obj)/vdso-syms.S: $(obj)/vdso.so FORCE 3587f3248cSGuo Ren $(call if_changed,so2s) 3687f3248cSGuo Ren 3787f3248cSGuo Ren# strip rule for the .so file 3887f3248cSGuo Ren$(obj)/%.so: OBJCOPYFLAGS := -S 3987f3248cSGuo Ren$(obj)/%.so: $(obj)/%.so.dbg FORCE 4087f3248cSGuo Ren $(call if_changed,objcopy) 4187f3248cSGuo Ren 4287f3248cSGuo Ren# actual build commands 4387f3248cSGuo Ren# The DSO images are built using a special linker script 4487f3248cSGuo Ren# Make sure only to export the intended __vdso_xxx symbol offsets. 4587f3248cSGuo Renquiet_cmd_vdsold = VDSOLD $@ 4687f3248cSGuo Ren cmd_vdsold = $(CC) $(KBUILD_CFLAGS) $(call cc-option, -no-pie) -nostdlib -nostartfiles $(SYSCFLAGS_$(@F)) \ 4787f3248cSGuo Ren -Wl,-T,$(filter-out FORCE,$^) -o $@.tmp && \ 4887f3248cSGuo Ren $(CROSS_COMPILE)objcopy \ 4987f3248cSGuo Ren $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \ 5087f3248cSGuo Ren rm $@.tmp 5187f3248cSGuo Ren 5287f3248cSGuo Ren# Extracts symbol offsets from the VDSO, converting them into an assembly file 5387f3248cSGuo Ren# that contains the same symbols at the same offsets. 5487f3248cSGuo Renquiet_cmd_so2s = SO2S $@ 55b1992c37SMasahiro Yamada cmd_so2s = $(NM) -D $< | $(src)/so2s.sh > $@ 56