Makefile 1.9 KB

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