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