14f6ad66aSAchin Gupta/* 2308d359bSDouglas Raillard * Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved. 34f6ad66aSAchin Gupta * 44f6ad66aSAchin Gupta * Redistribution and use in source and binary forms, with or without 54f6ad66aSAchin Gupta * modification, are permitted provided that the following conditions are met: 64f6ad66aSAchin Gupta * 74f6ad66aSAchin Gupta * Redistributions of source code must retain the above copyright notice, this 84f6ad66aSAchin Gupta * list of conditions and the following disclaimer. 94f6ad66aSAchin Gupta * 104f6ad66aSAchin Gupta * Redistributions in binary form must reproduce the above copyright notice, 114f6ad66aSAchin Gupta * this list of conditions and the following disclaimer in the documentation 124f6ad66aSAchin Gupta * and/or other materials provided with the distribution. 134f6ad66aSAchin Gupta * 144f6ad66aSAchin Gupta * Neither the name of ARM nor the names of its contributors may be used 154f6ad66aSAchin Gupta * to endorse or promote products derived from this software without specific 164f6ad66aSAchin Gupta * prior written permission. 174f6ad66aSAchin Gupta * 184f6ad66aSAchin Gupta * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 194f6ad66aSAchin Gupta * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 204f6ad66aSAchin Gupta * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 214f6ad66aSAchin Gupta * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 224f6ad66aSAchin Gupta * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 234f6ad66aSAchin Gupta * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 244f6ad66aSAchin Gupta * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 254f6ad66aSAchin Gupta * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 264f6ad66aSAchin Gupta * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 274f6ad66aSAchin Gupta * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 284f6ad66aSAchin Gupta * POSSIBILITY OF SUCH DAMAGE. 294f6ad66aSAchin Gupta */ 304f6ad66aSAchin Gupta 315f0cdb05SDan Handley#include <platform_def.h> 324f6ad66aSAchin Gupta 334f6ad66aSAchin GuptaOUTPUT_FORMAT(PLATFORM_LINKER_FORMAT) 344f6ad66aSAchin GuptaOUTPUT_ARCH(PLATFORM_LINKER_ARCH) 359f98aa1aSJeenu ViswambharanENTRY(bl2_entrypoint) 364f6ad66aSAchin Gupta 374f6ad66aSAchin GuptaMEMORY { 38d7fbf132SJuan Castillo RAM (rwx): ORIGIN = BL2_BASE, LENGTH = BL2_LIMIT - BL2_BASE 394f6ad66aSAchin Gupta} 404f6ad66aSAchin Gupta 414f6ad66aSAchin Gupta 424f6ad66aSAchin GuptaSECTIONS 434f6ad66aSAchin Gupta{ 444f6ad66aSAchin Gupta . = BL2_BASE; 458d69a03fSSandrine Bailleux ASSERT(. == ALIGN(4096), 468d69a03fSSandrine Bailleux "BL2_BASE address is not aligned on a page boundary.") 474f6ad66aSAchin Gupta 485d1c104fSSandrine Bailleux#if SEPARATE_CODE_AND_RODATA 495d1c104fSSandrine Bailleux .text . : { 505d1c104fSSandrine Bailleux __TEXT_START__ = .; 515d1c104fSSandrine Bailleux *bl2_entrypoint.o(.text*) 525d1c104fSSandrine Bailleux *(.text*) 535d1c104fSSandrine Bailleux *(.vectors) 545d1c104fSSandrine Bailleux . = NEXT(4096); 555d1c104fSSandrine Bailleux __TEXT_END__ = .; 565d1c104fSSandrine Bailleux } >RAM 575d1c104fSSandrine Bailleux 585d1c104fSSandrine Bailleux .rodata . : { 595d1c104fSSandrine Bailleux __RODATA_START__ = .; 605d1c104fSSandrine Bailleux *(.rodata*) 615d1c104fSSandrine Bailleux 625d1c104fSSandrine Bailleux /* Ensure 8-byte alignment for descriptors and ensure inclusion */ 635d1c104fSSandrine Bailleux . = ALIGN(8); 645d1c104fSSandrine Bailleux __PARSER_LIB_DESCS_START__ = .; 655d1c104fSSandrine Bailleux KEEP(*(.img_parser_lib_descs)) 665d1c104fSSandrine Bailleux __PARSER_LIB_DESCS_END__ = .; 675d1c104fSSandrine Bailleux 685d1c104fSSandrine Bailleux . = NEXT(4096); 695d1c104fSSandrine Bailleux __RODATA_END__ = .; 705d1c104fSSandrine Bailleux } >RAM 715d1c104fSSandrine Bailleux#else 728d69a03fSSandrine Bailleux ro . : { 738d69a03fSSandrine Bailleux __RO_START__ = .; 74dccc537aSAndrew Thoelke *bl2_entrypoint.o(.text*) 75dccc537aSAndrew Thoelke *(.text*) 768d69a03fSSandrine Bailleux *(.rodata*) 7705799ae0SJuan Castillo 7805799ae0SJuan Castillo /* Ensure 8-byte alignment for descriptors and ensure inclusion */ 7905799ae0SJuan Castillo . = ALIGN(8); 8005799ae0SJuan Castillo __PARSER_LIB_DESCS_START__ = .; 8105799ae0SJuan Castillo KEEP(*(.img_parser_lib_descs)) 8205799ae0SJuan Castillo __PARSER_LIB_DESCS_END__ = .; 8305799ae0SJuan Castillo 84b739f22aSAchin Gupta *(.vectors) 858d69a03fSSandrine Bailleux __RO_END_UNALIGNED__ = .; 868d69a03fSSandrine Bailleux /* 878d69a03fSSandrine Bailleux * Memory page(s) mapped to this section will be marked as 888d69a03fSSandrine Bailleux * read-only, executable. No RW data from the next section must 898d69a03fSSandrine Bailleux * creep in. Ensure the rest of the current memory page is unused. 908d69a03fSSandrine Bailleux */ 914f6ad66aSAchin Gupta . = NEXT(4096); 928d69a03fSSandrine Bailleux __RO_END__ = .; 934f6ad66aSAchin Gupta } >RAM 945d1c104fSSandrine Bailleux#endif 954f6ad66aSAchin Gupta 9654dc71e7SAchin Gupta /* 9754dc71e7SAchin Gupta * Define a linker symbol to mark start of the RW memory area for this 9854dc71e7SAchin Gupta * image. 9954dc71e7SAchin Gupta */ 10054dc71e7SAchin Gupta __RW_START__ = . ; 10154dc71e7SAchin Gupta 102*51faada7SDouglas Raillard /* 103*51faada7SDouglas Raillard * .data must be placed at a lower address than the stacks if the stack 104*51faada7SDouglas Raillard * protector is enabled. Alternatively, the .data.stack_protector_canary 105*51faada7SDouglas Raillard * section can be placed independently of the main .data section. 106*51faada7SDouglas Raillard */ 1078d69a03fSSandrine Bailleux .data . : { 1088d69a03fSSandrine Bailleux __DATA_START__ = .; 109dccc537aSAndrew Thoelke *(.data*) 1108d69a03fSSandrine Bailleux __DATA_END__ = .; 1118d69a03fSSandrine Bailleux } >RAM 1128d69a03fSSandrine Bailleux 1138d69a03fSSandrine Bailleux stacks (NOLOAD) : { 1148d69a03fSSandrine Bailleux __STACKS_START__ = .; 1158d69a03fSSandrine Bailleux *(tzfw_normal_stacks) 1168d69a03fSSandrine Bailleux __STACKS_END__ = .; 1178d69a03fSSandrine Bailleux } >RAM 1188d69a03fSSandrine Bailleux 1198d69a03fSSandrine Bailleux /* 1208d69a03fSSandrine Bailleux * The .bss section gets initialised to 0 at runtime. 121308d359bSDouglas Raillard * Its base address should be 16-byte aligned for better performance of the 122308d359bSDouglas Raillard * zero-initialization code. 1238d69a03fSSandrine Bailleux */ 1248d69a03fSSandrine Bailleux .bss : ALIGN(16) { 1258d69a03fSSandrine Bailleux __BSS_START__ = .; 126dccc537aSAndrew Thoelke *(SORT_BY_ALIGNMENT(.bss*)) 1274f6ad66aSAchin Gupta *(COMMON) 1288d69a03fSSandrine Bailleux __BSS_END__ = .; 1294f6ad66aSAchin Gupta } >RAM 1304f6ad66aSAchin Gupta 1318d69a03fSSandrine Bailleux /* 132e3fff153SJeenu Viswambharan * The xlat_table section is for full, aligned page tables (4K). 133a0cd989dSAchin Gupta * Removing them from .bss avoids forcing 4K alignment on 134a0cd989dSAchin Gupta * the .bss section and eliminates the unecessary zero init 135a0cd989dSAchin Gupta */ 136a0cd989dSAchin Gupta xlat_table (NOLOAD) : { 137a0cd989dSAchin Gupta *(xlat_table) 138a0cd989dSAchin Gupta } >RAM 139a0cd989dSAchin Gupta 140ab8707e6SSoby Mathew#if USE_COHERENT_MEM 141a0cd989dSAchin Gupta /* 1428d69a03fSSandrine Bailleux * The base address of the coherent memory section must be page-aligned (4K) 1438d69a03fSSandrine Bailleux * to guarantee that the coherent data are stored on their own pages and 1448d69a03fSSandrine Bailleux * are not mixed with normal data. This is required to set up the correct 1458d69a03fSSandrine Bailleux * memory attributes for the coherent data page tables. 1468d69a03fSSandrine Bailleux */ 1478d69a03fSSandrine Bailleux coherent_ram (NOLOAD) : ALIGN(4096) { 1488d69a03fSSandrine Bailleux __COHERENT_RAM_START__ = .; 1498d69a03fSSandrine Bailleux *(tzfw_coherent_mem) 1508d69a03fSSandrine Bailleux __COHERENT_RAM_END_UNALIGNED__ = .; 1518d69a03fSSandrine Bailleux /* 1528d69a03fSSandrine Bailleux * Memory page(s) mapped to this section will be marked 1538d69a03fSSandrine Bailleux * as device memory. No other unexpected data must creep in. 1548d69a03fSSandrine Bailleux * Ensure the rest of the current memory page is unused. 1558d69a03fSSandrine Bailleux */ 1568d69a03fSSandrine Bailleux . = NEXT(4096); 1578d69a03fSSandrine Bailleux __COHERENT_RAM_END__ = .; 1584f6ad66aSAchin Gupta } >RAM 159ab8707e6SSoby Mathew#endif 1604f6ad66aSAchin Gupta 16154dc71e7SAchin Gupta /* 16254dc71e7SAchin Gupta * Define a linker symbol to mark end of the RW memory area for this 16354dc71e7SAchin Gupta * image. 16454dc71e7SAchin Gupta */ 16554dc71e7SAchin Gupta __RW_END__ = .; 1668d69a03fSSandrine Bailleux __BL2_END__ = .; 1674f6ad66aSAchin Gupta 1688d69a03fSSandrine Bailleux __BSS_SIZE__ = SIZEOF(.bss); 169ab8707e6SSoby Mathew 170ab8707e6SSoby Mathew#if USE_COHERENT_MEM 1718d69a03fSSandrine Bailleux __COHERENT_RAM_UNALIGNED_SIZE__ = 1728d69a03fSSandrine Bailleux __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__; 173ab8707e6SSoby Mathew#endif 174a37255a2SSandrine Bailleux 175a37255a2SSandrine Bailleux ASSERT(. <= BL2_LIMIT, "BL2 image has exceeded its limit.") 1764f6ad66aSAchin Gupta} 177