xref: /openbmc/linux/arch/x86/um/vdso/Makefile (revision 3bf90eca)
1# SPDX-License-Identifier: GPL-2.0
2#
3# Building vDSO images for x86.
4#
5
6# do not instrument on vdso because KASAN is not compatible with user mode
7KASAN_SANITIZE			:= n
8
9# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
10KCOV_INSTRUMENT                := n
11
12VDSO64-y		:= y
13
14vdso-install-$(VDSO64-y)	+= vdso.so
15
16
17# files to link into the vdso
18vobjs-y := vdso-note.o um_vdso.o
19
20# files to link into kernel
21obj-$(VDSO64-y)			+= vdso.o vma.o
22
23vobjs := $(foreach F,$(vobjs-y),$(obj)/$F)
24
25$(obj)/vdso.o: $(obj)/vdso.so
26
27targets += vdso.so vdso.so.dbg vdso.lds $(vobjs-y)
28
29CPPFLAGS_vdso.lds += -P -C
30
31VDSO_LDFLAGS_vdso.lds = -m64 -Wl,-soname=linux-vdso.so.1 \
32       -Wl,-z,max-page-size=4096
33
34$(obj)/vdso.o: $(src)/vdso.S $(obj)/vdso.so
35
36$(obj)/vdso.so.dbg: $(obj)/vdso.lds $(vobjs) FORCE
37	$(call if_changed,vdso)
38
39$(obj)/%.so: OBJCOPYFLAGS := -S
40$(obj)/%.so: $(obj)/%.so.dbg FORCE
41	$(call if_changed,objcopy)
42
43#
44# Don't omit frame pointers for ease of userspace debugging, but do
45# optimize sibling calls.
46#
47CFL := $(PROFILING) -mcmodel=small -fPIC -O2 -fasynchronous-unwind-tables -m64 \
48       $(filter -g%,$(KBUILD_CFLAGS)) -fno-stack-protector \
49       -fno-omit-frame-pointer -foptimize-sibling-calls
50
51$(vobjs): KBUILD_CFLAGS += $(CFL)
52
53#
54# vDSO code runs in userspace and -pg doesn't help with profiling anyway.
55#
56CFLAGS_REMOVE_vdso-note.o = -pg -fprofile-arcs -ftest-coverage
57CFLAGS_REMOVE_um_vdso.o = -pg -fprofile-arcs -ftest-coverage
58
59#
60# The DSO images are built using a special linker script.
61#
62quiet_cmd_vdso = VDSO    $@
63      cmd_vdso = $(CC) -nostdlib -o $@ \
64		       $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \
65		       -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
66		 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
67
68VDSO_LDFLAGS = -fPIC -shared -Wl,--hash-style=sysv -z noexecstack
69GCOV_PROFILE := n
70
71#
72# Install the unstripped copy of vdso*.so listed in $(vdso-install-y).
73#
74quiet_cmd_vdso_install = INSTALL $@
75      cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
76$(vdso-install-y): %.so: $(obj)/%.so.dbg FORCE
77	@mkdir -p $(MODLIB)/vdso
78	$(call cmd,vdso_install)
79
80PHONY += vdso_install $(vdso-install-y)
81vdso_install: $(vdso-install-y)
82