1 # SPDX-License-Identifier: GPL-2.0-only
2 # Copied from arch/tile/kernel/vdso/Makefile
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
11 vdso-syms += vgettimeofday
14 vdso-syms += flush_icache
16 # Files to link into the vdso
17 obj-vdso = $(patsubst %, %.o, $(vdso-syms)) note.o
19 ccflags-y := -fno-stack-protector
21 ifneq ($(c-gettimeofday-y),)
22 CFLAGS_vgettimeofday.o += -fPIC -include $(c-gettimeofday-y)
26 targets := $(obj-vdso) vdso.so vdso.so.dbg vdso.lds
27 obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
30 CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
32 # Disable -pg to prevent insert call site
33 CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os
35 # Disable profiling and instrumentation for VDSO code
42 $(obj)/vdso.o: $(obj)/vdso.so
44 # link rule for the .so file, .lds has to be first
45 $(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE
46 $(call if_changed,vdsold)
47 LDFLAGS_vdso.so.dbg = -shared -S -soname=linux-vdso.so.1 \
48 --build-id=sha1 --hash-style=both --eh-frame-hdr
50 # strip rule for the .so file
51 $(obj)/%.so: OBJCOPYFLAGS := -S
52 $(obj)/%.so: $(obj)/%.so.dbg FORCE
53 $(call if_changed,objcopy)
55 # Generate VDSO offsets using helper script
56 gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh
57 quiet_cmd_vdsosym = VDSOSYM $@
58 cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@
60 include/generated/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE
61 $(call if_changed,vdsosym)
63 # actual build commands
64 # The DSO images are built using a special linker script
65 # Make sure only to export the intended __vdso_xxx symbol offsets.
66 quiet_cmd_vdsold = VDSOLD $@
67 cmd_vdsold = $(LD) $(ld_flags) -T $(filter-out FORCE,$^) -o $@.tmp && \
68 $(OBJCOPY) $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \
71 # install commands for the unstripped file
72 quiet_cmd_vdso_install = INSTALL $@
73 cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
75 vdso.so: $(obj)/vdso.so.dbg
76 @mkdir -p $(MODLIB)/vdso
77 $(call cmd,vdso_install)