1# SPDX-License-Identifier: GPL-2.0 2# List of files in the vdso, has to be asm only for now 3 4KCOV_INSTRUMENT := n 5 6obj-vdso64 = gettimeofday.o clock_getres.o clock_gettime.o note.o getcpu.o 7 8# Build rules 9 10targets := $(obj-vdso64) vdso64.so vdso64.so.dbg 11obj-vdso64 := $(addprefix $(obj)/, $(obj-vdso64)) 12 13KBUILD_AFLAGS_64 := $(filter-out -m64,$(KBUILD_AFLAGS)) 14KBUILD_AFLAGS_64 += -m64 -s 15 16KBUILD_CFLAGS_64 := $(filter-out -m64,$(KBUILD_CFLAGS)) 17KBUILD_CFLAGS_64 += -m64 -fPIC -shared -fno-common -fno-builtin 18KBUILD_CFLAGS_64 += -nostdlib -Wl,-soname=linux-vdso64.so.1 \ 19 $(call cc-ldoption, -Wl$(comma)--hash-style=both) 20 21$(targets:%=$(obj)/%.dbg): KBUILD_CFLAGS = $(KBUILD_CFLAGS_64) 22$(targets:%=$(obj)/%.dbg): KBUILD_AFLAGS = $(KBUILD_AFLAGS_64) 23 24obj-y += vdso64_wrapper.o 25extra-y += vdso64.lds 26CPPFLAGS_vdso64.lds += -P -C -U$(ARCH) 27 28# Disable gcov profiling, ubsan and kasan for VDSO code 29GCOV_PROFILE := n 30UBSAN_SANITIZE := n 31KASAN_SANITIZE := n 32 33# Force dependency (incbin is bad) 34$(obj)/vdso64_wrapper.o : $(obj)/vdso64.so 35 36# link rule for the .so file, .lds has to be first 37$(obj)/vdso64.so.dbg: $(src)/vdso64.lds $(obj-vdso64) FORCE 38 $(call if_changed,vdso64ld) 39 40# strip rule for the .so file 41$(obj)/%.so: OBJCOPYFLAGS := -S 42$(obj)/%.so: $(obj)/%.so.dbg FORCE 43 $(call if_changed,objcopy) 44 45# assembly rules for the .S files 46$(obj-vdso64): %.o: %.S FORCE 47 $(call if_changed_dep,vdso64as) 48 49# actual build commands 50quiet_cmd_vdso64ld = VDSO64L $@ 51 cmd_vdso64ld = $(CC) $(c_flags) -Wl,-T $(filter %.lds %.o,$^) -o $@ 52quiet_cmd_vdso64as = VDSO64A $@ 53 cmd_vdso64as = $(CC) $(a_flags) -c -o $@ $< 54 55# install commands for the unstripped file 56quiet_cmd_vdso_install = INSTALL $@ 57 cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@ 58 59vdso64.so: $(obj)/vdso64.so.dbg 60 @mkdir -p $(MODLIB)/vdso 61 $(call cmd,vdso_install) 62 63vdso_install: vdso64.so 64