1ea0364f1SPeter Tyser# 2ea0364f1SPeter Tyser# (C) Copyright 2000-2002 3ea0364f1SPeter Tyser# Wolfgang Denk, DENX Software Engineering, wd@denx.de. 4ea0364f1SPeter Tyser# 51a459660SWolfgang Denk# SPDX-License-Identifier: GPL-2.0+ 6ea0364f1SPeter Tyser# 7ea0364f1SPeter Tyser 88ae86b76SWolfgang Denkifndef CONFIG_STANDALONE_LOAD_ADDR 9806d2792SLokesh Vutlaifneq ($(CONFIG_OMAP_COMMON),) 108ae86b76SWolfgang DenkCONFIG_STANDALONE_LOAD_ADDR = 0x80300000 11ea0364f1SPeter Tyserelse 128ae86b76SWolfgang DenkCONFIG_STANDALONE_LOAD_ADDR = 0xc100000 13ea0364f1SPeter Tyserendif 14ea0364f1SPeter Tyserendif 15ea0364f1SPeter Tyser 16fd725691STom RiniLDFLAGS_FINAL += --gc-sections 173102274dSMasahiro YamadaPLATFORM_RELFLAGS += -ffunction-sections -fdata-sections \ 180ae76531SDavid Feng -fno-common -ffixed-r9 19bf1af3d8SMasahiro YamadaPLATFORM_RELFLAGS += $(call cc-option, -msoft-float) \ 20bf1af3d8SMasahiro Yamada $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,)) 21fd725691STom Rini 22959daa21SSimon Glass# Support generic board on ARM 23959daa21SSimon Glass__HAVE_ARCH_GENERIC_BOARD := y 24959daa21SSimon Glass 25*90f984e3SMasahiro YamadaPLATFORM_CPPFLAGS += -D__ARM__ 26ea0364f1SPeter Tyser 275356f545SAneesh V# Choose between ARM/Thumb instruction sets 285356f545SAneesh Vifeq ($(CONFIG_SYS_THUMB_BUILD),y) 295356f545SAneesh VPF_CPPFLAGS_ARM := $(call cc-option, -mthumb -mthumb-interwork,\ 305356f545SAneesh V $(call cc-option,-marm,)\ 315356f545SAneesh V $(call cc-option,-mno-thumb-interwork,)\ 325356f545SAneesh V ) 335356f545SAneesh Velse 345356f545SAneesh VPF_CPPFLAGS_ARM := $(call cc-option,-marm,) \ 355356f545SAneesh V $(call cc-option,-mno-thumb-interwork,) 365356f545SAneesh Vendif 37ea0364f1SPeter Tyser 3806a119a0STom Rini# Only test once 3906a119a0STom Riniifneq ($(CONFIG_SPL_BUILD),y) 40388b2e52SMasahiro Yamadaifeq ($(CONFIG_SYS_THUMB_BUILD),y) 41388b2e52SMasahiro Yamadaarchprepare: checkthumb 42388b2e52SMasahiro Yamada 43388b2e52SMasahiro Yamadacheckthumb: 44388b2e52SMasahiro Yamada @if test "$(call cc-version)" -lt "0404"; then \ 45388b2e52SMasahiro Yamada echo -n '*** Your GCC does not produce working '; \ 46388b2e52SMasahiro Yamada echo 'binaries in THUMB mode.'; \ 47388b2e52SMasahiro Yamada echo '*** Your board is configured for THUMB mode.'; \ 48388b2e52SMasahiro Yamada false; \ 49388b2e52SMasahiro Yamada fi 50388b2e52SMasahiro Yamadaendif 5106a119a0STom Riniendif 5206a119a0STom Rini 53ea0364f1SPeter Tyser# Try if EABI is supported, else fall back to old API, 54ea0364f1SPeter Tyser# i. e. for example: 55ea0364f1SPeter Tyser# - with ELDK 4.2 (EABI supported), use: 565356f545SAneesh V# -mabi=aapcs-linux 57ea0364f1SPeter Tyser# - with ELDK 4.1 (gcc 4.x, no EABI), use: 585356f545SAneesh V# -mabi=apcs-gnu 59ea0364f1SPeter Tyser# - with ELDK 3.1 (gcc 3.x), use: 605356f545SAneesh V# -mapcs-32 61cca4e4aeSWolfgang DenkPF_CPPFLAGS_ABI := $(call cc-option,\ 625356f545SAneesh V -mabi=aapcs-linux,\ 63ea0364f1SPeter Tyser $(call cc-option,\ 64ea0364f1SPeter Tyser -mapcs-32,\ 65ea0364f1SPeter Tyser $(call cc-option,\ 66ea0364f1SPeter Tyser -mabi=apcs-gnu,\ 67ea0364f1SPeter Tyser )\ 685356f545SAneesh V )\ 69ea0364f1SPeter Tyser ) 70cca4e4aeSWolfgang DenkPLATFORM_CPPFLAGS += $(PF_CPPFLAGS_ARM) $(PF_CPPFLAGS_ABI) 71ea0364f1SPeter Tyser 72ea0364f1SPeter Tyser# For EABI, make sure to provide raise() 73ea0364f1SPeter Tyserifneq (,$(findstring -mabi=aapcs-linux,$(PLATFORM_CPPFLAGS))) 745253418aSAneesh V# This file is parsed many times, so the string may get added multiple 755253418aSAneesh V# times. Also, the prefix needs to be different based on whether 765253418aSAneesh V# CONFIG_SPL_BUILD is defined or not. 'filter-out' the existing entry 775253418aSAneesh V# before adding the correct one. 78a86cf89cSMasahiro YamadaPLATFORM_LIBS := arch/arm/lib/eabi_compat.o \ 79a86cf89cSMasahiro Yamada $(filter-out arch/arm/lib/eabi_compat.o, $(PLATFORM_LIBS)) 80ea0364f1SPeter Tyserendif 8192d5ecbaSAlbert Aribaud 8292d5ecbaSAlbert Aribaud# needed for relocation 83a4594e41SStefano BabicLDFLAGS_u-boot += -pie 840f20bb60SAllen Martin 850f20bb60SAllen Martin# 860f20bb60SAllen Martin# FIXME: binutils versions < 2.22 have a bug in the assembler where 870f20bb60SAllen Martin# branches to weak symbols can be incorrectly optimized in thumb mode 880f20bb60SAllen Martin# to a short branch (b.n instruction) that won't reach when the symbol 890f20bb60SAllen Martin# gets preempted 900f20bb60SAllen Martin# 910f20bb60SAllen Martin# http://sourceware.org/bugzilla/show_bug.cgi?id=12532 920f20bb60SAllen Martin# 930f20bb60SAllen Martinifeq ($(CONFIG_SYS_THUMB_BUILD),y) 940f20bb60SAllen Martinifeq ($(GAS_BUG_12532),) 950f20bb60SAllen Martinexport GAS_BUG_12532:=$(shell if [ $(call binutils-version) -lt 0222 ] ; \ 960f20bb60SAllen Martin then echo y; else echo n; fi) 970f20bb60SAllen Martinendif 980f20bb60SAllen Martinifeq ($(GAS_BUG_12532),y) 990f20bb60SAllen MartinPLATFORM_RELFLAGS += -fno-optimize-sibling-calls 1000f20bb60SAllen Martinendif 1010f20bb60SAllen Martinendif 102c37980c3SAlbert ARIBAUD 103c37980c3SAlbert ARIBAUDifneq ($(CONFIG_SPL_BUILD),y) 104373d7983SJeroen Hofstee# Check that only R_ARM_RELATIVE relocations are generated. 105c37980c3SAlbert ARIBAUDALL-y += checkarmreloc 106373d7983SJeroen Hofstee# The movt / movw can hardcode 16 bit parts of the addresses in the 107373d7983SJeroen Hofstee# instruction. Relocation is not supported for that case, so disable 108373d7983SJeroen Hofstee# such usage by requiring word relocations. 109373d7983SJeroen HofsteePLATFORM_CPPFLAGS += $(call cc-option, -mword-relocations) 110c37980c3SAlbert ARIBAUDendif 11147ed5dd0SAlbert ARIBAUD 11247ed5dd0SAlbert ARIBAUD# limit ourselves to the sections we want in the .bin. 1130ae76531SDavid Fengifdef CONFIG_ARM64 11495ddcd68SMasahiro YamadaOBJCOPYFLAGS += -j .text -j .rodata -j .data -j .u_boot_list -j .rela.dyn 1150ae76531SDavid Fengelse 116bf433afdSMarc ZyngierOBJCOPYFLAGS += -j .text -j .secure_text -j .rodata -j .hash -j .data -j .got.plt -j .u_boot_list -j .rel.dyn 1170ae76531SDavid Fengendif 118630d2345SMasahiro Yamada 119072b2d88SAlexey Ignatovifdef CONFIG_OF_EMBED 120072b2d88SAlexey IgnatovOBJCOPYFLAGS += -j .dtb.init.rodata 121072b2d88SAlexey Ignatovendif 122072b2d88SAlexey Ignatov 123630d2345SMasahiro Yamadaifneq ($(CONFIG_IMX_CONFIG),) 124630d2345SMasahiro Yamadaifdef CONFIG_SPL 125630d2345SMasahiro Yamadaifndef CONFIG_SPL_BUILD 126630d2345SMasahiro YamadaALL-y += SPL 127630d2345SMasahiro Yamadaendif 128630d2345SMasahiro Yamadaelse 129e64348f5SStefano Babicifeq ($(CONFIG_OF_SEPARATE),y) 130e64348f5SStefano BabicALL-y += u-boot-dtb.imx 131e64348f5SStefano Babicelse 132630d2345SMasahiro YamadaALL-y += u-boot.imx 133630d2345SMasahiro Yamadaendif 134630d2345SMasahiro Yamadaendif 135e64348f5SStefano Babicendif 136