]> git.karo-electronics.de Git - karo-tx-linux.git/blob - arch/x86/vdso/Makefile
Merge branch 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
[karo-tx-linux.git] / arch / x86 / vdso / Makefile
1 #
2 # Building vDSO images for x86.
3 #
4
5 KBUILD_CFLAGS += $(DISABLE_LTO)
6
7 VDSO64-$(CONFIG_X86_64)         := y
8 VDSOX32-$(CONFIG_X86_X32_ABI)   := y
9 VDSO32-$(CONFIG_X86_32)         := y
10 VDSO32-$(CONFIG_COMPAT)         := y
11
12 vdso-install-$(VDSO64-y)        += vdso.so
13 vdso-install-$(VDSOX32-y)       += vdsox32.so
14 vdso-install-$(VDSO32-y)        += $(vdso32-images)
15
16
17 # files to link into the vdso
18 vobjs-y := vdso-note.o vclock_gettime.o vgetcpu.o
19
20 vobjs-$(VDSOX32-y) += $(vobjx32s-compat)
21
22 # Filter out x32 objects.
23 vobj64s := $(filter-out $(vobjx32s-compat),$(vobjs-y))
24
25 # files to link into kernel
26 obj-y                           += vma.o
27
28 # vDSO images to build
29 vdso_img-$(VDSO64-y)            += 64
30 vdso_img-$(VDSOX32-y)           += x32
31 vdso_img-$(VDSO32-y)            += 32-int80
32 vdso_img-$(CONFIG_COMPAT)       += 32-syscall
33 vdso_img-$(VDSO32-y)            += 32-sysenter
34
35 obj-$(VDSO32-y)                 += vdso32-setup.o
36
37 vobjs := $(foreach F,$(vobj64s),$(obj)/$F)
38
39 $(obj)/vdso.o: $(obj)/vdso.so
40
41 targets += vdso.lds $(vobjs-y)
42
43 # Build the vDSO image C files and link them in.
44 vdso_img_objs := $(vdso_img-y:%=vdso-image-%.o)
45 vdso_img_cfiles := $(vdso_img-y:%=vdso-image-%.c)
46 vdso_img_sodbg := $(vdso_img-y:%=vdso%.so.dbg)
47 obj-y += $(vdso_img_objs)
48 targets += $(vdso_img_cfiles)
49 targets += $(vdso_img_sodbg)
50 .SECONDARY: $(vdso_img-y:%=$(obj)/vdso-image-%.c)
51
52 export CPPFLAGS_vdso.lds += -P -C
53
54 VDSO_LDFLAGS_vdso.lds = -m64 -Wl,-soname=linux-vdso.so.1 \
55                         -Wl,--no-undefined \
56                         -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096 \
57                         $(DISABLE_LTO)
58
59 $(obj)/vdso64.so.dbg: $(src)/vdso.lds $(vobjs) FORCE
60         $(call if_changed,vdso)
61
62 HOST_EXTRACFLAGS += -I$(srctree)/tools/include
63 hostprogs-y                     += vdso2c
64
65 quiet_cmd_vdso2c = VDSO2C  $@
66 define cmd_vdso2c
67         $(obj)/vdso2c $< $@
68 endef
69
70 $(obj)/vdso-image-%.c: $(obj)/vdso%.so.dbg $(obj)/vdso2c FORCE
71         $(call if_changed,vdso2c)
72
73 #
74 # Don't omit frame pointers for ease of userspace debugging, but do
75 # optimize sibling calls.
76 #
77 CFL := $(PROFILING) -mcmodel=small -fPIC -O2 -fasynchronous-unwind-tables -m64 \
78        $(filter -g%,$(KBUILD_CFLAGS)) $(call cc-option, -fno-stack-protector) \
79        -fno-omit-frame-pointer -foptimize-sibling-calls
80
81 $(vobjs): KBUILD_CFLAGS += $(CFL)
82
83 #
84 # vDSO code runs in userspace and -pg doesn't help with profiling anyway.
85 #
86 CFLAGS_REMOVE_vdso-note.o = -pg
87 CFLAGS_REMOVE_vclock_gettime.o = -pg
88 CFLAGS_REMOVE_vgetcpu.o = -pg
89 CFLAGS_REMOVE_vvar.o = -pg
90
91 #
92 # X32 processes use x32 vDSO to access 64bit kernel data.
93 #
94 # Build x32 vDSO image:
95 # 1. Compile x32 vDSO as 64bit.
96 # 2. Convert object files to x32.
97 # 3. Build x32 VDSO image with x32 objects, which contains 64bit codes
98 # so that it can reach 64bit address space with 64bit pointers.
99 #
100
101 CPPFLAGS_vdsox32.lds = $(CPPFLAGS_vdso.lds)
102 VDSO_LDFLAGS_vdsox32.lds = -Wl,-m,elf32_x86_64 \
103                            -Wl,-soname=linux-vdso.so.1 \
104                            -Wl,-z,max-page-size=4096 \
105                            -Wl,-z,common-page-size=4096
106
107 vobjx32s-y := $(vobj64s:.o=-x32.o)
108 vobjx32s := $(foreach F,$(vobjx32s-y),$(obj)/$F)
109
110 # Convert 64bit object file to x32 for x32 vDSO.
111 quiet_cmd_x32 = X32     $@
112       cmd_x32 = $(OBJCOPY) -O elf32-x86-64 $< $@
113
114 $(obj)/%-x32.o: $(obj)/%.o FORCE
115         $(call if_changed,x32)
116
117 targets += vdsox32.lds $(vobjx32s-y)
118
119 $(obj)/vdsox32.so.dbg: $(src)/vdsox32.lds $(vobjx32s) FORCE
120         $(call if_changed,vdso)
121
122 #
123 # Build multiple 32-bit vDSO images to choose from at boot time.
124 #
125 vdso32.so-$(VDSO32-y)           += int80
126 vdso32.so-$(CONFIG_COMPAT)      += syscall
127 vdso32.so-$(VDSO32-y)           += sysenter
128
129 vdso32-images                   = $(vdso32.so-y:%=vdso32-%.so)
130
131 CPPFLAGS_vdso32.lds = $(CPPFLAGS_vdso.lds)
132 VDSO_LDFLAGS_vdso32.lds = -m32 -Wl,-m,elf_i386 -Wl,-soname=linux-gate.so.1
133
134 # This makes sure the $(obj) subdirectory exists even though vdso32/
135 # is not a kbuild sub-make subdirectory.
136 override obj-dirs = $(dir $(obj)) $(obj)/vdso32/
137
138 targets += vdso32/vdso32.lds
139 targets += vdso32/note.o vdso32/vclock_gettime.o $(vdso32.so-y:%=vdso32/%.o)
140 targets += vdso32/vclock_gettime.o
141
142 $(obj)/vdso32.o: $(vdso32-images:%=$(obj)/%)
143
144 KBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS))
145 $(vdso32-images:%=$(obj)/%.dbg): KBUILD_AFLAGS = $(KBUILD_AFLAGS_32)
146 $(vdso32-images:%=$(obj)/%.dbg): asflags-$(CONFIG_X86_64) += -m32
147
148 KBUILD_CFLAGS_32 := $(filter-out -m64,$(KBUILD_CFLAGS))
149 KBUILD_CFLAGS_32 := $(filter-out -mcmodel=kernel,$(KBUILD_CFLAGS_32))
150 KBUILD_CFLAGS_32 := $(filter-out -fno-pic,$(KBUILD_CFLAGS_32))
151 KBUILD_CFLAGS_32 := $(filter-out -mfentry,$(KBUILD_CFLAGS_32))
152 KBUILD_CFLAGS_32 += -m32 -msoft-float -mregparm=0 -fpic
153 KBUILD_CFLAGS_32 += $(call cc-option, -fno-stack-protector)
154 KBUILD_CFLAGS_32 += $(call cc-option, -foptimize-sibling-calls)
155 KBUILD_CFLAGS_32 += -fno-omit-frame-pointer
156 $(vdso32-images:%=$(obj)/%.dbg): KBUILD_CFLAGS = $(KBUILD_CFLAGS_32)
157
158 $(vdso32-images:%=$(obj)/%.dbg): $(obj)/vdso32-%.so.dbg: FORCE \
159                                  $(obj)/vdso32/vdso32.lds \
160                                  $(obj)/vdso32/vclock_gettime.o \
161                                  $(obj)/vdso32/note.o \
162                                  $(obj)/vdso32/%.o
163         $(call if_changed,vdso)
164
165 #
166 # The DSO images are built using a special linker script.
167 #
168 quiet_cmd_vdso = VDSO    $@
169       cmd_vdso = $(CC) -nostdlib -o $@ \
170                        $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \
171                        -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
172                  sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
173
174 VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) \
175         -Wl,-Bsymbolic $(LTO_CFLAGS)
176 GCOV_PROFILE := n
177
178 #
179 # Install the unstripped copy of vdso*.so listed in $(vdso-install-y).
180 #
181 quiet_cmd_vdso_install = INSTALL $@
182       cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
183 $(vdso-install-y): %.so: $(obj)/%.so.dbg FORCE
184         @mkdir -p $(MODLIB)/vdso
185         $(call cmd,vdso_install)
186
187 PHONY += vdso_install $(vdso-install-y)
188 vdso_install: $(vdso-install-y)
189
190 clean-files := vdso32-syscall* vdso32-sysenter* vdso32-int80*