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