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 := -fPIC -fno-common -fno-builtin -fno-stack-protector 10ccflags-y += -DDISABLE_BRANCH_PROFILING 11 12VDSO_LDFLAGS := -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-soname=linux-vdso.so.1 13VDSO_LDFLAGS += -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096 14VDSO_LDFLAGS += -nostdlib -shared 15VDSO_LDFLAGS += $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) 16VDSO_LDFLAGS += $(call cc-ldoption, -Wl$(comma)--build-id) 17VDSO_LDFLAGS += $(call cc-ldoption, -fuse-ld=bfd) 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# Force dependency 33$(obj)/vdso.o : $(obj)/vdso.so 34 35# Link rule for the .so file 36$(obj)/vdso.so.raw: $(src)/vdso.lds $(obj-vdso) FORCE 37 $(call if_changed,vdsold) 38 39$(obj)/vdso.so.dbg: $(obj)/vdso.so.raw $(obj)/vdsomunge FORCE 40 $(call if_changed,vdsomunge) 41 42# Strip rule for the .so file 43$(obj)/%.so: OBJCOPYFLAGS := -S 44$(obj)/%.so: $(obj)/%.so.dbg FORCE 45 $(call if_changed,objcopy) 46 47# Actual build commands 48quiet_cmd_vdsold = VDSO $@ 49 cmd_vdsold = $(CC) $(c_flags) $(VDSO_LDFLAGS) \ 50 -Wl,-T $(filter %.lds,$^) $(filter %.o,$^) -o $@ 51 52quiet_cmd_vdsomunge = MUNGE $@ 53 cmd_vdsomunge = $(objtree)/$(obj)/vdsomunge $< $@ 54 55# 56# Install the unstripped copy of vdso.so.dbg. If our toolchain 57# supports build-id, install .build-id links as well. 58# 59# Cribbed from arch/x86/vdso/Makefile. 60# 61quiet_cmd_vdso_install = INSTALL $< 62define cmd_vdso_install 63 cp $< "$(MODLIB)/vdso/vdso.so"; \ 64 if readelf -n $< | grep -q 'Build ID'; then \ 65 buildid=`readelf -n $< |grep 'Build ID' |sed -e 's/^.*Build ID: \(.*\)$$/\1/'`; \ 66 first=`echo $$buildid | cut -b-2`; \ 67 last=`echo $$buildid | cut -b3-`; \ 68 mkdir -p "$(MODLIB)/vdso/.build-id/$$first"; \ 69 ln -sf "../../vdso.so" "$(MODLIB)/vdso/.build-id/$$first/$$last.debug"; \ 70 fi 71endef 72 73$(MODLIB)/vdso: FORCE 74 @mkdir -p $(MODLIB)/vdso 75 76PHONY += vdso_install 77vdso_install: $(obj)/vdso.so.dbg $(MODLIB)/vdso FORCE 78 $(call cmd,vdso_install) 79