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