1# 2# (C) Copyright 2000-2002 3# Wolfgang Denk, DENX Software Engineering, wd@denx.de. 4# 5# SPDX-License-Identifier: GPL-2.0+ 6# 7 8ifeq ($(CROSS_COMPILE),) 9CROSS_COMPILE := arm-linux- 10endif 11 12ifndef CONFIG_STANDALONE_LOAD_ADDR 13ifneq ($(CONFIG_OMAP_COMMON),) 14CONFIG_STANDALONE_LOAD_ADDR = 0x80300000 15else 16CONFIG_STANDALONE_LOAD_ADDR = 0xc100000 17endif 18endif 19 20LDFLAGS_FINAL += --gc-sections 21PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections \ 22 -fno-common -ffixed-r9 23PLATFORM_RELFLAGS += $(call cc-option, -msoft-float) \ 24 $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,)) 25 26# Support generic board on ARM 27__HAVE_ARCH_GENERIC_BOARD := y 28 29PLATFORM_CPPFLAGS += -DCONFIG_ARM -D__ARM__ 30 31# Choose between ARM/Thumb instruction sets 32ifeq ($(CONFIG_SYS_THUMB_BUILD),y) 33PF_CPPFLAGS_ARM := $(call cc-option, -mthumb -mthumb-interwork,\ 34 $(call cc-option,-marm,)\ 35 $(call cc-option,-mno-thumb-interwork,)\ 36 ) 37else 38PF_CPPFLAGS_ARM := $(call cc-option,-marm,) \ 39 $(call cc-option,-mno-thumb-interwork,) 40endif 41 42# Only test once 43ifneq ($(CONFIG_SPL_BUILD),y) 44ifeq ($(CONFIG_SYS_THUMB_BUILD),y) 45archprepare: checkthumb 46 47checkthumb: 48 @if test "$(call cc-version)" -lt "0404"; then \ 49 echo -n '*** Your GCC does not produce working '; \ 50 echo 'binaries in THUMB mode.'; \ 51 echo '*** Your board is configured for THUMB mode.'; \ 52 false; \ 53 fi 54endif 55endif 56 57# Try if EABI is supported, else fall back to old API, 58# i. e. for example: 59# - with ELDK 4.2 (EABI supported), use: 60# -mabi=aapcs-linux 61# - with ELDK 4.1 (gcc 4.x, no EABI), use: 62# -mabi=apcs-gnu 63# - with ELDK 3.1 (gcc 3.x), use: 64# -mapcs-32 65PF_CPPFLAGS_ABI := $(call cc-option,\ 66 -mabi=aapcs-linux,\ 67 $(call cc-option,\ 68 -mapcs-32,\ 69 $(call cc-option,\ 70 -mabi=apcs-gnu,\ 71 )\ 72 )\ 73 ) 74PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_ARM) $(PF_CPPFLAGS_ABI) 75 76# For EABI, make sure to provide raise() 77ifneq (,$(findstring -mabi=aapcs-linux,$(PLATFORM_CPPFLAGS))) 78# This file is parsed many times, so the string may get added multiple 79# times. Also, the prefix needs to be different based on whether 80# CONFIG_SPL_BUILD is defined or not. 'filter-out' the existing entry 81# before adding the correct one. 82PLATFORM_LIBS := arch/arm/lib/eabi_compat.o \ 83 $(filter-out arch/arm/lib/eabi_compat.o, $(PLATFORM_LIBS)) 84endif 85 86# needed for relocation 87LDFLAGS_u-boot += -pie 88 89# 90# FIXME: binutils versions < 2.22 have a bug in the assembler where 91# branches to weak symbols can be incorrectly optimized in thumb mode 92# to a short branch (b.n instruction) that won't reach when the symbol 93# gets preempted 94# 95# http://sourceware.org/bugzilla/show_bug.cgi?id=12532 96# 97ifeq ($(CONFIG_SYS_THUMB_BUILD),y) 98ifeq ($(GAS_BUG_12532),) 99export GAS_BUG_12532:=$(shell if [ $(call binutils-version) -lt 0222 ] ; \ 100 then echo y; else echo n; fi) 101endif 102ifeq ($(GAS_BUG_12532),y) 103PLATFORM_RELFLAGS += -fno-optimize-sibling-calls 104endif 105endif 106 107ifneq ($(CONFIG_SPL_BUILD),y) 108# Check that only R_ARM_RELATIVE relocations are generated. 109ALL-y += checkarmreloc 110# The movt / movw can hardcode 16 bit parts of the addresses in the 111# instruction. Relocation is not supported for that case, so disable 112# such usage by requiring word relocations. 113PLATFORM_CPPFLAGS += $(call cc-option, -mword-relocations) 114endif 115 116# limit ourselves to the sections we want in the .bin. 117ifdef CONFIG_ARM64 118OBJCOPYFLAGS += -j .text -j .rodata -j .data -j .u_boot_list -j .rela.dyn 119else 120OBJCOPYFLAGS += -j .text -j .rodata -j .hash -j .data -j .got.plt -j .u_boot_list -j .rel.dyn 121endif 122 123ifneq ($(CONFIG_IMX_CONFIG),) 124ifdef CONFIG_SPL 125ifndef CONFIG_SPL_BUILD 126ALL-y += SPL 127endif 128else 129ALL-y += u-boot.imx 130endif 131endif 132