1# 2# Building vDSO images for x86. 3# 4 5VDSO64-$(CONFIG_X86_64) := y 6VDSO32-$(CONFIG_X86_32) := y 7VDSO32-$(CONFIG_COMPAT) := y 8 9vdso-install-$(VDSO64-y) += vdso.so 10vdso-install-$(VDSO32-y) += $(vdso32-images) 11 12 13# files to link into the vdso 14vobjs-y := vdso-note.o vclock_gettime.o vgetcpu.o vvar.o 15 16# files to link into kernel 17obj-$(VDSO64-y) += vma.o vdso.o 18obj-$(VDSO32-y) += vdso32.o vdso32-setup.o 19 20vobjs := $(foreach F,$(vobjs-y),$(obj)/$F) 21 22$(obj)/vdso.o: $(obj)/vdso.so 23 24targets += vdso.so vdso.so.dbg vdso.lds $(vobjs-y) 25 26export CPPFLAGS_vdso.lds += -P -C 27 28VDSO_LDFLAGS_vdso.lds = -m64 -Wl,-soname=linux-vdso.so.1 \ 29 -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096 30 31$(obj)/vdso.o: $(src)/vdso.S $(obj)/vdso.so 32 33$(obj)/vdso.so.dbg: $(src)/vdso.lds $(vobjs) FORCE 34 $(call if_changed,vdso) 35 36$(obj)/%.so: OBJCOPYFLAGS := -S 37$(obj)/%.so: $(obj)/%.so.dbg FORCE 38 $(call if_changed,objcopy) 39 40CFL := $(PROFILING) -mcmodel=small -fPIC -O2 -fasynchronous-unwind-tables -m64 \ 41 $(filter -g%,$(KBUILD_CFLAGS)) $(call cc-option, -fno-stack-protector) 42 43$(vobjs): KBUILD_CFLAGS += $(CFL) 44 45targets += vdso-syms.lds 46obj-$(VDSO64-y) += vdso-syms.lds 47 48# 49# Match symbols in the DSO that look like VDSO*; produce a file of constants. 50# 51sed-vdsosym := -e 's/^00*/0/' \ 52 -e 's/^\([0-9a-fA-F]*\) . \(VDSO[a-zA-Z0-9_]*\)$$/\2 = 0x\1;/p' 53quiet_cmd_vdsosym = VDSOSYM $@ 54define cmd_vdsosym 55 $(NM) $< | LC_ALL=C sed -n $(sed-vdsosym) | LC_ALL=C sort > $@ 56endef 57 58$(obj)/%-syms.lds: $(obj)/%.so.dbg FORCE 59 $(call if_changed,vdsosym) 60 61# 62# Build multiple 32-bit vDSO images to choose from at boot time. 63# 64obj-$(VDSO32-y) += vdso32-syms.lds 65vdso32.so-$(VDSO32-y) += int80 66vdso32.so-$(CONFIG_COMPAT) += syscall 67vdso32.so-$(VDSO32-y) += sysenter 68 69vdso32-images = $(vdso32.so-y:%=vdso32-%.so) 70 71CPPFLAGS_vdso32.lds = $(CPPFLAGS_vdso.lds) 72VDSO_LDFLAGS_vdso32.lds = -m32 -Wl,-soname=linux-gate.so.1 73 74# This makes sure the $(obj) subdirectory exists even though vdso32/ 75# is not a kbuild sub-make subdirectory. 76override obj-dirs = $(dir $(obj)) $(obj)/vdso32/ 77 78targets += vdso32/vdso32.lds 79targets += $(vdso32-images) $(vdso32-images:=.dbg) 80targets += vdso32/note.o $(vdso32.so-y:%=vdso32/%.o) 81 82extra-y += $(vdso32-images) 83 84$(obj)/vdso32.o: $(vdso32-images:%=$(obj)/%) 85 86KBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS)) 87$(vdso32-images:%=$(obj)/%.dbg): KBUILD_AFLAGS = $(KBUILD_AFLAGS_32) 88$(vdso32-images:%=$(obj)/%.dbg): asflags-$(CONFIG_X86_64) += -m32 89 90$(vdso32-images:%=$(obj)/%.dbg): $(obj)/vdso32-%.so.dbg: FORCE \ 91 $(obj)/vdso32/vdso32.lds \ 92 $(obj)/vdso32/note.o \ 93 $(obj)/vdso32/%.o 94 $(call if_changed,vdso) 95 96# Make vdso32-*-syms.lds from each image, and then make sure they match. 97# The only difference should be that some do not define VDSO32_SYSENTER_RETURN. 98 99targets += vdso32-syms.lds $(vdso32.so-y:%=vdso32-%-syms.lds) 100 101quiet_cmd_vdso32sym = VDSOSYM $@ 102define cmd_vdso32sym 103 if LC_ALL=C sort -u $(filter-out FORCE,$^) > $(@D)/.tmp_$(@F) && \ 104 $(foreach H,$(filter-out FORCE,$^),\ 105 if grep -q VDSO32_SYSENTER_RETURN $H; \ 106 then diff -u $(@D)/.tmp_$(@F) $H; \ 107 else sed /VDSO32_SYSENTER_RETURN/d $(@D)/.tmp_$(@F) | \ 108 diff -u - $H; fi &&) : ;\ 109 then mv -f $(@D)/.tmp_$(@F) $@; \ 110 else rm -f $(@D)/.tmp_$(@F); exit 1; \ 111 fi 112endef 113 114$(obj)/vdso32-syms.lds: $(vdso32.so-y:%=$(obj)/vdso32-%-syms.lds) FORCE 115 $(call if_changed,vdso32sym) 116 117# 118# The DSO images are built using a special linker script. 119# 120quiet_cmd_vdso = VDSO $@ 121 cmd_vdso = $(CC) -nostdlib -o $@ \ 122 $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \ 123 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \ 124 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@' 125 126VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) 127GCOV_PROFILE := n 128 129# 130# Install the unstripped copy of vdso*.so listed in $(vdso-install-y). 131# 132quiet_cmd_vdso_install = INSTALL $@ 133 cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@ 134$(vdso-install-y): %.so: $(obj)/%.so.dbg FORCE 135 @mkdir -p $(MODLIB)/vdso 136 $(call cmd,vdso_install) 137 138PHONY += vdso_install $(vdso-install-y) 139vdso_install: $(vdso-install-y) 140 141clean-files := vdso32-syscall* vdso32-sysenter* vdso32-int80* 142