183d290c5STom Rini/* SPDX-License-Identifier: GPL-2.0+ */ 2dde3b70dSSimon Glass/* 3dde3b70dSSimon Glass * Copyright (c) 2004-2008 Texas Instruments 4dde3b70dSSimon Glass * 5dde3b70dSSimon Glass * (C) Copyright 2002 6dde3b70dSSimon Glass * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de> 7dde3b70dSSimon Glass */ 8dde3b70dSSimon Glass 9bf433afdSMarc Zyngier#include <config.h> 10980d6a55SChen-Yu Tsai#include <asm/psci.h> 11bf433afdSMarc Zyngier 12dde3b70dSSimon GlassOUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") 13dde3b70dSSimon GlassOUTPUT_ARCH(arm) 14dde3b70dSSimon GlassENTRY(_start) 15dde3b70dSSimon GlassSECTIONS 16dde3b70dSSimon Glass{ 17c1352119SSimon Glass#ifndef CONFIG_CMDLINE 18c1352119SSimon Glass /DISCARD/ : { *(.u_boot_list_2_cmd_*) } 19c1352119SSimon Glass#endif 20c5e954ecSWang Dongsheng#if defined(CONFIG_ARMV7_SECURE_BASE) && defined(CONFIG_ARMV7_NONSEC) 21d47cb0b6SPeng Fan /* 22c5e954ecSWang Dongsheng * If CONFIG_ARMV7_SECURE_BASE is true, secure code will not 23c5e954ecSWang Dongsheng * bundle with u-boot, and code offsets are fixed. Secure zone 24c5e954ecSWang Dongsheng * only needs to be copied from the loading address to 25c5e954ecSWang Dongsheng * CONFIG_ARMV7_SECURE_BASE, which is the linking and running 26c5e954ecSWang Dongsheng * address for secure code. 27d47cb0b6SPeng Fan * 28c5e954ecSWang Dongsheng * If CONFIG_ARMV7_SECURE_BASE is undefined, the secure zone will 29c5e954ecSWang Dongsheng * be included in u-boot address space, and some absolute address 30c5e954ecSWang Dongsheng * were used in secure code. The absolute addresses of the secure 31c5e954ecSWang Dongsheng * code also needs to be relocated along with the accompanying u-boot 32c5e954ecSWang Dongsheng * code. 33c5e954ecSWang Dongsheng * 34c5e954ecSWang Dongsheng * So DISCARD is only for CONFIG_ARMV7_SECURE_BASE. 35d47cb0b6SPeng Fan */ 36d47cb0b6SPeng Fan /DISCARD/ : { *(.rel._secure*) } 37c5e954ecSWang Dongsheng#endif 38dde3b70dSSimon Glass . = 0x00000000; 39dde3b70dSSimon Glass 40dde3b70dSSimon Glass . = ALIGN(4); 41dde3b70dSSimon Glass .text : 42dde3b70dSSimon Glass { 43d026dec8SAlbert ARIBAUD *(.__image_copy_start) 4441623c91SAlbert ARIBAUD *(.vectors) 45b68d6712SStephen Warren CPUDIR/start.o (.text*) 467e21fbcaSAlexander Graf } 477e21fbcaSAlexander Graf 487e21fbcaSAlexander Graf /* This needs to come before *(.text*) */ 497e21fbcaSAlexander Graf .__efi_runtime_start : { 507e21fbcaSAlexander Graf *(.__efi_runtime_start) 517e21fbcaSAlexander Graf } 527e21fbcaSAlexander Graf 537e21fbcaSAlexander Graf .efi_runtime : { 547e21fbcaSAlexander Graf *(.text.efi_runtime*) 557e21fbcaSAlexander Graf *(.rodata.efi_runtime*) 567e21fbcaSAlexander Graf *(.data.efi_runtime*) 577e21fbcaSAlexander Graf } 587e21fbcaSAlexander Graf 597e21fbcaSAlexander Graf .__efi_runtime_stop : { 607e21fbcaSAlexander Graf *(.__efi_runtime_stop) 617e21fbcaSAlexander Graf } 627e21fbcaSAlexander Graf 637e21fbcaSAlexander Graf .text_rest : 647e21fbcaSAlexander Graf { 65b68d6712SStephen Warren *(.text*) 66dde3b70dSSimon Glass } 67dde3b70dSSimon Glass 68104d6fb6SJan Kiszka#ifdef CONFIG_ARMV7_NONSEC 69bf433afdSMarc Zyngier 70a1274cc9SChen-Yu Tsai /* Align the secure section only if we're going to use it in situ */ 71*792b2047SChen-Yu Tsai .__secure_start 72a1274cc9SChen-Yu Tsai#ifndef CONFIG_ARMV7_SECURE_BASE 73a1274cc9SChen-Yu Tsai ALIGN(CONSTANT(COMMONPAGESIZE)) 74a1274cc9SChen-Yu Tsai#endif 75*792b2047SChen-Yu Tsai : { 76a1274cc9SChen-Yu Tsai KEEP(*(.__secure_start)) 77a1274cc9SChen-Yu Tsai } 78a1274cc9SChen-Yu Tsai 79bf433afdSMarc Zyngier#ifndef CONFIG_ARMV7_SECURE_BASE 80bf433afdSMarc Zyngier#define CONFIG_ARMV7_SECURE_BASE 81b56e06d3SChen-Yu Tsai#define __ARMV7_PSCI_STACK_IN_RAM 82bf433afdSMarc Zyngier#endif 83bf433afdSMarc Zyngier 84bf433afdSMarc Zyngier .secure_text CONFIG_ARMV7_SECURE_BASE : 85bf433afdSMarc Zyngier AT(ADDR(.__secure_start) + SIZEOF(.__secure_start)) 86bf433afdSMarc Zyngier { 87bf433afdSMarc Zyngier *(._secure.text) 88bf433afdSMarc Zyngier } 89bf433afdSMarc Zyngier 90a5aa7ff3SChen-Yu Tsai .secure_data : AT(LOADADDR(.secure_text) + SIZEOF(.secure_text)) 91a5aa7ff3SChen-Yu Tsai { 92a5aa7ff3SChen-Yu Tsai *(._secure.data) 93a5aa7ff3SChen-Yu Tsai } 94a5aa7ff3SChen-Yu Tsai 952fe1281cSMasahiro Yamada#ifdef CONFIG_ARMV7_PSCI 96a5aa7ff3SChen-Yu Tsai .secure_stack ALIGN(ADDR(.secure_data) + SIZEOF(.secure_data), 97980d6a55SChen-Yu Tsai CONSTANT(COMMONPAGESIZE)) (NOLOAD) : 98b56e06d3SChen-Yu Tsai#ifdef __ARMV7_PSCI_STACK_IN_RAM 99980d6a55SChen-Yu Tsai AT(ADDR(.secure_stack)) 100980d6a55SChen-Yu Tsai#else 101a5aa7ff3SChen-Yu Tsai AT(LOADADDR(.secure_data) + SIZEOF(.secure_data)) 102980d6a55SChen-Yu Tsai#endif 103980d6a55SChen-Yu Tsai { 104980d6a55SChen-Yu Tsai KEEP(*(.__secure_stack_start)) 1052fe1281cSMasahiro Yamada 106980d6a55SChen-Yu Tsai /* Skip addreses for stack */ 107980d6a55SChen-Yu Tsai . = . + CONFIG_ARMV7_PSCI_NR_CPUS * ARM_PSCI_STACK_SIZE; 1082fe1281cSMasahiro Yamada 109980d6a55SChen-Yu Tsai /* Align end of stack section to page boundary */ 110980d6a55SChen-Yu Tsai . = ALIGN(CONSTANT(COMMONPAGESIZE)); 111980d6a55SChen-Yu Tsai 112980d6a55SChen-Yu Tsai KEEP(*(.__secure_stack_end)) 1133eff6818SChen-Yu Tsai 1143eff6818SChen-Yu Tsai#ifdef CONFIG_ARMV7_SECURE_MAX_SIZE 1153eff6818SChen-Yu Tsai /* 1163eff6818SChen-Yu Tsai * We are not checking (__secure_end - __secure_start) here, 1173eff6818SChen-Yu Tsai * as these are the load addresses, and do not include the 1183eff6818SChen-Yu Tsai * stack section. Instead, use the end of the stack section 1193eff6818SChen-Yu Tsai * and the start of the text section. 1203eff6818SChen-Yu Tsai */ 1213eff6818SChen-Yu Tsai ASSERT((. - ADDR(.secure_text)) <= CONFIG_ARMV7_SECURE_MAX_SIZE, 1223eff6818SChen-Yu Tsai "Error: secure section exceeds secure memory size"); 1233eff6818SChen-Yu Tsai#endif 124980d6a55SChen-Yu Tsai } 125980d6a55SChen-Yu Tsai 126980d6a55SChen-Yu Tsai#ifndef __ARMV7_PSCI_STACK_IN_RAM 127980d6a55SChen-Yu Tsai /* Reset VMA but don't allocate space if we have secure SRAM */ 128980d6a55SChen-Yu Tsai . = LOADADDR(.secure_stack); 129b56e06d3SChen-Yu Tsai#endif 130b56e06d3SChen-Yu Tsai 1312fe1281cSMasahiro Yamada#endif 1322fe1281cSMasahiro Yamada 133980d6a55SChen-Yu Tsai .__secure_end : AT(ADDR(.__secure_end)) { 134bf433afdSMarc Zyngier *(.__secure_end) 135bf433afdSMarc Zyngier LONG(0x1d1071c); /* Must output something to reset LMA */ 136bf433afdSMarc Zyngier } 137bf433afdSMarc Zyngier#endif 138bf433afdSMarc Zyngier 139dde3b70dSSimon Glass . = ALIGN(4); 140dde3b70dSSimon Glass .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) } 141dde3b70dSSimon Glass 142dde3b70dSSimon Glass . = ALIGN(4); 143dde3b70dSSimon Glass .data : { 144b68d6712SStephen Warren *(.data*) 145dde3b70dSSimon Glass } 146dde3b70dSSimon Glass 147dde3b70dSSimon Glass . = ALIGN(4); 148dde3b70dSSimon Glass 149dde3b70dSSimon Glass . = .; 150dde3b70dSSimon Glass 151dde3b70dSSimon Glass . = ALIGN(4); 15255675142SMarek Vasut .u_boot_list : { 153ef123c52SAlbert ARIBAUD KEEP(*(SORT(.u_boot_list*))); 15455675142SMarek Vasut } 15555675142SMarek Vasut 15655675142SMarek Vasut . = ALIGN(4); 157dde3b70dSSimon Glass 15850149ea3SAlexander Graf .efi_runtime_rel_start : 15950149ea3SAlexander Graf { 16050149ea3SAlexander Graf *(.__efi_runtime_rel_start) 16150149ea3SAlexander Graf } 16250149ea3SAlexander Graf 16350149ea3SAlexander Graf .efi_runtime_rel : { 1647e21fbcaSAlexander Graf *(.rel*.efi_runtime) 1657e21fbcaSAlexander Graf *(.rel*.efi_runtime.*) 16650149ea3SAlexander Graf } 16750149ea3SAlexander Graf 16850149ea3SAlexander Graf .efi_runtime_rel_stop : 16950149ea3SAlexander Graf { 17050149ea3SAlexander Graf *(.__efi_runtime_rel_stop) 17150149ea3SAlexander Graf } 17250149ea3SAlexander Graf 17383ebd4a6STom Rini . = ALIGN(4); 17450149ea3SAlexander Graf 175d026dec8SAlbert ARIBAUD .image_copy_end : 176d026dec8SAlbert ARIBAUD { 177d026dec8SAlbert ARIBAUD *(.__image_copy_end) 178d026dec8SAlbert ARIBAUD } 179dde3b70dSSimon Glass 18047bd65efSAlbert ARIBAUD .rel_dyn_start : 18147bd65efSAlbert ARIBAUD { 18247bd65efSAlbert ARIBAUD *(.__rel_dyn_start) 18347bd65efSAlbert ARIBAUD } 18447bd65efSAlbert ARIBAUD 185dde3b70dSSimon Glass .rel.dyn : { 186dde3b70dSSimon Glass *(.rel*) 18747bd65efSAlbert ARIBAUD } 18847bd65efSAlbert ARIBAUD 18947bd65efSAlbert ARIBAUD .rel_dyn_end : 19047bd65efSAlbert ARIBAUD { 19147bd65efSAlbert ARIBAUD *(.__rel_dyn_end) 192dde3b70dSSimon Glass } 193dde3b70dSSimon Glass 194d0b5d9daSAlbert ARIBAUD .end : 195d0b5d9daSAlbert ARIBAUD { 196d0b5d9daSAlbert ARIBAUD *(.__end) 197d0b5d9daSAlbert ARIBAUD } 198d0b5d9daSAlbert ARIBAUD 199d0b5d9daSAlbert ARIBAUD _image_binary_end = .; 200dde3b70dSSimon Glass 201dde3b70dSSimon Glass /* 202dde3b70dSSimon Glass * Deprecated: this MMU section is used by pxa at present but 203dde3b70dSSimon Glass * should not be used by new boards/CPUs. 204dde3b70dSSimon Glass */ 205dde3b70dSSimon Glass . = ALIGN(4096); 206dde3b70dSSimon Glass .mmutable : { 207dde3b70dSSimon Glass *(.mmutable) 208dde3b70dSSimon Glass } 209dde3b70dSSimon Glass 210f84a7b8fSAlbert ARIBAUD/* 211f84a7b8fSAlbert ARIBAUD * Compiler-generated __bss_start and __bss_end, see arch/arm/lib/bss.c 212f84a7b8fSAlbert ARIBAUD * __bss_base and __bss_limit are for linker only (overlay ordering) 213f84a7b8fSAlbert ARIBAUD */ 214f84a7b8fSAlbert ARIBAUD 2153ebd1cbcSAlbert ARIBAUD .bss_start __rel_dyn_start (OVERLAY) : { 2163ebd1cbcSAlbert ARIBAUD KEEP(*(.__bss_start)); 217f84a7b8fSAlbert ARIBAUD __bss_base = .; 2183ebd1cbcSAlbert ARIBAUD } 2193ebd1cbcSAlbert ARIBAUD 220f84a7b8fSAlbert ARIBAUD .bss __bss_base (OVERLAY) : { 221b68d6712SStephen Warren *(.bss*) 222dde3b70dSSimon Glass . = ALIGN(4); 223f84a7b8fSAlbert ARIBAUD __bss_limit = .; 224dde3b70dSSimon Glass } 225dde3b70dSSimon Glass 226f84a7b8fSAlbert ARIBAUD .bss_end __bss_limit (OVERLAY) : { 227f84a7b8fSAlbert ARIBAUD KEEP(*(.__bss_end)); 228dde3b70dSSimon Glass } 229dde3b70dSSimon Glass 230d0b5d9daSAlbert ARIBAUD .dynsym _image_binary_end : { *(.dynsym) } 23147ed5dd0SAlbert ARIBAUD .dynbss : { *(.dynbss) } 23247ed5dd0SAlbert ARIBAUD .dynstr : { *(.dynstr*) } 23347ed5dd0SAlbert ARIBAUD .dynamic : { *(.dynamic*) } 23447ed5dd0SAlbert ARIBAUD .plt : { *(.plt*) } 23547ed5dd0SAlbert ARIBAUD .interp : { *(.interp*) } 2362c67e0e7SAndreas Färber .gnu.hash : { *(.gnu.hash) } 23747ed5dd0SAlbert ARIBAUD .gnu : { *(.gnu*) } 23847ed5dd0SAlbert ARIBAUD .ARM.exidx : { *(.ARM.exidx*) } 239b02bfc4dSAlbert ARIBAUD .gnu.linkonce.armexidx : { *(.gnu.linkonce.armexidx.*) } 240dde3b70dSSimon Glass} 241