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. 6ARCH_REL_TYPE_ABS := R_RISCV_32|R_RISCV_64|R_RISCV_JUMP_SLOT 7include $(srctree)/lib/vdso/Makefile 8# Symbols present in the vdso 9vdso-syms = rt_sigreturn 10ifdef CONFIG_64BIT 11vdso-syms += vgettimeofday 12endif 13vdso-syms += getcpu 14vdso-syms += flush_icache 15 16# Files to link into the vdso 17obj-vdso = $(patsubst %, %.o, $(vdso-syms)) note.o 18 19ccflags-y := -fno-stack-protector 20 21ifneq ($(c-gettimeofday-y),) 22 CFLAGS_vgettimeofday.o += -fPIC -include $(c-gettimeofday-y) 23endif 24 25# Build rules 26targets := $(obj-vdso) vdso.so vdso.so.dbg vdso.lds vdso-syms.S 27obj-vdso := $(addprefix $(obj)/, $(obj-vdso)) 28 29obj-y += vdso.o vdso-syms.o 30CPPFLAGS_vdso.lds += -P -C -U$(ARCH) 31 32# Disable -pg to prevent insert call site 33CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os 34 35# Disable profiling and instrumentation for VDSO code 36GCOV_PROFILE := n 37KCOV_INSTRUMENT := n 38KASAN_SANITIZE := n 39 40# Force dependency 41$(obj)/vdso.o: $(obj)/vdso.so 42 43# link rule for the .so file, .lds has to be first 44$(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE 45 $(call if_changed,vdsold) 46LDFLAGS_vdso.so.dbg = -shared -s -soname=linux-vdso.so.1 \ 47 --build-id=sha1 --hash-style=both --eh-frame-hdr 48 49# We also create a special relocatable object that should mirror the symbol 50# table and layout of the linked DSO. With ld --just-symbols we can then 51# refer to these symbols in the kernel code rather than hand-coded addresses. 52$(obj)/vdso-syms.S: $(obj)/vdso.so FORCE 53 $(call if_changed,so2s) 54 55# strip rule for the .so file 56$(obj)/%.so: OBJCOPYFLAGS := -S 57$(obj)/%.so: $(obj)/%.so.dbg FORCE 58 $(call if_changed,objcopy) 59 60# actual build commands 61# The DSO images are built using a special linker script 62# Make sure only to export the intended __vdso_xxx symbol offsets. 63quiet_cmd_vdsold = VDSOLD $@ 64 cmd_vdsold = $(LD) $(ld_flags) -T $(filter-out FORCE,$^) -o $@.tmp && \ 65 $(OBJCOPY) $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \ 66 rm $@.tmp 67 68# Extracts symbol offsets from the VDSO, converting them into an assembly file 69# that contains the same symbols at the same offsets. 70quiet_cmd_so2s = SO2S $@ 71 cmd_so2s = $(NM) -D $< | $(srctree)/$(src)/so2s.sh > $@ 72 73# install commands for the unstripped file 74quiet_cmd_vdso_install = INSTALL $@ 75 cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@ 76 77vdso.so: $(obj)/vdso.so.dbg 78 @mkdir -p $(MODLIB)/vdso 79 $(call cmd,vdso_install) 80 81vdso_install: vdso.so 82