1# SPDX-License-Identifier: GPL-2.0-only 2# 3# Makefile for compat_vdso 4# 5 6# Symbols present in the compat_vdso 7compat_vdso-syms = rt_sigreturn 8compat_vdso-syms += getcpu 9compat_vdso-syms += flush_icache 10 11COMPAT_CC := $(CC) 12COMPAT_LD := $(LD) 13 14COMPAT_CC_FLAGS := -march=rv32g -mabi=ilp32 15COMPAT_LD_FLAGS := -melf32lriscv 16 17# Disable attributes, as they're useless and break the build. 18COMPAT_CC_FLAGS += $(call cc-option,-mno-riscv-attribute) 19COMPAT_CC_FLAGS += $(call as-option,-Wa$(comma)-mno-arch-attr) 20 21# Files to link into the compat_vdso 22obj-compat_vdso = $(patsubst %, %.o, $(compat_vdso-syms)) note.o 23 24# Build rules 25targets := $(obj-compat_vdso) compat_vdso.so compat_vdso.so.dbg compat_vdso.lds 26obj-compat_vdso := $(addprefix $(obj)/, $(obj-compat_vdso)) 27 28obj-y += compat_vdso.o 29CPPFLAGS_compat_vdso.lds += -P -C -U$(ARCH) 30 31# Disable profiling and instrumentation for VDSO code 32GCOV_PROFILE := n 33KCOV_INSTRUMENT := n 34KASAN_SANITIZE := n 35UBSAN_SANITIZE := n 36 37# Force dependency 38$(obj)/compat_vdso.o: $(obj)/compat_vdso.so 39 40# link rule for the .so file, .lds has to be first 41$(obj)/compat_vdso.so.dbg: $(obj)/compat_vdso.lds $(obj-compat_vdso) FORCE 42 $(call if_changed,compat_vdsold) 43LDFLAGS_compat_vdso.so.dbg = -shared -S -soname=linux-compat_vdso.so.1 \ 44 --build-id=sha1 --hash-style=both --eh-frame-hdr 45 46$(obj-compat_vdso): %.o: %.S FORCE 47 $(call if_changed_dep,compat_vdsoas) 48 49# strip rule for the .so file 50$(obj)/%.so: OBJCOPYFLAGS := -S 51$(obj)/%.so: $(obj)/%.so.dbg FORCE 52 $(call if_changed,objcopy) 53 54# Generate VDSO offsets using helper script 55gen-compat_vdsosym := $(srctree)/$(src)/gen_compat_vdso_offsets.sh 56quiet_cmd_compat_vdsosym = VDSOSYM $@ 57 cmd_compat_vdsosym = $(NM) $< | $(gen-compat_vdsosym) | LC_ALL=C sort > $@ 58 59include/generated/compat_vdso-offsets.h: $(obj)/compat_vdso.so.dbg FORCE 60 $(call if_changed,compat_vdsosym) 61 62# actual build commands 63# The DSO images are built using a special linker script 64# Make sure only to export the intended __compat_vdso_xxx symbol offsets. 65quiet_cmd_compat_vdsold = VDSOLD $@ 66 cmd_compat_vdsold = $(COMPAT_LD) $(ld_flags) $(COMPAT_LD_FLAGS) -T $(filter-out FORCE,$^) -o $@.tmp && \ 67 $(OBJCOPY) $(patsubst %, -G __compat_vdso_%, $(compat_vdso-syms)) $@.tmp $@ && \ 68 rm $@.tmp 69 70# actual build commands 71quiet_cmd_compat_vdsoas = VDSOAS $@ 72 cmd_compat_vdsoas = $(COMPAT_CC) $(a_flags) $(COMPAT_CC_FLAGS) -c -o $@ $< 73 74# install commands for the unstripped file 75quiet_cmd_compat_vdso_install = INSTALL $@ 76 cmd_compat_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/compat_vdso/$@ 77 78compat_vdso.so: $(obj)/compat_vdso.so.dbg 79 @mkdir -p $(MODLIB)/compat_vdso 80 $(call cmd,compat_vdso_install) 81 82compat_vdso_install: compat_vdso.so 83