blob: 9d259d94e429c4cc493542ad4cf238a513b13743 [file] [log] [blame]
Nathan Lynch85122872015-03-25 19:14:22 +01001hostprogs-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
Nathan Lynchd33ce232015-06-03 00:46:04 +01009ccflags-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)
Nathan Lynchd2b30cd2015-06-03 00:41:15 +010017VDSO_LDFLAGS += $(call cc-option, -fuse-ld=bfd)
Nathan Lynch85122872015-03-25 19:14:22 +010018
Nathan Lynchf80f6532015-04-18 00:39:16 +010019obj-$(CONFIG_VDSO) += vdso.o
20extra-$(CONFIG_VDSO) += vdso.lds
Nathan Lynch85122872015-03-25 19:14:22 +010021CPPFLAGS_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 $@
Nathan Lynchd33ce232015-06-03 00:46:04 +010049 cmd_vdsold = $(CC) $(c_flags) $(VDSO_LDFLAGS) \
50 -Wl,-T $(filter %.lds,$^) $(filter %.o,$^) -o $@
Nathan Lynch85122872015-03-25 19:14:22 +010051
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)