config.mk 5.0 KB

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