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