Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 1 | # |
Roland McGrath | 0249c9c | 2008-01-30 13:30:42 +0100 | [diff] [blame] | 2 | # Building vDSO images for x86. |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 3 | # |
| 4 | |
Roland McGrath | 0249c9c | 2008-01-30 13:30:42 +0100 | [diff] [blame] | 5 | VDSO64-$(CONFIG_X86_64) := y |
| 6 | VDSO32-$(CONFIG_X86_32) := y |
| 7 | VDSO32-$(CONFIG_COMPAT) := y |
| 8 | |
| 9 | vdso-install-$(VDSO64-y) += vdso.so |
Roland McGrath | 2c15826 | 2008-02-11 14:38:51 -0800 | [diff] [blame] | 10 | vdso-install-$(VDSO32-y) += $(vdso32-images) |
Roland McGrath | 0249c9c | 2008-01-30 13:30:42 +0100 | [diff] [blame] | 11 | |
| 12 | |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 13 | # files to link into the vdso |
Roland McGrath | 7f3646a | 2008-01-30 13:30:41 +0100 | [diff] [blame] | 14 | vobjs-y := vdso-note.o vclock_gettime.o vgetcpu.o vvar.o |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 15 | |
| 16 | # files to link into kernel |
Roland McGrath | 6c3652e | 2008-01-30 13:30:42 +0100 | [diff] [blame] | 17 | obj-$(VDSO64-y) += vma.o vdso.o |
Roland McGrath | af65d64 | 2008-01-30 13:30:43 +0100 | [diff] [blame] | 18 | obj-$(VDSO32-y) += vdso32.o vdso32-setup.o |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 19 | |
| 20 | vobjs := $(foreach F,$(vobjs-y),$(obj)/$F) |
| 21 | |
| 22 | $(obj)/vdso.o: $(obj)/vdso.so |
| 23 | |
Roland McGrath | 2b9c97e | 2008-01-30 13:30:41 +0100 | [diff] [blame] | 24 | targets += vdso.so vdso.so.dbg vdso.lds $(vobjs-y) |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 25 | |
Sam Ravnborg | d746d64 | 2007-11-12 20:14:19 +0100 | [diff] [blame] | 26 | export CPPFLAGS_vdso.lds += -P -C |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 27 | |
H. Peter Anvin | de2a8cf | 2010-12-13 16:01:38 -0800 | [diff] [blame^] | 28 | VDSO_LDFLAGS_vdso.lds = -m64 -Wl,-soname=linux-vdso.so.1 \ |
Roland McGrath | 16e48e7 | 2008-01-30 13:30:44 +0100 | [diff] [blame] | 29 | -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096 |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 30 | |
| 31 | $(obj)/vdso.o: $(src)/vdso.S $(obj)/vdso.so |
| 32 | |
Roland McGrath | f79eb83 | 2007-10-17 18:04:32 +0200 | [diff] [blame] | 33 | $(obj)/vdso.so.dbg: $(src)/vdso.lds $(vobjs) FORCE |
Roland McGrath | 16e48e7 | 2008-01-30 13:30:44 +0100 | [diff] [blame] | 34 | $(call if_changed,vdso) |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 35 | |
Roland McGrath | f79eb83 | 2007-10-17 18:04:32 +0200 | [diff] [blame] | 36 | $(obj)/%.so: OBJCOPYFLAGS := -S |
| 37 | $(obj)/%.so: $(obj)/%.so.dbg FORCE |
| 38 | $(call if_changed,objcopy) |
| 39 | |
Roland McGrath | 8705a49 | 2008-04-14 12:19:30 -0700 | [diff] [blame] | 40 | CFL := $(PROFILING) -mcmodel=small -fPIC -O2 -fasynchronous-unwind-tables -m64 \ |
Tejun Heo | d627ded | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 41 | $(filter -g%,$(KBUILD_CFLAGS)) $(call cc-option, -fno-stack-protector) |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 42 | |
Glauber de Oliveira Costa | f6bc402 | 2008-03-19 14:25:53 -0300 | [diff] [blame] | 43 | $(vobjs): KBUILD_CFLAGS += $(CFL) |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 44 | |
Roland McGrath | 5b93049 | 2008-01-30 13:30:40 +0100 | [diff] [blame] | 45 | targets += vdso-syms.lds |
Roland McGrath | 6c3652e | 2008-01-30 13:30:42 +0100 | [diff] [blame] | 46 | obj-$(VDSO64-y) += vdso-syms.lds |
Roland McGrath | 5b93049 | 2008-01-30 13:30:40 +0100 | [diff] [blame] | 47 | |
| 48 | # |
| 49 | # Match symbols in the DSO that look like VDSO*; produce a file of constants. |
| 50 | # |
| 51 | sed-vdsosym := -e 's/^00*/0/' \ |
Roland McGrath | f2dbe03 | 2008-02-27 11:42:15 -0800 | [diff] [blame] | 52 | -e 's/^\([0-9a-fA-F]*\) . \(VDSO[a-zA-Z0-9_]*\)$$/\2 = 0x\1;/p' |
Roland McGrath | 5b93049 | 2008-01-30 13:30:40 +0100 | [diff] [blame] | 53 | quiet_cmd_vdsosym = VDSOSYM $@ |
Roland McGrath | f2dbe03 | 2008-02-27 11:42:15 -0800 | [diff] [blame] | 54 | define cmd_vdsosym |
| 55 | $(NM) $< | LC_ALL=C sed -n $(sed-vdsosym) | LC_ALL=C sort > $@ |
| 56 | endef |
Roland McGrath | 5b93049 | 2008-01-30 13:30:40 +0100 | [diff] [blame] | 57 | |
| 58 | $(obj)/%-syms.lds: $(obj)/%.so.dbg FORCE |
| 59 | $(call if_changed,vdsosym) |
| 60 | |
Roland McGrath | 0249c9c | 2008-01-30 13:30:42 +0100 | [diff] [blame] | 61 | # |
| 62 | # Build multiple 32-bit vDSO images to choose from at boot time. |
| 63 | # |
Roland McGrath | 6c3652e | 2008-01-30 13:30:42 +0100 | [diff] [blame] | 64 | obj-$(VDSO32-y) += vdso32-syms.lds |
Jeremy Fitzhardinge | 6a52e4b | 2008-07-12 02:22:00 -0700 | [diff] [blame] | 65 | vdso32.so-$(VDSO32-y) += int80 |
Roland McGrath | 00f8b1b | 2008-01-30 13:30:43 +0100 | [diff] [blame] | 66 | vdso32.so-$(CONFIG_COMPAT) += syscall |
Roland McGrath | 0249c9c | 2008-01-30 13:30:42 +0100 | [diff] [blame] | 67 | vdso32.so-$(VDSO32-y) += sysenter |
| 68 | |
Roland McGrath | 2c15826 | 2008-02-11 14:38:51 -0800 | [diff] [blame] | 69 | vdso32-images = $(vdso32.so-y:%=vdso32-%.so) |
| 70 | |
Roland McGrath | 0249c9c | 2008-01-30 13:30:42 +0100 | [diff] [blame] | 71 | CPPFLAGS_vdso32.lds = $(CPPFLAGS_vdso.lds) |
H. Peter Anvin | de2a8cf | 2010-12-13 16:01:38 -0800 | [diff] [blame^] | 72 | VDSO_LDFLAGS_vdso32.lds = -m32 -Wl,-soname=linux-gate.so.1 |
Roland McGrath | 0249c9c | 2008-01-30 13:30:42 +0100 | [diff] [blame] | 73 | |
| 74 | # This makes sure the $(obj) subdirectory exists even though vdso32/ |
| 75 | # is not a kbuild sub-make subdirectory. |
| 76 | override obj-dirs = $(dir $(obj)) $(obj)/vdso32/ |
| 77 | |
| 78 | targets += vdso32/vdso32.lds |
Roland McGrath | 2c15826 | 2008-02-11 14:38:51 -0800 | [diff] [blame] | 79 | targets += $(vdso32-images) $(vdso32-images:=.dbg) |
Roland McGrath | 0249c9c | 2008-01-30 13:30:42 +0100 | [diff] [blame] | 80 | targets += vdso32/note.o $(vdso32.so-y:%=vdso32/%.o) |
| 81 | |
Roland McGrath | 2c15826 | 2008-02-11 14:38:51 -0800 | [diff] [blame] | 82 | extra-y += $(vdso32-images) |
Roland McGrath | 0249c9c | 2008-01-30 13:30:42 +0100 | [diff] [blame] | 83 | |
Roland McGrath | 2c15826 | 2008-02-11 14:38:51 -0800 | [diff] [blame] | 84 | $(obj)/vdso32.o: $(vdso32-images:%=$(obj)/%) |
Roland McGrath | 6c3652e | 2008-01-30 13:30:42 +0100 | [diff] [blame] | 85 | |
Roland McGrath | 0249c9c | 2008-01-30 13:30:42 +0100 | [diff] [blame] | 86 | KBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS)) |
Roland McGrath | 2c15826 | 2008-02-11 14:38:51 -0800 | [diff] [blame] | 87 | $(vdso32-images:%=$(obj)/%.dbg): KBUILD_AFLAGS = $(KBUILD_AFLAGS_32) |
| 88 | $(vdso32-images:%=$(obj)/%.dbg): asflags-$(CONFIG_X86_64) += -m32 |
Roland McGrath | 0249c9c | 2008-01-30 13:30:42 +0100 | [diff] [blame] | 89 | |
Roland McGrath | 2c15826 | 2008-02-11 14:38:51 -0800 | [diff] [blame] | 90 | $(vdso32-images:%=$(obj)/%.dbg): $(obj)/vdso32-%.so.dbg: FORCE \ |
| 91 | $(obj)/vdso32/vdso32.lds \ |
| 92 | $(obj)/vdso32/note.o \ |
| 93 | $(obj)/vdso32/%.o |
Roland McGrath | 0249c9c | 2008-01-30 13:30:42 +0100 | [diff] [blame] | 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 | |
| 99 | targets += vdso32-syms.lds $(vdso32.so-y:%=vdso32-%-syms.lds) |
| 100 | |
| 101 | quiet_cmd_vdso32sym = VDSOSYM $@ |
| 102 | define 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 |
| 112 | endef |
| 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 | # |
| 120 | quiet_cmd_vdso = VDSO $@ |
| 121 | cmd_vdso = $(CC) -nostdlib -o $@ \ |
| 122 | $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \ |
H. Peter Anvin | 05d0b08 | 2010-06-18 14:36:26 -0700 | [diff] [blame] | 123 | -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \ |
| 124 | sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@' |
Roland McGrath | 0249c9c | 2008-01-30 13:30:42 +0100 | [diff] [blame] | 125 | |
Sam Ravnborg | f86fd30 | 2009-09-19 10:14:33 +0200 | [diff] [blame] | 126 | VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) |
Peter Oberparleiter | 7bf99fb | 2009-06-17 16:28:09 -0700 | [diff] [blame] | 127 | GCOV_PROFILE := n |
Roland McGrath | 0249c9c | 2008-01-30 13:30:42 +0100 | [diff] [blame] | 128 | |
| 129 | # |
| 130 | # Install the unstripped copy of vdso*.so listed in $(vdso-install-y). |
| 131 | # |
Roland McGrath | f79eb83 | 2007-10-17 18:04:32 +0200 | [diff] [blame] | 132 | quiet_cmd_vdso_install = INSTALL $@ |
| 133 | cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@ |
Roland McGrath | 0249c9c | 2008-01-30 13:30:42 +0100 | [diff] [blame] | 134 | $(vdso-install-y): %.so: $(obj)/%.so.dbg FORCE |
Roland McGrath | f79eb83 | 2007-10-17 18:04:32 +0200 | [diff] [blame] | 135 | @mkdir -p $(MODLIB)/vdso |
| 136 | $(call cmd,vdso_install) |
| 137 | |
Roland McGrath | 0249c9c | 2008-01-30 13:30:42 +0100 | [diff] [blame] | 138 | PHONY += vdso_install $(vdso-install-y) |
| 139 | vdso_install: $(vdso-install-y) |
Sam Ravnborg | d531b4f | 2008-01-30 13:32:27 +0100 | [diff] [blame] | 140 | |
| 141 | clean-files := vdso32-syscall* vdso32-sysenter* vdso32-int80* |