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