x86, vdso: Introduce VVAR marco for vdso32
[deliverable/linux.git] / arch / x86 / vdso / Makefile
CommitLineData
2aae950b 1#
0249c9c1 2# Building vDSO images for x86.
2aae950b
AK
3#
4
0249c9c1 5VDSO64-$(CONFIG_X86_64) := y
1a21d4e0 6VDSOX32-$(CONFIG_X86_X32_ABI) := y
0249c9c1
RM
7VDSO32-$(CONFIG_X86_32) := y
8VDSO32-$(CONFIG_COMPAT) := y
9
10vdso-install-$(VDSO64-y) += vdso.so
1a21d4e0 11vdso-install-$(VDSOX32-y) += vdsox32.so
2c158269 12vdso-install-$(VDSO32-y) += $(vdso32-images)
0249c9c1
RM
13
14
2aae950b 15# files to link into the vdso
8c49d9a7 16vobjs-y := vdso-note.o vclock_gettime.o vgetcpu.o
2aae950b 17
1a21d4e0
L
18vobjs-$(VDSOX32-y) += $(vobjx32s-compat)
19
20# Filter out x32 objects.
21vobj64s := $(filter-out $(vobjx32s-compat),$(vobjs-y))
22
2aae950b 23# files to link into kernel
6c3652ef 24obj-$(VDSO64-y) += vma.o vdso.o
1a21d4e0 25obj-$(VDSOX32-y) += vdsox32.o
af65d648 26obj-$(VDSO32-y) += vdso32.o vdso32-setup.o
2aae950b 27
1a21d4e0 28vobjs := $(foreach F,$(vobj64s),$(obj)/$F)
2aae950b
AK
29
30$(obj)/vdso.o: $(obj)/vdso.so
31
2b9c97e1 32targets += vdso.so vdso.so.dbg vdso.lds $(vobjs-y)
2aae950b 33
d746d647 34export CPPFLAGS_vdso.lds += -P -C
2aae950b 35
de2a8cf9 36VDSO_LDFLAGS_vdso.lds = -m64 -Wl,-soname=linux-vdso.so.1 \
7f79ad15 37 -Wl,--no-undefined \
16e48e7e 38 -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096
2aae950b
AK
39
40$(obj)/vdso.o: $(src)/vdso.S $(obj)/vdso.so
41
f79eb83b 42$(obj)/vdso.so.dbg: $(src)/vdso.lds $(vobjs) FORCE
16e48e7e 43 $(call if_changed,vdso)
2aae950b 44
f79eb83b
RM
45$(obj)/%.so: OBJCOPYFLAGS := -S
46$(obj)/%.so: $(obj)/%.so.dbg FORCE
47 $(call if_changed,objcopy)
48
6447facb
AL
49#
50# Don't omit frame pointers for ease of userspace debugging, but do
51# optimize sibling calls.
52#
8705a49c 53CFL := $(PROFILING) -mcmodel=small -fPIC -O2 -fasynchronous-unwind-tables -m64 \
6447facb
AL
54 $(filter -g%,$(KBUILD_CFLAGS)) $(call cc-option, -fno-stack-protector) \
55 -fno-omit-frame-pointer -foptimize-sibling-calls
2aae950b 56
f6bc4029 57$(vobjs): KBUILD_CFLAGS += $(CFL)
2aae950b 58
6447facb
AL
59#
60# vDSO code runs in userspace and -pg doesn't help with profiling anyway.
61#
62CFLAGS_REMOVE_vdso-note.o = -pg
63CFLAGS_REMOVE_vclock_gettime.o = -pg
64CFLAGS_REMOVE_vgetcpu.o = -pg
65CFLAGS_REMOVE_vvar.o = -pg
66
5b930493 67targets += vdso-syms.lds
6c3652ef 68obj-$(VDSO64-y) += vdso-syms.lds
5b930493
RM
69
70#
71# Match symbols in the DSO that look like VDSO*; produce a file of constants.
72#
73sed-vdsosym := -e 's/^00*/0/' \
f2dbe03d 74 -e 's/^\([0-9a-fA-F]*\) . \(VDSO[a-zA-Z0-9_]*\)$$/\2 = 0x\1;/p'
5b930493 75quiet_cmd_vdsosym = VDSOSYM $@
f2dbe03d
RM
76define cmd_vdsosym
77 $(NM) $< | LC_ALL=C sed -n $(sed-vdsosym) | LC_ALL=C sort > $@
78endef
5b930493
RM
79
80$(obj)/%-syms.lds: $(obj)/%.so.dbg FORCE
81 $(call if_changed,vdsosym)
82
1a21d4e0
L
83#
84# X32 processes use x32 vDSO to access 64bit kernel data.
85#
86# Build x32 vDSO image:
87# 1. Compile x32 vDSO as 64bit.
88# 2. Convert object files to x32.
89# 3. Build x32 VDSO image with x32 objects, which contains 64bit codes
90# so that it can reach 64bit address space with 64bit pointers.
91#
92
93targets += vdsox32-syms.lds
94obj-$(VDSOX32-y) += vdsox32-syms.lds
95
96CPPFLAGS_vdsox32.lds = $(CPPFLAGS_vdso.lds)
97VDSO_LDFLAGS_vdsox32.lds = -Wl,-m,elf32_x86_64 \
98 -Wl,-soname=linux-vdso.so.1 \
99 -Wl,-z,max-page-size=4096 \
100 -Wl,-z,common-page-size=4096
101
102vobjx32s-y := $(vobj64s:.o=-x32.o)
103vobjx32s := $(foreach F,$(vobjx32s-y),$(obj)/$F)
104
105# Convert 64bit object file to x32 for x32 vDSO.
106quiet_cmd_x32 = X32 $@
107 cmd_x32 = $(OBJCOPY) -O elf32-x86-64 $< $@
108
109$(obj)/%-x32.o: $(obj)/%.o FORCE
110 $(call if_changed,x32)
111
112targets += vdsox32.so vdsox32.so.dbg vdsox32.lds $(vobjx32s-y)
113
114$(obj)/vdsox32.o: $(src)/vdsox32.S $(obj)/vdsox32.so
115
116$(obj)/vdsox32.so.dbg: $(src)/vdsox32.lds $(vobjx32s) FORCE
117 $(call if_changed,vdso)
118
0249c9c1
RM
119#
120# Build multiple 32-bit vDSO images to choose from at boot time.
121#
6c3652ef 122obj-$(VDSO32-y) += vdso32-syms.lds
6a52e4b1 123vdso32.so-$(VDSO32-y) += int80
00f8b1bc 124vdso32.so-$(CONFIG_COMPAT) += syscall
0249c9c1
RM
125vdso32.so-$(VDSO32-y) += sysenter
126
2c158269
RM
127vdso32-images = $(vdso32.so-y:%=vdso32-%.so)
128
0249c9c1 129CPPFLAGS_vdso32.lds = $(CPPFLAGS_vdso.lds)
de2a8cf9 130VDSO_LDFLAGS_vdso32.lds = -m32 -Wl,-soname=linux-gate.so.1
0249c9c1
RM
131
132# This makes sure the $(obj) subdirectory exists even though vdso32/
133# is not a kbuild sub-make subdirectory.
134override obj-dirs = $(dir $(obj)) $(obj)/vdso32/
135
136targets += vdso32/vdso32.lds
2c158269 137targets += $(vdso32-images) $(vdso32-images:=.dbg)
0249c9c1
RM
138targets += vdso32/note.o $(vdso32.so-y:%=vdso32/%.o)
139
2c158269 140extra-y += $(vdso32-images)
0249c9c1 141
2c158269 142$(obj)/vdso32.o: $(vdso32-images:%=$(obj)/%)
6c3652ef 143
0249c9c1 144KBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS))
2c158269
RM
145$(vdso32-images:%=$(obj)/%.dbg): KBUILD_AFLAGS = $(KBUILD_AFLAGS_32)
146$(vdso32-images:%=$(obj)/%.dbg): asflags-$(CONFIG_X86_64) += -m32
0249c9c1 147
2c158269
RM
148$(vdso32-images:%=$(obj)/%.dbg): $(obj)/vdso32-%.so.dbg: FORCE \
149 $(obj)/vdso32/vdso32.lds \
150 $(obj)/vdso32/note.o \
151 $(obj)/vdso32/%.o
0249c9c1
RM
152 $(call if_changed,vdso)
153
154# Make vdso32-*-syms.lds from each image, and then make sure they match.
155# The only difference should be that some do not define VDSO32_SYSENTER_RETURN.
156
157targets += vdso32-syms.lds $(vdso32.so-y:%=vdso32-%-syms.lds)
158
159quiet_cmd_vdso32sym = VDSOSYM $@
160define cmd_vdso32sym
161 if LC_ALL=C sort -u $(filter-out FORCE,$^) > $(@D)/.tmp_$(@F) && \
162 $(foreach H,$(filter-out FORCE,$^),\
163 if grep -q VDSO32_SYSENTER_RETURN $H; \
164 then diff -u $(@D)/.tmp_$(@F) $H; \
165 else sed /VDSO32_SYSENTER_RETURN/d $(@D)/.tmp_$(@F) | \
166 diff -u - $H; fi &&) : ;\
167 then mv -f $(@D)/.tmp_$(@F) $@; \
168 else rm -f $(@D)/.tmp_$(@F); exit 1; \
169 fi
170endef
171
172$(obj)/vdso32-syms.lds: $(vdso32.so-y:%=$(obj)/vdso32-%-syms.lds) FORCE
173 $(call if_changed,vdso32sym)
174
175#
176# The DSO images are built using a special linker script.
177#
178quiet_cmd_vdso = VDSO $@
179 cmd_vdso = $(CC) -nostdlib -o $@ \
180 $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \
05d0b088
PA
181 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
182 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
0249c9c1 183
f86fd306 184VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
7bf99fb6 185GCOV_PROFILE := n
0249c9c1
RM
186
187#
188# Install the unstripped copy of vdso*.so listed in $(vdso-install-y).
189#
f79eb83b
RM
190quiet_cmd_vdso_install = INSTALL $@
191 cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
0249c9c1 192$(vdso-install-y): %.so: $(obj)/%.so.dbg FORCE
f79eb83b
RM
193 @mkdir -p $(MODLIB)/vdso
194 $(call cmd,vdso_install)
195
0249c9c1
RM
196PHONY += vdso_install $(vdso-install-y)
197vdso_install: $(vdso-install-y)
d531b4fd
SR
198
199clean-files := vdso32-syscall* vdso32-sysenter* vdso32-int80*
This page took 0.530946 seconds and 5 git commands to generate.