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