14f6ad66aSAchin Gupta/* 2*6c09af9fSZelalem Aweke * Copyright (c) 2013-2021, 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__ = .; 28*6c09af9fSZelalem Aweke#if ENABLE_RME 29*6c09af9fSZelalem Aweke *bl2_rme_entrypoint.o(.text*) 30*6c09af9fSZelalem Aweke#else /* ENABLE_RME */ 315d1c104fSSandrine Bailleux *bl2_entrypoint.o(.text*) 32*6c09af9fSZelalem Aweke#endif /* ENABLE_RME */ 33ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.text*)) 345d1c104fSSandrine Bailleux *(.vectors) 355629b2b1SRoberto Vargas . = ALIGN(PAGE_SIZE); 365d1c104fSSandrine Bailleux __TEXT_END__ = .; 375d1c104fSSandrine Bailleux } >RAM 385d1c104fSSandrine Bailleux 39ad925094SRoberto Vargas /* .ARM.extab and .ARM.exidx are only added because Clang need them */ 40ad925094SRoberto Vargas .ARM.extab . : { 41ad925094SRoberto Vargas *(.ARM.extab* .gnu.linkonce.armextab.*) 42ad925094SRoberto Vargas } >RAM 43ad925094SRoberto Vargas 44ad925094SRoberto Vargas .ARM.exidx . : { 45ad925094SRoberto Vargas *(.ARM.exidx* .gnu.linkonce.armexidx.*) 46ad925094SRoberto Vargas } >RAM 47ad925094SRoberto Vargas 485d1c104fSSandrine Bailleux .rodata . : { 495d1c104fSSandrine Bailleux __RODATA_START__ = .; 50ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.rodata*)) 515d1c104fSSandrine Bailleux 520a0a7a9aSMasahiro Yamada RODATA_COMMON 535d1c104fSSandrine Bailleux 545629b2b1SRoberto Vargas . = ALIGN(PAGE_SIZE); 555d1c104fSSandrine Bailleux __RODATA_END__ = .; 565d1c104fSSandrine Bailleux } >RAM 575d1c104fSSandrine Bailleux#else 588d69a03fSSandrine Bailleux ro . : { 598d69a03fSSandrine Bailleux __RO_START__ = .; 60dccc537aSAndrew Thoelke *bl2_entrypoint.o(.text*) 61ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.text*)) 62ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.rodata*)) 6305799ae0SJuan Castillo 640a0a7a9aSMasahiro Yamada RODATA_COMMON 6505799ae0SJuan Castillo 66b739f22aSAchin Gupta *(.vectors) 678d69a03fSSandrine Bailleux __RO_END_UNALIGNED__ = .; 688d69a03fSSandrine Bailleux /* 698d69a03fSSandrine Bailleux * Memory page(s) mapped to this section will be marked as 708d69a03fSSandrine Bailleux * read-only, executable. No RW data from the next section must 718d69a03fSSandrine Bailleux * creep in. Ensure the rest of the current memory page is unused. 728d69a03fSSandrine Bailleux */ 735629b2b1SRoberto Vargas . = ALIGN(PAGE_SIZE); 748d69a03fSSandrine Bailleux __RO_END__ = .; 754f6ad66aSAchin Gupta } >RAM 765d1c104fSSandrine Bailleux#endif 774f6ad66aSAchin Gupta 7854dc71e7SAchin Gupta /* 7954dc71e7SAchin Gupta * Define a linker symbol to mark start of the RW memory area for this 8054dc71e7SAchin Gupta * image. 8154dc71e7SAchin Gupta */ 8254dc71e7SAchin Gupta __RW_START__ = . ; 8354dc71e7SAchin Gupta 84caa3e7e0SMasahiro Yamada DATA_SECTION >RAM 85a926a9f6SMasahiro Yamada STACK_SECTION >RAM 86a7739bc7SMasahiro Yamada BSS_SECTION >RAM 87665e71b8SMasahiro Yamada XLAT_TABLE_SECTION >RAM 88a0cd989dSAchin Gupta 89ab8707e6SSoby Mathew#if USE_COHERENT_MEM 90a0cd989dSAchin Gupta /* 918d69a03fSSandrine Bailleux * The base address of the coherent memory section must be page-aligned (4K) 928d69a03fSSandrine Bailleux * to guarantee that the coherent data are stored on their own pages and 938d69a03fSSandrine Bailleux * are not mixed with normal data. This is required to set up the correct 948d69a03fSSandrine Bailleux * memory attributes for the coherent data page tables. 958d69a03fSSandrine Bailleux */ 96a2aedac2SAntonio Nino Diaz coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) { 978d69a03fSSandrine Bailleux __COHERENT_RAM_START__ = .; 988d69a03fSSandrine Bailleux *(tzfw_coherent_mem) 998d69a03fSSandrine Bailleux __COHERENT_RAM_END_UNALIGNED__ = .; 1008d69a03fSSandrine Bailleux /* 1018d69a03fSSandrine Bailleux * Memory page(s) mapped to this section will be marked 1028d69a03fSSandrine Bailleux * as device memory. No other unexpected data must creep in. 1038d69a03fSSandrine Bailleux * Ensure the rest of the current memory page is unused. 1048d69a03fSSandrine Bailleux */ 1055629b2b1SRoberto Vargas . = ALIGN(PAGE_SIZE); 1068d69a03fSSandrine Bailleux __COHERENT_RAM_END__ = .; 1074f6ad66aSAchin Gupta } >RAM 108ab8707e6SSoby Mathew#endif 1094f6ad66aSAchin Gupta 11054dc71e7SAchin Gupta /* 11154dc71e7SAchin Gupta * Define a linker symbol to mark end of the RW memory area for this 11254dc71e7SAchin Gupta * image. 11354dc71e7SAchin Gupta */ 11454dc71e7SAchin Gupta __RW_END__ = .; 1158d69a03fSSandrine Bailleux __BL2_END__ = .; 1164f6ad66aSAchin Gupta 1178d69a03fSSandrine Bailleux __BSS_SIZE__ = SIZEOF(.bss); 118ab8707e6SSoby Mathew 119ab8707e6SSoby Mathew#if USE_COHERENT_MEM 1208d69a03fSSandrine Bailleux __COHERENT_RAM_UNALIGNED_SIZE__ = 1218d69a03fSSandrine Bailleux __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__; 122ab8707e6SSoby Mathew#endif 123a37255a2SSandrine Bailleux 124a37255a2SSandrine Bailleux ASSERT(. <= BL2_LIMIT, "BL2 image has exceeded its limit.") 1254f6ad66aSAchin Gupta} 126