]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - arch/x86/entry/vdso/Makefile
objtool: Mark non-standard object files and directories
[mirror_ubuntu-bionic-kernel.git] / arch / x86 / entry / vdso / Makefile
CommitLineData
2aae950b 1#
0249c9c1 2# Building vDSO images for x86.
2aae950b
AK
3#
4
67424d5a 5KBUILD_CFLAGS += $(DISABLE_LTO)
c0dd6716
JP
6KASAN_SANITIZE := n
7UBSAN_SANITIZE := n
8OBJECT_FILES_NON_STANDARD := y
67424d5a 9
0249c9c1 10VDSO64-$(CONFIG_X86_64) := y
1a21d4e0 11VDSOX32-$(CONFIG_X86_X32_ABI) := y
0249c9c1 12VDSO32-$(CONFIG_X86_32) := y
ab8b82ee 13VDSO32-$(CONFIG_IA32_EMULATION) := y
0249c9c1 14
2aae950b 15# files to link into the vdso
da861e18 16vobjs-y := vdso-note.o vclock_gettime.o vgetcpu.o
1a21d4e0 17
2aae950b 18# files to link into kernel
b4b541a6 19obj-y += vma.o
c0dd6716 20OBJECT_FILES_NON_STANDARD_vma.o := n
6f121e54
AL
21
22# vDSO images to build
23vdso_img-$(VDSO64-y) += 64
24vdso_img-$(VDSOX32-y) += x32
0a6d1fa0 25vdso_img-$(VDSO32-y) += 32
6f121e54
AL
26
27obj-$(VDSO32-y) += vdso32-setup.o
2aae950b 28
e0bf7b86 29vobjs := $(foreach F,$(vobjs-y),$(obj)/$F)
2aae950b
AK
30
31$(obj)/vdso.o: $(obj)/vdso.so
32
6f121e54
AL
33targets += vdso.lds $(vobjs-y)
34
35# Build the vDSO image C files and link them in.
36vdso_img_objs := $(vdso_img-y:%=vdso-image-%.o)
37vdso_img_cfiles := $(vdso_img-y:%=vdso-image-%.c)
38vdso_img_sodbg := $(vdso_img-y:%=vdso%.so.dbg)
39obj-y += $(vdso_img_objs)
40targets += $(vdso_img_cfiles)
41targets += $(vdso_img_sodbg)
da861e18
AL
42.SECONDARY: $(vdso_img-y:%=$(obj)/vdso-image-%.c) \
43 $(vdso_img-y:%=$(obj)/vdso%.so)
2aae950b 44
d746d647 45export CPPFLAGS_vdso.lds += -P -C
2aae950b 46
de2a8cf9 47VDSO_LDFLAGS_vdso.lds = -m64 -Wl,-soname=linux-vdso.so.1 \
7f79ad15 48 -Wl,--no-undefined \
67424d5a
AK
49 -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096 \
50 $(DISABLE_LTO)
2aae950b 51
6f121e54 52$(obj)/vdso64.so.dbg: $(src)/vdso.lds $(vobjs) FORCE
16e48e7e 53 $(call if_changed,vdso)
2aae950b 54
ef7254a5 55HOST_EXTRACFLAGS += -I$(srctree)/tools/include -I$(srctree)/include/uapi -I$(srctree)/arch/x86/include/uapi
6f121e54
AL
56hostprogs-y += vdso2c
57
58quiet_cmd_vdso2c = VDSO2C $@
59define cmd_vdso2c
da861e18 60 $(obj)/vdso2c $< $(<:%.dbg=%) $@
6f121e54
AL
61endef
62
da861e18 63$(obj)/vdso-image-%.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(obj)/vdso2c FORCE
6f121e54 64 $(call if_changed,vdso2c)
f79eb83b 65
6447facb
AL
66#
67# Don't omit frame pointers for ease of userspace debugging, but do
68# optimize sibling calls.
69#
8705a49c 70CFL := $(PROFILING) -mcmodel=small -fPIC -O2 -fasynchronous-unwind-tables -m64 \
6447facb 71 $(filter -g%,$(KBUILD_CFLAGS)) $(call cc-option, -fno-stack-protector) \
46b57a76 72 -fno-omit-frame-pointer -foptimize-sibling-calls \
f24f9108 73 -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO
2aae950b 74
f6bc4029 75$(vobjs): KBUILD_CFLAGS += $(CFL)
2aae950b 76
6447facb
AL
77#
78# vDSO code runs in userspace and -pg doesn't help with profiling anyway.
79#
80CFLAGS_REMOVE_vdso-note.o = -pg
81CFLAGS_REMOVE_vclock_gettime.o = -pg
82CFLAGS_REMOVE_vgetcpu.o = -pg
83CFLAGS_REMOVE_vvar.o = -pg
84
1a21d4e0
L
85#
86# X32 processes use x32 vDSO to access 64bit kernel data.
87#
88# Build x32 vDSO image:
89# 1. Compile x32 vDSO as 64bit.
90# 2. Convert object files to x32.
91# 3. Build x32 VDSO image with x32 objects, which contains 64bit codes
92# so that it can reach 64bit address space with 64bit pointers.
93#
94
1a21d4e0
L
95CPPFLAGS_vdsox32.lds = $(CPPFLAGS_vdso.lds)
96VDSO_LDFLAGS_vdsox32.lds = -Wl,-m,elf32_x86_64 \
97 -Wl,-soname=linux-vdso.so.1 \
98 -Wl,-z,max-page-size=4096 \
99 -Wl,-z,common-page-size=4096
100
e0bf7b86
AL
101# 64-bit objects to re-brand as x32
102vobjs64-for-x32 := $(filter-out $(vobjs-nox32),$(vobjs-y))
103
104# x32-rebranded versions
105vobjx32s-y := $(vobjs64-for-x32:.o=-x32.o)
106
107# same thing, but in the output directory
1a21d4e0
L
108vobjx32s := $(foreach F,$(vobjx32s-y),$(obj)/$F)
109
110# Convert 64bit object file to x32 for x32 vDSO.
111quiet_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
6f121e54 117targets += vdsox32.lds $(vobjx32s-y)
1a21d4e0 118
da861e18
AL
119$(obj)/%.so: OBJCOPYFLAGS := -S
120$(obj)/%.so: $(obj)/%.so.dbg
121 $(call if_changed,objcopy)
122
1a21d4e0
L
123$(obj)/vdsox32.so.dbg: $(src)/vdsox32.lds $(vobjx32s) FORCE
124 $(call if_changed,vdso)
125
0249c9c1 126CPPFLAGS_vdso32.lds = $(CPPFLAGS_vdso.lds)
67424d5a 127VDSO_LDFLAGS_vdso32.lds = -m32 -Wl,-m,elf_i386 -Wl,-soname=linux-gate.so.1
0249c9c1
RM
128
129# This makes sure the $(obj) subdirectory exists even though vdso32/
130# is not a kbuild sub-make subdirectory.
131override obj-dirs = $(dir $(obj)) $(obj)/vdso32/
132
133targets += vdso32/vdso32.lds
0a6d1fa0 134targets += vdso32/note.o vdso32/vclock_gettime.o vdso32/system_call.o
da861e18 135targets += vdso32/vclock_gettime.o
0249c9c1 136
f24f9108 137KBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS)) -DBUILD_VDSO
0a6d1fa0
AL
138$(obj)/vdso32.so.dbg: KBUILD_AFLAGS = $(KBUILD_AFLAGS_32)
139$(obj)/vdso32.so.dbg: asflags-$(CONFIG_X86_64) += -m32
0249c9c1 140
7a59ed41
SS
141KBUILD_CFLAGS_32 := $(filter-out -m64,$(KBUILD_CFLAGS))
142KBUILD_CFLAGS_32 := $(filter-out -mcmodel=kernel,$(KBUILD_CFLAGS_32))
143KBUILD_CFLAGS_32 := $(filter-out -fno-pic,$(KBUILD_CFLAGS_32))
144KBUILD_CFLAGS_32 := $(filter-out -mfentry,$(KBUILD_CFLAGS_32))
145KBUILD_CFLAGS_32 += -m32 -msoft-float -mregparm=0 -fpic
008cc907
PA
146KBUILD_CFLAGS_32 += $(call cc-option, -fno-stack-protector)
147KBUILD_CFLAGS_32 += $(call cc-option, -foptimize-sibling-calls)
148KBUILD_CFLAGS_32 += -fno-omit-frame-pointer
46b57a76 149KBUILD_CFLAGS_32 += -DDISABLE_BRANCH_PROFILING
0a6d1fa0 150$(obj)/vdso32.so.dbg: KBUILD_CFLAGS = $(KBUILD_CFLAGS_32)
7a59ed41 151
0a6d1fa0
AL
152$(obj)/vdso32.so.dbg: FORCE \
153 $(obj)/vdso32/vdso32.lds \
154 $(obj)/vdso32/vclock_gettime.o \
155 $(obj)/vdso32/note.o \
156 $(obj)/vdso32/system_call.o
0249c9c1
RM
157 $(call if_changed,vdso)
158
0249c9c1
RM
159#
160# The DSO images are built using a special linker script.
161#
162quiet_cmd_vdso = VDSO $@
163 cmd_vdso = $(CC) -nostdlib -o $@ \
164 $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \
05d0b088
PA
165 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
166 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
0249c9c1 167
6b7e2654 168VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=both) \
dda1e95c 169 $(call cc-ldoption, -Wl$(comma)--build-id) -Wl,-Bsymbolic $(LTO_CFLAGS)
7bf99fb6 170GCOV_PROFILE := n
0249c9c1
RM
171
172#
dda1e95c
AL
173# Install the unstripped copies of vdso*.so. If our toolchain supports
174# build-id, install .build-id links as well.
0249c9c1 175#
a934fb5b 176quiet_cmd_vdso_install = INSTALL $(@:install_%=%)
dda1e95c
AL
177define cmd_vdso_install
178 cp $< "$(MODLIB)/vdso/$(@:install_%=%)"; \
179 if readelf -n $< |grep -q 'Build ID'; then \
180 buildid=`readelf -n $< |grep 'Build ID' |sed -e 's/^.*Build ID: \(.*\)$$/\1/'`; \
181 first=`echo $$buildid | cut -b-2`; \
182 last=`echo $$buildid | cut -b3-`; \
183 mkdir -p "$(MODLIB)/vdso/.build-id/$$first"; \
184 ln -sf "../../$(@:install_%=%)" "$(MODLIB)/vdso/.build-id/$$first/$$last.debug"; \
185 fi
186endef
a934fb5b
AL
187
188vdso_img_insttargets := $(vdso_img_sodbg:%.dbg=install_%)
189
190$(MODLIB)/vdso: FORCE
f79eb83b 191 @mkdir -p $(MODLIB)/vdso
a934fb5b
AL
192
193$(vdso_img_insttargets): install_%: $(obj)/%.dbg $(MODLIB)/vdso FORCE
f79eb83b
RM
194 $(call cmd,vdso_install)
195
a934fb5b
AL
196PHONY += vdso_install $(vdso_img_insttargets)
197vdso_install: $(vdso_img_insttargets) FORCE
d531b4fd 198
0a6d1fa0 199clean-files := vdso32.so vdso32.so.dbg vdso64* vdso-image-*.c vdsox32.so*