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