config.mk 4.9 KB

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