blob: 89182ad44ee8ccff9616f6c20d6b23ca35c76f6a [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 Lynch85122872015-03-25 19:14:22 +010017
Nathan Lynchf80f6532015-04-18 00:39:16 +010018obj-$(CONFIG_VDSO) += vdso.o
19extra-$(CONFIG_VDSO) += vdso.lds
Nathan Lynch85122872015-03-25 19:14:22 +010020CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
21
22CFLAGS_REMOVE_vdso.o = -pg
23
24# Force -O2 to avoid libgcc dependencies
25CFLAGS_REMOVE_vgettimeofday.o = -pg -Os
26CFLAGS_vgettimeofday.o = -O2
27
28# Disable gcov profiling for VDSO code
29GCOV_PROFILE := n
30
31# Force dependency
32$(obj)/vdso.o : $(obj)/vdso.so
33
34# Link rule for the .so file
35$(obj)/vdso.so.raw: $(src)/vdso.lds $(obj-vdso) FORCE
36 $(call if_changed,vdsold)
37
38$(obj)/vdso.so.dbg: $(obj)/vdso.so.raw $(obj)/vdsomunge FORCE
39 $(call if_changed,vdsomunge)
40
41# Strip rule for the .so file
42$(obj)/%.so: OBJCOPYFLAGS := -S
43$(obj)/%.so: $(obj)/%.so.dbg FORCE
44 $(call if_changed,objcopy)
45
46# Actual build commands
47quiet_cmd_vdsold = VDSO $@
Nathan Lynchd33ce232015-06-03 00:46:04 +010048 cmd_vdsold = $(CC) $(c_flags) $(VDSO_LDFLAGS) \
49 -Wl,-T $(filter %.lds,$^) $(filter %.o,$^) -o $@
Nathan Lynch85122872015-03-25 19:14:22 +010050
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 FORCE
77 $(call cmd,vdso_install)