config.mk 3.7 KB

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