• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# SPDX-License-Identifier: GPL-2.0
2# Symbols present in the vdso
3vdso-syms = rt_sigreturn gettimeofday
4
5# Files to link into the vdso
6obj-vdso = $(patsubst %, v%.o, $(vdso-syms))
7
8# Build rules
9targets := $(obj-vdso) vdso.so vdso.so.dbg vdso.lds vdso-dummy.o
10obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
11
12# vdso32 is only for tilegx -m32 compat task.
13VDSO32-$(CONFIG_COMPAT) := y
14
15obj-y += vdso.o vdso-syms.o
16obj-$(VDSO32-y) += vdso32.o
17CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
18
19# vDSO code runs in userspace and -pg doesn't help with profiling anyway.
20CFLAGS_REMOVE_vdso.o = -pg
21CFLAGS_REMOVE_vdso32.o = -pg
22CFLAGS_REMOVE_vrt_sigreturn.o = -pg
23CFLAGS_REMOVE_vrt_sigreturn32.o = -pg
24CFLAGS_REMOVE_vgettimeofday.o = -pg
25CFLAGS_REMOVE_vgettimeofday32.o = -pg
26
27ifdef CONFIG_FEEDBACK_COLLECT
28# vDSO code runs in userspace, not collecting feedback data.
29CFLAGS_REMOVE_vdso.o = -ffeedback-generate
30CFLAGS_REMOVE_vdso32.o = -ffeedback-generate
31CFLAGS_REMOVE_vrt_sigreturn.o = -ffeedback-generate
32CFLAGS_REMOVE_vrt_sigreturn32.o = -ffeedback-generate
33CFLAGS_REMOVE_vgettimeofday.o = -ffeedback-generate
34CFLAGS_REMOVE_vgettimeofday32.o = -ffeedback-generate
35endif
36
37# Disable gcov profiling for VDSO code
38GCOV_PROFILE := n
39
40# Force dependency
41$(obj)/vdso.o: $(obj)/vdso.so
42
43# link rule for the .so file, .lds has to be first
44SYSCFLAGS_vdso.so.dbg = $(c_flags)
45$(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso) FORCE
46	$(call if_changed,vdsold)
47
48# We also create a special relocatable object that should mirror the symbol
49# table and layout of the linked DSO.  With ld -R we can then refer to
50# these symbols in the kernel code rather than hand-coded addresses.
51
52SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \
53                            $(call cc-ldoption, -Wl$(comma)--hash-style=both)
54SYSCFLAGS_vdso_dummy.o = -r
55$(obj)/vdso-dummy.o: $(src)/vdso.lds $(obj)/vrt_sigreturn.o FORCE
56	$(call if_changed,vdsold)
57
58LDFLAGS_vdso-syms.o := -r -R
59$(obj)/vdso-syms.o: $(obj)/vdso-dummy.o FORCE
60	$(call if_changed,ld)
61
62# strip rule for the .so file
63$(obj)/%.so: OBJCOPYFLAGS := -S
64$(obj)/%.so: $(obj)/%.so.dbg FORCE
65	$(call if_changed,objcopy)
66
67# actual build commands
68# The DSO images are built using a special linker script
69# Add -lgcc so tilepro gets static muldi3 and lshrdi3 definitions.
70# Make sure only to export the intended __vdso_xxx symbol offsets.
71quiet_cmd_vdsold = VDSOLD  $@
72      cmd_vdsold = $(CC) $(KCFLAGS) -nostdlib $(SYSCFLAGS_$(@F)) \
73                           -Wl,-T,$(filter-out FORCE,$^) -o $@.tmp -lgcc && \
74                   $(CROSS_COMPILE)objcopy \
75                           $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@
76
77# install commands for the unstripped file
78quiet_cmd_vdso_install = INSTALL $@
79      cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
80
81vdso.so: $(obj)/vdso.so.dbg
82	@mkdir -p $(MODLIB)/vdso
83	$(call cmd,vdso_install)
84
85vdso32.so: $(obj)/vdso32.so.dbg
86	$(call cmd,vdso_install)
87
88vdso_install: vdso.so
89vdso32_install: vdso32.so
90
91
92KBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS))
93KBUILD_AFLAGS_32 += -m32 -s
94KBUILD_CFLAGS_32 := $(filter-out -m64,$(KBUILD_CFLAGS))
95KBUILD_CFLAGS_32 += -m32 -fPIC -shared
96
97obj-vdso32 = $(patsubst %, v%32.o, $(vdso-syms))
98
99targets += $(obj-vdso32) vdso32.so vdso32.so.dbg
100obj-vdso32 := $(addprefix $(obj)/, $(obj-vdso32))
101
102$(obj-vdso32:%=%): KBUILD_AFLAGS = $(KBUILD_AFLAGS_32)
103$(obj-vdso32:%=%): KBUILD_CFLAGS = $(KBUILD_CFLAGS_32)
104
105$(obj)/vgettimeofday32.o: $(obj)/vgettimeofday.c FORCE
106	$(call if_changed_rule,cc_o_c)
107
108$(obj)/vrt_sigreturn32.o: $(obj)/vrt_sigreturn.S FORCE
109	$(call if_changed,as_o_S)
110
111# Force dependency
112$(obj)/vdso32.o: $(obj)/vdso32.so
113
114SYSCFLAGS_vdso32.so.dbg = -m32 -shared -s -Wl,-soname=linux-vdso32.so.1 \
115			    $(call cc-ldoption, -Wl$(comma)--hash-style=both)
116$(obj)/vdso32.so.dbg: $(src)/vdso.lds $(obj-vdso32) FORCE
117	$(call if_changed,vdsold)
118