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