Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf
[sfrench/cifs-2.6.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
21 # Disable gcov profiling for VDSO code
22 GCOV_PROFILE := n
23
24 # Force dependency
25 $(obj)/vdso.o: $(obj)/vdso.so
26
27 # link rule for the .so file, .lds has to be first
28 SYSCFLAGS_vdso.so.dbg = $(c_flags)
29 $(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso) FORCE
30         $(call if_changed,vdsold)
31
32 # We also create a special relocatable object that should mirror the symbol
33 # table and layout of the linked DSO.  With ld -R we can then refer to
34 # these symbols in the kernel code rather than hand-coded addresses.
35
36 SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \
37                             $(call cc-ldoption, -Wl$(comma)--hash-style=both)
38 $(obj)/vdso-dummy.o: $(src)/vdso.lds $(obj)/rt_sigreturn.o FORCE
39         $(call if_changed,vdsold)
40
41 LDFLAGS_vdso-syms.o := -r -R
42 $(obj)/vdso-syms.o: $(obj)/vdso-dummy.o FORCE
43         $(call if_changed,ld)
44
45 # strip rule for the .so file
46 $(obj)/%.so: OBJCOPYFLAGS := -S
47 $(obj)/%.so: $(obj)/%.so.dbg FORCE
48         $(call if_changed,objcopy)
49
50 # actual build commands
51 # The DSO images are built using a special linker script
52 # Add -lgcc so rv32 gets static muldi3 and lshrdi3 definitions.
53 # Make sure only to export the intended __vdso_xxx symbol offsets.
54 quiet_cmd_vdsold = VDSOLD  $@
55       cmd_vdsold = $(CC) $(KCFLAGS) -nostdlib $(SYSCFLAGS_$(@F)) \
56                            -Wl,-T,$(filter-out FORCE,$^) -o $@.tmp -lgcc && \
57                    $(CROSS_COMPILE)objcopy \
58                            $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@
59
60 # install commands for the unstripped file
61 quiet_cmd_vdso_install = INSTALL $@
62       cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
63
64 vdso.so: $(obj)/vdso.so.dbg
65         @mkdir -p $(MODLIB)/vdso
66         $(call cmd,vdso_install)
67
68 vdso_install: vdso.so