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 | |
ad5d1122 | 19 | ifneq ($(c-gettimeofday-y),) |
a0fc3b32 | 20 | CFLAGS_vgettimeofday.o += -fPIC -include $(c-gettimeofday-y) |
ad5d1122 VC |
21 | endif |
22 | ||
e2c0cdfb PD |
23 | # Build rules |
24 | targets := $(obj-vdso) vdso.so vdso.so.dbg vdso.lds vdso-dummy.o | |
25 | obj-vdso := $(addprefix $(obj)/, $(obj-vdso)) | |
26 | ||
27 | obj-y += vdso.o vdso-syms.o | |
28 | CPPFLAGS_vdso.lds += -P -C -U$(ARCH) | |
29 | ||
30 | # Disable gcov profiling for VDSO code | |
31 | GCOV_PROFILE := n | |
32 | ||
33 | # Force dependency | |
34 | $(obj)/vdso.o: $(obj)/vdso.so | |
35 | ||
36 | # link rule for the .so file, .lds has to be first | |
37 | SYSCFLAGS_vdso.so.dbg = $(c_flags) | |
38 | $(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso) FORCE | |
39 | $(call if_changed,vdsold) | |
40 | ||
41 | # We also create a special relocatable object that should mirror the symbol | |
3c1918c8 IH |
42 | # table and layout of the linked DSO. With ld --just-symbols we can then |
43 | # refer to these symbols in the kernel code rather than hand-coded addresses. | |
e2c0cdfb PD |
44 | |
45 | SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \ | |
b399abe7 | 46 | -Wl,--build-id -Wl,--hash-style=both |
e2c0cdfb PD |
47 | $(obj)/vdso-dummy.o: $(src)/vdso.lds $(obj)/rt_sigreturn.o FORCE |
48 | $(call if_changed,vdsold) | |
49 | ||
3c1918c8 | 50 | LDFLAGS_vdso-syms.o := -r --just-symbols |
e2c0cdfb PD |
51 | $(obj)/vdso-syms.o: $(obj)/vdso-dummy.o FORCE |
52 | $(call if_changed,ld) | |
53 | ||
54 | # strip rule for the .so file | |
55 | $(obj)/%.so: OBJCOPYFLAGS := -S | |
56 | $(obj)/%.so: $(obj)/%.so.dbg FORCE | |
57 | $(call if_changed,objcopy) | |
58 | ||
59 | # actual build commands | |
60 | # The DSO images are built using a special linker script | |
61 | # Add -lgcc so rv32 gets static muldi3 and lshrdi3 definitions. | |
62 | # Make sure only to export the intended __vdso_xxx symbol offsets. | |
63 | quiet_cmd_vdsold = VDSOLD $@ | |
4938c79b PD |
64 | cmd_vdsold = $(CC) $(KBUILD_CFLAGS) $(call cc-option, -no-pie) -nostdlib -nostartfiles $(SYSCFLAGS_$(@F)) \ |
65 | -Wl,-T,$(filter-out FORCE,$^) -o $@.tmp && \ | |
e2c0cdfb | 66 | $(CROSS_COMPILE)objcopy \ |
95f4d9cc IH |
67 | $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \ |
68 | rm $@.tmp | |
e2c0cdfb PD |
69 | |
70 | # install commands for the unstripped file | |
71 | quiet_cmd_vdso_install = INSTALL $@ | |
72 | cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@ | |
73 | ||
74 | vdso.so: $(obj)/vdso.so.dbg | |
75 | @mkdir -p $(MODLIB)/vdso | |
76 | $(call cmd,vdso_install) | |
77 | ||
78 | vdso_install: vdso.so |