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 | 8512287 | 2015-03-25 19:14:22 +0100 | [diff] [blame] | 17 | |
Nathan Lynch | f80f653 | 2015-04-18 00:39:16 +0100 | [diff] [blame] | 18 | obj-$(CONFIG_VDSO) += vdso.o |
| 19 | extra-$(CONFIG_VDSO) += vdso.lds |
Nathan Lynch | 8512287 | 2015-03-25 19:14:22 +0100 | [diff] [blame] | 20 | CPPFLAGS_vdso.lds += -P -C -U$(ARCH) |
| 21 | |
| 22 | CFLAGS_REMOVE_vdso.o = -pg |
| 23 | |
| 24 | # Force -O2 to avoid libgcc dependencies |
| 25 | CFLAGS_REMOVE_vgettimeofday.o = -pg -Os |
| 26 | CFLAGS_vgettimeofday.o = -O2 |
| 27 | |
| 28 | # Disable gcov profiling for VDSO code |
| 29 | GCOV_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 |
| 47 | quiet_cmd_vdsold = VDSO $@ |
Nathan Lynch | d33ce23 | 2015-06-03 00:46:04 +0100 | [diff] [blame^] | 48 | cmd_vdsold = $(CC) $(c_flags) $(VDSO_LDFLAGS) \ |
| 49 | -Wl,-T $(filter %.lds,$^) $(filter %.o,$^) -o $@ |
Nathan Lynch | 8512287 | 2015-03-25 19:14:22 +0100 | [diff] [blame] | 50 | |
| 51 | quiet_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 | # |
| 60 | quiet_cmd_vdso_install = INSTALL $< |
| 61 | define 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 |
| 70 | endef |
| 71 | |
| 72 | $(MODLIB)/vdso: FORCE |
| 73 | @mkdir -p $(MODLIB)/vdso |
| 74 | |
| 75 | PHONY += vdso_install |
| 76 | vdso_install: $(obj)/vdso.so.dbg $(MODLIB)/vdso FORCE |
| 77 | $(call cmd,vdso_install) |