bl31.ld.S revision e3fff153803bcf256d95e5b4d31a0c04d50ed5e4
14f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta/* 2e83b0cadc67882c1ba7f430d16dab80c9b3a0228Dan Handley * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved. 34f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta * 44f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta * Redistribution and use in source and binary forms, with or without 54f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta * modification, are permitted provided that the following conditions are met: 64f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta * 74f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta * Redistributions of source code must retain the above copyright notice, this 84f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta * list of conditions and the following disclaimer. 94f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta * 104f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta * Redistributions in binary form must reproduce the above copyright notice, 114f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta * this list of conditions and the following disclaimer in the documentation 124f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta * and/or other materials provided with the distribution. 134f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta * 144f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta * Neither the name of ARM nor the names of its contributors may be used 154f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta * to endorse or promote products derived from this software without specific 164f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta * prior written permission. 174f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta * 184f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 194f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 204f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 214f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 224f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 234f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 244f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 254f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 264f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 274f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 284f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta * POSSIBILITY OF SUCH DAMAGE. 294f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta */ 304f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta 314f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta#include <platform.h> 324f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta 334f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin GuptaOUTPUT_FORMAT(PLATFORM_LINKER_FORMAT) 344f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin GuptaOUTPUT_ARCH(PLATFORM_LINKER_ARCH) 354f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta 364f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta 374f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin GuptaMEMORY { 384f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta RAM (rwx): ORIGIN = TZRAM_BASE, LENGTH = TZRAM_SIZE 394f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta} 404f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta 414f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta 424f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin GuptaSECTIONS 434f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta{ 448d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux . = BL31_BASE; 458d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux ASSERT(. == ALIGN(4096), 468d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux "BL31_BASE address is not aligned on a page boundary.") 474f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta 488d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux ro . : { 498d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux __RO_START__ = .; 508d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux *bl31_entrypoint.o(.text) 514f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta *(.text) 528d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux *(.rodata*) 537421b4653dcfe6b10be5ca7167d2a5f3584c95c1Achin Gupta 547421b4653dcfe6b10be5ca7167d2a5f3584c95c1Achin Gupta /* Ensure 8-byte alignment for descriptors */ 557421b4653dcfe6b10be5ca7167d2a5f3584c95c1Achin Gupta . = ALIGN(8); 567421b4653dcfe6b10be5ca7167d2a5f3584c95c1Achin Gupta __RT_SVC_DESCS_START__ = .; 577421b4653dcfe6b10be5ca7167d2a5f3584c95c1Achin Gupta *(rt_svc_descs) 587421b4653dcfe6b10be5ca7167d2a5f3584c95c1Achin Gupta __RT_SVC_DESCS_END__ = .; 597421b4653dcfe6b10be5ca7167d2a5f3584c95c1Achin Gupta 60b739f22a99c96d5a295f083125505b5b5ec2f8b6Achin Gupta *(.vectors) 618d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux __RO_END_UNALIGNED__ = .; 628d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux /* 638d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux * Memory page(s) mapped to this section will be marked as read-only, 648d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux * executable. No RW data from the next section must creep in. 658d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux * Ensure the rest of the current memory page is unused. 668d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux */ 678d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux . = NEXT(4096); 688d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux __RO_END__ = .; 694f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta } >RAM 704f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta 718d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux .data . : { 728d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux __DATA_START__ = .; 738d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux *(.data) 748d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux __DATA_END__ = .; 754f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta } >RAM 764f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta 778d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux stacks (NOLOAD) : { 788d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux __STACKS_START__ = .; 798d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux *(tzfw_normal_stacks) 808d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux __STACKS_END__ = .; 814f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta } >RAM 824f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta 838d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux /* 848d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux * The .bss section gets initialised to 0 at runtime. 858d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux * Its base address must be 16-byte aligned. 868d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux */ 878d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux .bss : ALIGN(16) { 888d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux __BSS_START__ = .; 894f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta *(.bss) 904f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta *(COMMON) 918d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux __BSS_END__ = .; 924f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta } >RAM 934f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta 948d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux /* 95e3fff153803bcf256d95e5b4d31a0c04d50ed5e4Jeenu Viswambharan * The xlat_table section is for full, aligned page tables (4K). 96a0cd989dd589acaa6cddaa6617bd59dde0b8ce26Achin Gupta * Removing them from .bss avoids forcing 4K alignment on 97a0cd989dd589acaa6cddaa6617bd59dde0b8ce26Achin Gupta * the .bss section and eliminates the unecessary zero init 98a0cd989dd589acaa6cddaa6617bd59dde0b8ce26Achin Gupta */ 99a0cd989dd589acaa6cddaa6617bd59dde0b8ce26Achin Gupta xlat_table (NOLOAD) : { 100a0cd989dd589acaa6cddaa6617bd59dde0b8ce26Achin Gupta *(xlat_table) 101a0cd989dd589acaa6cddaa6617bd59dde0b8ce26Achin Gupta } >RAM 102a0cd989dd589acaa6cddaa6617bd59dde0b8ce26Achin Gupta 103a0cd989dd589acaa6cddaa6617bd59dde0b8ce26Achin Gupta /* 1048d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux * The base address of the coherent memory section must be page-aligned (4K) 1058d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux * to guarantee that the coherent data are stored on their own pages and 1068d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux * are not mixed with normal data. This is required to set up the correct 1078d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux * memory attributes for the coherent data page tables. 1088d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux */ 1098d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux coherent_ram (NOLOAD) : ALIGN(4096) { 1108d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux __COHERENT_RAM_START__ = .; 1118d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux *(tzfw_coherent_mem) 1128d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux __COHERENT_RAM_END_UNALIGNED__ = .; 1138d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux /* 1148d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux * Memory page(s) mapped to this section will be marked 1158d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux * as device memory. No other unexpected data must creep in. 1168d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux * Ensure the rest of the current memory page is unused. 1178d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux */ 1188d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux . = NEXT(4096); 1198d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux __COHERENT_RAM_END__ = .; 1204f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta } >RAM 1214f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta 1228d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux __BL31_END__ = .; 1234f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta 1248d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux __BSS_SIZE__ = SIZEOF(.bss); 1258d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux __COHERENT_RAM_UNALIGNED_SIZE__ = 1268d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__; 1274f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta 1288d69a03f6a7db3c437b7cfdd15402627277d8cb4Sandrine Bailleux ASSERT(. <= BL2_BASE, "BL31 image overlaps BL2 image.") 1294f6ad66ae9fcc8bcb3b0fcee10b7ab1ffcaf1a5Achin Gupta} 130