14f6ad66aSAchin Gupta/* 2*da04341eSChris 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 7caa3e7e0SMasahiro Yamada/* 8f90fe02fSChris Kay * The .data section gets copied from ROM to RAM at runtime. Its LMA should be 9f90fe02fSChris Kay * 16-byte aligned to allow efficient copying of 16-bytes aligned regions in it. 10caa3e7e0SMasahiro Yamada * Its VMA must be page-aligned as it marks the first read/write page. 11caa3e7e0SMasahiro Yamada */ 12caa3e7e0SMasahiro Yamada#define DATA_ALIGN 16 13caa3e7e0SMasahiro Yamada 14665e71b8SMasahiro Yamada#include <common/bl_common.ld.h> 1509d40e0eSAntonio Nino Diaz#include <lib/xlat_tables/xlat_tables_defs.h> 164f6ad66aSAchin Gupta 174f6ad66aSAchin GuptaOUTPUT_FORMAT(PLATFORM_LINKER_FORMAT) 184f6ad66aSAchin GuptaOUTPUT_ARCH(PLATFORM_LINKER_ARCH) 199f98aa1aSJeenu ViswambharanENTRY(bl1_entrypoint) 204f6ad66aSAchin Gupta 214f6ad66aSAchin GuptaMEMORY { 22d7fbf132SJuan Castillo ROM (rx): ORIGIN = BL1_RO_BASE, LENGTH = BL1_RO_LIMIT - BL1_RO_BASE 23d7fbf132SJuan Castillo RAM (rwx): ORIGIN = BL1_RW_BASE, LENGTH = BL1_RW_LIMIT - BL1_RW_BASE 244f6ad66aSAchin Gupta} 254f6ad66aSAchin Gupta 26f90fe02fSChris KaySECTIONS { 274f59d835SSandrine Bailleux . = BL1_RO_BASE; 28f90fe02fSChris Kay 29a2aedac2SAntonio Nino Diaz ASSERT(. == ALIGN(PAGE_SIZE), 304f59d835SSandrine Bailleux "BL1_RO_BASE address is not aligned on a page boundary.") 314f59d835SSandrine Bailleux 325d1c104fSSandrine Bailleux#if SEPARATE_CODE_AND_RODATA 335d1c104fSSandrine Bailleux .text . : { 345d1c104fSSandrine Bailleux __TEXT_START__ = .; 35f90fe02fSChris Kay 365d1c104fSSandrine Bailleux *bl1_entrypoint.o(.text*) 37ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.text*)) 385d1c104fSSandrine Bailleux *(.vectors) 39f90fe02fSChris Kay 405629b2b1SRoberto Vargas . = ALIGN(PAGE_SIZE); 41f90fe02fSChris Kay 425d1c104fSSandrine Bailleux __TEXT_END__ = .; 435d1c104fSSandrine Bailleux } >ROM 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 } >ROM 49ad925094SRoberto Vargas 50ad925094SRoberto Vargas .ARM.exidx . : { 51ad925094SRoberto Vargas *(.ARM.exidx* .gnu.linkonce.armexidx.*) 52ad925094SRoberto Vargas } >ROM 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 615d1c104fSSandrine Bailleux /* 625d1c104fSSandrine Bailleux * No need to pad out the .rodata section to a page boundary. Next is 635d1c104fSSandrine Bailleux * the .data section, which can mapped in ROM with the same memory 645d1c104fSSandrine Bailleux * attributes as the .rodata section. 6541286590SArve Hjønnevåg * 66f90fe02fSChris Kay * Pad out to 16 bytes though as .data section needs to be 16-byte 67f90fe02fSChris Kay * aligned and lld does not align the LMA to the alignment specified 6841286590SArve Hjønnevåg * on the .data section. 695d1c104fSSandrine Bailleux */ 705d1c104fSSandrine Bailleux __RODATA_END__ = .; 71f90fe02fSChris Kay 7241286590SArve Hjønnevåg . = ALIGN(16); 735d1c104fSSandrine Bailleux } >ROM 74f90fe02fSChris Kay#else /* SEPARATE_CODE_AND_RODATA */ 75*da04341eSChris Kay .ro . : { 768d69a03fSSandrine Bailleux __RO_START__ = .; 77f90fe02fSChris Kay 78dccc537aSAndrew Thoelke *bl1_entrypoint.o(.text*) 79ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.text*)) 80ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.rodata*)) 819b476841SSoby Mathew 820a0a7a9aSMasahiro Yamada RODATA_COMMON 839b476841SSoby Mathew 84b739f22aSAchin Gupta *(.vectors) 85f90fe02fSChris Kay 868d69a03fSSandrine Bailleux __RO_END__ = .; 8741286590SArve Hjønnevåg 8841286590SArve Hjønnevåg /* 89f90fe02fSChris Kay * Pad out to 16 bytes as the .data section needs to be 16-byte aligned 90f90fe02fSChris Kay * and lld does not align the LMA to the alignment specified on the 91f90fe02fSChris Kay * .data section. 9241286590SArve Hjønnevåg */ 9341286590SArve Hjønnevåg . = ALIGN(16); 944f6ad66aSAchin Gupta } >ROM 95f90fe02fSChris Kay#endif /* SEPARATE_CODE_AND_RODATA */ 964f6ad66aSAchin Gupta 979b476841SSoby Mathew ASSERT(__CPU_OPS_END__ > __CPU_OPS_START__, 989b476841SSoby Mathew "cpu_ops not defined for this platform.") 999b476841SSoby Mathew 10051faada7SDouglas Raillard . = BL1_RW_BASE; 101f90fe02fSChris Kay 102a2aedac2SAntonio Nino Diaz ASSERT(BL1_RW_BASE == ALIGN(PAGE_SIZE), 10351faada7SDouglas Raillard "BL1_RW_BASE address is not aligned on a page boundary.") 10451faada7SDouglas Raillard 105caa3e7e0SMasahiro Yamada DATA_SECTION >RAM AT>ROM 106f90fe02fSChris Kay 107caa3e7e0SMasahiro Yamada __DATA_RAM_START__ = __DATA_START__; 108caa3e7e0SMasahiro Yamada __DATA_RAM_END__ = __DATA_END__; 1094f6ad66aSAchin Gupta 110a926a9f6SMasahiro Yamada STACK_SECTION >RAM 111a7739bc7SMasahiro Yamada BSS_SECTION >RAM 112665e71b8SMasahiro Yamada XLAT_TABLE_SECTION >RAM 11374cbb839SJeenu Viswambharan 114ab8707e6SSoby Mathew#if USE_COHERENT_MEM 11574cbb839SJeenu Viswambharan /* 116f90fe02fSChris Kay * The base address of the coherent memory section must be page-aligned to 117f90fe02fSChris Kay * guarantee that the coherent data are stored on their own pages and are 118f90fe02fSChris Kay * not mixed with normal data. This is required to set up the correct memory 119f90fe02fSChris Kay * attributes for the coherent data page tables. 1208d69a03fSSandrine Bailleux */ 121*da04341eSChris Kay .coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) { 1228d69a03fSSandrine Bailleux __COHERENT_RAM_START__ = .; 123*da04341eSChris Kay *(.tzfw_coherent_mem) 1248d69a03fSSandrine Bailleux __COHERENT_RAM_END_UNALIGNED__ = .; 125f90fe02fSChris Kay 1268d69a03fSSandrine Bailleux /* 127f90fe02fSChris Kay * Memory page(s) mapped to this section will be marked as device 128f90fe02fSChris Kay * memory. No other unexpected data must creep in. Ensure the rest of 129f90fe02fSChris Kay * the current memory page is unused. 1308d69a03fSSandrine Bailleux */ 1315629b2b1SRoberto Vargas . = ALIGN(PAGE_SIZE); 132f90fe02fSChris Kay 1338d69a03fSSandrine Bailleux __COHERENT_RAM_END__ = .; 1348d69a03fSSandrine Bailleux } >RAM 135f90fe02fSChris Kay#endif /* USE_COHERENT_MEM */ 1364f6ad66aSAchin Gupta 1378d69a03fSSandrine Bailleux __BL1_RAM_START__ = ADDR(.data); 1388d69a03fSSandrine Bailleux __BL1_RAM_END__ = .; 1394f6ad66aSAchin Gupta 1408d69a03fSSandrine Bailleux __DATA_ROM_START__ = LOADADDR(.data); 1418d69a03fSSandrine Bailleux __DATA_SIZE__ = SIZEOF(.data); 142c02fcc4aSSandrine Bailleux 143a37255a2SSandrine Bailleux /* 144a37255a2SSandrine Bailleux * The .data section is the last PROGBITS section so its end marks the end 145c02fcc4aSSandrine Bailleux * of BL1's actual content in Trusted ROM. 146a37255a2SSandrine Bailleux */ 147c02fcc4aSSandrine Bailleux __BL1_ROM_END__ = __DATA_ROM_START__ + __DATA_SIZE__; 148f90fe02fSChris Kay 149c02fcc4aSSandrine Bailleux ASSERT(__BL1_ROM_END__ <= BL1_RO_LIMIT, 150c02fcc4aSSandrine Bailleux "BL1's ROM content has exceeded its limit.") 1518d69a03fSSandrine Bailleux 1528d69a03fSSandrine Bailleux __BSS_SIZE__ = SIZEOF(.bss); 1538d69a03fSSandrine Bailleux 154ab8707e6SSoby Mathew#if USE_COHERENT_MEM 1558d69a03fSSandrine Bailleux __COHERENT_RAM_UNALIGNED_SIZE__ = 1568d69a03fSSandrine Bailleux __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__; 157f90fe02fSChris Kay#endif /* USE_COHERENT_MEM */ 1588d69a03fSSandrine Bailleux 159a37255a2SSandrine Bailleux ASSERT(. <= BL1_RW_LIMIT, "BL1's RW section has exceeded its limit.") 1604f6ad66aSAchin Gupta} 161