14f6ad66aSAchin Gupta/* 25e7e8bfaSHarrison Mutai * 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 { 275e7e8bfaSHarrison Mutai ROM_REGION_START = ORIGIN(ROM); 285e7e8bfaSHarrison Mutai ROM_REGION_LENGTH = LENGTH(ROM); 295e7e8bfaSHarrison Mutai RAM_REGION_START = ORIGIN(RAM); 305e7e8bfaSHarrison Mutai RAM_REGION_LENGTH = LENGTH(RAM); 315e7e8bfaSHarrison Mutai 324f59d835SSandrine Bailleux . = BL1_RO_BASE; 33f90fe02fSChris Kay 34a2aedac2SAntonio Nino Diaz ASSERT(. == ALIGN(PAGE_SIZE), 354f59d835SSandrine Bailleux "BL1_RO_BASE address is not aligned on a page boundary.") 364f59d835SSandrine Bailleux 375d1c104fSSandrine Bailleux#if SEPARATE_CODE_AND_RODATA 385d1c104fSSandrine Bailleux .text . : { 39*3d6edc32SAndrey Skvortsov ASSERT(. == ALIGN(PAGE_SIZE), 40*3d6edc32SAndrey Skvortsov ".text address is not aligned on a page boundary."); 41*3d6edc32SAndrey Skvortsov 425d1c104fSSandrine Bailleux __TEXT_START__ = .; 43f90fe02fSChris Kay 445d1c104fSSandrine Bailleux *bl1_entrypoint.o(.text*) 45ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.text*)) 465d1c104fSSandrine Bailleux *(.vectors) 47f7d445fcSMichal Simek __TEXT_END_UNALIGNED__ = .; 48f90fe02fSChris Kay 495629b2b1SRoberto Vargas . = ALIGN(PAGE_SIZE); 50f90fe02fSChris Kay 515d1c104fSSandrine Bailleux __TEXT_END__ = .; 525d1c104fSSandrine Bailleux } >ROM 535d1c104fSSandrine Bailleux 54f90fe02fSChris Kay /* .ARM.extab and .ARM.exidx are only added because Clang needs them */ 55ad925094SRoberto Vargas .ARM.extab . : { 56ad925094SRoberto Vargas *(.ARM.extab* .gnu.linkonce.armextab.*) 57ad925094SRoberto Vargas } >ROM 58ad925094SRoberto Vargas 59ad925094SRoberto Vargas .ARM.exidx . : { 60ad925094SRoberto Vargas *(.ARM.exidx* .gnu.linkonce.armexidx.*) 61ad925094SRoberto Vargas } >ROM 62ad925094SRoberto Vargas 635d1c104fSSandrine Bailleux .rodata . : { 645d1c104fSSandrine Bailleux __RODATA_START__ = .; 65f90fe02fSChris Kay 66ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.rodata*)) 675d1c104fSSandrine Bailleux 680a0a7a9aSMasahiro Yamada RODATA_COMMON 695d1c104fSSandrine Bailleux 705d1c104fSSandrine Bailleux /* 715d1c104fSSandrine Bailleux * No need to pad out the .rodata section to a page boundary. Next is 725d1c104fSSandrine Bailleux * the .data section, which can mapped in ROM with the same memory 735d1c104fSSandrine Bailleux * attributes as the .rodata section. 7441286590SArve Hjønnevåg * 75f90fe02fSChris Kay * Pad out to 16 bytes though as .data section needs to be 16-byte 76f90fe02fSChris Kay * aligned and lld does not align the LMA to the alignment specified 7741286590SArve Hjønnevåg * on the .data section. 785d1c104fSSandrine Bailleux */ 79f7d445fcSMichal Simek __RODATA_END_UNALIGNED__ = .; 805d1c104fSSandrine Bailleux __RODATA_END__ = .; 81f90fe02fSChris Kay 8241286590SArve Hjønnevåg . = ALIGN(16); 835d1c104fSSandrine Bailleux } >ROM 84f90fe02fSChris Kay#else /* SEPARATE_CODE_AND_RODATA */ 85da04341eSChris Kay .ro . : { 86*3d6edc32SAndrey Skvortsov ASSERT(. == ALIGN(PAGE_SIZE), 87*3d6edc32SAndrey Skvortsov ".ro address is not aligned on a page boundary."); 88*3d6edc32SAndrey Skvortsov 898d69a03fSSandrine Bailleux __RO_START__ = .; 90f90fe02fSChris Kay 91dccc537aSAndrew Thoelke *bl1_entrypoint.o(.text*) 92ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.text*)) 93ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.rodata*)) 949b476841SSoby Mathew 950a0a7a9aSMasahiro Yamada RODATA_COMMON 969b476841SSoby Mathew 97b739f22aSAchin Gupta *(.vectors) 98f90fe02fSChris Kay 998d69a03fSSandrine Bailleux __RO_END__ = .; 10041286590SArve Hjønnevåg 10141286590SArve Hjønnevåg /* 102f90fe02fSChris Kay * Pad out to 16 bytes as the .data section needs to be 16-byte aligned 103f90fe02fSChris Kay * and lld does not align the LMA to the alignment specified on the 104f90fe02fSChris Kay * .data section. 10541286590SArve Hjønnevåg */ 10641286590SArve Hjønnevåg . = ALIGN(16); 1074f6ad66aSAchin Gupta } >ROM 108f90fe02fSChris Kay#endif /* SEPARATE_CODE_AND_RODATA */ 1094f6ad66aSAchin Gupta 1109b476841SSoby Mathew ASSERT(__CPU_OPS_END__ > __CPU_OPS_START__, 1119b476841SSoby Mathew "cpu_ops not defined for this platform.") 1129b476841SSoby Mathew 1135e7e8bfaSHarrison Mutai ROM_REGION_END = .; 11451faada7SDouglas Raillard . = BL1_RW_BASE; 115f90fe02fSChris Kay 116a2aedac2SAntonio Nino Diaz ASSERT(BL1_RW_BASE == ALIGN(PAGE_SIZE), 11751faada7SDouglas Raillard "BL1_RW_BASE address is not aligned on a page boundary.") 11851faada7SDouglas Raillard 119caa3e7e0SMasahiro Yamada DATA_SECTION >RAM AT>ROM 120f90fe02fSChris Kay 121caa3e7e0SMasahiro Yamada __DATA_RAM_START__ = __DATA_START__; 122caa3e7e0SMasahiro Yamada __DATA_RAM_END__ = __DATA_END__; 1234f6ad66aSAchin Gupta 124a926a9f6SMasahiro Yamada STACK_SECTION >RAM 125a7739bc7SMasahiro Yamada BSS_SECTION >RAM 126665e71b8SMasahiro Yamada XLAT_TABLE_SECTION >RAM 12774cbb839SJeenu Viswambharan 128ab8707e6SSoby Mathew#if USE_COHERENT_MEM 12974cbb839SJeenu Viswambharan /* 130f90fe02fSChris Kay * The base address of the coherent memory section must be page-aligned to 131f90fe02fSChris Kay * guarantee that the coherent data are stored on their own pages and are 132f90fe02fSChris Kay * not mixed with normal data. This is required to set up the correct memory 133f90fe02fSChris Kay * attributes for the coherent data page tables. 1348d69a03fSSandrine Bailleux */ 135da04341eSChris Kay .coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) { 1368d69a03fSSandrine Bailleux __COHERENT_RAM_START__ = .; 137da04341eSChris Kay *(.tzfw_coherent_mem) 1388d69a03fSSandrine Bailleux __COHERENT_RAM_END_UNALIGNED__ = .; 139f90fe02fSChris Kay 1408d69a03fSSandrine Bailleux /* 141f90fe02fSChris Kay * Memory page(s) mapped to this section will be marked as device 142f90fe02fSChris Kay * memory. No other unexpected data must creep in. Ensure the rest of 143f90fe02fSChris Kay * the current memory page is unused. 1448d69a03fSSandrine Bailleux */ 1455629b2b1SRoberto Vargas . = ALIGN(PAGE_SIZE); 146f90fe02fSChris Kay 1478d69a03fSSandrine Bailleux __COHERENT_RAM_END__ = .; 1488d69a03fSSandrine Bailleux } >RAM 149f90fe02fSChris Kay#endif /* USE_COHERENT_MEM */ 1504f6ad66aSAchin Gupta 1518d69a03fSSandrine Bailleux __BL1_RAM_START__ = ADDR(.data); 1528d69a03fSSandrine Bailleux __BL1_RAM_END__ = .; 1534f6ad66aSAchin Gupta 1548d69a03fSSandrine Bailleux __DATA_ROM_START__ = LOADADDR(.data); 1558d69a03fSSandrine Bailleux __DATA_SIZE__ = SIZEOF(.data); 156c02fcc4aSSandrine Bailleux 157a37255a2SSandrine Bailleux /* 158a37255a2SSandrine Bailleux * The .data section is the last PROGBITS section so its end marks the end 159c02fcc4aSSandrine Bailleux * of BL1's actual content in Trusted ROM. 160a37255a2SSandrine Bailleux */ 161c02fcc4aSSandrine Bailleux __BL1_ROM_END__ = __DATA_ROM_START__ + __DATA_SIZE__; 162f90fe02fSChris Kay 163c02fcc4aSSandrine Bailleux ASSERT(__BL1_ROM_END__ <= BL1_RO_LIMIT, 164c02fcc4aSSandrine Bailleux "BL1's ROM content has exceeded its limit.") 1658d69a03fSSandrine Bailleux 1668d69a03fSSandrine Bailleux __BSS_SIZE__ = SIZEOF(.bss); 1678d69a03fSSandrine Bailleux 168ab8707e6SSoby Mathew#if USE_COHERENT_MEM 1698d69a03fSSandrine Bailleux __COHERENT_RAM_UNALIGNED_SIZE__ = 1708d69a03fSSandrine Bailleux __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__; 171f90fe02fSChris Kay#endif /* USE_COHERENT_MEM */ 1728d69a03fSSandrine Bailleux 173a37255a2SSandrine Bailleux ASSERT(. <= BL1_RW_LIMIT, "BL1's RW section has exceeded its limit.") 1745e7e8bfaSHarrison Mutai RAM_REGION_END = .; 1754f6ad66aSAchin Gupta} 176