blob: c54fff37b5ff071270dfe8843e8966da43005c4f [file] [log] [blame]
Kyle Swenson8d8f6542021-03-15 11:02:55 -06001# Symbols present in the vdso
2vdso-syms = rt_sigreturn gettimeofday
3
4# Files to link into the vdso
5obj-vdso = $(patsubst %, v%.o, $(vdso-syms))
6
7# Build rules
8targets := $(obj-vdso) vdso.so vdso.so.dbg vdso.lds
9obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
10
11# vdso32 is only for tilegx -m32 compat task.
12VDSO32-$(CONFIG_COMPAT) := y
13
14obj-y += vdso.o
15obj-$(VDSO32-y) += vdso32.o
16extra-y += vdso.lds
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)
46 $(call if_changed,vdsold)
47
48
49# We also create a special relocatable object that should mirror the symbol
50# table and layout of the linked DSO. With ld -R we can then refer to
51# these symbols in the kernel code rather than hand-coded addresses.
52extra-y += vdso-syms.o
53$(obj)/built-in.o: $(obj)/vdso-syms.o
54$(obj)/built-in.o: ld_flags += -R $(obj)/vdso-syms.o
55
56SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \
57 $(call cc-ldoption, -Wl$(comma)--hash-style=both)
58SYSCFLAGS_vdso_syms.o = -r
59$(obj)/vdso-syms.o: $(src)/vdso.lds $(obj)/vrt_sigreturn.o FORCE
60 $(call if_changed,vdsold)
61
62
63# strip rule for the .so file
64$(obj)/%.so: OBJCOPYFLAGS := -S
65$(obj)/%.so: $(obj)/%.so.dbg FORCE
66 $(call if_changed,objcopy)
67
68# actual build commands
69# The DSO images are built using a special linker script
70# Add -lgcc so tilepro gets static muldi3 and lshrdi3 definitions.
71# Make sure only to export the intended __vdso_xxx symbol offsets.
72quiet_cmd_vdsold = VDSOLD $@
73 cmd_vdsold = $(CC) $(KCFLAGS) -nostdlib $(SYSCFLAGS_$(@F)) \
74 -Wl,-T,$(filter-out FORCE,$^) -o $@.tmp -lgcc && \
75 $(CROSS_COMPILE)objcopy \
76 $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@
77
78# install commands for the unstripped file
79quiet_cmd_vdso_install = INSTALL $@
80 cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
81
82vdso.so: $(obj)/vdso.so.dbg
83 @mkdir -p $(MODLIB)/vdso
84 $(call cmd,vdso_install)
85
86vdso32.so: $(obj)/vdso32.so.dbg
87 $(call cmd,vdso_install)
88
89vdso_install: vdso.so
90vdso32_install: vdso32.so
91
92
93KBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS))
94KBUILD_AFLAGS_32 += -m32 -s
95KBUILD_CFLAGS_32 := $(filter-out -m64,$(KBUILD_CFLAGS))
96KBUILD_CFLAGS_32 += -m32 -fPIC -shared
97
98obj-vdso32 = $(patsubst %, v%32.o, $(vdso-syms))
99obj-vdso32 := $(addprefix $(obj)/, $(obj-vdso32))
100
101targets += $(obj-vdso32) vdso32.so vdso32.so.dbg
102
103$(obj-vdso32:%=%): KBUILD_AFLAGS = $(KBUILD_AFLAGS_32)
104$(obj-vdso32:%=%): KBUILD_CFLAGS = $(KBUILD_CFLAGS_32)
105
106$(obj)/vgettimeofday32.o: $(obj)/vgettimeofday.c
107 $(call if_changed_rule,cc_o_c)
108
109$(obj)/vrt_sigreturn32.o: $(obj)/vrt_sigreturn.S
110 $(call if_changed,as_o_S)
111
112# Force dependency
113$(obj)/vdso32.o: $(obj)/vdso32.so
114
115SYSCFLAGS_vdso32.so.dbg = -m32 -shared -s -Wl,-soname=linux-vdso32.so.1 \
116 $(call cc-ldoption, -Wl$(comma)--hash-style=both)
117$(obj)/vdso32.so.dbg: $(src)/vdso.lds $(obj-vdso32)
118 $(call if_changed,vdsold)