1# SPDX-License-Identifier: GPL-2.0 2# 3# Building a vDSO image for AArch64. 4# 5# Author: Will Deacon <will.deacon@arm.com> 6# Heavily based on the vDSO Makefiles for other archs. 7# 8 9obj-vdso := gettimeofday.o note.o sigreturn.o 10 11# Build rules 12targets := $(obj-vdso) vdso.so vdso.so.dbg 13obj-vdso := $(addprefix $(obj)/, $(obj-vdso)) 14 15ccflags-y := -shared -fno-common -fno-builtin 16ccflags-y += -nostdlib -Wl,-soname=linux-vdso.so.1 \ 17 $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) 18ccflags-y += $(DISABLE_LTO) 19 20# Disable gcov profiling for VDSO code 21GCOV_PROFILE := n 22 23# Workaround for bare-metal (ELF) toolchains that neglect to pass -shared 24# down to collect2, resulting in silent corruption of the vDSO image. 25ccflags-y += -Wl,-shared 26 27obj-y += vdso.o 28extra-y += vdso.lds 29CPPFLAGS_vdso.lds += -P -C -U$(ARCH) 30 31# Force dependency (incbin is bad) 32$(obj)/vdso.o : $(obj)/vdso.so 33 34# Link rule for the .so file, .lds has to be first 35$(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso) 36 $(call if_changed,vdsold) 37 38# Strip rule for the .so file 39$(obj)/%.so: OBJCOPYFLAGS := -S 40$(obj)/%.so: $(obj)/%.so.dbg FORCE 41 $(call if_changed,objcopy) 42 43# Generate VDSO offsets using helper script 44gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh 45quiet_cmd_vdsosym = VDSOSYM $@ 46define cmd_vdsosym 47 $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@ 48endef 49 50include/generated/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE 51 $(call if_changed,vdsosym) 52 53# Assembly rules for the .S files 54$(obj-vdso): %.o: %.S FORCE 55 $(call if_changed_dep,vdsoas) 56 57# Actual build commands 58quiet_cmd_vdsold = VDSOL $@ 59 cmd_vdsold = $(CC) $(c_flags) -Wl,-n -Wl,-T $^ -o $@ 60quiet_cmd_vdsoas = VDSOA $@ 61 cmd_vdsoas = $(CC) $(a_flags) -c -o $@ $< 62 63# Install commands for the unstripped file 64quiet_cmd_vdso_install = INSTALL $@ 65 cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@ 66 67vdso.so: $(obj)/vdso.so.dbg 68 @mkdir -p $(MODLIB)/vdso 69 $(call cmd,vdso_install) 70 71vdso_install: vdso.so 72