GNU Linux-libre 5.4.274-gnu1
[releases.git] / arch / riscv / kernel / vdso / Makefile
1 # SPDX-License-Identifier: GPL-2.0-only
2 # Copied from arch/tile/kernel/vdso/Makefile
3
4 # Symbols present in the vdso
5 vdso-syms  = rt_sigreturn
6 ifdef CONFIG_64BIT
7 vdso-syms += gettimeofday
8 vdso-syms += clock_gettime
9 vdso-syms += clock_getres
10 endif
11 vdso-syms += getcpu
12 vdso-syms += flush_icache
13
14 # Files to link into the vdso
15 obj-vdso = $(patsubst %, %.o, $(vdso-syms))
16
17 # Build rules
18 targets := $(obj-vdso) vdso.so vdso.so.dbg vdso.lds vdso-dummy.o
19 obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
20
21 obj-y += vdso.o vdso-syms.o
22 CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
23 ifneq ($(filter vgettimeofday, $(vdso-syms)),)
24 CPPFLAGS_vdso.lds += -DHAS_VGETTIMEOFDAY
25 endif
26
27 # Disable gcov profiling for VDSO code
28 GCOV_PROFILE := n
29
30 # Force dependency
31 $(obj)/vdso.o: $(obj)/vdso.so
32
33 # link rule for the .so file, .lds has to be first
34 SYSCFLAGS_vdso.so.dbg = $(c_flags)
35 $(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso) FORCE
36         $(call if_changed,vdsold)
37
38 # We also create a special relocatable object that should mirror the symbol
39 # table and layout of the linked DSO. With ld --just-symbols we can then
40 # refer to these symbols in the kernel code rather than hand-coded addresses.
41
42 SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \
43         -Wl,--build-id -Wl,--hash-style=both
44 $(obj)/vdso-dummy.o: $(src)/vdso.lds $(obj)/rt_sigreturn.o FORCE
45         $(call if_changed,vdsold)
46
47 LDFLAGS_vdso-syms.o := -r --just-symbols
48 $(obj)/vdso-syms.o: $(obj)/vdso-dummy.o FORCE
49         $(call if_changed,ld)
50
51 # strip rule for the .so file
52 $(obj)/%.so: OBJCOPYFLAGS := -S
53 $(obj)/%.so: $(obj)/%.so.dbg FORCE
54         $(call if_changed,objcopy)
55
56 # actual build commands
57 # The DSO images are built using a special linker script
58 # Add -lgcc so rv32 gets static muldi3 and lshrdi3 definitions.
59 # Make sure only to export the intended __vdso_xxx symbol offsets.
60 quiet_cmd_vdsold = VDSOLD  $@
61       cmd_vdsold = $(CC) $(KBUILD_CFLAGS) $(call cc-option, -no-pie) -nostdlib -nostartfiles $(SYSCFLAGS_$(@F)) \
62                            -Wl,-T,$(filter-out FORCE,$^) -o $@.tmp && \
63                    $(CROSS_COMPILE)objcopy \
64                            $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \
65                    rm $@.tmp
66
67 # install commands for the unstripped file
68 quiet_cmd_vdso_install = INSTALL $@
69       cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
70
71 vdso.so: $(obj)/vdso.so.dbg
72         @mkdir -p $(MODLIB)/vdso
73         $(call cmd,vdso_install)
74
75 vdso_install: vdso.so