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