Prepare v2023.10
[platform/kernel/u-boot.git] / arch / arm / config.mk
1 # SPDX-License-Identifier: GPL-2.0+
2 #
3 # (C) Copyright 2000-2002
4 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5
6 ifeq ($(CONFIG_ARM64),y)
7 FIXED_REG := -ffixed-x18
8 else
9 FIXED_REG := -ffixed-r9
10 endif
11
12 CFLAGS_NON_EFI := -fno-pic $(FIXED_REG) -ffunction-sections -fdata-sections \
13                   -fstack-protector-strong
14 CFLAGS_EFI := -fpic -fshort-wchar
15
16 ifneq ($(LTO_ENABLE)$(CONFIG_USE_PRIVATE_LIBGCC),yy)
17 LDFLAGS_FINAL += --gc-sections
18 endif
19
20 ifneq ($(LTO_ENABLE),y)
21 PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
22 endif
23
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,))
28
29 # LLVM support
30 LLVM_RELFLAGS           := $(call cc-option,-mllvm,) \
31                         $(call cc-option,-mno-movt,)
32 PLATFORM_RELFLAGS       += $(LLVM_RELFLAGS)
33
34 PLATFORM_CPPFLAGS += -D__ARM__
35
36 ifdef CONFIG_ARM64
37 PLATFORM_ELFFLAGS += -B aarch64 -O elf64-littleaarch64
38 else
39 PLATFORM_ELFFLAGS += -B arm -O elf32-littlearm
40 endif
41
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,)\
49                 )
50 else
51 PF_CPPFLAGS_ARM := $(call cc-option,-marm,) \
52                 $(call cc-option,-mno-thumb-interwork,)
53 endif
54
55 # Only test once
56 ifeq ($(CONFIG_$(SPL_)SYS_THUMB_BUILD),y)
57 archprepare: checkthumb checkgcc6
58
59 checkthumb:
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.'; \
65                 false; \
66         fi
67 else
68 archprepare: checkgcc6
69 endif
70
71 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'; \
75                 false; \
76         fi
77
78
79 # Try if EABI is supported, else fall back to old API,
80 # i. e. for example:
81 # - with ELDK 4.2 (EABI supported), use:
82 #       -mabi=aapcs-linux
83 # - with ELDK 4.1 (gcc 4.x, no EABI), use:
84 #       -mabi=apcs-gnu
85 # - with ELDK 3.1 (gcc 3.x), use:
86 #       -mapcs-32
87 PF_CPPFLAGS_ABI := $(call cc-option,\
88                         -mabi=aapcs-linux,\
89                         $(call cc-option,\
90                                 -mapcs-32,\
91                                 $(call cc-option,\
92                                         -mabi=apcs-gnu,\
93                                 )\
94                         )\
95                 )
96 PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_ARM) $(PF_CPPFLAGS_ABI)
97
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))
106 endif
107
108 # needed for relocation
109 LDFLAGS_u-boot += -pie
110
111 #
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
115 # gets preempted
116 #
117 # http://sourceware.org/bugzilla/show_bug.cgi?id=12532
118 #
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)
123 endif
124 ifeq ($(GAS_BUG_12532),y)
125 PLATFORM_RELFLAGS += -fno-optimize-sibling-calls
126 endif
127 endif
128
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)
137 endif
138
139 # limit ourselves to the sections we want in the .bin.
140 ifdef CONFIG_ARM64
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
144 else
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
148 endif
149
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
155
156 ifdef CONFIG_EFI_LOADER
157 OBJCOPYFLAGS += -j .efi_runtime -j .efi_runtime_rel
158 endif
159
160 ifdef CONFIG_MACH_IMX
161 ifneq ($(CONFIG_IMX_CONFIG),"")
162 ifdef CONFIG_SPL
163 ifndef CONFIG_SPL_BUILD
164 INPUTS-y += SPL
165 endif
166 else
167 ifeq ($(CONFIG_OF_SEPARATE),y)
168 INPUTS-y += u-boot-dtb.imx
169 else
170 INPUTS-y += u-boot.imx
171 endif
172 endif
173 ifneq ($(CONFIG_VF610),)
174 INPUTS-y += u-boot.vyb
175 endif
176 endif
177 endif
178
179 EFI_LDS := elf_arm_efi.lds
180 EFI_CRT0 := crt0_arm_efi.o
181 EFI_RELOC := reloc_arm_efi.o