Makefile 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. #
  2. # Building vDSO images for sparc.
  3. #
  4. KBUILD_CFLAGS += $(DISABLE_LTO)
  5. VDSO64-$(CONFIG_SPARC64) := y
  6. VDSOCOMPAT-$(CONFIG_COMPAT) := y
  7. # files to link into the vdso
  8. vobjs-y := vdso-note.o vclock_gettime.o
  9. # files to link into kernel
  10. obj-y += vma.o
  11. # vDSO images to build
  12. vdso_img-$(VDSO64-y) += 64
  13. vdso_img-$(VDSOCOMPAT-y) += 32
  14. vobjs := $(foreach F,$(vobjs-y),$(obj)/$F)
  15. $(obj)/vdso.o: $(obj)/vdso.so
  16. targets += vdso.lds $(vobjs-y)
  17. # Build the vDSO image C files and link them in.
  18. vdso_img_objs := $(vdso_img-y:%=vdso-image-%.o)
  19. vdso_img_cfiles := $(vdso_img-y:%=vdso-image-%.c)
  20. vdso_img_sodbg := $(vdso_img-y:%=vdso%.so.dbg)
  21. obj-y += $(vdso_img_objs)
  22. targets += $(vdso_img_cfiles)
  23. targets += $(vdso_img_sodbg) $(vdso_img-y:%=vdso%.so)
  24. CPPFLAGS_vdso.lds += -P -C
  25. VDSO_LDFLAGS_vdso.lds = -m64 -Wl,-soname=linux-vdso.so.1 \
  26. -Wl,--no-undefined \
  27. -Wl,-z,max-page-size=8192 -Wl,-z,common-page-size=8192 \
  28. $(DISABLE_LTO)
  29. $(obj)/vdso64.so.dbg: $(obj)/vdso.lds $(vobjs) FORCE
  30. $(call if_changed,vdso)
  31. HOST_EXTRACFLAGS += -I$(srctree)/tools/include
  32. hostprogs-y += vdso2c
  33. quiet_cmd_vdso2c = VDSO2C $@
  34. cmd_vdso2c = $(obj)/vdso2c $< $(<:%.dbg=%) $@
  35. $(obj)/vdso-image-%.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(obj)/vdso2c FORCE
  36. $(call if_changed,vdso2c)
  37. #
  38. # Don't omit frame pointers for ease of userspace debugging, but do
  39. # optimize sibling calls.
  40. #
  41. CFL := $(PROFILING) -mcmodel=medlow -fPIC -O2 -fasynchronous-unwind-tables \
  42. -m64 -ffixed-g2 -ffixed-g3 -fcall-used-g4 -fcall-used-g5 -ffixed-g6 \
  43. -ffixed-g7 $(filter -g%,$(KBUILD_CFLAGS)) \
  44. $(call cc-option, -fno-stack-protector) -fno-omit-frame-pointer \
  45. -foptimize-sibling-calls -DBUILD_VDSO
  46. $(vobjs): KBUILD_CFLAGS += $(CFL)
  47. #
  48. # vDSO code runs in userspace and -pg doesn't help with profiling anyway.
  49. #
  50. CFLAGS_REMOVE_vdso-note.o = -pg
  51. CFLAGS_REMOVE_vclock_gettime.o = -pg
  52. $(obj)/%.so: OBJCOPYFLAGS := -S
  53. $(obj)/%.so: $(obj)/%.so.dbg
  54. $(call if_changed,objcopy)
  55. CPPFLAGS_vdso32.lds = $(CPPFLAGS_vdso.lds)
  56. VDSO_LDFLAGS_vdso32.lds = -m32 -Wl,-m,elf32_sparc,-soname=linux-gate.so.1
  57. #This makes sure the $(obj) subdirectory exists even though vdso32/
  58. #is not a kbuild sub-make subdirectory
  59. override obj-dirs = $(dir $(obj)) $(obj)/vdso32/
  60. targets += vdso32/vdso32.lds
  61. targets += vdso32/vdso-note.o
  62. targets += vdso32/vclock_gettime.o
  63. KBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS)) -DBUILD_VDSO
  64. $(obj)/vdso32.so.dbg: KBUILD_AFLAGS = $(KBUILD_AFLAGS_32)
  65. $(obj)/vdso32.so.dbg: asflags-$(CONFIG_SPARC64) += -m32
  66. KBUILD_CFLAGS_32 := $(filter-out -m64,$(KBUILD_CFLAGS))
  67. KBUILD_CFLAGS_32 := $(filter-out -mcmodel=medlow,$(KBUILD_CFLAGS_32))
  68. KBUILD_CFLAGS_32 := $(filter-out -fno-pic,$(KBUILD_CFLAGS_32))
  69. KBUILD_CFLAGS_32 := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS_32))
  70. KBUILD_CFLAGS_32 += -m32 -msoft-float -fpic -mno-app-regs -ffixed-g7
  71. KBUILD_CFLAGS_32 += $(call cc-option, -fno-stack-protector)
  72. KBUILD_CFLAGS_32 += $(call cc-option, -foptimize-sibling-calls)
  73. KBUILD_CFLAGS_32 += -fno-omit-frame-pointer
  74. KBUILD_CFLAGS_32 += -DDISABLE_BRANCH_PROFILING
  75. KBUILD_CFLAGS_32 += -mv8plus
  76. $(obj)/vdso32.so.dbg: KBUILD_CFLAGS = $(KBUILD_CFLAGS_32)
  77. $(obj)/vdso32.so.dbg: FORCE \
  78. $(obj)/vdso32/vdso32.lds \
  79. $(obj)/vdso32/vclock_gettime.o \
  80. $(obj)/vdso32/vdso-note.o
  81. $(call if_changed,vdso)
  82. #
  83. # The DSO images are built using a special linker script.
  84. #
  85. quiet_cmd_vdso = VDSO $@
  86. cmd_vdso = $(CC) -nostdlib -o $@ \
  87. $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \
  88. -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^)
  89. VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) \
  90. $(call cc-ldoption, -Wl$(comma)--build-id) -Wl,-Bsymbolic
  91. GCOV_PROFILE := n
  92. #
  93. # Install the unstripped copies of vdso*.so. If our toolchain supports
  94. # build-id, install .build-id links as well.
  95. #
  96. quiet_cmd_vdso_install = INSTALL $(@:install_%=%)
  97. define cmd_vdso_install
  98. cp $< "$(MODLIB)/vdso/$(@:install_%=%)"; \
  99. if readelf -n $< |grep -q 'Build ID'; then \
  100. buildid=`readelf -n $< |grep 'Build ID' |sed -e 's/^.*Build ID: \(.*\)$$/\1/'`; \
  101. first=`echo $$buildid | cut -b-2`; \
  102. last=`echo $$buildid | cut -b3-`; \
  103. mkdir -p "$(MODLIB)/vdso/.build-id/$$first"; \
  104. ln -sf "../../$(@:install_%=%)" "$(MODLIB)/vdso/.build-id/$$first/$$last.debug"; \
  105. fi
  106. endef
  107. vdso_img_insttargets := $(vdso_img_sodbg:%.dbg=install_%)
  108. $(MODLIB)/vdso: FORCE
  109. @mkdir -p $(MODLIB)/vdso
  110. $(vdso_img_insttargets): install_%: $(obj)/%.dbg $(MODLIB)/vdso FORCE
  111. $(call cmd,vdso_install)
  112. PHONY += vdso_install $(vdso_img_insttargets)
  113. vdso_install: $(vdso_img_insttargets) FORCE