xref: /linux/arch/x86/um/vdso/Makefile (revision f3a8b6645dc2e60d11f20c1c23afd964ff4e55ae)
1#
2# Building vDSO images for x86.
3#
4
5# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
6KCOV_INSTRUMENT                := n
7
8VDSO64-y		:= y
9
10vdso-install-$(VDSO64-y)	+= vdso.so
11
12
13# files to link into the vdso
14vobjs-y := vdso-note.o um_vdso.o
15
16# files to link into kernel
17obj-$(VDSO64-y)			+= vdso.o vma.o
18
19vobjs := $(foreach F,$(vobjs-y),$(obj)/$F)
20
21$(obj)/vdso.o: $(obj)/vdso.so
22
23targets += vdso.so vdso.so.dbg vdso.lds $(vobjs-y)
24
25export CPPFLAGS_vdso.lds += -P -C
26
27VDSO_LDFLAGS_vdso.lds = -m64 -Wl,-soname=linux-vdso.so.1 \
28       -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096
29
30$(obj)/vdso.o: $(src)/vdso.S $(obj)/vdso.so
31
32$(obj)/vdso.so.dbg: $(src)/vdso.lds $(vobjs) FORCE
33	$(call if_changed,vdso)
34
35$(obj)/%.so: OBJCOPYFLAGS := -S
36$(obj)/%.so: $(obj)/%.so.dbg FORCE
37	$(call if_changed,objcopy)
38
39#
40# Don't omit frame pointers for ease of userspace debugging, but do
41# optimize sibling calls.
42#
43CFL := $(PROFILING) -mcmodel=small -fPIC -O2 -fasynchronous-unwind-tables -m64 \
44       $(filter -g%,$(KBUILD_CFLAGS)) $(call cc-option, -fno-stack-protector) \
45       -fno-omit-frame-pointer -foptimize-sibling-calls
46
47$(vobjs): KBUILD_CFLAGS += $(CFL)
48
49#
50# vDSO code runs in userspace and -pg doesn't help with profiling anyway.
51#
52CFLAGS_REMOVE_vdso-note.o = -pg -fprofile-arcs -ftest-coverage
53CFLAGS_REMOVE_um_vdso.o = -pg -fprofile-arcs -ftest-coverage
54
55targets += vdso-syms.lds
56obj-$(VDSO64-y)			+= vdso-syms.lds
57
58#
59# Match symbols in the DSO that look like VDSO*; produce a file of constants.
60#
61sed-vdsosym := -e 's/^00*/0/' \
62	-e 's/^\([0-9a-fA-F]*\) . \(VDSO[a-zA-Z0-9_]*\)$$/\2 = 0x\1;/p'
63quiet_cmd_vdsosym = VDSOSYM $@
64define cmd_vdsosym
65	$(NM) $< | LC_ALL=C sed -n $(sed-vdsosym) | LC_ALL=C sort > $@
66endef
67
68$(obj)/%-syms.lds: $(obj)/%.so.dbg FORCE
69	$(call if_changed,vdsosym)
70
71#
72# The DSO images are built using a special linker script.
73#
74quiet_cmd_vdso = VDSO    $@
75      cmd_vdso = $(CC) -nostdlib -o $@ \
76		       $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \
77		       -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
78		 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
79
80VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
81GCOV_PROFILE := n
82
83#
84# Install the unstripped copy of vdso*.so listed in $(vdso-install-y).
85#
86quiet_cmd_vdso_install = INSTALL $@
87      cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
88$(vdso-install-y): %.so: $(obj)/%.so.dbg FORCE
89	@mkdir -p $(MODLIB)/vdso
90	$(call cmd,vdso_install)
91
92PHONY += vdso_install $(vdso-install-y)
93vdso_install: $(vdso-install-y)
94