hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/arch/riscv/kernel/vdso/Makefile
....@@ -1,46 +1,60 @@
1
+# SPDX-License-Identifier: GPL-2.0-only
12 # Copied from arch/tile/kernel/vdso/Makefile
23
4
+# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
5
+# the inclusion of generic Makefile.
6
+ARCH_REL_TYPE_ABS := R_RISCV_32|R_RISCV_64|R_RISCV_JUMP_SLOT
7
+include $(srctree)/lib/vdso/Makefile
38 # Symbols present in the vdso
49 vdso-syms = rt_sigreturn
5
-vdso-syms += gettimeofday
6
-vdso-syms += clock_gettime
7
-vdso-syms += clock_getres
10
+ifdef CONFIG_64BIT
11
+vdso-syms += vgettimeofday
12
+endif
813 vdso-syms += getcpu
914 vdso-syms += flush_icache
1015
1116 # Files to link into the vdso
12
-obj-vdso = $(patsubst %, %.o, $(vdso-syms))
17
+obj-vdso = $(patsubst %, %.o, $(vdso-syms)) note.o
18
+
19
+ccflags-y := -fno-stack-protector
20
+ccflags-y += -DDISABLE_BRANCH_PROFILING
21
+
22
+ifneq ($(c-gettimeofday-y),)
23
+ CFLAGS_vgettimeofday.o += -fPIC -include $(c-gettimeofday-y)
24
+endif
1325
1426 # Build rules
15
-targets := $(obj-vdso) vdso.so vdso.so.dbg vdso.lds vdso-dummy.o
27
+targets := $(obj-vdso) vdso.so vdso.so.dbg vdso.lds vdso-syms.S
1628 obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
1729
1830 obj-y += vdso.o vdso-syms.o
1931 CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
32
+ifneq ($(filter vgettimeofday, $(vdso-syms)),)
33
+CPPFLAGS_vdso.lds += -DHAS_VGETTIMEOFDAY
34
+endif
2035
21
-# Disable gcov profiling for VDSO code
36
+# Disable -pg to prevent insert call site
37
+CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE)
38
+
39
+# Disable profiling and instrumentation for VDSO code
2240 GCOV_PROFILE := n
41
+KCOV_INSTRUMENT := n
42
+KASAN_SANITIZE := n
2343
2444 # Force dependency
2545 $(obj)/vdso.o: $(obj)/vdso.so
2646
2747 # link rule for the .so file, .lds has to be first
28
-SYSCFLAGS_vdso.so.dbg = $(c_flags)
29
-$(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso) FORCE
48
+$(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE
3049 $(call if_changed,vdsold)
50
+LDFLAGS_vdso.so.dbg = -shared -s -soname=linux-vdso.so.1 \
51
+ --build-id=sha1 --hash-style=both --eh-frame-hdr
3152
3253 # We also create a special relocatable object that should mirror the symbol
3354 # table and layout of the linked DSO. With ld --just-symbols we can then
3455 # refer to these symbols in the kernel code rather than hand-coded addresses.
35
-
36
-SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \
37
- $(call cc-ldoption, -Wl$(comma)--hash-style=both)
38
-$(obj)/vdso-dummy.o: $(src)/vdso.lds $(obj)/rt_sigreturn.o FORCE
39
- $(call if_changed,vdsold)
40
-
41
-LDFLAGS_vdso-syms.o := -r --just-symbols
42
-$(obj)/vdso-syms.o: $(obj)/vdso-dummy.o FORCE
43
- $(call if_changed,ld)
56
+$(obj)/vdso-syms.S: $(obj)/vdso.so FORCE
57
+ $(call if_changed,so2s)
4458
4559 # strip rule for the .so file
4660 $(obj)/%.so: OBJCOPYFLAGS := -S
....@@ -49,15 +63,17 @@
4963
5064 # actual build commands
5165 # The DSO images are built using a special linker script
52
-# Add -lgcc so rv32 gets static muldi3 and lshrdi3 definitions.
5366 # Make sure only to export the intended __vdso_xxx symbol offsets.
5467 quiet_cmd_vdsold = VDSOLD $@
55
- cmd_vdsold = $(CC) $(KBUILD_CFLAGS) $(call cc-option, -no-pie) -nostdlib -nostartfiles $(SYSCFLAGS_$(@F)) \
56
- -Wl,-T,$(filter-out FORCE,$^) -o $@.tmp && \
57
- $(CROSS_COMPILE)objcopy \
58
- $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \
68
+ cmd_vdsold = $(LD) $(ld_flags) -T $(filter-out FORCE,$^) -o $@.tmp && \
69
+ $(OBJCOPY) $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \
5970 rm $@.tmp
6071
72
+# Extracts symbol offsets from the VDSO, converting them into an assembly file
73
+# that contains the same symbols at the same offsets.
74
+quiet_cmd_so2s = SO2S $@
75
+ cmd_so2s = $(NM) -D $< | $(srctree)/$(src)/so2s.sh > $@
76
+
6177 # install commands for the unstripped file
6278 quiet_cmd_vdso_install = INSTALL $@
6379 cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@