14f6ad66aSAchin Gupta/* 2da04341eSChris Kay * Copyright (c) 2013-2023, 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 18f90fe02fSChris KaySECTIONS { 19f6088168SHarrison Mutai RAM_REGION_START = ORIGIN(RAM); 20f6088168SHarrison Mutai RAM_REGION_LENGTH = LENGTH(RAM); 214f6ad66aSAchin Gupta . = BL2_BASE; 22f90fe02fSChris Kay 23a2aedac2SAntonio Nino Diaz ASSERT(. == ALIGN(PAGE_SIZE), 248d69a03fSSandrine Bailleux "BL2_BASE address is not aligned on a page boundary.") 254f6ad66aSAchin Gupta 265d1c104fSSandrine Bailleux#if SEPARATE_CODE_AND_RODATA 275d1c104fSSandrine Bailleux .text . : { 285d1c104fSSandrine Bailleux __TEXT_START__ = .; 29f90fe02fSChris Kay 306c09af9fSZelalem Aweke#if ENABLE_RME 316c09af9fSZelalem Aweke *bl2_rme_entrypoint.o(.text*) 326c09af9fSZelalem Aweke#else /* ENABLE_RME */ 335d1c104fSSandrine Bailleux *bl2_entrypoint.o(.text*) 346c09af9fSZelalem Aweke#endif /* ENABLE_RME */ 35f90fe02fSChris Kay 36ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.text*)) 375d1c104fSSandrine Bailleux *(.vectors) 38*f7d445fcSMichal Simek __TEXT_END_UNALIGNED__ = .; 39f90fe02fSChris Kay 405629b2b1SRoberto Vargas . = ALIGN(PAGE_SIZE); 41f90fe02fSChris Kay 425d1c104fSSandrine Bailleux __TEXT_END__ = .; 435d1c104fSSandrine Bailleux } >RAM 445d1c104fSSandrine Bailleux 45f90fe02fSChris Kay /* .ARM.extab and .ARM.exidx are only added because Clang needs them */ 46ad925094SRoberto Vargas .ARM.extab . : { 47ad925094SRoberto Vargas *(.ARM.extab* .gnu.linkonce.armextab.*) 48ad925094SRoberto Vargas } >RAM 49ad925094SRoberto Vargas 50ad925094SRoberto Vargas .ARM.exidx . : { 51ad925094SRoberto Vargas *(.ARM.exidx* .gnu.linkonce.armexidx.*) 52ad925094SRoberto Vargas } >RAM 53ad925094SRoberto Vargas 545d1c104fSSandrine Bailleux .rodata . : { 555d1c104fSSandrine Bailleux __RODATA_START__ = .; 56f90fe02fSChris Kay 57ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.rodata*)) 585d1c104fSSandrine Bailleux 590a0a7a9aSMasahiro Yamada RODATA_COMMON 605d1c104fSSandrine Bailleux 61*f7d445fcSMichal Simek __RODATA_END_UNALIGNED__ = .; 625629b2b1SRoberto Vargas . = ALIGN(PAGE_SIZE); 63f90fe02fSChris Kay 645d1c104fSSandrine Bailleux __RODATA_END__ = .; 655d1c104fSSandrine Bailleux } >RAM 66f90fe02fSChris Kay#else /* SEPARATE_CODE_AND_RODATA */ 67da04341eSChris Kay .ro . : { 688d69a03fSSandrine Bailleux __RO_START__ = .; 69f90fe02fSChris Kay 70dccc537aSAndrew Thoelke *bl2_entrypoint.o(.text*) 71ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.text*)) 72ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.rodata*)) 7305799ae0SJuan Castillo 740a0a7a9aSMasahiro Yamada RODATA_COMMON 7505799ae0SJuan Castillo 76b739f22aSAchin Gupta *(.vectors) 77f90fe02fSChris Kay 788d69a03fSSandrine Bailleux __RO_END_UNALIGNED__ = .; 794f6ad66aSAchin Gupta 8054dc71e7SAchin Gupta /* 81f90fe02fSChris Kay * Memory page(s) mapped to this section will be marked as read-only, 82f90fe02fSChris Kay * executable. No RW data from the next section must creep in. Ensure 83f90fe02fSChris Kay * that the rest of the current memory page is unused. 8454dc71e7SAchin Gupta */ 85f90fe02fSChris Kay . = ALIGN(PAGE_SIZE); 86f90fe02fSChris Kay 87f90fe02fSChris Kay __RO_END__ = .; 88f90fe02fSChris Kay } >RAM 89f90fe02fSChris Kay#endif /* SEPARATE_CODE_AND_RODATA */ 90f90fe02fSChris Kay 9154dc71e7SAchin Gupta __RW_START__ = .; 9254dc71e7SAchin Gupta 93caa3e7e0SMasahiro Yamada DATA_SECTION >RAM 94a926a9f6SMasahiro Yamada STACK_SECTION >RAM 95a7739bc7SMasahiro Yamada BSS_SECTION >RAM 96665e71b8SMasahiro Yamada XLAT_TABLE_SECTION >RAM 97a0cd989dSAchin Gupta 98ab8707e6SSoby Mathew#if USE_COHERENT_MEM 99a0cd989dSAchin Gupta /* 100f90fe02fSChris Kay * The base address of the coherent memory section must be page-aligned to 101f90fe02fSChris Kay * guarantee that the coherent data are stored on their own pages and are 102f90fe02fSChris Kay * not mixed with normal data. This is required to set up the correct 1038d69a03fSSandrine Bailleux * memory attributes for the coherent data page tables. 1048d69a03fSSandrine Bailleux */ 105da04341eSChris Kay .coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) { 1068d69a03fSSandrine Bailleux __COHERENT_RAM_START__ = .; 107da04341eSChris Kay *(.tzfw_coherent_mem) 1088d69a03fSSandrine Bailleux __COHERENT_RAM_END_UNALIGNED__ = .; 1094f6ad66aSAchin Gupta 11054dc71e7SAchin Gupta /* 111f90fe02fSChris Kay * Memory page(s) mapped to this section will be marked as device 112f90fe02fSChris Kay * memory. No other unexpected data must creep in. Ensure the rest of 113f90fe02fSChris Kay * the current memory page is unused. 11454dc71e7SAchin Gupta */ 115f90fe02fSChris Kay . = ALIGN(PAGE_SIZE); 116f90fe02fSChris Kay 117f90fe02fSChris Kay __COHERENT_RAM_END__ = .; 118f90fe02fSChris Kay } >RAM 119f90fe02fSChris Kay#endif /* USE_COHERENT_MEM */ 120f90fe02fSChris Kay 12154dc71e7SAchin Gupta __RW_END__ = .; 1228d69a03fSSandrine Bailleux __BL2_END__ = .; 123f6088168SHarrison Mutai RAM_REGION_END = .; 1244f6ad66aSAchin Gupta 1258d69a03fSSandrine Bailleux __BSS_SIZE__ = SIZEOF(.bss); 126ab8707e6SSoby Mathew 127ab8707e6SSoby Mathew#if USE_COHERENT_MEM 1288d69a03fSSandrine Bailleux __COHERENT_RAM_UNALIGNED_SIZE__ = 1298d69a03fSSandrine Bailleux __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__; 130f90fe02fSChris Kay#endif /* USE_COHERENT_MEM */ 131a37255a2SSandrine Bailleux 132a37255a2SSandrine Bailleux ASSERT(. <= BL2_LIMIT, "BL2 image has exceeded its limit.") 1334f6ad66aSAchin Gupta} 134