Makefile 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. #
  2. # Building vDSO images for x86.
  3. #
  4. VDSO64-$(CONFIG_X86_64) := y
  5. VDSO32-$(CONFIG_X86_32) := y
  6. VDSO32-$(CONFIG_COMPAT) := y
  7. vdso-install-$(VDSO64-y) += vdso.so
  8. vdso-install-$(VDSO32-y) += $(vdso32-images)
  9. # files to link into the vdso
  10. vobjs-y := vdso-note.o vclock_gettime.o vgetcpu.o
  11. # files to link into kernel
  12. obj-$(VDSO64-y) += vma.o vdso.o
  13. obj-$(VDSO32-y) += vdso32.o vdso32-setup.o
  14. vobjs := $(foreach F,$(vobjs-y),$(obj)/$F)
  15. $(obj)/vdso.o: $(obj)/vdso.so
  16. targets += vdso.so vdso.so.dbg vdso.lds $(vobjs-y)
  17. export CPPFLAGS_vdso.lds += -P -C
  18. VDSO_LDFLAGS_vdso.lds = -m64 -Wl,-soname=linux-vdso.so.1 \
  19. -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096
  20. $(obj)/vdso.o: $(src)/vdso.S $(obj)/vdso.so
  21. $(obj)/vdso.so.dbg: $(src)/vdso.lds $(vobjs) FORCE
  22. $(call if_changed,vdso)
  23. $(obj)/%.so: OBJCOPYFLAGS := -S
  24. $(obj)/%.so: $(obj)/%.so.dbg FORCE
  25. $(call if_changed,objcopy)
  26. #
  27. # Don't omit frame pointers for ease of userspace debugging, but do
  28. # optimize sibling calls.
  29. #
  30. CFL := $(PROFILING) -mcmodel=small -fPIC -O2 -fasynchronous-unwind-tables -m64 \
  31. $(filter -g%,$(KBUILD_CFLAGS)) $(call cc-option, -fno-stack-protector) \
  32. -fno-omit-frame-pointer -foptimize-sibling-calls
  33. $(vobjs): KBUILD_CFLAGS += $(CFL)
  34. #
  35. # vDSO code runs in userspace and -pg doesn't help with profiling anyway.
  36. #
  37. CFLAGS_REMOVE_vdso-note.o = -pg
  38. CFLAGS_REMOVE_vclock_gettime.o = -pg
  39. CFLAGS_REMOVE_vgetcpu.o = -pg
  40. CFLAGS_REMOVE_vvar.o = -pg
  41. targets += vdso-syms.lds
  42. obj-$(VDSO64-y) += vdso-syms.lds
  43. #
  44. # Match symbols in the DSO that look like VDSO*; produce a file of constants.
  45. #
  46. sed-vdsosym := -e 's/^00*/0/' \
  47. -e 's/^\([0-9a-fA-F]*\) . \(VDSO[a-zA-Z0-9_]*\)$$/\2 = 0x\1;/p'
  48. quiet_cmd_vdsosym = VDSOSYM $@
  49. define cmd_vdsosym
  50. $(NM) $< | LC_ALL=C sed -n $(sed-vdsosym) | LC_ALL=C sort > $@
  51. endef
  52. $(obj)/%-syms.lds: $(obj)/%.so.dbg FORCE
  53. $(call if_changed,vdsosym)
  54. #
  55. # Build multiple 32-bit vDSO images to choose from at boot time.
  56. #
  57. obj-$(VDSO32-y) += vdso32-syms.lds
  58. vdso32.so-$(VDSO32-y) += int80
  59. vdso32.so-$(CONFIG_COMPAT) += syscall
  60. vdso32.so-$(VDSO32-y) += sysenter
  61. vdso32-images = $(vdso32.so-y:%=vdso32-%.so)
  62. CPPFLAGS_vdso32.lds = $(CPPFLAGS_vdso.lds)
  63. VDSO_LDFLAGS_vdso32.lds = -m32 -Wl,-soname=linux-gate.so.1
  64. # This makes sure the $(obj) subdirectory exists even though vdso32/
  65. # is not a kbuild sub-make subdirectory.
  66. override obj-dirs = $(dir $(obj)) $(obj)/vdso32/
  67. targets += vdso32/vdso32.lds
  68. targets += $(vdso32-images) $(vdso32-images:=.dbg)
  69. targets += vdso32/note.o $(vdso32.so-y:%=vdso32/%.o)
  70. extra-y += $(vdso32-images)
  71. $(obj)/vdso32.o: $(vdso32-images:%=$(obj)/%)
  72. KBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS))
  73. $(vdso32-images:%=$(obj)/%.dbg): KBUILD_AFLAGS = $(KBUILD_AFLAGS_32)
  74. $(vdso32-images:%=$(obj)/%.dbg): asflags-$(CONFIG_X86_64) += -m32
  75. $(vdso32-images:%=$(obj)/%.dbg): $(obj)/vdso32-%.so.dbg: FORCE \
  76. $(obj)/vdso32/vdso32.lds \
  77. $(obj)/vdso32/note.o \
  78. $(obj)/vdso32/%.o
  79. $(call if_changed,vdso)
  80. # Make vdso32-*-syms.lds from each image, and then make sure they match.
  81. # The only difference should be that some do not define VDSO32_SYSENTER_RETURN.
  82. targets += vdso32-syms.lds $(vdso32.so-y:%=vdso32-%-syms.lds)
  83. quiet_cmd_vdso32sym = VDSOSYM $@
  84. define cmd_vdso32sym
  85. if LC_ALL=C sort -u $(filter-out FORCE,$^) > $(@D)/.tmp_$(@F) && \
  86. $(foreach H,$(filter-out FORCE,$^),\
  87. if grep -q VDSO32_SYSENTER_RETURN $H; \
  88. then diff -u $(@D)/.tmp_$(@F) $H; \
  89. else sed /VDSO32_SYSENTER_RETURN/d $(@D)/.tmp_$(@F) | \
  90. diff -u - $H; fi &&) : ;\
  91. then mv -f $(@D)/.tmp_$(@F) $@; \
  92. else rm -f $(@D)/.tmp_$(@F); exit 1; \
  93. fi
  94. endef
  95. $(obj)/vdso32-syms.lds: $(vdso32.so-y:%=$(obj)/vdso32-%-syms.lds) FORCE
  96. $(call if_changed,vdso32sym)
  97. #
  98. # The DSO images are built using a special linker script.
  99. #
  100. quiet_cmd_vdso = VDSO $@
  101. cmd_vdso = $(CC) -nostdlib -o $@ \
  102. $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \
  103. -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
  104. sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
  105. VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
  106. GCOV_PROFILE := n
  107. #
  108. # Install the unstripped copy of vdso*.so listed in $(vdso-install-y).
  109. #
  110. quiet_cmd_vdso_install = INSTALL $@
  111. cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
  112. $(vdso-install-y): %.so: $(obj)/%.so.dbg FORCE
  113. @mkdir -p $(MODLIB)/vdso
  114. $(call cmd,vdso_install)
  115. PHONY += vdso_install $(vdso-install-y)
  116. vdso_install: $(vdso-install-y)
  117. clean-files := vdso32-syscall* vdso32-sysenter* vdso32-int80*