]>
Commit | Line | Data |
---|---|---|
ec8f24b7 | 1 | # SPDX-License-Identifier: GPL-2.0-only |
e2c0cdfb PD |
2 | # Copied from arch/tile/kernel/vdso/Makefile |
3 | ||
ad5d1122 VC |
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 | |
e2c0cdfb | 8 | # Symbols present in the vdso |
28dfbe6e | 9 | vdso-syms = rt_sigreturn |
d4c08b97 | 10 | ifdef CONFIG_64BIT |
ad5d1122 | 11 | vdso-syms += vgettimeofday |
d4c08b97 | 12 | endif |
28dfbe6e | 13 | vdso-syms += getcpu |
921ebd8f | 14 | vdso-syms += flush_icache |
e2c0cdfb PD |
15 | |
16 | # Files to link into the vdso | |
0a9f2a61 | 17 | obj-vdso = $(patsubst %, %.o, $(vdso-syms)) note.o |
e2c0cdfb | 18 | |
40284a07 TK |
19 | ccflags-y := -fno-stack-protector |
20 | ||
ad5d1122 | 21 | ifneq ($(c-gettimeofday-y),) |
a0fc3b32 | 22 | CFLAGS_vgettimeofday.o += -fPIC -include $(c-gettimeofday-y) |
ad5d1122 VC |
23 | endif |
24 | ||
e2c0cdfb PD |
25 | # Build rules |
26 | targets := $(obj-vdso) vdso.so vdso.so.dbg vdso.lds vdso-dummy.o | |
27 | obj-vdso := $(addprefix $(obj)/, $(obj-vdso)) | |
28 | ||
29 | obj-y += vdso.o vdso-syms.o | |
30 | CPPFLAGS_vdso.lds += -P -C -U$(ARCH) | |
31 | ||
e05d57dc GR |
32 | # Disable -pg to prevent insert call site |
33 | CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os | |
34 | ||
ca9d7dcd | 35 | # Disable profiling and instrumentation for VDSO code |
e2c0cdfb | 36 | GCOV_PROFILE := n |
20d38f7c | 37 | KCOV_INSTRUMENT := n |
ca9d7dcd | 38 | KASAN_SANITIZE := n |
e2c0cdfb PD |
39 | |
40 | # Force dependency | |
41 | $(obj)/vdso.o: $(obj)/vdso.so | |
42 | ||
43 | # link rule for the .so file, .lds has to be first | |
44 | SYSCFLAGS_vdso.so.dbg = $(c_flags) | |
45 | $(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso) FORCE | |
46 | $(call if_changed,vdsold) | |
c2c81bb2 | 47 | SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \ |
e553fdc8 | 48 | -Wl,--build-id=sha1 -Wl,--hash-style=both |
e2c0cdfb PD |
49 | |
50 | # We also create a special relocatable object that should mirror the symbol | |
3c1918c8 IH |
51 | # table and layout of the linked DSO. With ld --just-symbols we can then |
52 | # refer to these symbols in the kernel code rather than hand-coded addresses. | |
c2c81bb2 PD |
53 | $(obj)/vdso-syms.S: $(obj)/vdso.so FORCE |
54 | $(call if_changed,so2s) | |
e2c0cdfb PD |
55 | |
56 | # strip rule for the .so file | |
57 | $(obj)/%.so: OBJCOPYFLAGS := -S | |
58 | $(obj)/%.so: $(obj)/%.so.dbg FORCE | |
59 | $(call if_changed,objcopy) | |
60 | ||
61 | # actual build commands | |
62 | # The DSO images are built using a special linker script | |
63 | # Add -lgcc so rv32 gets static muldi3 and lshrdi3 definitions. | |
64 | # Make sure only to export the intended __vdso_xxx symbol offsets. | |
65 | quiet_cmd_vdsold = VDSOLD $@ | |
4938c79b PD |
66 | cmd_vdsold = $(CC) $(KBUILD_CFLAGS) $(call cc-option, -no-pie) -nostdlib -nostartfiles $(SYSCFLAGS_$(@F)) \ |
67 | -Wl,-T,$(filter-out FORCE,$^) -o $@.tmp && \ | |
e2c0cdfb | 68 | $(CROSS_COMPILE)objcopy \ |
95f4d9cc IH |
69 | $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \ |
70 | rm $@.tmp | |
e2c0cdfb | 71 | |
c2c81bb2 PD |
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 | ||
e2c0cdfb PD |
77 | # install commands for the unstripped file |
78 | quiet_cmd_vdso_install = INSTALL $@ | |
79 | cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@ | |
80 | ||
81 | vdso.so: $(obj)/vdso.so.dbg | |
82 | @mkdir -p $(MODLIB)/vdso | |
83 | $(call cmd,vdso_install) | |
84 | ||
85 | vdso_install: vdso.so |