1# SPDX-License-Identifier: GPL-2.0 2hostprogs-y := vdsomunge 3 4obj-vdso := vgettimeofday.o datapage.o 5 6# Build rules 7targets := $(obj-vdso) vdso.so vdso.so.dbg vdso.so.raw vdso.lds 8obj-vdso := $(addprefix $(obj)/, $(obj-vdso)) 9 10ccflags-y := -fPIC -fno-common -fno-builtin -fno-stack-protector 11ccflags-y += -DDISABLE_BRANCH_PROFILING 12 13ldflags-y = -Bsymbolic --no-undefined -soname=linux-vdso.so.1 \ 14 -z max-page-size=4096 -z common-page-size=4096 \ 15 -nostdlib -shared \ 16 $(call ld-option, --hash-style=sysv) \ 17 $(call ld-option, --build-id) \ 18 -T 19 20obj-$(CONFIG_VDSO) += vdso.o 21extra-$(CONFIG_VDSO) += vdso.lds 22CPPFLAGS_vdso.lds += -P -C -U$(ARCH) 23 24CFLAGS_REMOVE_vdso.o = -pg 25 26# Force -O2 to avoid libgcc dependencies 27CFLAGS_REMOVE_vgettimeofday.o = -pg -Os 28CFLAGS_vgettimeofday.o = -O2 29 30# Disable gcov profiling for VDSO code 31GCOV_PROFILE := n 32 33# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. 34KCOV_INSTRUMENT := n 35 36# Force dependency 37$(obj)/vdso.o : $(obj)/vdso.so 38 39# Link rule for the .so file 40$(obj)/vdso.so.raw: $(obj)/vdso.lds $(obj-vdso) FORCE 41 $(call if_changed,ld) 42 43$(obj)/vdso.so.dbg: $(obj)/vdso.so.raw $(obj)/vdsomunge FORCE 44 $(call if_changed,vdsomunge) 45 46# Strip rule for the .so file 47$(obj)/%.so: OBJCOPYFLAGS := -S 48$(obj)/%.so: $(obj)/%.so.dbg FORCE 49 $(call if_changed,objcopy) 50 51quiet_cmd_vdsomunge = MUNGE $@ 52 cmd_vdsomunge = $(objtree)/$(obj)/vdsomunge $< $@ 53 54# 55# Install the unstripped copy of vdso.so.dbg. If our toolchain 56# supports build-id, install .build-id links as well. 57# 58# Cribbed from arch/x86/vdso/Makefile. 59# 60quiet_cmd_vdso_install = INSTALL $< 61define cmd_vdso_install 62 cp $< "$(MODLIB)/vdso/vdso.so"; \ 63 if readelf -n $< | grep -q 'Build ID'; then \ 64 buildid=`readelf -n $< |grep 'Build ID' |sed -e 's/^.*Build ID: \(.*\)$$/\1/'`; \ 65 first=`echo $$buildid | cut -b-2`; \ 66 last=`echo $$buildid | cut -b3-`; \ 67 mkdir -p "$(MODLIB)/vdso/.build-id/$$first"; \ 68 ln -sf "../../vdso.so" "$(MODLIB)/vdso/.build-id/$$first/$$last.debug"; \ 69 fi 70endef 71 72$(MODLIB)/vdso: FORCE 73 @mkdir -p $(MODLIB)/vdso 74 75PHONY += vdso_install 76vdso_install: $(obj)/vdso.so.dbg $(MODLIB)/vdso 77 $(call cmd,vdso_install) 78