Makefile 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. # SPDX-License-Identifier: GPL-2.0-only
  2. #
  3. # Building vDSO images for sparc.
  4. #
  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 = -m elf64_sparc -soname linux-vdso.so.1 --no-undefined \
  26. -z max-page-size=8192
  27. $(obj)/vdso64.so.dbg: $(obj)/vdso.lds $(vobjs) FORCE
  28. $(call if_changed,vdso)
  29. HOST_EXTRACFLAGS += -I$(srctree)/tools/include
  30. hostprogs += vdso2c
  31. quiet_cmd_vdso2c = VDSO2C $@
  32. cmd_vdso2c = $(obj)/vdso2c $< $(<:%.dbg=%) $@
  33. $(obj)/vdso-image-%.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(obj)/vdso2c FORCE
  34. $(call if_changed,vdso2c)
  35. #
  36. # Don't omit frame pointers for ease of userspace debugging, but do
  37. # optimize sibling calls.
  38. #
  39. CFL := $(PROFILING) -mcmodel=medlow -fPIC -O2 -fasynchronous-unwind-tables -m64 \
  40. $(filter -g%,$(KBUILD_CFLAGS)) -fno-stack-protector \
  41. -fno-omit-frame-pointer -foptimize-sibling-calls \
  42. -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO
  43. SPARC_REG_CFLAGS = -ffixed-g4 -ffixed-g5 -fcall-used-g5 -fcall-used-g7
  44. $(vobjs): KBUILD_CFLAGS := $(filter-out $(RANDSTRUCT_CFLAGS) $(GCC_PLUGINS_CFLAGS) $(SPARC_REG_CFLAGS),$(KBUILD_CFLAGS)) $(CFL)
  45. #
  46. # vDSO code runs in userspace and -pg doesn't help with profiling anyway.
  47. #
  48. CFLAGS_REMOVE_vclock_gettime.o = -pg
  49. CFLAGS_REMOVE_vdso32/vclock_gettime.o = -pg
  50. $(obj)/%.so: OBJCOPYFLAGS := -S
  51. $(obj)/%.so: $(obj)/%.so.dbg FORCE
  52. $(call if_changed,objcopy)
  53. CPPFLAGS_vdso32/vdso32.lds = $(CPPFLAGS_vdso.lds)
  54. VDSO_LDFLAGS_vdso32.lds = -m elf32_sparc -soname linux-gate.so.1
  55. #This makes sure the $(obj) subdirectory exists even though vdso32/
  56. #is not a kbuild sub-make subdirectory
  57. override obj-dirs = $(dir $(obj)) $(obj)/vdso32/
  58. targets += vdso32/vdso32.lds
  59. targets += vdso32/vdso-note.o
  60. targets += vdso32/vclock_gettime.o
  61. KBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS)) -DBUILD_VDSO
  62. $(obj)/vdso32.so.dbg: KBUILD_AFLAGS = $(KBUILD_AFLAGS_32)
  63. $(obj)/vdso32.so.dbg: asflags-$(CONFIG_SPARC64) += -m32
  64. KBUILD_CFLAGS_32 := $(filter-out -m64,$(KBUILD_CFLAGS))
  65. KBUILD_CFLAGS_32 := $(filter-out -mcmodel=medlow,$(KBUILD_CFLAGS_32))
  66. KBUILD_CFLAGS_32 := $(filter-out -fno-pic,$(KBUILD_CFLAGS_32))
  67. KBUILD_CFLAGS_32 := $(filter-out $(RANDSTRUCT_CFLAGS),$(KBUILD_CFLAGS_32))
  68. KBUILD_CFLAGS_32 := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS_32))
  69. KBUILD_CFLAGS_32 := $(filter-out $(SPARC_REG_CFLAGS),$(KBUILD_CFLAGS_32))
  70. KBUILD_CFLAGS_32 += -m32 -msoft-float -fpic
  71. KBUILD_CFLAGS_32 += -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 = $(LD) -nostdlib -o $@ \
  87. $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \
  88. -T $(filter %.lds,$^) $(filter %.o,$^) && \
  89. sh $(srctree)/$(src)/checkundef.sh '$(OBJDUMP)' '$@'
  90. VDSO_LDFLAGS = -shared --hash-style=both --build-id=sha1 -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