xref: /openbmc/u-boot/arch/arm/config.mk (revision 406fd7e207d3593f150079514a371dccdc651ce7)
183d290c5STom Rini# SPDX-License-Identifier: GPL-2.0+
2ea0364f1SPeter Tyser#
3ea0364f1SPeter Tyser# (C) Copyright 2000-2002
4ea0364f1SPeter Tyser# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5ea0364f1SPeter Tyser
68ae86b76SWolfgang Denkifndef CONFIG_STANDALONE_LOAD_ADDR
7a93fbf4aSMasahiro Yamadaifneq ($(CONFIG_ARCH_OMAP2PLUS),)
88ae86b76SWolfgang DenkCONFIG_STANDALONE_LOAD_ADDR = 0x80300000
9ea0364f1SPeter Tyserelse
108ae86b76SWolfgang DenkCONFIG_STANDALONE_LOAD_ADDR = 0xc100000
11ea0364f1SPeter Tyserendif
12ea0364f1SPeter Tyserendif
13ea0364f1SPeter Tyser
14dd46eef2SSimon GlassCFLAGS_NON_EFI := -fno-pic -ffixed-r9 -ffunction-sections -fdata-sections
15dd46eef2SSimon GlassCFLAGS_EFI := -fpic -fshort-wchar
16dd46eef2SSimon Glass
17fd725691STom RiniLDFLAGS_FINAL += --gc-sections
183102274dSMasahiro YamadaPLATFORM_RELFLAGS += -ffunction-sections -fdata-sections \
190ae76531SDavid Feng		     -fno-common -ffixed-r9
20bf1af3d8SMasahiro YamadaPLATFORM_RELFLAGS += $(call cc-option, -msoft-float) \
21bf1af3d8SMasahiro Yamada      $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,))
22fd725691STom Rini
23b745e828STom Rini# LLVM support
243b6407b8STom RiniLLVM_RELFLAGS		:= $(call cc-option,-mllvm,) \
253b6407b8STom Rini			$(call cc-option,-mno-movt,)
26b745e828STom RiniPLATFORM_RELFLAGS	+= $(LLVM_RELFLAGS)
27b745e828STom Rini
2890f984e3SMasahiro YamadaPLATFORM_CPPFLAGS += -D__ARM__
29ea0364f1SPeter Tyser
30d57259b9SÁlvaro Fernández Rojasifdef CONFIG_ARM64
31d57259b9SÁlvaro Fernández RojasPLATFORM_ELFFLAGS += -B aarch64 -O elf64-littleaarch64
32d57259b9SÁlvaro Fernández Rojaselse
33d57259b9SÁlvaro Fernández RojasPLATFORM_ELFFLAGS += -B arm -O elf32-littlearm
34d57259b9SÁlvaro Fernández Rojasendif
35d57259b9SÁlvaro Fernández Rojas
365356f545SAneesh V# Choose between ARM/Thumb instruction sets
373a649407STom Riniifeq ($(CONFIG_$(SPL_)SYS_THUMB_BUILD),y)
3875d7a0d7SStefan AgnerAFLAGS_IMPLICIT_IT	:= $(call as-option,-Wa$(comma)-mimplicit-it=always)
3975d7a0d7SStefan AgnerPF_CPPFLAGS_ARM		:= $(AFLAGS_IMPLICIT_IT) \
4075d7a0d7SStefan Agner			$(call cc-option, -mthumb -mthumb-interwork,\
415356f545SAneesh V			$(call cc-option,-marm,)\
425356f545SAneesh V			$(call cc-option,-mno-thumb-interwork,)\
435356f545SAneesh V		)
445356f545SAneesh Velse
455356f545SAneesh VPF_CPPFLAGS_ARM := $(call cc-option,-marm,) \
465356f545SAneesh V		$(call cc-option,-mno-thumb-interwork,)
475356f545SAneesh Vendif
48ea0364f1SPeter Tyser
4906a119a0STom Rini# Only test once
503a649407STom Riniifeq ($(CONFIG_$(SPL_)SYS_THUMB_BUILD),y)
51d2366dfeSTom Riniarchprepare: checkthumb checkgcc6
52388b2e52SMasahiro Yamada
53388b2e52SMasahiro Yamadacheckthumb:
546e2f1538STom Rini	@if test "$(call cc-name)" = "gcc" -a \
556e2f1538STom Rini			"$(call cc-version)" -lt "0404"; then \
56388b2e52SMasahiro Yamada		echo -n '*** Your GCC does not produce working '; \
57388b2e52SMasahiro Yamada		echo 'binaries in THUMB mode.'; \
58388b2e52SMasahiro Yamada		echo '*** Your board is configured for THUMB mode.'; \
59388b2e52SMasahiro Yamada		false; \
60388b2e52SMasahiro Yamada	fi
61d2366dfeSTom Rinielse
62d2366dfeSTom Riniarchprepare: checkgcc6
63388b2e52SMasahiro Yamadaendif
6406a119a0STom Rini
65d2366dfeSTom Rinicheckgcc6:
66d2366dfeSTom Rini	@if test "$(call cc-name)" = "gcc" -a \
67d2366dfeSTom Rini			"$(call cc-version)" -lt "0600"; then \
686b867dabSTom Rini		echo '*** Your GCC is older than 6.0 and is not supported'; \
696b867dabSTom Rini		false; \
70d2366dfeSTom Rini	fi
71d2366dfeSTom Rini
72d2366dfeSTom Rini
73ea0364f1SPeter Tyser# Try if EABI is supported, else fall back to old API,
74ea0364f1SPeter Tyser# i. e. for example:
75ea0364f1SPeter Tyser# - with ELDK 4.2 (EABI supported), use:
765356f545SAneesh V#	-mabi=aapcs-linux
77ea0364f1SPeter Tyser# - with ELDK 4.1 (gcc 4.x, no EABI), use:
785356f545SAneesh V#	-mabi=apcs-gnu
79ea0364f1SPeter Tyser# - with ELDK 3.1 (gcc 3.x), use:
805356f545SAneesh V#	-mapcs-32
81cca4e4aeSWolfgang DenkPF_CPPFLAGS_ABI := $(call cc-option,\
825356f545SAneesh V			-mabi=aapcs-linux,\
83ea0364f1SPeter Tyser			$(call cc-option,\
84ea0364f1SPeter Tyser				-mapcs-32,\
85ea0364f1SPeter Tyser				$(call cc-option,\
86ea0364f1SPeter Tyser					-mabi=apcs-gnu,\
87ea0364f1SPeter Tyser				)\
885356f545SAneesh V			)\
89ea0364f1SPeter Tyser		)
90cca4e4aeSWolfgang DenkPLATFORM_CPPFLAGS += $(PF_CPPFLAGS_ARM) $(PF_CPPFLAGS_ABI)
91ea0364f1SPeter Tyser
92ea0364f1SPeter Tyser# For EABI, make sure to provide raise()
93ea0364f1SPeter Tyserifneq (,$(findstring -mabi=aapcs-linux,$(PLATFORM_CPPFLAGS)))
945253418aSAneesh V# This file is parsed many times, so the string may get added multiple
955253418aSAneesh V# times. Also, the prefix needs to be different based on whether
965253418aSAneesh V# CONFIG_SPL_BUILD is defined or not. 'filter-out' the existing entry
975253418aSAneesh V# before adding the correct one.
98a86cf89cSMasahiro YamadaPLATFORM_LIBS := arch/arm/lib/eabi_compat.o \
99a86cf89cSMasahiro Yamada	$(filter-out arch/arm/lib/eabi_compat.o, $(PLATFORM_LIBS))
100ea0364f1SPeter Tyserendif
10192d5ecbaSAlbert Aribaud
10292d5ecbaSAlbert Aribaud# needed for relocation
103a4594e41SStefano BabicLDFLAGS_u-boot += -pie
1040f20bb60SAllen Martin
1050f20bb60SAllen Martin#
1060f20bb60SAllen Martin# FIXME: binutils versions < 2.22 have a bug in the assembler where
1070f20bb60SAllen Martin# branches to weak symbols can be incorrectly optimized in thumb mode
1080f20bb60SAllen Martin# to a short branch (b.n instruction) that won't reach when the symbol
1090f20bb60SAllen Martin# gets preempted
1100f20bb60SAllen Martin#
1110f20bb60SAllen Martin# http://sourceware.org/bugzilla/show_bug.cgi?id=12532
1120f20bb60SAllen Martin#
1133a649407STom Riniifeq ($(CONFIG_$(SPL_)SYS_THUMB_BUILD),y)
1140f20bb60SAllen Martinifeq ($(GAS_BUG_12532),)
1150f20bb60SAllen Martinexport GAS_BUG_12532:=$(shell if [ $(call binutils-version) -lt 0222 ] ; \
1160f20bb60SAllen Martin	then echo y; else echo n; fi)
1170f20bb60SAllen Martinendif
1180f20bb60SAllen Martinifeq ($(GAS_BUG_12532),y)
1190f20bb60SAllen MartinPLATFORM_RELFLAGS += -fno-optimize-sibling-calls
1200f20bb60SAllen Martinendif
1210f20bb60SAllen Martinendif
122c37980c3SAlbert ARIBAUD
123c37980c3SAlbert ARIBAUDifneq ($(CONFIG_SPL_BUILD),y)
124373d7983SJeroen Hofstee# Check that only R_ARM_RELATIVE relocations are generated.
125c37980c3SAlbert ARIBAUDALL-y += checkarmreloc
126373d7983SJeroen Hofstee# The movt / movw can hardcode 16 bit parts of the addresses in the
127373d7983SJeroen Hofstee# instruction. Relocation is not supported for that case, so disable
128373d7983SJeroen Hofstee# such usage by requiring word relocations.
129373d7983SJeroen HofsteePLATFORM_CPPFLAGS += $(call cc-option, -mword-relocations)
130397d7d5aSPeng FanPLATFORM_CPPFLAGS += $(call cc-option, -fno-pic)
131c37980c3SAlbert ARIBAUDendif
13247ed5dd0SAlbert ARIBAUD
13347ed5dd0SAlbert ARIBAUD# limit ourselves to the sections we want in the .bin.
1340ae76531SDavid Fengifdef CONFIG_ARM64
135df88cb3bSmacro.wave.z@gmail.comOBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .data \
136cf2a8fd6SSimon Glass		-j .u_boot_list -j .rela.dyn -j .got -j .got.plt \
137*7e21fbcaSAlexander Graf		-j .binman_sym_table -j .text_rest
1380ae76531SDavid Fengelse
139a5aa7ff3SChen-Yu TsaiOBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .hash \
140cf2a8fd6SSimon Glass		-j .data -j .got -j .got.plt -j .u_boot_list -j .rel.dyn \
141*7e21fbcaSAlexander Graf		-j .binman_sym_table -j .text_rest
1420ae76531SDavid Fengendif
143630d2345SMasahiro Yamada
14454cc4dcfSPantelis Antoniou# if a dtb section exists we always have to include it
14554cc4dcfSPantelis Antoniou# there are only two cases where it is generated
14654cc4dcfSPantelis Antoniou# 1) OF_EMBEDED is turned on
14754cc4dcfSPantelis Antoniou# 2) unit tests include device tree blobs
148072b2d88SAlexey IgnatovOBJCOPYFLAGS += -j .dtb.init.rodata
149072b2d88SAlexey Ignatov
15050149ea3SAlexander Grafifdef CONFIG_EFI_LOADER
15150149ea3SAlexander GrafOBJCOPYFLAGS += -j .efi_runtime -j .efi_runtime_rel
15250149ea3SAlexander Grafendif
15350149ea3SAlexander Graf
154630d2345SMasahiro Yamadaifneq ($(CONFIG_IMX_CONFIG),)
155630d2345SMasahiro Yamadaifdef CONFIG_SPL
156630d2345SMasahiro Yamadaifndef CONFIG_SPL_BUILD
157630d2345SMasahiro YamadaALL-y += SPL
158630d2345SMasahiro Yamadaendif
159630d2345SMasahiro Yamadaelse
160e64348f5SStefano Babicifeq ($(CONFIG_OF_SEPARATE),y)
161e64348f5SStefano BabicALL-y += u-boot-dtb.imx
162e64348f5SStefano Babicelse
163630d2345SMasahiro YamadaALL-y += u-boot.imx
164630d2345SMasahiro Yamadaendif
165630d2345SMasahiro Yamadaendif
166ed0c2c0aSAlbert ARIBAUD \(3ADEV\)ifneq ($(CONFIG_VF610),)
167ed0c2c0aSAlbert ARIBAUD \(3ADEV\)ALL-y += u-boot.vyb
168ed0c2c0aSAlbert ARIBAUD \(3ADEV\)endif
169e64348f5SStefano Babicendif
170dd46eef2SSimon Glass
171dd46eef2SSimon GlassEFI_LDS := elf_arm_efi.lds
172dd46eef2SSimon GlassEFI_CRT0 := crt0_arm_efi.o
173dd46eef2SSimon GlassEFI_RELOC := reloc_arm_efi.o
174