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