Makefile 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. # SPDX-License-Identifier: GPL-2.0
  2. # Objects to go into the VDSO.
  3. obj-vdso-y := elf.o gettimeofday.o sigreturn.o
  4. # Common compiler flags between ABIs.
  5. ccflags-vdso := \
  6. $(filter -I%,$(KBUILD_CFLAGS)) \
  7. $(filter -E%,$(KBUILD_CFLAGS)) \
  8. $(filter -mmicromips,$(KBUILD_CFLAGS)) \
  9. $(filter -march=%,$(KBUILD_CFLAGS)) \
  10. $(filter -m%-float,$(KBUILD_CFLAGS)) \
  11. $(filter -mno-loongson-%,$(KBUILD_CFLAGS)) \
  12. $(CLANG_FLAGS) \
  13. -D__VDSO__
  14. cflags-vdso := $(ccflags-vdso) \
  15. $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \
  16. -O2 -g -fPIC -fno-strict-aliasing -fno-common -fno-builtin -G 0 \
  17. -DDISABLE_BRANCH_PROFILING \
  18. $(call cc-option, -fno-asynchronous-unwind-tables) \
  19. $(call cc-option, -fno-stack-protector)
  20. aflags-vdso := $(ccflags-vdso) \
  21. -D__ASSEMBLY__ -Wa,-gdwarf-2
  22. #
  23. # For the pre-R6 code in arch/mips/vdso/vdso.h for locating
  24. # the base address of VDSO, the linker will emit a R_MIPS_PC32
  25. # relocation in binutils > 2.25 but it will fail with older versions
  26. # because that relocation is not supported for that symbol. As a result
  27. # of which we are forced to disable the VDSO symbols when building
  28. # with < 2.25 binutils on pre-R6 kernels. For more references on why we
  29. # can't use other methods to get the base address of VDSO please refer to
  30. # the comments on that file.
  31. #
  32. ifndef CONFIG_CPU_MIPSR6
  33. ifeq ($(call ld-ifversion, -lt, 225000000, y),y)
  34. $(warning MIPS VDSO requires binutils >= 2.25)
  35. obj-vdso-y := $(filter-out gettimeofday.o, $(obj-vdso-y))
  36. ccflags-vdso += -DDISABLE_MIPS_VDSO
  37. endif
  38. endif
  39. # VDSO linker flags.
  40. VDSO_LDFLAGS := \
  41. -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-soname=linux-vdso.so.1 \
  42. $(addprefix -Wl$(comma),$(filter -E%,$(KBUILD_CFLAGS))) \
  43. -nostdlib -shared \
  44. $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) \
  45. $(call cc-ldoption, -Wl$(comma)--build-id)
  46. GCOV_PROFILE := n
  47. #
  48. # Shared build commands.
  49. #
  50. quiet_cmd_vdsold = VDSO $@
  51. cmd_vdsold = $(CC) $(c_flags) $(VDSO_LDFLAGS) \
  52. -Wl,-T $(filter %.lds,$^) $(filter %.o,$^) -o $@
  53. quiet_cmd_vdsoas_o_S = AS $@
  54. cmd_vdsoas_o_S = $(CC) $(a_flags) -c -o $@ $<
  55. # Strip rule for the raw .so files
  56. $(obj)/%.so.raw: OBJCOPYFLAGS := -S
  57. $(obj)/%.so.raw: $(obj)/%.so.dbg.raw FORCE
  58. $(call if_changed,objcopy)
  59. hostprogs-y := genvdso
  60. quiet_cmd_genvdso = GENVDSO $@
  61. define cmd_genvdso
  62. $(foreach file,$(filter %.raw,$^),cp $(file) $(file:%.raw=%) &&) \
  63. $(obj)/genvdso $(<:%.raw=%) $(<:%.dbg.raw=%) $@ $(VDSO_NAME)
  64. endef
  65. #
  66. # Build native VDSO.
  67. #
  68. native-abi := $(filter -mabi=%,$(KBUILD_CFLAGS))
  69. targets += $(obj-vdso-y)
  70. targets += vdso.lds
  71. targets += vdso.so.dbg.raw vdso.so.raw
  72. targets += vdso.so.dbg vdso.so
  73. targets += vdso-image.c
  74. obj-vdso := $(obj-vdso-y:%.o=$(obj)/%.o)
  75. $(obj-vdso): KBUILD_CFLAGS := $(cflags-vdso) $(native-abi)
  76. $(obj-vdso): KBUILD_AFLAGS := $(aflags-vdso) $(native-abi)
  77. $(obj)/vdso.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) $(native-abi)
  78. $(obj)/vdso.so.dbg.raw: $(obj)/vdso.lds $(obj-vdso) FORCE
  79. $(call if_changed,vdsold)
  80. $(obj)/vdso-image.c: $(obj)/vdso.so.dbg.raw $(obj)/vdso.so.raw \
  81. $(obj)/genvdso FORCE
  82. $(call if_changed,genvdso)
  83. obj-y += vdso-image.o
  84. #
  85. # Build O32 VDSO.
  86. #
  87. # Define these outside the ifdef to ensure they are picked up by clean.
  88. targets += $(obj-vdso-y:%.o=%-o32.o)
  89. targets += vdso-o32.lds
  90. targets += vdso-o32.so.dbg.raw vdso-o32.so.raw
  91. targets += vdso-o32.so.dbg vdso-o32.so
  92. targets += vdso-o32-image.c
  93. ifdef CONFIG_MIPS32_O32
  94. obj-vdso-o32 := $(obj-vdso-y:%.o=$(obj)/%-o32.o)
  95. $(obj-vdso-o32): KBUILD_CFLAGS := $(cflags-vdso) -mabi=32
  96. $(obj-vdso-o32): KBUILD_AFLAGS := $(aflags-vdso) -mabi=32
  97. $(obj)/%-o32.o: $(src)/%.S FORCE
  98. $(call if_changed_dep,vdsoas_o_S)
  99. $(obj)/%-o32.o: $(src)/%.c FORCE
  100. $(call cmd,force_checksrc)
  101. $(call if_changed_rule,cc_o_c)
  102. $(obj)/vdso-o32.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) -mabi=32
  103. $(obj)/vdso-o32.lds: $(src)/vdso.lds.S FORCE
  104. $(call if_changed_dep,cpp_lds_S)
  105. $(obj)/vdso-o32.so.dbg.raw: $(obj)/vdso-o32.lds $(obj-vdso-o32) FORCE
  106. $(call if_changed,vdsold)
  107. $(obj)/vdso-o32-image.c: VDSO_NAME := o32
  108. $(obj)/vdso-o32-image.c: $(obj)/vdso-o32.so.dbg.raw $(obj)/vdso-o32.so.raw \
  109. $(obj)/genvdso FORCE
  110. $(call if_changed,genvdso)
  111. obj-y += vdso-o32-image.o
  112. endif
  113. #
  114. # Build N32 VDSO.
  115. #
  116. targets += $(obj-vdso-y:%.o=%-n32.o)
  117. targets += vdso-n32.lds
  118. targets += vdso-n32.so.dbg.raw vdso-n32.so.raw
  119. targets += vdso-n32.so.dbg vdso-n32.so
  120. targets += vdso-n32-image.c
  121. ifdef CONFIG_MIPS32_N32
  122. obj-vdso-n32 := $(obj-vdso-y:%.o=$(obj)/%-n32.o)
  123. $(obj-vdso-n32): KBUILD_CFLAGS := $(cflags-vdso) -mabi=n32
  124. $(obj-vdso-n32): KBUILD_AFLAGS := $(aflags-vdso) -mabi=n32
  125. $(obj)/%-n32.o: $(src)/%.S FORCE
  126. $(call if_changed_dep,vdsoas_o_S)
  127. $(obj)/%-n32.o: $(src)/%.c FORCE
  128. $(call cmd,force_checksrc)
  129. $(call if_changed_rule,cc_o_c)
  130. $(obj)/vdso-n32.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) -mabi=n32
  131. $(obj)/vdso-n32.lds: $(src)/vdso.lds.S FORCE
  132. $(call if_changed_dep,cpp_lds_S)
  133. $(obj)/vdso-n32.so.dbg.raw: $(obj)/vdso-n32.lds $(obj-vdso-n32) FORCE
  134. $(call if_changed,vdsold)
  135. $(obj)/vdso-n32-image.c: VDSO_NAME := n32
  136. $(obj)/vdso-n32-image.c: $(obj)/vdso-n32.so.dbg.raw $(obj)/vdso-n32.so.raw \
  137. $(obj)/genvdso FORCE
  138. $(call if_changed,genvdso)
  139. obj-y += vdso-n32-image.o
  140. endif
  141. # FIXME: Need install rule for debug.
  142. # Needs to deal with dependency for generation of dbg by cmd_genvdso...