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