.. | .. |
---|
| 1 | +# SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | # Copied from arch/tile/kernel/vdso/Makefile |
---|
2 | 3 | |
---|
| 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 |
---|
3 | 8 | # Symbols present in the vdso |
---|
4 | 9 | 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 |
---|
8 | 13 | vdso-syms += getcpu |
---|
9 | 14 | vdso-syms += flush_icache |
---|
10 | 15 | |
---|
11 | 16 | # 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 |
---|
13 | 25 | |
---|
14 | 26 | # 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 |
---|
16 | 28 | obj-vdso := $(addprefix $(obj)/, $(obj-vdso)) |
---|
17 | 29 | |
---|
18 | 30 | obj-y += vdso.o vdso-syms.o |
---|
19 | 31 | CPPFLAGS_vdso.lds += -P -C -U$(ARCH) |
---|
| 32 | +ifneq ($(filter vgettimeofday, $(vdso-syms)),) |
---|
| 33 | +CPPFLAGS_vdso.lds += -DHAS_VGETTIMEOFDAY |
---|
| 34 | +endif |
---|
20 | 35 | |
---|
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 |
---|
22 | 40 | GCOV_PROFILE := n |
---|
| 41 | +KCOV_INSTRUMENT := n |
---|
| 42 | +KASAN_SANITIZE := n |
---|
23 | 43 | |
---|
24 | 44 | # Force dependency |
---|
25 | 45 | $(obj)/vdso.o: $(obj)/vdso.so |
---|
26 | 46 | |
---|
27 | 47 | # 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 |
---|
30 | 49 | $(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 |
---|
31 | 52 | |
---|
32 | 53 | # We also create a special relocatable object that should mirror the symbol |
---|
33 | 54 | # table and layout of the linked DSO. With ld --just-symbols we can then |
---|
34 | 55 | # 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) |
---|
44 | 58 | |
---|
45 | 59 | # strip rule for the .so file |
---|
46 | 60 | $(obj)/%.so: OBJCOPYFLAGS := -S |
---|
.. | .. |
---|
49 | 63 | |
---|
50 | 64 | # actual build commands |
---|
51 | 65 | # The DSO images are built using a special linker script |
---|
52 | | -# Add -lgcc so rv32 gets static muldi3 and lshrdi3 definitions. |
---|
53 | 66 | # Make sure only to export the intended __vdso_xxx symbol offsets. |
---|
54 | 67 | 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 $@ && \ |
---|
59 | 70 | rm $@.tmp |
---|
60 | 71 | |
---|
| 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 | + |
---|
61 | 77 | # install commands for the unstripped file |
---|
62 | 78 | quiet_cmd_vdso_install = INSTALL $@ |
---|
63 | 79 | cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@ |
---|