14f6ad66aSAchin Gupta/* 2883d1b5dSAntonio Nino Diaz * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved. 34f6ad66aSAchin Gupta * 482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause 54f6ad66aSAchin Gupta */ 64f6ad66aSAchin Gupta 75f0cdb05SDan Handley#include <platform_def.h> 8a2aedac2SAntonio Nino Diaz#include <xlat_tables_defs.h> 94f6ad66aSAchin Gupta 104f6ad66aSAchin GuptaOUTPUT_FORMAT(PLATFORM_LINKER_FORMAT) 114f6ad66aSAchin GuptaOUTPUT_ARCH(PLATFORM_LINKER_ARCH) 129f98aa1aSJeenu ViswambharanENTRY(bl2_entrypoint) 134f6ad66aSAchin Gupta 144f6ad66aSAchin GuptaMEMORY { 15d7fbf132SJuan Castillo RAM (rwx): ORIGIN = BL2_BASE, LENGTH = BL2_LIMIT - BL2_BASE 164f6ad66aSAchin Gupta} 174f6ad66aSAchin Gupta 184f6ad66aSAchin Gupta 194f6ad66aSAchin GuptaSECTIONS 204f6ad66aSAchin Gupta{ 214f6ad66aSAchin Gupta . = BL2_BASE; 22a2aedac2SAntonio Nino Diaz ASSERT(. == ALIGN(PAGE_SIZE), 238d69a03fSSandrine Bailleux "BL2_BASE address is not aligned on a page boundary.") 244f6ad66aSAchin Gupta 255d1c104fSSandrine Bailleux#if SEPARATE_CODE_AND_RODATA 265d1c104fSSandrine Bailleux .text . : { 275d1c104fSSandrine Bailleux __TEXT_START__ = .; 285d1c104fSSandrine Bailleux *bl2_entrypoint.o(.text*) 295d1c104fSSandrine Bailleux *(.text*) 305d1c104fSSandrine Bailleux *(.vectors) 31*5629b2b1SRoberto Vargas . = ALIGN(PAGE_SIZE); 325d1c104fSSandrine Bailleux __TEXT_END__ = .; 335d1c104fSSandrine Bailleux } >RAM 345d1c104fSSandrine Bailleux 355d1c104fSSandrine Bailleux .rodata . : { 365d1c104fSSandrine Bailleux __RODATA_START__ = .; 375d1c104fSSandrine Bailleux *(.rodata*) 385d1c104fSSandrine Bailleux 395d1c104fSSandrine Bailleux /* Ensure 8-byte alignment for descriptors and ensure inclusion */ 405d1c104fSSandrine Bailleux . = ALIGN(8); 415d1c104fSSandrine Bailleux __PARSER_LIB_DESCS_START__ = .; 425d1c104fSSandrine Bailleux KEEP(*(.img_parser_lib_descs)) 435d1c104fSSandrine Bailleux __PARSER_LIB_DESCS_END__ = .; 445d1c104fSSandrine Bailleux 45*5629b2b1SRoberto Vargas . = ALIGN(PAGE_SIZE); 465d1c104fSSandrine Bailleux __RODATA_END__ = .; 475d1c104fSSandrine Bailleux } >RAM 485d1c104fSSandrine Bailleux#else 498d69a03fSSandrine Bailleux ro . : { 508d69a03fSSandrine Bailleux __RO_START__ = .; 51dccc537aSAndrew Thoelke *bl2_entrypoint.o(.text*) 52dccc537aSAndrew Thoelke *(.text*) 538d69a03fSSandrine Bailleux *(.rodata*) 5405799ae0SJuan Castillo 5505799ae0SJuan Castillo /* Ensure 8-byte alignment for descriptors and ensure inclusion */ 5605799ae0SJuan Castillo . = ALIGN(8); 5705799ae0SJuan Castillo __PARSER_LIB_DESCS_START__ = .; 5805799ae0SJuan Castillo KEEP(*(.img_parser_lib_descs)) 5905799ae0SJuan Castillo __PARSER_LIB_DESCS_END__ = .; 6005799ae0SJuan Castillo 61b739f22aSAchin Gupta *(.vectors) 628d69a03fSSandrine Bailleux __RO_END_UNALIGNED__ = .; 638d69a03fSSandrine Bailleux /* 648d69a03fSSandrine Bailleux * Memory page(s) mapped to this section will be marked as 658d69a03fSSandrine Bailleux * read-only, executable. No RW data from the next section must 668d69a03fSSandrine Bailleux * creep in. Ensure the rest of the current memory page is unused. 678d69a03fSSandrine Bailleux */ 68*5629b2b1SRoberto Vargas . = ALIGN(PAGE_SIZE); 698d69a03fSSandrine Bailleux __RO_END__ = .; 704f6ad66aSAchin Gupta } >RAM 715d1c104fSSandrine Bailleux#endif 724f6ad66aSAchin Gupta 7354dc71e7SAchin Gupta /* 7454dc71e7SAchin Gupta * Define a linker symbol to mark start of the RW memory area for this 7554dc71e7SAchin Gupta * image. 7654dc71e7SAchin Gupta */ 7754dc71e7SAchin Gupta __RW_START__ = . ; 7854dc71e7SAchin Gupta 7951faada7SDouglas Raillard /* 8051faada7SDouglas Raillard * .data must be placed at a lower address than the stacks if the stack 8151faada7SDouglas Raillard * protector is enabled. Alternatively, the .data.stack_protector_canary 8251faada7SDouglas Raillard * section can be placed independently of the main .data section. 8351faada7SDouglas Raillard */ 848d69a03fSSandrine Bailleux .data . : { 858d69a03fSSandrine Bailleux __DATA_START__ = .; 86dccc537aSAndrew Thoelke *(.data*) 878d69a03fSSandrine Bailleux __DATA_END__ = .; 888d69a03fSSandrine Bailleux } >RAM 898d69a03fSSandrine Bailleux 908d69a03fSSandrine Bailleux stacks (NOLOAD) : { 918d69a03fSSandrine Bailleux __STACKS_START__ = .; 928d69a03fSSandrine Bailleux *(tzfw_normal_stacks) 938d69a03fSSandrine Bailleux __STACKS_END__ = .; 948d69a03fSSandrine Bailleux } >RAM 958d69a03fSSandrine Bailleux 968d69a03fSSandrine Bailleux /* 978d69a03fSSandrine Bailleux * The .bss section gets initialised to 0 at runtime. 98308d359bSDouglas Raillard * Its base address should be 16-byte aligned for better performance of the 99308d359bSDouglas Raillard * zero-initialization code. 1008d69a03fSSandrine Bailleux */ 1018d69a03fSSandrine Bailleux .bss : ALIGN(16) { 1028d69a03fSSandrine Bailleux __BSS_START__ = .; 103dccc537aSAndrew Thoelke *(SORT_BY_ALIGNMENT(.bss*)) 1044f6ad66aSAchin Gupta *(COMMON) 1058d69a03fSSandrine Bailleux __BSS_END__ = .; 1064f6ad66aSAchin Gupta } >RAM 1074f6ad66aSAchin Gupta 1088d69a03fSSandrine Bailleux /* 109e3fff153SJeenu Viswambharan * The xlat_table section is for full, aligned page tables (4K). 110a0cd989dSAchin Gupta * Removing them from .bss avoids forcing 4K alignment on 111883d1b5dSAntonio Nino Diaz * the .bss section. The tables are initialized to zero by the translation 112883d1b5dSAntonio Nino Diaz * tables library. 113a0cd989dSAchin Gupta */ 114a0cd989dSAchin Gupta xlat_table (NOLOAD) : { 115a0cd989dSAchin Gupta *(xlat_table) 116a0cd989dSAchin Gupta } >RAM 117a0cd989dSAchin Gupta 118ab8707e6SSoby Mathew#if USE_COHERENT_MEM 119a0cd989dSAchin Gupta /* 1208d69a03fSSandrine Bailleux * The base address of the coherent memory section must be page-aligned (4K) 1218d69a03fSSandrine Bailleux * to guarantee that the coherent data are stored on their own pages and 1228d69a03fSSandrine Bailleux * are not mixed with normal data. This is required to set up the correct 1238d69a03fSSandrine Bailleux * memory attributes for the coherent data page tables. 1248d69a03fSSandrine Bailleux */ 125a2aedac2SAntonio Nino Diaz coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) { 1268d69a03fSSandrine Bailleux __COHERENT_RAM_START__ = .; 1278d69a03fSSandrine Bailleux *(tzfw_coherent_mem) 1288d69a03fSSandrine Bailleux __COHERENT_RAM_END_UNALIGNED__ = .; 1298d69a03fSSandrine Bailleux /* 1308d69a03fSSandrine Bailleux * Memory page(s) mapped to this section will be marked 1318d69a03fSSandrine Bailleux * as device memory. No other unexpected data must creep in. 1328d69a03fSSandrine Bailleux * Ensure the rest of the current memory page is unused. 1338d69a03fSSandrine Bailleux */ 134*5629b2b1SRoberto Vargas . = ALIGN(PAGE_SIZE); 1358d69a03fSSandrine Bailleux __COHERENT_RAM_END__ = .; 1364f6ad66aSAchin Gupta } >RAM 137ab8707e6SSoby Mathew#endif 1384f6ad66aSAchin Gupta 13954dc71e7SAchin Gupta /* 14054dc71e7SAchin Gupta * Define a linker symbol to mark end of the RW memory area for this 14154dc71e7SAchin Gupta * image. 14254dc71e7SAchin Gupta */ 14354dc71e7SAchin Gupta __RW_END__ = .; 1448d69a03fSSandrine Bailleux __BL2_END__ = .; 1454f6ad66aSAchin Gupta 1468d69a03fSSandrine Bailleux __BSS_SIZE__ = SIZEOF(.bss); 147ab8707e6SSoby Mathew 148ab8707e6SSoby Mathew#if USE_COHERENT_MEM 1498d69a03fSSandrine Bailleux __COHERENT_RAM_UNALIGNED_SIZE__ = 1508d69a03fSSandrine Bailleux __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__; 151ab8707e6SSoby Mathew#endif 152a37255a2SSandrine Bailleux 153a37255a2SSandrine Bailleux ASSERT(. <= BL2_LIMIT, "BL2 image has exceeded its limit.") 1544f6ad66aSAchin Gupta} 155