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