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 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(bl1_entrypoint) 134f6ad66aSAchin Gupta 144f6ad66aSAchin GuptaMEMORY { 15d7fbf132SJuan Castillo ROM (rx): ORIGIN = BL1_RO_BASE, LENGTH = BL1_RO_LIMIT - BL1_RO_BASE 16d7fbf132SJuan Castillo RAM (rwx): ORIGIN = BL1_RW_BASE, LENGTH = BL1_RW_LIMIT - BL1_RW_BASE 174f6ad66aSAchin Gupta} 184f6ad66aSAchin Gupta 194f6ad66aSAchin GuptaSECTIONS 204f6ad66aSAchin Gupta{ 214f59d835SSandrine Bailleux . = BL1_RO_BASE; 22a2aedac2SAntonio Nino Diaz ASSERT(. == ALIGN(PAGE_SIZE), 234f59d835SSandrine Bailleux "BL1_RO_BASE address is not aligned on a page boundary.") 244f59d835SSandrine Bailleux 255d1c104fSSandrine Bailleux#if SEPARATE_CODE_AND_RODATA 265d1c104fSSandrine Bailleux .text . : { 275d1c104fSSandrine Bailleux __TEXT_START__ = .; 285d1c104fSSandrine Bailleux *bl1_entrypoint.o(.text*) 29ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.text*)) 305d1c104fSSandrine Bailleux *(.vectors) 315629b2b1SRoberto Vargas . = ALIGN(PAGE_SIZE); 325d1c104fSSandrine Bailleux __TEXT_END__ = .; 335d1c104fSSandrine Bailleux } >ROM 345d1c104fSSandrine Bailleux 35ad925094SRoberto Vargas /* .ARM.extab and .ARM.exidx are only added because Clang need them */ 36ad925094SRoberto Vargas .ARM.extab . : { 37ad925094SRoberto Vargas *(.ARM.extab* .gnu.linkonce.armextab.*) 38ad925094SRoberto Vargas } >ROM 39ad925094SRoberto Vargas 40ad925094SRoberto Vargas .ARM.exidx . : { 41ad925094SRoberto Vargas *(.ARM.exidx* .gnu.linkonce.armexidx.*) 42ad925094SRoberto Vargas } >ROM 43ad925094SRoberto Vargas 445d1c104fSSandrine Bailleux .rodata . : { 455d1c104fSSandrine Bailleux __RODATA_START__ = .; 46ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.rodata*)) 475d1c104fSSandrine Bailleux 48*0a0a7a9aSMasahiro Yamada RODATA_COMMON 495d1c104fSSandrine Bailleux 505d1c104fSSandrine Bailleux /* 515d1c104fSSandrine Bailleux * No need to pad out the .rodata section to a page boundary. Next is 525d1c104fSSandrine Bailleux * the .data section, which can mapped in ROM with the same memory 535d1c104fSSandrine Bailleux * attributes as the .rodata section. 5441286590SArve Hjønnevåg * 5541286590SArve Hjønnevåg * Pad out to 16 bytes though as .data section needs to be 16 byte 5641286590SArve Hjønnevåg * aligned and lld does not align the LMA to the aligment specified 5741286590SArve Hjønnevåg * on the .data section. 585d1c104fSSandrine Bailleux */ 595d1c104fSSandrine Bailleux __RODATA_END__ = .; 6041286590SArve Hjønnevåg . = ALIGN(16); 615d1c104fSSandrine Bailleux } >ROM 625d1c104fSSandrine Bailleux#else 634f59d835SSandrine Bailleux ro . : { 648d69a03fSSandrine Bailleux __RO_START__ = .; 65dccc537aSAndrew Thoelke *bl1_entrypoint.o(.text*) 66ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.text*)) 67ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.rodata*)) 689b476841SSoby Mathew 69*0a0a7a9aSMasahiro Yamada RODATA_COMMON 709b476841SSoby Mathew 71b739f22aSAchin Gupta *(.vectors) 728d69a03fSSandrine Bailleux __RO_END__ = .; 7341286590SArve Hjønnevåg 7441286590SArve Hjønnevåg /* 7541286590SArve Hjønnevåg * Pad out to 16 bytes as .data section needs to be 16 byte aligned and 7641286590SArve Hjønnevåg * lld does not align the LMA to the aligment specified on the .data 7741286590SArve Hjønnevåg * section. 7841286590SArve Hjønnevåg */ 7941286590SArve Hjønnevåg . = ALIGN(16); 804f6ad66aSAchin Gupta } >ROM 815d1c104fSSandrine Bailleux#endif 824f6ad66aSAchin Gupta 839b476841SSoby Mathew ASSERT(__CPU_OPS_END__ > __CPU_OPS_START__, 849b476841SSoby Mathew "cpu_ops not defined for this platform.") 859b476841SSoby Mathew 8651faada7SDouglas Raillard . = BL1_RW_BASE; 87a2aedac2SAntonio Nino Diaz ASSERT(BL1_RW_BASE == ALIGN(PAGE_SIZE), 8851faada7SDouglas Raillard "BL1_RW_BASE address is not aligned on a page boundary.") 8951faada7SDouglas Raillard 908d69a03fSSandrine Bailleux /* 918d69a03fSSandrine Bailleux * The .data section gets copied from ROM to RAM at runtime. 9251faada7SDouglas Raillard * Its LMA should be 16-byte aligned to allow efficient copying of 16-bytes 9351faada7SDouglas Raillard * aligned regions in it. 944f59d835SSandrine Bailleux * Its VMA must be page-aligned as it marks the first read/write page. 9551faada7SDouglas Raillard * 9651faada7SDouglas Raillard * It must be placed at a lower address than the stacks if the stack 9751faada7SDouglas Raillard * protector is enabled. Alternatively, the .data.stack_protector_canary 9851faada7SDouglas Raillard * section can be placed independently of the main .data section. 998d69a03fSSandrine Bailleux */ 1004f59d835SSandrine Bailleux .data . : ALIGN(16) { 1014f6ad66aSAchin Gupta __DATA_RAM_START__ = .; 102ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.data*)) 1038d69a03fSSandrine Bailleux __DATA_RAM_END__ = .; 1044f6ad66aSAchin Gupta } >RAM AT>ROM 1054f6ad66aSAchin Gupta 1064f59d835SSandrine Bailleux stacks . (NOLOAD) : { 1078d69a03fSSandrine Bailleux __STACKS_START__ = .; 1084f6ad66aSAchin Gupta *(tzfw_normal_stacks) 1098d69a03fSSandrine Bailleux __STACKS_END__ = .; 1104f6ad66aSAchin Gupta } >RAM 1114f6ad66aSAchin Gupta 1128d69a03fSSandrine Bailleux /* 1138d69a03fSSandrine Bailleux * The .bss section gets initialised to 0 at runtime. 114308d359bSDouglas Raillard * Its base address should be 16-byte aligned for better performance of the 115308d359bSDouglas Raillard * zero-initialization code. 1168d69a03fSSandrine Bailleux */ 1178d69a03fSSandrine Bailleux .bss : ALIGN(16) { 1188d69a03fSSandrine Bailleux __BSS_START__ = .; 119ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.bss*)) 1208d69a03fSSandrine Bailleux *(COMMON) 1218d69a03fSSandrine Bailleux __BSS_END__ = .; 1228d69a03fSSandrine Bailleux } >RAM 1234f6ad66aSAchin Gupta 124665e71b8SMasahiro Yamada XLAT_TABLE_SECTION >RAM 12574cbb839SJeenu Viswambharan 126ab8707e6SSoby Mathew#if USE_COHERENT_MEM 12774cbb839SJeenu Viswambharan /* 1288d69a03fSSandrine Bailleux * The base address of the coherent memory section must be page-aligned (4K) 1298d69a03fSSandrine Bailleux * to guarantee that the coherent data are stored on their own pages and 1308d69a03fSSandrine Bailleux * are not mixed with normal data. This is required to set up the correct 1318d69a03fSSandrine Bailleux * memory attributes for the coherent data page tables. 1328d69a03fSSandrine Bailleux */ 133a2aedac2SAntonio Nino Diaz coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) { 1348d69a03fSSandrine Bailleux __COHERENT_RAM_START__ = .; 1358d69a03fSSandrine Bailleux *(tzfw_coherent_mem) 1368d69a03fSSandrine Bailleux __COHERENT_RAM_END_UNALIGNED__ = .; 1378d69a03fSSandrine Bailleux /* 1388d69a03fSSandrine Bailleux * Memory page(s) mapped to this section will be marked 1398d69a03fSSandrine Bailleux * as device memory. No other unexpected data must creep in. 1408d69a03fSSandrine Bailleux * Ensure the rest of the current memory page is unused. 1418d69a03fSSandrine Bailleux */ 1425629b2b1SRoberto Vargas . = ALIGN(PAGE_SIZE); 1438d69a03fSSandrine Bailleux __COHERENT_RAM_END__ = .; 1448d69a03fSSandrine Bailleux } >RAM 145ab8707e6SSoby Mathew#endif 1464f6ad66aSAchin Gupta 1478d69a03fSSandrine Bailleux __BL1_RAM_START__ = ADDR(.data); 1488d69a03fSSandrine Bailleux __BL1_RAM_END__ = .; 1494f6ad66aSAchin Gupta 1508d69a03fSSandrine Bailleux __DATA_ROM_START__ = LOADADDR(.data); 1518d69a03fSSandrine Bailleux __DATA_SIZE__ = SIZEOF(.data); 152c02fcc4aSSandrine Bailleux 153a37255a2SSandrine Bailleux /* 154a37255a2SSandrine Bailleux * The .data section is the last PROGBITS section so its end marks the end 155c02fcc4aSSandrine Bailleux * of BL1's actual content in Trusted ROM. 156a37255a2SSandrine Bailleux */ 157c02fcc4aSSandrine Bailleux __BL1_ROM_END__ = __DATA_ROM_START__ + __DATA_SIZE__; 158c02fcc4aSSandrine Bailleux ASSERT(__BL1_ROM_END__ <= BL1_RO_LIMIT, 159c02fcc4aSSandrine Bailleux "BL1's ROM content has exceeded its limit.") 1608d69a03fSSandrine Bailleux 1618d69a03fSSandrine Bailleux __BSS_SIZE__ = SIZEOF(.bss); 1628d69a03fSSandrine Bailleux 163ab8707e6SSoby Mathew#if USE_COHERENT_MEM 1648d69a03fSSandrine Bailleux __COHERENT_RAM_UNALIGNED_SIZE__ = 1658d69a03fSSandrine Bailleux __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__; 166ab8707e6SSoby Mathew#endif 1678d69a03fSSandrine Bailleux 168a37255a2SSandrine Bailleux ASSERT(. <= BL1_RW_LIMIT, "BL1's RW section has exceeded its limit.") 1694f6ad66aSAchin Gupta} 170