14f6ad66aSAchin Gupta/* 2ab1981dbSLouis Mayencourt * Copyright (c) 2013-2020, ARM Limited and Contributors. All rights reserved. 34f6ad66aSAchin Gupta * 482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause 54f6ad66aSAchin Gupta */ 64f6ad66aSAchin Gupta 7665e71b8SMasahiro Yamada#include <common/bl_common.ld.h> 809d40e0eSAntonio Nino Diaz#include <lib/xlat_tables/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*) 29ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.text*)) 305d1c104fSSandrine Bailleux *(.vectors) 315629b2b1SRoberto Vargas . = ALIGN(PAGE_SIZE); 325d1c104fSSandrine Bailleux __TEXT_END__ = .; 335d1c104fSSandrine Bailleux } >RAM 345d1c104fSSandrine Bailleux 35ad925094SRoberto Vargas /* .ARM.extab and .ARM.exidx are only added because Clang need them */ 36ad925094SRoberto Vargas .ARM.extab . : { 37ad925094SRoberto Vargas *(.ARM.extab* .gnu.linkonce.armextab.*) 38ad925094SRoberto Vargas } >RAM 39ad925094SRoberto Vargas 40ad925094SRoberto Vargas .ARM.exidx . : { 41ad925094SRoberto Vargas *(.ARM.exidx* .gnu.linkonce.armexidx.*) 42ad925094SRoberto Vargas } >RAM 43ad925094SRoberto Vargas 445d1c104fSSandrine Bailleux .rodata . : { 455d1c104fSSandrine Bailleux __RODATA_START__ = .; 46ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.rodata*)) 475d1c104fSSandrine Bailleux 48*0a0a7a9aSMasahiro Yamada RODATA_COMMON 495d1c104fSSandrine Bailleux 505629b2b1SRoberto Vargas . = ALIGN(PAGE_SIZE); 515d1c104fSSandrine Bailleux __RODATA_END__ = .; 525d1c104fSSandrine Bailleux } >RAM 535d1c104fSSandrine Bailleux#else 548d69a03fSSandrine Bailleux ro . : { 558d69a03fSSandrine Bailleux __RO_START__ = .; 56dccc537aSAndrew Thoelke *bl2_entrypoint.o(.text*) 57ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.text*)) 58ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.rodata*)) 5905799ae0SJuan Castillo 60*0a0a7a9aSMasahiro Yamada RODATA_COMMON 6105799ae0SJuan Castillo 62b739f22aSAchin Gupta *(.vectors) 638d69a03fSSandrine Bailleux __RO_END_UNALIGNED__ = .; 648d69a03fSSandrine Bailleux /* 658d69a03fSSandrine Bailleux * Memory page(s) mapped to this section will be marked as 668d69a03fSSandrine Bailleux * read-only, executable. No RW data from the next section must 678d69a03fSSandrine Bailleux * creep in. Ensure the rest of the current memory page is unused. 688d69a03fSSandrine Bailleux */ 695629b2b1SRoberto Vargas . = ALIGN(PAGE_SIZE); 708d69a03fSSandrine Bailleux __RO_END__ = .; 714f6ad66aSAchin Gupta } >RAM 725d1c104fSSandrine Bailleux#endif 734f6ad66aSAchin Gupta 7454dc71e7SAchin Gupta /* 7554dc71e7SAchin Gupta * Define a linker symbol to mark start of the RW memory area for this 7654dc71e7SAchin Gupta * image. 7754dc71e7SAchin Gupta */ 7854dc71e7SAchin Gupta __RW_START__ = . ; 7954dc71e7SAchin Gupta 8051faada7SDouglas Raillard /* 8151faada7SDouglas Raillard * .data must be placed at a lower address than the stacks if the stack 8251faada7SDouglas Raillard * protector is enabled. Alternatively, the .data.stack_protector_canary 8351faada7SDouglas Raillard * section can be placed independently of the main .data section. 8451faada7SDouglas Raillard */ 858d69a03fSSandrine Bailleux .data . : { 868d69a03fSSandrine Bailleux __DATA_START__ = .; 87ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.data*)) 888d69a03fSSandrine Bailleux __DATA_END__ = .; 898d69a03fSSandrine Bailleux } >RAM 908d69a03fSSandrine Bailleux 918d69a03fSSandrine Bailleux stacks (NOLOAD) : { 928d69a03fSSandrine Bailleux __STACKS_START__ = .; 938d69a03fSSandrine Bailleux *(tzfw_normal_stacks) 948d69a03fSSandrine Bailleux __STACKS_END__ = .; 958d69a03fSSandrine Bailleux } >RAM 968d69a03fSSandrine Bailleux 978d69a03fSSandrine Bailleux /* 988d69a03fSSandrine Bailleux * The .bss section gets initialised to 0 at runtime. 99308d359bSDouglas Raillard * Its base address should be 16-byte aligned for better performance of the 100308d359bSDouglas Raillard * zero-initialization code. 1018d69a03fSSandrine Bailleux */ 1028d69a03fSSandrine Bailleux .bss : ALIGN(16) { 1038d69a03fSSandrine Bailleux __BSS_START__ = .; 104dccc537aSAndrew Thoelke *(SORT_BY_ALIGNMENT(.bss*)) 1054f6ad66aSAchin Gupta *(COMMON) 1068d69a03fSSandrine Bailleux __BSS_END__ = .; 1074f6ad66aSAchin Gupta } >RAM 1084f6ad66aSAchin Gupta 109665e71b8SMasahiro Yamada XLAT_TABLE_SECTION >RAM 110a0cd989dSAchin Gupta 111ab8707e6SSoby Mathew#if USE_COHERENT_MEM 112a0cd989dSAchin Gupta /* 1138d69a03fSSandrine Bailleux * The base address of the coherent memory section must be page-aligned (4K) 1148d69a03fSSandrine Bailleux * to guarantee that the coherent data are stored on their own pages and 1158d69a03fSSandrine Bailleux * are not mixed with normal data. This is required to set up the correct 1168d69a03fSSandrine Bailleux * memory attributes for the coherent data page tables. 1178d69a03fSSandrine Bailleux */ 118a2aedac2SAntonio Nino Diaz coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) { 1198d69a03fSSandrine Bailleux __COHERENT_RAM_START__ = .; 1208d69a03fSSandrine Bailleux *(tzfw_coherent_mem) 1218d69a03fSSandrine Bailleux __COHERENT_RAM_END_UNALIGNED__ = .; 1228d69a03fSSandrine Bailleux /* 1238d69a03fSSandrine Bailleux * Memory page(s) mapped to this section will be marked 1248d69a03fSSandrine Bailleux * as device memory. No other unexpected data must creep in. 1258d69a03fSSandrine Bailleux * Ensure the rest of the current memory page is unused. 1268d69a03fSSandrine Bailleux */ 1275629b2b1SRoberto Vargas . = ALIGN(PAGE_SIZE); 1288d69a03fSSandrine Bailleux __COHERENT_RAM_END__ = .; 1294f6ad66aSAchin Gupta } >RAM 130ab8707e6SSoby Mathew#endif 1314f6ad66aSAchin Gupta 13254dc71e7SAchin Gupta /* 13354dc71e7SAchin Gupta * Define a linker symbol to mark end of the RW memory area for this 13454dc71e7SAchin Gupta * image. 13554dc71e7SAchin Gupta */ 13654dc71e7SAchin Gupta __RW_END__ = .; 1378d69a03fSSandrine Bailleux __BL2_END__ = .; 1384f6ad66aSAchin Gupta 1398d69a03fSSandrine Bailleux __BSS_SIZE__ = SIZEOF(.bss); 140ab8707e6SSoby Mathew 141ab8707e6SSoby Mathew#if USE_COHERENT_MEM 1428d69a03fSSandrine Bailleux __COHERENT_RAM_UNALIGNED_SIZE__ = 1438d69a03fSSandrine Bailleux __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__; 144ab8707e6SSoby Mathew#endif 145a37255a2SSandrine Bailleux 146a37255a2SSandrine Bailleux ASSERT(. <= BL2_LIMIT, "BL2 image has exceeded its limit.") 1474f6ad66aSAchin Gupta} 148