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