config.mk 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. # SPDX-License-Identifier: GPL-2.0+
  2. #
  3. # (C) Copyright 2000-2002
  4. # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  5. ifeq ($(CONFIG_ARM64),y)
  6. FIXED_REG := -ffixed-x18
  7. else
  8. FIXED_REG := -ffixed-r9
  9. endif
  10. CFLAGS_NON_EFI := -fno-pic $(FIXED_REG) -ffunction-sections -fdata-sections \
  11. -fstack-protector-strong
  12. CFLAGS_EFI := -fpic -fshort-wchar
  13. ifneq ($(LTO_ENABLE)$(CONFIG_USE_PRIVATE_LIBGCC),yy)
  14. LDFLAGS_FINAL += --gc-sections
  15. endif
  16. ifneq ($(LTO_ENABLE),y)
  17. PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
  18. endif
  19. PLATFORM_RELFLAGS += -fno-common $(FIXED_REG)
  20. PLATFORM_RELFLAGS += $(call cc-option, -msoft-float) \
  21. $(call cc-option,-mgeneral-regs-only) \
  22. $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,))
  23. # LLVM support
  24. LLVM_RELFLAGS := $(call cc-option,-mllvm,) \
  25. $(call cc-option,-mno-movt,)
  26. PLATFORM_RELFLAGS += $(LLVM_RELFLAGS)
  27. PLATFORM_CPPFLAGS += -D__ARM__
  28. ifdef CONFIG_ARM64
  29. PLATFORM_ELFFLAGS += -B aarch64 -O elf64-littleaarch64
  30. else
  31. PLATFORM_ELFFLAGS += -B arm -O elf32-littlearm
  32. endif
  33. # Choose between ARM/Thumb instruction sets
  34. ifeq ($(CONFIG_$(SPL_)SYS_THUMB_BUILD),y)
  35. AFLAGS_IMPLICIT_IT := $(call as-option,-Wa$(comma)-mimplicit-it=always)
  36. PF_CPPFLAGS_ARM := $(AFLAGS_IMPLICIT_IT) \
  37. $(call cc-option, -mthumb -mthumb-interwork,\
  38. $(call cc-option,-marm,)\
  39. $(call cc-option,-mno-thumb-interwork,)\
  40. )
  41. else
  42. PF_CPPFLAGS_ARM := $(call cc-option,-marm,) \
  43. $(call cc-option,-mno-thumb-interwork,)
  44. endif
  45. # Only test once
  46. ifeq ($(CONFIG_$(SPL_)SYS_THUMB_BUILD),y)
  47. archprepare: checkthumb checkgcc6
  48. checkthumb:
  49. @if test "$(call cc-name)" = "gcc" -a \
  50. "$(call cc-version)" -lt "0404"; then \
  51. echo -n '*** Your GCC does not produce working '; \
  52. echo 'binaries in THUMB mode.'; \
  53. echo '*** Your board is configured for THUMB mode.'; \
  54. false; \
  55. fi
  56. else
  57. archprepare: checkgcc6
  58. endif
  59. checkgcc6:
  60. @if test "$(call cc-name)" = "gcc" -a \
  61. "$(call cc-version)" -lt "0600"; then \
  62. echo '*** Your GCC is older than 6.0 and is not supported'; \
  63. false; \
  64. fi
  65. # Try if EABI is supported, else fall back to old API,
  66. # i. e. for example:
  67. # - with ELDK 4.2 (EABI supported), use:
  68. # -mabi=aapcs-linux
  69. # - with ELDK 4.1 (gcc 4.x, no EABI), use:
  70. # -mabi=apcs-gnu
  71. # - with ELDK 3.1 (gcc 3.x), use:
  72. # -mapcs-32
  73. PF_CPPFLAGS_ABI := $(call cc-option,\
  74. -mabi=aapcs-linux,\
  75. $(call cc-option,\
  76. -mapcs-32,\
  77. $(call cc-option,\
  78. -mabi=apcs-gnu,\
  79. )\
  80. )\
  81. )
  82. PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_ARM) $(PF_CPPFLAGS_ABI)
  83. # For EABI, make sure to provide raise()
  84. ifneq (,$(findstring -mabi=aapcs-linux,$(PLATFORM_CPPFLAGS)))
  85. # This file is parsed many times, so the string may get added multiple
  86. # times. Also, the prefix needs to be different based on whether
  87. # CONFIG_SPL_BUILD is defined or not. 'filter-out' the existing entry
  88. # before adding the correct one.
  89. PLATFORM_LIBS := arch/arm/lib/eabi_compat.o \
  90. $(filter-out arch/arm/lib/eabi_compat.o, $(PLATFORM_LIBS))
  91. endif
  92. # needed for relocation
  93. LDFLAGS_u-boot += -pie
  94. #
  95. # FIXME: binutils versions < 2.22 have a bug in the assembler where
  96. # branches to weak symbols can be incorrectly optimized in thumb mode
  97. # to a short branch (b.n instruction) that won't reach when the symbol
  98. # gets preempted
  99. #
  100. # http://sourceware.org/bugzilla/show_bug.cgi?id=12532
  101. #
  102. ifeq ($(CONFIG_$(SPL_)SYS_THUMB_BUILD),y)
  103. ifeq ($(GAS_BUG_12532),)
  104. export GAS_BUG_12532:=$(shell if [ $(call binutils-version) -lt 0222 ] ; \
  105. then echo y; else echo n; fi)
  106. endif
  107. ifeq ($(GAS_BUG_12532),y)
  108. PLATFORM_RELFLAGS += -fno-optimize-sibling-calls
  109. endif
  110. endif
  111. ifneq ($(CONFIG_SPL_BUILD),y)
  112. # Check that only R_ARM_RELATIVE relocations are generated.
  113. INPUTS-y += checkarmreloc
  114. # The movt / movw can hardcode 16 bit parts of the addresses in the
  115. # instruction. Relocation is not supported for that case, so disable
  116. # such usage by requiring word relocations.
  117. PLATFORM_CPPFLAGS += $(call cc-option, -mword-relocations)
  118. PLATFORM_CPPFLAGS += $(call cc-option, -fno-pic)
  119. endif
  120. # limit ourselves to the sections we want in the .bin.
  121. ifdef CONFIG_ARM64
  122. OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .data \
  123. -j __u_boot_list -j .rela.dyn -j .got -j .got.plt \
  124. -j .binman_sym_table -j .text_rest
  125. else
  126. OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .hash \
  127. -j .data -j .got -j .got.plt -j __u_boot_list -j .rel.dyn \
  128. -j .binman_sym_table -j .text_rest
  129. endif
  130. # if a dtb section exists we always have to include it
  131. # there are only two cases where it is generated
  132. # 1) OF_EMBEDED is turned on
  133. # 2) unit tests include device tree blobs
  134. OBJCOPYFLAGS += -j .dtb.init.rodata
  135. ifdef CONFIG_EFI_LOADER
  136. OBJCOPYFLAGS += -j .efi_runtime -j .efi_runtime_rel
  137. endif
  138. ifdef CONFIG_MACH_IMX
  139. ifneq ($(CONFIG_IMX_CONFIG),"")
  140. ifdef CONFIG_SPL
  141. ifndef CONFIG_SPL_BUILD
  142. INPUTS-y += SPL
  143. endif
  144. else
  145. ifeq ($(CONFIG_OF_SEPARATE),y)
  146. INPUTS-y += u-boot-dtb.imx
  147. else
  148. INPUTS-y += u-boot.imx
  149. endif
  150. endif
  151. ifneq ($(CONFIG_VF610),)
  152. INPUTS-y += u-boot.vyb
  153. endif
  154. endif
  155. endif
  156. EFI_LDS := elf_arm_efi.lds
  157. EFI_CRT0 := crt0_arm_efi.o
  158. EFI_RELOC := reloc_arm_efi.o