Makefile 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. # Symbols present in the vdso
  2. vdso-syms = rt_sigreturn gettimeofday
  3. # Files to link into the vdso
  4. obj-vdso = $(patsubst %, v%.o, $(vdso-syms))
  5. # Build rules
  6. targets := $(obj-vdso) vdso.so vdso.so.dbg vdso.lds
  7. obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
  8. # vdso32 is only for tilegx -m32 compat task.
  9. VDSO32-$(CONFIG_COMPAT) := y
  10. obj-y += vdso.o
  11. obj-$(VDSO32-y) += vdso32.o
  12. extra-y += vdso.lds
  13. CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
  14. # vDSO code runs in userspace and -pg doesn't help with profiling anyway.
  15. CFLAGS_REMOVE_vdso.o = -pg
  16. CFLAGS_REMOVE_vdso32.o = -pg
  17. CFLAGS_REMOVE_vrt_sigreturn.o = -pg
  18. CFLAGS_REMOVE_vrt_sigreturn32.o = -pg
  19. CFLAGS_REMOVE_vgettimeofday.o = -pg
  20. CFLAGS_REMOVE_vgettimeofday32.o = -pg
  21. ifdef CONFIG_FEEDBACK_COLLECT
  22. # vDSO code runs in userspace, not collecting feedback data.
  23. CFLAGS_REMOVE_vdso.o = -ffeedback-generate
  24. CFLAGS_REMOVE_vdso32.o = -ffeedback-generate
  25. CFLAGS_REMOVE_vrt_sigreturn.o = -ffeedback-generate
  26. CFLAGS_REMOVE_vrt_sigreturn32.o = -ffeedback-generate
  27. CFLAGS_REMOVE_vgettimeofday.o = -ffeedback-generate
  28. CFLAGS_REMOVE_vgettimeofday32.o = -ffeedback-generate
  29. endif
  30. # Disable gcov profiling for VDSO code
  31. GCOV_PROFILE := n
  32. # Force dependency
  33. $(obj)/vdso.o: $(obj)/vdso.so
  34. # link rule for the .so file, .lds has to be first
  35. SYSCFLAGS_vdso.so.dbg = $(c_flags)
  36. $(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso)
  37. $(call if_changed,vdsold)
  38. # We also create a special relocatable object that should mirror the symbol
  39. # table and layout of the linked DSO. With ld -R we can then refer to
  40. # these symbols in the kernel code rather than hand-coded addresses.
  41. extra-y += vdso-syms.o
  42. $(obj)/built-in.o: $(obj)/vdso-syms.o
  43. $(obj)/built-in.o: ld_flags += -R $(obj)/vdso-syms.o
  44. SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \
  45. $(call cc-ldoption, -Wl$(comma)--hash-style=both)
  46. SYSCFLAGS_vdso_syms.o = -r
  47. $(obj)/vdso-syms.o: $(src)/vdso.lds $(obj)/vrt_sigreturn.o FORCE
  48. $(call if_changed,vdsold)
  49. # strip rule for the .so file
  50. $(obj)/%.so: OBJCOPYFLAGS := -S
  51. $(obj)/%.so: $(obj)/%.so.dbg FORCE
  52. $(call if_changed,objcopy)
  53. # actual build commands
  54. # The DSO images are built using a special linker script
  55. # Add -lgcc so tilepro gets static muldi3 and lshrdi3 definitions.
  56. # Make sure only to export the intended __vdso_xxx symbol offsets.
  57. quiet_cmd_vdsold = VDSOLD $@
  58. cmd_vdsold = $(CC) $(KCFLAGS) -nostdlib $(SYSCFLAGS_$(@F)) \
  59. -Wl,-T,$(filter-out FORCE,$^) -o $@.tmp -lgcc && \
  60. $(CROSS_COMPILE)objcopy \
  61. $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@
  62. # install commands for the unstripped file
  63. quiet_cmd_vdso_install = INSTALL $@
  64. cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
  65. vdso.so: $(obj)/vdso.so.dbg
  66. @mkdir -p $(MODLIB)/vdso
  67. $(call cmd,vdso_install)
  68. vdso32.so: $(obj)/vdso32.so.dbg
  69. $(call cmd,vdso_install)
  70. vdso_install: vdso.so
  71. vdso32_install: vdso32.so
  72. KBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS))
  73. KBUILD_AFLAGS_32 += -m32 -s
  74. KBUILD_CFLAGS_32 := $(filter-out -m64,$(KBUILD_CFLAGS))
  75. KBUILD_CFLAGS_32 += -m32 -fPIC -shared
  76. obj-vdso32 = $(patsubst %, v%32.o, $(vdso-syms))
  77. obj-vdso32 := $(addprefix $(obj)/, $(obj-vdso32))
  78. targets += $(obj-vdso32) vdso32.so vdso32.so.dbg
  79. $(obj-vdso32:%=%): KBUILD_AFLAGS = $(KBUILD_AFLAGS_32)
  80. $(obj-vdso32:%=%): KBUILD_CFLAGS = $(KBUILD_CFLAGS_32)
  81. $(obj)/vgettimeofday32.o: $(obj)/vgettimeofday.c
  82. $(call if_changed_rule,cc_o_c)
  83. $(obj)/vrt_sigreturn32.o: $(obj)/vrt_sigreturn.S
  84. $(call if_changed,as_o_S)
  85. # Force dependency
  86. $(obj)/vdso32.o: $(obj)/vdso32.so
  87. SYSCFLAGS_vdso32.so.dbg = -m32 -shared -s -Wl,-soname=linux-vdso32.so.1 \
  88. $(call cc-ldoption, -Wl$(comma)--hash-style=both)
  89. $(obj)/vdso32.so.dbg: $(src)/vdso.lds $(obj-vdso32)
  90. $(call if_changed,vdsold)