1779df224SSven Schnelle# SPDX-License-Identifier: GPL-2.0 2779df224SSven Schnelle# List of files in the vdso 3779df224SSven Schnelle 4779df224SSven SchnelleKCOV_INSTRUMENT := n 5779df224SSven Schnelle 6aff69273SFangrui Song# Include the generic Makefile to check the built vdso. 7779df224SSven Schnelleinclude $(srctree)/lib/vdso/Makefile 8779df224SSven Schnelleobj-vdso32 = vdso_user_wrapper-32.o note-32.o 9779df224SSven Schnelle 10779df224SSven Schnelle# Build rules 11779df224SSven Schnelle 12779df224SSven Schnelletargets := $(obj-vdso32) vdso32.so vdso32.so.dbg 13779df224SSven Schnelleobj-vdso32 := $(addprefix $(obj)/, $(obj-vdso32)) 14779df224SSven Schnelle 15779df224SSven SchnelleKBUILD_AFLAGS += -DBUILD_VDSO 16779df224SSven SchnelleKBUILD_CFLAGS += -DBUILD_VDSO -DDISABLE_BRANCH_PROFILING 17779df224SSven Schnelle 18779df224SSven SchnelleKBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS)) 19779df224SSven SchnelleKBUILD_AFLAGS_32 += -m31 -s 20779df224SSven Schnelle 21779df224SSven SchnelleKBUILD_CFLAGS_32 := $(filter-out -m64,$(KBUILD_CFLAGS)) 22d15e4314SSumanth KorikkarKBUILD_CFLAGS_32 := $(filter-out -mno-pic-data-is-text-relative,$(KBUILD_CFLAGS_32)) 23a4228691SJens RemusKBUILD_CFLAGS_32 := $(filter-out -fno-asynchronous-unwind-tables,$(KBUILD_CFLAGS_32)) 24a4228691SJens RemusKBUILD_CFLAGS_32 += -m31 -fPIC -shared -fno-common -fno-builtin -fasynchronous-unwind-tables 25779df224SSven Schnelle 26d19c74e2SNathan ChancellorLDFLAGS_vdso32.so.dbg += -shared -soname=linux-vdso32.so.1 \ 27779df224SSven Schnelle --hash-style=both --build-id=sha1 -melf_s390 -T 28779df224SSven Schnelle 29779df224SSven Schnelle$(targets:%=$(obj)/%.dbg): KBUILD_CFLAGS = $(KBUILD_CFLAGS_32) 30779df224SSven Schnelle$(targets:%=$(obj)/%.dbg): KBUILD_AFLAGS = $(KBUILD_AFLAGS_32) 31779df224SSven Schnelle 32779df224SSven Schnelleobj-y += vdso32_wrapper.o 3398f7cd23SSven Schnelletargets += vdso32.lds 34779df224SSven SchnelleCPPFLAGS_vdso32.lds += -P -C -U$(ARCH) 35779df224SSven Schnelle 36779df224SSven Schnelle# Disable gcov profiling, ubsan and kasan for VDSO code 37779df224SSven SchnelleGCOV_PROFILE := n 38779df224SSven SchnelleUBSAN_SANITIZE := n 39779df224SSven SchnelleKASAN_SANITIZE := n 40e37b3dd0SIlya LeoshkevichKCSAN_SANITIZE := n 41779df224SSven Schnelle 42779df224SSven Schnelle# Force dependency (incbin is bad) 43779df224SSven Schnelle$(obj)/vdso32_wrapper.o : $(obj)/vdso32.so 44779df224SSven Schnelle 450dd0bbc2SSven Schnellequiet_cmd_vdso_and_check = VDSO $@ 460dd0bbc2SSven Schnelle cmd_vdso_and_check = $(cmd_ld); $(cmd_vdso_check) 470dd0bbc2SSven Schnelle 48779df224SSven Schnelle$(obj)/vdso32.so.dbg: $(src)/vdso32.lds $(obj-vdso32) FORCE 490dd0bbc2SSven Schnelle $(call if_changed,vdso_and_check) 50779df224SSven Schnelle 51779df224SSven Schnelle# strip rule for the .so file 52779df224SSven Schnelle$(obj)/%.so: OBJCOPYFLAGS := -S 53779df224SSven Schnelle$(obj)/%.so: $(obj)/%.so.dbg FORCE 54779df224SSven Schnelle $(call if_changed,objcopy) 55779df224SSven Schnelle 56779df224SSven Schnelle$(obj-vdso32): %-32.o: %.S FORCE 57779df224SSven Schnelle $(call if_changed_dep,vdso32as) 58779df224SSven Schnelle 59779df224SSven Schnelle# actual build commands 60779df224SSven Schnellequiet_cmd_vdso32as = VDSO32A $@ 61779df224SSven Schnelle cmd_vdso32as = $(CC) $(a_flags) -c -o $@ $< 62779df224SSven Schnellequiet_cmd_vdso32cc = VDSO32C $@ 63779df224SSven Schnelle cmd_vdso32cc = $(CC) $(c_flags) -c -o $@ $< 64779df224SSven Schnelle 65779df224SSven Schnelle# install commands for the unstripped file 66779df224SSven Schnellequiet_cmd_vdso_install = INSTALL $@ 67779df224SSven Schnelle cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@ 68779df224SSven Schnelle 69779df224SSven Schnellevdso32.so: $(obj)/vdso32.so.dbg 70779df224SSven Schnelle @mkdir -p $(MODLIB)/vdso 71779df224SSven Schnelle $(call cmd,vdso_install) 72779df224SSven Schnelle 73779df224SSven Schnellevdso_install: vdso32.so 74779df224SSven Schnelle 75779df224SSven Schnelle# Generate VDSO offsets using helper script 76779df224SSven Schnellegen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh 77779df224SSven Schnellequiet_cmd_vdsosym = VDSOSYM $@ 78779df224SSven Schnelle cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@ 79779df224SSven Schnelle 80779df224SSven Schnelleinclude/generated/vdso32-offsets.h: $(obj)/vdso32.so.dbg FORCE 81779df224SSven Schnelle $(call if_changed,vdsosym) 82