Makefile 4.9 KB

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