Merge tag 'docs-5.10-2' of git://git.lwn.net/linux
[linux-2.6-microblaze.git] / arch / riscv / kernel / vdso / Makefile
1 # SPDX-License-Identifier: GPL-2.0-only
2 # Copied from arch/tile/kernel/vdso/Makefile
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
8 # Symbols present in the vdso
9 vdso-syms  = rt_sigreturn
10 ifdef CONFIG_64BIT
11 vdso-syms += vgettimeofday
12 endif
13 vdso-syms += getcpu
14 vdso-syms += flush_icache
15
16 # Files to link into the vdso
17 obj-vdso = $(patsubst %, %.o, $(vdso-syms)) note.o
18
19 ccflags-y := -fno-stack-protector
20
21 ifneq ($(c-gettimeofday-y),)
22   CFLAGS_vgettimeofday.o += -fPIC -include $(c-gettimeofday-y)
23 endif
24
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
32 # Disable -pg to prevent insert call site
33 CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os
34
35 # Disable gcov profiling for VDSO code
36 GCOV_PROFILE := n
37 KCOV_INSTRUMENT := n
38
39 # Force dependency
40 $(obj)/vdso.o: $(obj)/vdso.so
41
42 # link rule for the .so file, .lds has to be first
43 SYSCFLAGS_vdso.so.dbg = $(c_flags)
44 $(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso) FORCE
45         $(call if_changed,vdsold)
46
47 # We also create a special relocatable object that should mirror the symbol
48 # table and layout of the linked DSO. With ld --just-symbols we can then
49 # refer to these symbols in the kernel code rather than hand-coded addresses.
50
51 SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \
52         -Wl,--build-id=sha1 -Wl,--hash-style=both
53 $(obj)/vdso-dummy.o: $(src)/vdso.lds $(obj)/rt_sigreturn.o FORCE
54         $(call if_changed,vdsold)
55
56 LDFLAGS_vdso-syms.o := -r --just-symbols
57 $(obj)/vdso-syms.o: $(obj)/vdso-dummy.o FORCE
58         $(call if_changed,ld)
59
60 # strip rule for the .so file
61 $(obj)/%.so: OBJCOPYFLAGS := -S
62 $(obj)/%.so: $(obj)/%.so.dbg FORCE
63         $(call if_changed,objcopy)
64
65 # actual build commands
66 # The DSO images are built using a special linker script
67 # Add -lgcc so rv32 gets static muldi3 and lshrdi3 definitions.
68 # Make sure only to export the intended __vdso_xxx symbol offsets.
69 quiet_cmd_vdsold = VDSOLD  $@
70       cmd_vdsold = $(CC) $(KBUILD_CFLAGS) $(call cc-option, -no-pie) -nostdlib -nostartfiles $(SYSCFLAGS_$(@F)) \
71                            -Wl,-T,$(filter-out FORCE,$^) -o $@.tmp && \
72                    $(CROSS_COMPILE)objcopy \
73                            $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \
74                    rm $@.tmp
75
76 # install commands for the unstripped file
77 quiet_cmd_vdso_install = INSTALL $@
78       cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
79
80 vdso.so: $(obj)/vdso.so.dbg
81         @mkdir -p $(MODLIB)/vdso
82         $(call cmd,vdso_install)
83
84 vdso_install: vdso.so