14f6ad66aSAchin Gupta/* 2c367b75eSMadhukar Pappireddy * 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(bl31_entrypoint) 134f6ad66aSAchin Gupta 144f6ad66aSAchin Gupta 154f6ad66aSAchin GuptaMEMORY { 16d7fbf132SJuan Castillo RAM (rwx): ORIGIN = BL31_BASE, LENGTH = BL31_LIMIT - BL31_BASE 17f8578e64SSamuel Holland#if SEPARATE_NOBITS_REGION 18f8578e64SSamuel Holland NOBITS (rw!a): ORIGIN = BL31_NOBITS_BASE, LENGTH = BL31_NOBITS_LIMIT - BL31_NOBITS_BASE 19f8578e64SSamuel Holland#else 20f8578e64SSamuel Holland#define NOBITS RAM 21f8578e64SSamuel Holland#endif 224f6ad66aSAchin Gupta} 234f6ad66aSAchin Gupta 24ec693569SCaesar Wang#ifdef PLAT_EXTRA_LD_SCRIPT 25ec693569SCaesar Wang#include <plat.ld.S> 26ec693569SCaesar Wang#endif 274f6ad66aSAchin Gupta 284f6ad66aSAchin GuptaSECTIONS 294f6ad66aSAchin Gupta{ 304f6ad66aSAchin Gupta . = BL31_BASE; 31a2aedac2SAntonio Nino Diaz ASSERT(. == ALIGN(PAGE_SIZE), 328d69a03fSSandrine Bailleux "BL31_BASE address is not aligned on a page boundary.") 334f6ad66aSAchin Gupta 34931f7c61SSoby Mathew __BL31_START__ = .; 35931f7c61SSoby Mathew 365d1c104fSSandrine Bailleux#if SEPARATE_CODE_AND_RODATA 375d1c104fSSandrine Bailleux .text . : { 385d1c104fSSandrine Bailleux __TEXT_START__ = .; 395d1c104fSSandrine Bailleux *bl31_entrypoint.o(.text*) 40d7b5f408SJimmy Brisson *(SORT_BY_ALIGNMENT(SORT(.text*))) 415d1c104fSSandrine Bailleux *(.vectors) 425629b2b1SRoberto Vargas . = ALIGN(PAGE_SIZE); 435d1c104fSSandrine Bailleux __TEXT_END__ = .; 445d1c104fSSandrine Bailleux } >RAM 455d1c104fSSandrine Bailleux 465d1c104fSSandrine Bailleux .rodata . : { 475d1c104fSSandrine Bailleux __RODATA_START__ = .; 48ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.rodata*)) 495d1c104fSSandrine Bailleux 50*8a68e864SLeon Chen#if PLAT_EXTRA_RODATA_INCLUDES 51*8a68e864SLeon Chen#include <plat.ld.rodata.inc> 52*8a68e864SLeon Chen#endif 53*8a68e864SLeon Chen 540a0a7a9aSMasahiro Yamada RODATA_COMMON 55931f7c61SSoby Mathew 568e743bcdSJeenu Viswambharan /* Place pubsub sections for events */ 578e743bcdSJeenu Viswambharan . = ALIGN(8); 5809d40e0eSAntonio Nino Diaz#include <lib/el3_runtime/pubsub_events.h> 598e743bcdSJeenu Viswambharan 605629b2b1SRoberto Vargas . = ALIGN(PAGE_SIZE); 615d1c104fSSandrine Bailleux __RODATA_END__ = .; 625d1c104fSSandrine Bailleux } >RAM 635d1c104fSSandrine Bailleux#else 648d69a03fSSandrine Bailleux ro . : { 658d69a03fSSandrine Bailleux __RO_START__ = .; 66dccc537aSAndrew Thoelke *bl31_entrypoint.o(.text*) 67ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.text*)) 68ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.rodata*)) 697421b465SAchin Gupta 700a0a7a9aSMasahiro Yamada RODATA_COMMON 715bfac4fcSSoby Mathew 728e743bcdSJeenu Viswambharan /* Place pubsub sections for events */ 738e743bcdSJeenu Viswambharan . = ALIGN(8); 7409d40e0eSAntonio Nino Diaz#include <lib/el3_runtime/pubsub_events.h> 758e743bcdSJeenu Viswambharan 76b739f22aSAchin Gupta *(.vectors) 778d69a03fSSandrine Bailleux __RO_END_UNALIGNED__ = .; 788d69a03fSSandrine Bailleux /* 798d69a03fSSandrine Bailleux * Memory page(s) mapped to this section will be marked as read-only, 808d69a03fSSandrine Bailleux * executable. No RW data from the next section must creep in. 818d69a03fSSandrine Bailleux * Ensure the rest of the current memory page is unused. 828d69a03fSSandrine Bailleux */ 835629b2b1SRoberto Vargas . = ALIGN(PAGE_SIZE); 848d69a03fSSandrine Bailleux __RO_END__ = .; 854f6ad66aSAchin Gupta } >RAM 865d1c104fSSandrine Bailleux#endif 874f6ad66aSAchin Gupta 889b476841SSoby Mathew ASSERT(__CPU_OPS_END__ > __CPU_OPS_START__, 899b476841SSoby Mathew "cpu_ops not defined for this platform.") 909b476841SSoby Mathew 91538b0020SPaul Beesley#if SPM_MM 9232e83537SArd Biesheuvel#ifndef SPM_SHIM_EXCEPTIONS_VMA 9332e83537SArd Biesheuvel#define SPM_SHIM_EXCEPTIONS_VMA RAM 9432e83537SArd Biesheuvel#endif 9532e83537SArd Biesheuvel 962fccb228SAntonio Nino Diaz /* 972fccb228SAntonio Nino Diaz * Exception vectors of the SPM shim layer. They must be aligned to a 2K 982fccb228SAntonio Nino Diaz * address, but we need to place them in a separate page so that we can set 992fccb228SAntonio Nino Diaz * individual permissions to them, so the actual alignment needed is 4K. 1002fccb228SAntonio Nino Diaz * 1012fccb228SAntonio Nino Diaz * There's no need to include this into the RO section of BL31 because it 1022fccb228SAntonio Nino Diaz * doesn't need to be accessed by BL31. 1032fccb228SAntonio Nino Diaz */ 104a2aedac2SAntonio Nino Diaz spm_shim_exceptions : ALIGN(PAGE_SIZE) { 1052fccb228SAntonio Nino Diaz __SPM_SHIM_EXCEPTIONS_START__ = .; 1062fccb228SAntonio Nino Diaz *(.spm_shim_exceptions) 1075629b2b1SRoberto Vargas . = ALIGN(PAGE_SIZE); 1082fccb228SAntonio Nino Diaz __SPM_SHIM_EXCEPTIONS_END__ = .; 10932e83537SArd Biesheuvel } >SPM_SHIM_EXCEPTIONS_VMA AT>RAM 11032e83537SArd Biesheuvel 11132e83537SArd Biesheuvel PROVIDE(__SPM_SHIM_EXCEPTIONS_LMA__ = LOADADDR(spm_shim_exceptions)); 11232e83537SArd Biesheuvel . = LOADADDR(spm_shim_exceptions) + SIZEOF(spm_shim_exceptions); 1132fccb228SAntonio Nino Diaz#endif 1142fccb228SAntonio Nino Diaz 11554dc71e7SAchin Gupta /* 11654dc71e7SAchin Gupta * Define a linker symbol to mark start of the RW memory area for this 11754dc71e7SAchin Gupta * image. 11854dc71e7SAchin Gupta */ 11954dc71e7SAchin Gupta __RW_START__ = . ; 12054dc71e7SAchin Gupta 121caa3e7e0SMasahiro Yamada DATA_SECTION >RAM 122e8ad6168SMasahiro Yamada RELA_SECTION >RAM 123931f7c61SSoby Mathew 124a1b6db6cSSandrine Bailleux#ifdef BL31_PROGBITS_LIMIT 125d178637dSJuan Castillo ASSERT(. <= BL31_PROGBITS_LIMIT, "BL31 progbits has exceeded its limit.") 126a1b6db6cSSandrine Bailleux#endif 127a1b6db6cSSandrine Bailleux 128f8578e64SSamuel Holland#if SEPARATE_NOBITS_REGION 129f8578e64SSamuel Holland /* 130f8578e64SSamuel Holland * Define a linker symbol to mark end of the RW memory area for this 131f8578e64SSamuel Holland * image. 132f8578e64SSamuel Holland */ 133c367b75eSMadhukar Pappireddy . = ALIGN(PAGE_SIZE); 134f8578e64SSamuel Holland __RW_END__ = .; 135f8578e64SSamuel Holland __BL31_END__ = .; 136f8578e64SSamuel Holland 137f8578e64SSamuel Holland ASSERT(. <= BL31_LIMIT, "BL31 image has exceeded its limit.") 138f8578e64SSamuel Holland 139f8578e64SSamuel Holland . = BL31_NOBITS_BASE; 140f8578e64SSamuel Holland ASSERT(. == ALIGN(PAGE_SIZE), 141f8578e64SSamuel Holland "BL31 NOBITS base address is not aligned on a page boundary.") 142f8578e64SSamuel Holland 143f8578e64SSamuel Holland __NOBITS_START__ = .; 144f8578e64SSamuel Holland#endif 145f8578e64SSamuel Holland 146a926a9f6SMasahiro Yamada STACK_SECTION >NOBITS 147a7739bc7SMasahiro Yamada BSS_SECTION >NOBITS 148665e71b8SMasahiro Yamada XLAT_TABLE_SECTION >NOBITS 149a0cd989dSAchin Gupta 150ab8707e6SSoby Mathew#if USE_COHERENT_MEM 151a0cd989dSAchin Gupta /* 1528d69a03fSSandrine Bailleux * The base address of the coherent memory section must be page-aligned (4K) 1538d69a03fSSandrine Bailleux * to guarantee that the coherent data are stored on their own pages and 1548d69a03fSSandrine Bailleux * are not mixed with normal data. This is required to set up the correct 1558d69a03fSSandrine Bailleux * memory attributes for the coherent data page tables. 1568d69a03fSSandrine Bailleux */ 157a2aedac2SAntonio Nino Diaz coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) { 1588d69a03fSSandrine Bailleux __COHERENT_RAM_START__ = .; 159ee7b35c4SAndrew Thoelke /* 160ee7b35c4SAndrew Thoelke * Bakery locks are stored in coherent memory 161ee7b35c4SAndrew Thoelke * 162ee7b35c4SAndrew Thoelke * Each lock's data is contiguous and fully allocated by the compiler 163ee7b35c4SAndrew Thoelke */ 164ee7b35c4SAndrew Thoelke *(bakery_lock) 1658d69a03fSSandrine Bailleux *(tzfw_coherent_mem) 1668d69a03fSSandrine Bailleux __COHERENT_RAM_END_UNALIGNED__ = .; 1678d69a03fSSandrine Bailleux /* 1688d69a03fSSandrine Bailleux * Memory page(s) mapped to this section will be marked 1698d69a03fSSandrine Bailleux * as device memory. No other unexpected data must creep in. 1708d69a03fSSandrine Bailleux * Ensure the rest of the current memory page is unused. 1718d69a03fSSandrine Bailleux */ 1725629b2b1SRoberto Vargas . = ALIGN(PAGE_SIZE); 1738d69a03fSSandrine Bailleux __COHERENT_RAM_END__ = .; 174f8578e64SSamuel Holland } >NOBITS 175ab8707e6SSoby Mathew#endif 1764f6ad66aSAchin Gupta 177f8578e64SSamuel Holland#if SEPARATE_NOBITS_REGION 178f8578e64SSamuel Holland /* 179f8578e64SSamuel Holland * Define a linker symbol to mark end of the NOBITS memory area for this 180f8578e64SSamuel Holland * image. 181f8578e64SSamuel Holland */ 182f8578e64SSamuel Holland __NOBITS_END__ = .; 183f8578e64SSamuel Holland 184f8578e64SSamuel Holland ASSERT(. <= BL31_NOBITS_LIMIT, "BL31 NOBITS region has exceeded its limit.") 185f8578e64SSamuel Holland#else 18654dc71e7SAchin Gupta /* 18754dc71e7SAchin Gupta * Define a linker symbol to mark end of the RW memory area for this 18854dc71e7SAchin Gupta * image. 18954dc71e7SAchin Gupta */ 19054dc71e7SAchin Gupta __RW_END__ = .; 1918d69a03fSSandrine Bailleux __BL31_END__ = .; 1924f6ad66aSAchin Gupta 193511046eaSMasahiro Yamada /DISCARD/ : { 194511046eaSMasahiro Yamada *(.dynsym .dynstr .hash .gnu.hash) 195511046eaSMasahiro Yamada } 196511046eaSMasahiro Yamada 197d178637dSJuan Castillo ASSERT(. <= BL31_LIMIT, "BL31 image has exceeded its limit.") 198f8578e64SSamuel Holland#endif 1994f6ad66aSAchin Gupta} 200