Nathan Lynch | 8512287 | 2015-03-25 19:14:22 +0100 | [diff] [blame] | 1 | hostprogs-y := vdsomunge |
| 2 | |
| 3 | obj-vdso := vgettimeofday.o datapage.o |
| 4 | |
| 5 | # Build rules |
| 6 | targets := $(obj-vdso) vdso.so vdso.so.dbg vdso.so.raw vdso.lds |
| 7 | obj-vdso := $(addprefix $(obj)/, $(obj-vdso)) |
| 8 | |
Nathan Lynch | d33ce23 | 2015-06-03 00:46:04 +0100 | [diff] [blame] | 9 | ccflags-y := -fPIC -fno-common -fno-builtin -fno-stack-protector |
| 10 | ccflags-y += -DDISABLE_BRANCH_PROFILING |
| 11 | |
| 12 | VDSO_LDFLAGS := -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-soname=linux-vdso.so.1 |
| 13 | VDSO_LDFLAGS += -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096 |
| 14 | VDSO_LDFLAGS += -nostdlib -shared |
| 15 | VDSO_LDFLAGS += $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) |
| 16 | VDSO_LDFLAGS += $(call cc-ldoption, -Wl$(comma)--build-id) |
Nathan Lynch | d2b30cd | 2015-06-03 00:41:15 +0100 | [diff] [blame] | 17 | VDSO_LDFLAGS += $(call cc-option, -fuse-ld=bfd) |
Nathan Lynch | 8512287 | 2015-03-25 19:14:22 +0100 | [diff] [blame] | 18 | |
Nathan Lynch | f80f653 | 2015-04-18 00:39:16 +0100 | [diff] [blame] | 19 | obj-$(CONFIG_VDSO) += vdso.o |
| 20 | extra-$(CONFIG_VDSO) += vdso.lds |
Nathan Lynch | 8512287 | 2015-03-25 19:14:22 +0100 | [diff] [blame] | 21 | CPPFLAGS_vdso.lds += -P -C -U$(ARCH) |
| 22 | |
| 23 | CFLAGS_REMOVE_vdso.o = -pg |
| 24 | |
| 25 | # Force -O2 to avoid libgcc dependencies |
| 26 | CFLAGS_REMOVE_vgettimeofday.o = -pg -Os |
| 27 | CFLAGS_vgettimeofday.o = -O2 |
| 28 | |
| 29 | # Disable gcov profiling for VDSO code |
| 30 | GCOV_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 |
| 48 | quiet_cmd_vdsold = VDSO $@ |
Nathan Lynch | d33ce23 | 2015-06-03 00:46:04 +0100 | [diff] [blame] | 49 | cmd_vdsold = $(CC) $(c_flags) $(VDSO_LDFLAGS) \ |
| 50 | -Wl,-T $(filter %.lds,$^) $(filter %.o,$^) -o $@ |
Nathan Lynch | 8512287 | 2015-03-25 19:14:22 +0100 | [diff] [blame] | 51 | |
| 52 | quiet_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 | # |
| 61 | quiet_cmd_vdso_install = INSTALL $< |
| 62 | define 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 |
| 71 | endef |
| 72 | |
| 73 | $(MODLIB)/vdso: FORCE |
| 74 | @mkdir -p $(MODLIB)/vdso |
| 75 | |
| 76 | PHONY += vdso_install |
| 77 | vdso_install: $(obj)/vdso.so.dbg $(MODLIB)/vdso FORCE |
| 78 | $(call cmd,vdso_install) |