Makefile 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. obj-vdso := gettimeofday.o note.o sigreturn.o
  8. # Build rules
  9. targets := $(obj-vdso) vdso.so vdso.so.dbg
  10. obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
  11. ccflags-y := -shared -fno-common -fno-builtin
  12. ccflags-y += -nostdlib -Wl,-soname=linux-vdso.so.1 \
  13. $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
  14. # Disable gcov profiling for VDSO code
  15. GCOV_PROFILE := n
  16. # Workaround for bare-metal (ELF) toolchains that neglect to pass -shared
  17. # down to collect2, resulting in silent corruption of the vDSO image.
  18. ccflags-y += -Wl,-shared
  19. obj-y += vdso.o
  20. extra-y += vdso.lds vdso-offsets.h
  21. CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
  22. # Force dependency (incbin is bad)
  23. $(obj)/vdso.o : $(obj)/vdso.so
  24. # Link rule for the .so file, .lds has to be first
  25. $(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso)
  26. $(call if_changed,vdsold)
  27. # Strip rule for the .so file
  28. $(obj)/%.so: OBJCOPYFLAGS := -S
  29. $(obj)/%.so: $(obj)/%.so.dbg FORCE
  30. $(call if_changed,objcopy)
  31. # Generate VDSO offsets using helper script
  32. gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh
  33. quiet_cmd_vdsosym = VDSOSYM $@
  34. define cmd_vdsosym
  35. $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@ && \
  36. cp $@ include/generated/
  37. endef
  38. $(obj)/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