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 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 GuptaMEMORY { 15d7fbf132SJuan Castillo RAM (rwx): ORIGIN = BL31_BASE, LENGTH = BL31_LIMIT - BL31_BASE 16f90fe02fSChris Kay 17f8578e64SSamuel Holland#if SEPARATE_NOBITS_REGION 18f8578e64SSamuel Holland NOBITS (rw!a): ORIGIN = BL31_NOBITS_BASE, LENGTH = BL31_NOBITS_LIMIT - BL31_NOBITS_BASE 19f90fe02fSChris Kay#else /* SEPARATE_NOBITS_REGION */ 20f8578e64SSamuel Holland# define NOBITS RAM 21f90fe02fSChris Kay#endif /* SEPARATE_NOBITS_REGION */ 224f6ad66aSAchin Gupta} 234f6ad66aSAchin Gupta 24ec693569SCaesar Wang#ifdef PLAT_EXTRA_LD_SCRIPT 25ec693569SCaesar Wang# include <plat.ld.S> 26f90fe02fSChris Kay#endif /* PLAT_EXTRA_LD_SCRIPT */ 274f6ad66aSAchin Gupta 28f90fe02fSChris KaySECTIONS { 294f6ad66aSAchin Gupta . = BL31_BASE; 30f90fe02fSChris Kay 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__ = .; 39f90fe02fSChris Kay 405d1c104fSSandrine Bailleux *bl31_entrypoint.o(.text*) 41d7b5f408SJimmy Brisson *(SORT_BY_ALIGNMENT(SORT(.text*))) 425d1c104fSSandrine Bailleux *(.vectors) 43f90fe02fSChris Kay 445629b2b1SRoberto Vargas . = ALIGN(PAGE_SIZE); 45f90fe02fSChris Kay 465d1c104fSSandrine Bailleux __TEXT_END__ = .; 475d1c104fSSandrine Bailleux } >RAM 485d1c104fSSandrine Bailleux 495d1c104fSSandrine Bailleux .rodata . : { 505d1c104fSSandrine Bailleux __RODATA_START__ = .; 51f90fe02fSChris Kay 52ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.rodata*)) 535d1c104fSSandrine Bailleux 548a68e864SLeon Chen# if PLAT_EXTRA_RODATA_INCLUDES 558a68e864SLeon Chen# include <plat.ld.rodata.inc> 56f90fe02fSChris Kay# endif /* PLAT_EXTRA_RODATA_INCLUDES */ 578a68e864SLeon Chen 580a0a7a9aSMasahiro Yamada RODATA_COMMON 59931f7c61SSoby Mathew 608e743bcdSJeenu Viswambharan . = ALIGN(8); 61f90fe02fSChris Kay 6209d40e0eSAntonio Nino Diaz# include <lib/el3_runtime/pubsub_events.h> 638e743bcdSJeenu Viswambharan 645629b2b1SRoberto Vargas . = ALIGN(PAGE_SIZE); 65f90fe02fSChris Kay 665d1c104fSSandrine Bailleux __RODATA_END__ = .; 675d1c104fSSandrine Bailleux } >RAM 68f90fe02fSChris Kay#else /* SEPARATE_CODE_AND_RODATA */ 69*da04341eSChris Kay .ro . : { 708d69a03fSSandrine Bailleux __RO_START__ = .; 71f90fe02fSChris Kay 72dccc537aSAndrew Thoelke *bl31_entrypoint.o(.text*) 73ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.text*)) 74ebd6efaeSSamuel Holland *(SORT_BY_ALIGNMENT(.rodata*)) 757421b465SAchin Gupta 760a0a7a9aSMasahiro Yamada RODATA_COMMON 775bfac4fcSSoby Mathew 788e743bcdSJeenu Viswambharan . = ALIGN(8); 79f90fe02fSChris Kay 8009d40e0eSAntonio Nino Diaz# include <lib/el3_runtime/pubsub_events.h> 818e743bcdSJeenu Viswambharan 82b739f22aSAchin Gupta *(.vectors) 83f90fe02fSChris Kay 848d69a03fSSandrine Bailleux __RO_END_UNALIGNED__ = .; 85f90fe02fSChris Kay 868d69a03fSSandrine Bailleux /* 878d69a03fSSandrine Bailleux * Memory page(s) mapped to this section will be marked as read-only, 88f90fe02fSChris Kay * executable. No RW data from the next section must creep in. Ensure 89f90fe02fSChris Kay * that the rest of the current memory page is unused. 908d69a03fSSandrine Bailleux */ 915629b2b1SRoberto Vargas . = ALIGN(PAGE_SIZE); 92f90fe02fSChris Kay 938d69a03fSSandrine Bailleux __RO_END__ = .; 944f6ad66aSAchin Gupta } >RAM 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 100538b0020SPaul Beesley#if SPM_MM 10132e83537SArd Biesheuvel# ifndef SPM_SHIM_EXCEPTIONS_VMA 10232e83537SArd Biesheuvel# define SPM_SHIM_EXCEPTIONS_VMA RAM 103f90fe02fSChris Kay# endif /* SPM_SHIM_EXCEPTIONS_VMA */ 10432e83537SArd Biesheuvel 1052fccb228SAntonio Nino Diaz /* 1062fccb228SAntonio Nino Diaz * Exception vectors of the SPM shim layer. They must be aligned to a 2K 107f90fe02fSChris Kay * address but we need to place them in a separate page so that we can set 108f90fe02fSChris Kay * individual permissions on them, so the actual alignment needed is the 109f90fe02fSChris Kay * page size. 1102fccb228SAntonio Nino Diaz * 1112fccb228SAntonio Nino Diaz * There's no need to include this into the RO section of BL31 because it 1122fccb228SAntonio Nino Diaz * doesn't need to be accessed by BL31. 1132fccb228SAntonio Nino Diaz */ 114*da04341eSChris Kay .spm_shim_exceptions : ALIGN(PAGE_SIZE) { 1152fccb228SAntonio Nino Diaz __SPM_SHIM_EXCEPTIONS_START__ = .; 116f90fe02fSChris Kay 1172fccb228SAntonio Nino Diaz *(.spm_shim_exceptions) 118f90fe02fSChris Kay 1195629b2b1SRoberto Vargas . = ALIGN(PAGE_SIZE); 120f90fe02fSChris Kay 1212fccb228SAntonio Nino Diaz __SPM_SHIM_EXCEPTIONS_END__ = .; 12232e83537SArd Biesheuvel } >SPM_SHIM_EXCEPTIONS_VMA AT>RAM 12332e83537SArd Biesheuvel 124*da04341eSChris Kay PROVIDE(__SPM_SHIM_EXCEPTIONS_LMA__ = LOADADDR(.spm_shim_exceptions)); 1252fccb228SAntonio Nino Diaz 126*da04341eSChris Kay . = LOADADDR(.spm_shim_exceptions) + SIZEOF(.spm_shim_exceptions); 127f90fe02fSChris Kay#endif /* SPM_MM */ 128f90fe02fSChris Kay 12954dc71e7SAchin Gupta __RW_START__ = .; 13054dc71e7SAchin Gupta 131caa3e7e0SMasahiro Yamada DATA_SECTION >RAM 132e8ad6168SMasahiro Yamada RELA_SECTION >RAM 133931f7c61SSoby Mathew 134a1b6db6cSSandrine Bailleux#ifdef BL31_PROGBITS_LIMIT 135d178637dSJuan Castillo ASSERT(. <= BL31_PROGBITS_LIMIT, "BL31 progbits has exceeded its limit.") 136f90fe02fSChris Kay#endif /* BL31_PROGBITS_LIMIT */ 137a1b6db6cSSandrine Bailleux 138f8578e64SSamuel Holland#if SEPARATE_NOBITS_REGION 139c367b75eSMadhukar Pappireddy . = ALIGN(PAGE_SIZE); 140f90fe02fSChris Kay 141f8578e64SSamuel Holland __RW_END__ = .; 142f8578e64SSamuel Holland __BL31_END__ = .; 143f8578e64SSamuel Holland 144f8578e64SSamuel Holland ASSERT(. <= BL31_LIMIT, "BL31 image has exceeded its limit.") 145f8578e64SSamuel Holland 146f8578e64SSamuel Holland . = BL31_NOBITS_BASE; 147f90fe02fSChris Kay 148f8578e64SSamuel Holland ASSERT(. == ALIGN(PAGE_SIZE), 149f8578e64SSamuel Holland "BL31 NOBITS base address is not aligned on a page boundary.") 150f8578e64SSamuel Holland 151f8578e64SSamuel Holland __NOBITS_START__ = .; 152f90fe02fSChris Kay#endif /* SEPARATE_NOBITS_REGION */ 153f8578e64SSamuel Holland 154a926a9f6SMasahiro Yamada STACK_SECTION >NOBITS 155a7739bc7SMasahiro Yamada BSS_SECTION >NOBITS 156665e71b8SMasahiro Yamada XLAT_TABLE_SECTION >NOBITS 157a0cd989dSAchin Gupta 158ab8707e6SSoby Mathew#if USE_COHERENT_MEM 159a0cd989dSAchin Gupta /* 160f90fe02fSChris Kay * The base address of the coherent memory section must be page-aligned to 161f90fe02fSChris Kay * guarantee that the coherent data are stored on their own pages and are 162f90fe02fSChris Kay * not mixed with normal data. This is required to set up the correct 1638d69a03fSSandrine Bailleux * memory attributes for the coherent data page tables. 1648d69a03fSSandrine Bailleux */ 165*da04341eSChris Kay .coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) { 1668d69a03fSSandrine Bailleux __COHERENT_RAM_START__ = .; 167f90fe02fSChris Kay 168ee7b35c4SAndrew Thoelke /* 169f90fe02fSChris Kay * Bakery locks are stored in coherent memory. Each lock's data is 170f90fe02fSChris Kay * contiguous and fully allocated by the compiler. 171ee7b35c4SAndrew Thoelke */ 172*da04341eSChris Kay *(.bakery_lock) 173*da04341eSChris Kay *(.tzfw_coherent_mem) 174f90fe02fSChris Kay 1758d69a03fSSandrine Bailleux __COHERENT_RAM_END_UNALIGNED__ = .; 176f90fe02fSChris Kay 1778d69a03fSSandrine Bailleux /* 178f90fe02fSChris Kay * Memory page(s) mapped to this section will be marked as device 179f90fe02fSChris Kay * memory. No other unexpected data must creep in. Ensure the rest of 180f90fe02fSChris Kay * the current memory page is unused. 1818d69a03fSSandrine Bailleux */ 1825629b2b1SRoberto Vargas . = ALIGN(PAGE_SIZE); 183f90fe02fSChris Kay 1848d69a03fSSandrine Bailleux __COHERENT_RAM_END__ = .; 185f8578e64SSamuel Holland } >NOBITS 186f90fe02fSChris Kay#endif /* USE_COHERENT_MEM */ 1874f6ad66aSAchin Gupta 188f8578e64SSamuel Holland#if SEPARATE_NOBITS_REGION 189f8578e64SSamuel Holland __NOBITS_END__ = .; 190f8578e64SSamuel Holland 191f8578e64SSamuel Holland ASSERT(. <= BL31_NOBITS_LIMIT, "BL31 NOBITS region has exceeded its limit.") 192f90fe02fSChris Kay#else /* SEPARATE_NOBITS_REGION */ 19354dc71e7SAchin Gupta __RW_END__ = .; 1948d69a03fSSandrine Bailleux __BL31_END__ = .; 1954f6ad66aSAchin Gupta 19664207f85SSamuel Holland ASSERT(. <= BL31_LIMIT, "BL31 image has exceeded its limit.") 197f90fe02fSChris Kay#endif /* SEPARATE_NOBITS_REGION */ 19864207f85SSamuel Holland 199511046eaSMasahiro Yamada /DISCARD/ : { 200511046eaSMasahiro Yamada *(.dynsym .dynstr .hash .gnu.hash) 201511046eaSMasahiro Yamada } 2024f6ad66aSAchin Gupta} 203