Makefile 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. # SPDX-License-Identifier: GPL-2.0
  2. # Objects to go into the VDSO.
  3. # Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
  4. # the inclusion of generic Makefile.
  5. ARCH_REL_TYPE_ABS := R_MIPS_JUMP_SLOT|R_MIPS_GLOB_DAT
  6. include $(srctree)/lib/vdso/Makefile
  7. obj-vdso-y := elf.o vgettimeofday.o sigreturn.o
  8. # Common compiler flags between ABIs.
  9. ccflags-vdso := \
  10. $(filter -I%,$(KBUILD_CFLAGS)) \
  11. $(filter -E%,$(KBUILD_CFLAGS)) \
  12. $(filter -mmicromips,$(KBUILD_CFLAGS)) \
  13. $(filter -march=%,$(KBUILD_CFLAGS)) \
  14. $(filter -m%-float,$(KBUILD_CFLAGS)) \
  15. $(filter -mno-loongson-%,$(KBUILD_CFLAGS)) \
  16. $(CLANG_FLAGS) \
  17. -D__VDSO__
  18. ifndef CONFIG_64BIT
  19. ccflags-vdso += -DBUILD_VDSO32
  20. endif
  21. #
  22. # The -fno-jump-tables flag only prevents the compiler from generating
  23. # jump tables but does not prevent the compiler from emitting absolute
  24. # offsets.
  25. cflags-vdso := $(ccflags-vdso) \
  26. $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \
  27. -O3 -g -fPIC -fno-strict-aliasing -fno-common -fno-builtin -G 0 \
  28. -mrelax-pic-calls $(call cc-option, -mexplicit-relocs) \
  29. -fno-stack-protector -fno-jump-tables -DDISABLE_BRANCH_PROFILING \
  30. $(call cc-option, -fno-asynchronous-unwind-tables)
  31. aflags-vdso := $(ccflags-vdso) \
  32. -D__ASSEMBLY__ -Wa,-gdwarf-2
  33. ifneq ($(c-gettimeofday-y),)
  34. CFLAGS_vgettimeofday.o = -include $(c-gettimeofday-y)
  35. # config-n32-o32-env.c prepares the environment to build a 32bit vDSO
  36. # library on a 64bit kernel.
  37. # Note: Needs to be included before than the generic library.
  38. CFLAGS_vgettimeofday-o32.o = -include $(srctree)/$(src)/config-n32-o32-env.c -include $(c-gettimeofday-y)
  39. CFLAGS_vgettimeofday-n32.o = -include $(srctree)/$(src)/config-n32-o32-env.c -include $(c-gettimeofday-y)
  40. endif
  41. CFLAGS_REMOVE_vgettimeofday.o = -pg
  42. ifdef CONFIG_MIPS_DISABLE_VDSO
  43. ifndef CONFIG_MIPS_LD_CAN_LINK_VDSO
  44. $(warning MIPS VDSO requires binutils >= 2.25)
  45. endif
  46. obj-vdso-y := $(filter-out vgettimeofday.o, $(obj-vdso-y))
  47. endif
  48. # VDSO linker flags.
  49. ldflags-y := -Bsymbolic --no-undefined -soname=linux-vdso.so.1 \
  50. $(filter -E%,$(KBUILD_CFLAGS)) -nostdlib -shared \
  51. -G 0 --eh-frame-hdr --hash-style=sysv --build-id=sha1 -T
  52. CFLAGS_REMOVE_vdso.o = -pg
  53. GCOV_PROFILE := n
  54. UBSAN_SANITIZE := n
  55. KCOV_INSTRUMENT := n
  56. # Check that we don't have PIC 'jalr t9' calls left
  57. quiet_cmd_vdso_mips_check = VDSOCHK $@
  58. cmd_vdso_mips_check = if $(OBJDUMP) --disassemble $@ | egrep -h "jalr.*t9" > /dev/null; \
  59. then (echo >&2 "$@: PIC 'jalr t9' calls are not supported"; \
  60. rm -f $@; /bin/false); fi
  61. #
  62. # Shared build commands.
  63. #
  64. quiet_cmd_vdsold_and_vdso_check = LD $@
  65. cmd_vdsold_and_vdso_check = $(cmd_ld); $(cmd_vdso_check); $(cmd_vdso_mips_check)
  66. quiet_cmd_vdsoas_o_S = AS $@
  67. cmd_vdsoas_o_S = $(CC) $(a_flags) -c -o $@ $<
  68. # Strip rule for the raw .so files
  69. $(obj)/%.so.raw: OBJCOPYFLAGS := -S
  70. $(obj)/%.so.raw: $(obj)/%.so.dbg.raw FORCE
  71. $(call if_changed,objcopy)
  72. hostprogs := genvdso
  73. quiet_cmd_genvdso = GENVDSO $@
  74. define cmd_genvdso
  75. $(foreach file,$(filter %.raw,$^),cp $(file) $(file:%.raw=%) &&) \
  76. $(obj)/genvdso $(<:%.raw=%) $(<:%.dbg.raw=%) $@ $(VDSO_NAME)
  77. endef
  78. #
  79. # Build native VDSO.
  80. #
  81. native-abi := $(filter -mabi=%,$(KBUILD_CFLAGS))
  82. targets += $(obj-vdso-y)
  83. targets += vdso.lds
  84. targets += vdso.so.dbg.raw vdso.so.raw
  85. targets += vdso.so.dbg vdso.so
  86. targets += vdso-image.c
  87. obj-vdso := $(obj-vdso-y:%.o=$(obj)/%.o)
  88. $(obj-vdso): KBUILD_CFLAGS := $(cflags-vdso) $(native-abi)
  89. $(obj-vdso): KBUILD_AFLAGS := $(aflags-vdso) $(native-abi)
  90. $(obj)/vdso.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) $(native-abi)
  91. $(obj)/vdso.so.dbg.raw: $(obj)/vdso.lds $(obj-vdso) FORCE
  92. $(call if_changed,vdsold_and_vdso_check)
  93. $(obj)/vdso-image.c: $(obj)/vdso.so.dbg.raw $(obj)/vdso.so.raw \
  94. $(obj)/genvdso FORCE
  95. $(call if_changed,genvdso)
  96. obj-y += vdso-image.o
  97. #
  98. # Build O32 VDSO.
  99. #
  100. # Define these outside the ifdef to ensure they are picked up by clean.
  101. targets += $(obj-vdso-y:%.o=%-o32.o)
  102. targets += vdso-o32.lds
  103. targets += vdso-o32.so.dbg.raw vdso-o32.so.raw
  104. targets += vdso-o32.so.dbg vdso-o32.so
  105. targets += vdso-o32-image.c
  106. ifdef CONFIG_MIPS32_O32
  107. obj-vdso-o32 := $(obj-vdso-y:%.o=$(obj)/%-o32.o)
  108. $(obj-vdso-o32): KBUILD_CFLAGS := $(cflags-vdso) -mabi=32
  109. $(obj-vdso-o32): KBUILD_AFLAGS := $(aflags-vdso) -mabi=32
  110. $(obj)/%-o32.o: $(src)/%.S FORCE
  111. $(call if_changed_dep,vdsoas_o_S)
  112. $(obj)/%-o32.o: $(src)/%.c FORCE
  113. $(call cmd,force_checksrc)
  114. $(call if_changed_rule,cc_o_c)
  115. $(obj)/vdso-o32.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) -mabi=32
  116. $(obj)/vdso-o32.lds: $(src)/vdso.lds.S FORCE
  117. $(call if_changed_dep,cpp_lds_S)
  118. $(obj)/vdso-o32.so.dbg.raw: $(obj)/vdso-o32.lds $(obj-vdso-o32) FORCE
  119. $(call if_changed,vdsold_and_vdso_check)
  120. $(obj)/vdso-o32-image.c: VDSO_NAME := o32
  121. $(obj)/vdso-o32-image.c: $(obj)/vdso-o32.so.dbg.raw $(obj)/vdso-o32.so.raw \
  122. $(obj)/genvdso FORCE
  123. $(call if_changed,genvdso)
  124. obj-y += vdso-o32-image.o
  125. endif
  126. #
  127. # Build N32 VDSO.
  128. #
  129. targets += $(obj-vdso-y:%.o=%-n32.o)
  130. targets += vdso-n32.lds
  131. targets += vdso-n32.so.dbg.raw vdso-n32.so.raw
  132. targets += vdso-n32.so.dbg vdso-n32.so
  133. targets += vdso-n32-image.c
  134. ifdef CONFIG_MIPS32_N32
  135. obj-vdso-n32 := $(obj-vdso-y:%.o=$(obj)/%-n32.o)
  136. $(obj-vdso-n32): KBUILD_CFLAGS := $(cflags-vdso) -mabi=n32
  137. $(obj-vdso-n32): KBUILD_AFLAGS := $(aflags-vdso) -mabi=n32
  138. $(obj)/%-n32.o: $(src)/%.S FORCE
  139. $(call if_changed_dep,vdsoas_o_S)
  140. $(obj)/%-n32.o: $(src)/%.c FORCE
  141. $(call cmd,force_checksrc)
  142. $(call if_changed_rule,cc_o_c)
  143. $(obj)/vdso-n32.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) -mabi=n32
  144. $(obj)/vdso-n32.lds: $(src)/vdso.lds.S FORCE
  145. $(call if_changed_dep,cpp_lds_S)
  146. $(obj)/vdso-n32.so.dbg.raw: $(obj)/vdso-n32.lds $(obj-vdso-n32) FORCE
  147. $(call if_changed,vdsold_and_vdso_check)
  148. $(obj)/vdso-n32-image.c: VDSO_NAME := n32
  149. $(obj)/vdso-n32-image.c: $(obj)/vdso-n32.so.dbg.raw $(obj)/vdso-n32.so.raw \
  150. $(obj)/genvdso FORCE
  151. $(call if_changed,genvdso)
  152. obj-y += vdso-n32-image.o
  153. endif
  154. # FIXME: Need install rule for debug.
  155. # Needs to deal with dependency for generation of dbg by cmd_genvdso...