config.mk 4.3 KB

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