14f6ad66aSAchin Gupta/* 2665e71b8SMasahiro Yamada * 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 7*caa3e7e0SMasahiro Yamada/* 8*caa3e7e0SMasahiro Yamada * The .data section gets copied from ROM to RAM at runtime. 9*caa3e7e0SMasahiro Yamada * Its LMA should be 16-byte aligned to allow efficient copying of 16-bytes 10*caa3e7e0SMasahiro Yamada * aligned regions in it. 11*caa3e7e0SMasahiro Yamada * Its VMA must be page-aligned as it marks the first read/write page. 12*caa3e7e0SMasahiro Yamada */ 13*caa3e7e0SMasahiro Yamada#define DATA_ALIGN 16 14*caa3e7e0SMasahiro Yamada 15665e71b8SMasahiro Yamada#include <common/bl_common.ld.h> 1609d40e0eSAntonio Nino Diaz#include <lib/xlat_tables/xlat_tables_defs.h> 174f6ad66aSAchin Gupta 184f6ad66aSAchin GuptaOUTPUT_FORMAT(PLATFORM_LINKER_FORMAT) 194f6ad66aSAchin GuptaOUTPUT_ARCH(PLATFORM_LINKER_ARCH) 209f98aa1aSJeenu ViswambharanENTRY(bl1_entrypoint) 214f6ad66aSAchin Gupta 224f6ad66aSAchin GuptaMEMORY { 23d7fbf132SJuan Castillo ROM (rx): ORIGIN = BL1_RO_BASE, LENGTH = BL1_RO_LIMIT - BL1_RO_BASE 24d7fbf132SJuan Castillo RAM (rwx): ORIGIN = BL1_RW_BASE, LENGTH = BL1_RW_LIMIT - BL1_RW_BASE 254f6ad66aSAchin Gupta} 264f6ad66aSAchin Gupta 274f6ad66aSAchin GuptaSECTIONS 284f6ad66aSAchin Gupta{ 294f59d835SSandrine Bailleux . = BL1_RO_BASE; 30a2aedac2SAntonio Nino Diaz ASSERT(. == ALIGN(PAGE_SIZE), 314f59d835SSandrine Bailleux "BL1_RO_BASE address is not aligned on a page boundary.") 324f59d835SSandrine Bailleux 335d1c104fSSandrine Bailleux#if SEPARATE_CODE_AND_RODATA 345d1c104fSSandrine Bailleux .text . : { 355d1c104fSSandrine Bailleux __TEXT_START__ = .; 365d1c104fSSandrine Bailleux *bl1_entrypoint.o(.text*) 37ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.text*)) 385d1c104fSSandrine Bailleux *(.vectors) 395629b2b1SRoberto Vargas . = ALIGN(PAGE_SIZE); 405d1c104fSSandrine Bailleux __TEXT_END__ = .; 415d1c104fSSandrine Bailleux } >ROM 425d1c104fSSandrine Bailleux 43ad925094SRoberto Vargas /* .ARM.extab and .ARM.exidx are only added because Clang need them */ 44ad925094SRoberto Vargas .ARM.extab . : { 45ad925094SRoberto Vargas *(.ARM.extab* .gnu.linkonce.armextab.*) 46ad925094SRoberto Vargas } >ROM 47ad925094SRoberto Vargas 48ad925094SRoberto Vargas .ARM.exidx . : { 49ad925094SRoberto Vargas *(.ARM.exidx* .gnu.linkonce.armexidx.*) 50ad925094SRoberto Vargas } >ROM 51ad925094SRoberto Vargas 525d1c104fSSandrine Bailleux .rodata . : { 535d1c104fSSandrine Bailleux __RODATA_START__ = .; 54ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.rodata*)) 555d1c104fSSandrine Bailleux 560a0a7a9aSMasahiro Yamada RODATA_COMMON 575d1c104fSSandrine Bailleux 585d1c104fSSandrine Bailleux /* 595d1c104fSSandrine Bailleux * No need to pad out the .rodata section to a page boundary. Next is 605d1c104fSSandrine Bailleux * the .data section, which can mapped in ROM with the same memory 615d1c104fSSandrine Bailleux * attributes as the .rodata section. 6241286590SArve Hjønnevåg * 6341286590SArve Hjønnevåg * Pad out to 16 bytes though as .data section needs to be 16 byte 6441286590SArve Hjønnevåg * aligned and lld does not align the LMA to the aligment specified 6541286590SArve Hjønnevåg * on the .data section. 665d1c104fSSandrine Bailleux */ 675d1c104fSSandrine Bailleux __RODATA_END__ = .; 6841286590SArve Hjønnevåg . = ALIGN(16); 695d1c104fSSandrine Bailleux } >ROM 705d1c104fSSandrine Bailleux#else 714f59d835SSandrine Bailleux ro . : { 728d69a03fSSandrine Bailleux __RO_START__ = .; 73dccc537aSAndrew Thoelke *bl1_entrypoint.o(.text*) 74ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.text*)) 75ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.rodata*)) 769b476841SSoby Mathew 770a0a7a9aSMasahiro Yamada RODATA_COMMON 789b476841SSoby Mathew 79b739f22aSAchin Gupta *(.vectors) 808d69a03fSSandrine Bailleux __RO_END__ = .; 8141286590SArve Hjønnevåg 8241286590SArve Hjønnevåg /* 8341286590SArve Hjønnevåg * Pad out to 16 bytes as .data section needs to be 16 byte aligned and 8441286590SArve Hjønnevåg * lld does not align the LMA to the aligment specified on the .data 8541286590SArve Hjønnevåg * section. 8641286590SArve Hjønnevåg */ 8741286590SArve Hjønnevåg . = ALIGN(16); 884f6ad66aSAchin Gupta } >ROM 895d1c104fSSandrine Bailleux#endif 904f6ad66aSAchin Gupta 919b476841SSoby Mathew ASSERT(__CPU_OPS_END__ > __CPU_OPS_START__, 929b476841SSoby Mathew "cpu_ops not defined for this platform.") 939b476841SSoby Mathew 9451faada7SDouglas Raillard . = BL1_RW_BASE; 95a2aedac2SAntonio Nino Diaz ASSERT(BL1_RW_BASE == ALIGN(PAGE_SIZE), 9651faada7SDouglas Raillard "BL1_RW_BASE address is not aligned on a page boundary.") 9751faada7SDouglas Raillard 98*caa3e7e0SMasahiro Yamada DATA_SECTION >RAM AT>ROM 99*caa3e7e0SMasahiro Yamada __DATA_RAM_START__ = __DATA_START__; 100*caa3e7e0SMasahiro Yamada __DATA_RAM_END__ = __DATA_END__; 1014f6ad66aSAchin Gupta 102a926a9f6SMasahiro Yamada STACK_SECTION >RAM 103a7739bc7SMasahiro Yamada BSS_SECTION >RAM 104665e71b8SMasahiro Yamada XLAT_TABLE_SECTION >RAM 10574cbb839SJeenu Viswambharan 106ab8707e6SSoby Mathew#if USE_COHERENT_MEM 10774cbb839SJeenu Viswambharan /* 1088d69a03fSSandrine Bailleux * The base address of the coherent memory section must be page-aligned (4K) 1098d69a03fSSandrine Bailleux * to guarantee that the coherent data are stored on their own pages and 1108d69a03fSSandrine Bailleux * are not mixed with normal data. This is required to set up the correct 1118d69a03fSSandrine Bailleux * memory attributes for the coherent data page tables. 1128d69a03fSSandrine Bailleux */ 113a2aedac2SAntonio Nino Diaz coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) { 1148d69a03fSSandrine Bailleux __COHERENT_RAM_START__ = .; 1158d69a03fSSandrine Bailleux *(tzfw_coherent_mem) 1168d69a03fSSandrine Bailleux __COHERENT_RAM_END_UNALIGNED__ = .; 1178d69a03fSSandrine Bailleux /* 1188d69a03fSSandrine Bailleux * Memory page(s) mapped to this section will be marked 1198d69a03fSSandrine Bailleux * as device memory. No other unexpected data must creep in. 1208d69a03fSSandrine Bailleux * Ensure the rest of the current memory page is unused. 1218d69a03fSSandrine Bailleux */ 1225629b2b1SRoberto Vargas . = ALIGN(PAGE_SIZE); 1238d69a03fSSandrine Bailleux __COHERENT_RAM_END__ = .; 1248d69a03fSSandrine Bailleux } >RAM 125ab8707e6SSoby Mathew#endif 1264f6ad66aSAchin Gupta 1278d69a03fSSandrine Bailleux __BL1_RAM_START__ = ADDR(.data); 1288d69a03fSSandrine Bailleux __BL1_RAM_END__ = .; 1294f6ad66aSAchin Gupta 1308d69a03fSSandrine Bailleux __DATA_ROM_START__ = LOADADDR(.data); 1318d69a03fSSandrine Bailleux __DATA_SIZE__ = SIZEOF(.data); 132c02fcc4aSSandrine Bailleux 133a37255a2SSandrine Bailleux /* 134a37255a2SSandrine Bailleux * The .data section is the last PROGBITS section so its end marks the end 135c02fcc4aSSandrine Bailleux * of BL1's actual content in Trusted ROM. 136a37255a2SSandrine Bailleux */ 137c02fcc4aSSandrine Bailleux __BL1_ROM_END__ = __DATA_ROM_START__ + __DATA_SIZE__; 138c02fcc4aSSandrine Bailleux ASSERT(__BL1_ROM_END__ <= BL1_RO_LIMIT, 139c02fcc4aSSandrine Bailleux "BL1's ROM content has exceeded its limit.") 1408d69a03fSSandrine Bailleux 1418d69a03fSSandrine Bailleux __BSS_SIZE__ = SIZEOF(.bss); 1428d69a03fSSandrine Bailleux 143ab8707e6SSoby Mathew#if USE_COHERENT_MEM 1448d69a03fSSandrine Bailleux __COHERENT_RAM_UNALIGNED_SIZE__ = 1458d69a03fSSandrine Bailleux __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__; 146ab8707e6SSoby Mathew#endif 1478d69a03fSSandrine Bailleux 148a37255a2SSandrine Bailleux ASSERT(. <= BL1_RW_LIMIT, "BL1's RW section has exceeded its limit.") 1494f6ad66aSAchin Gupta} 150