Makefile 1.8 KB

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