Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 1 | /* |
Madhukar Pappireddy | f4e6ea6 | 2020-01-27 15:32:15 -0600 | [diff] [blame] | 2 | * Copyright (c) 2013-2020, ARM Limited and Contributors. All rights reserved. |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
Masahiro Yamada | 0b67e56 | 2020-03-09 17:39:48 +0900 | [diff] [blame] | 7 | #include <common/bl_common.ld.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 8 | #include <lib/xlat_tables/xlat_tables_defs.h> |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 9 | |
| 10 | OUTPUT_FORMAT(PLATFORM_LINKER_FORMAT) |
| 11 | OUTPUT_ARCH(PLATFORM_LINKER_ARCH) |
Jeenu Viswambharan | 2a30a75 | 2014-03-11 11:06:45 +0000 | [diff] [blame] | 12 | ENTRY(bl31_entrypoint) |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 13 | |
| 14 | |
| 15 | MEMORY { |
Juan Castillo | fd8c077 | 2014-09-16 10:40:35 +0100 | [diff] [blame] | 16 | RAM (rwx): ORIGIN = BL31_BASE, LENGTH = BL31_LIMIT - BL31_BASE |
Samuel Holland | 31a14e1 | 2018-10-17 21:40:18 -0500 | [diff] [blame] | 17 | #if SEPARATE_NOBITS_REGION |
| 18 | NOBITS (rw!a): ORIGIN = BL31_NOBITS_BASE, LENGTH = BL31_NOBITS_LIMIT - BL31_NOBITS_BASE |
| 19 | #else |
| 20 | #define NOBITS RAM |
| 21 | #endif |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 22 | } |
| 23 | |
Caesar Wang | d90f43e | 2016-10-11 09:36:00 +0800 | [diff] [blame] | 24 | #ifdef PLAT_EXTRA_LD_SCRIPT |
| 25 | #include <plat.ld.S> |
| 26 | #endif |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 27 | |
| 28 | SECTIONS |
| 29 | { |
Sandrine Bailleux | 8d69a03 | 2013-11-27 09:38:52 +0000 | [diff] [blame] | 30 | . = BL31_BASE; |
Antonio Nino Diaz | 2ce2b09 | 2017-11-15 11:45:35 +0000 | [diff] [blame] | 31 | ASSERT(. == ALIGN(PAGE_SIZE), |
Sandrine Bailleux | 8d69a03 | 2013-11-27 09:38:52 +0000 | [diff] [blame] | 32 | "BL31_BASE address is not aligned on a page boundary.") |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 33 | |
Soby Mathew | 4e28c20 | 2018-10-14 08:09:22 +0100 | [diff] [blame] | 34 | __BL31_START__ = .; |
| 35 | |
Sandrine Bailleux | f91f144 | 2016-07-08 14:37:40 +0100 | [diff] [blame] | 36 | #if SEPARATE_CODE_AND_RODATA |
| 37 | .text . : { |
| 38 | __TEXT_START__ = .; |
| 39 | *bl31_entrypoint.o(.text*) |
Samuel Holland | 23f5e54 | 2019-10-20 16:11:25 -0500 | [diff] [blame] | 40 | *(SORT_BY_ALIGNMENT(.text*)) |
Sandrine Bailleux | f91f144 | 2016-07-08 14:37:40 +0100 | [diff] [blame] | 41 | *(.vectors) |
Roberto Vargas | d93fde3 | 2018-04-11 11:53:31 +0100 | [diff] [blame] | 42 | . = ALIGN(PAGE_SIZE); |
Sandrine Bailleux | f91f144 | 2016-07-08 14:37:40 +0100 | [diff] [blame] | 43 | __TEXT_END__ = .; |
| 44 | } >RAM |
| 45 | |
| 46 | .rodata . : { |
| 47 | __RODATA_START__ = .; |
Samuel Holland | 23f5e54 | 2019-10-20 16:11:25 -0500 | [diff] [blame] | 48 | *(SORT_BY_ALIGNMENT(.rodata*)) |
Sandrine Bailleux | f91f144 | 2016-07-08 14:37:40 +0100 | [diff] [blame] | 49 | |
Masahiro Yamada | 583f8dd | 2020-03-26 10:57:12 +0900 | [diff] [blame] | 50 | RODATA_COMMON |
Soby Mathew | 4e28c20 | 2018-10-14 08:09:22 +0100 | [diff] [blame] | 51 | |
Jeenu Viswambharan | e3f2200 | 2017-09-22 08:32:10 +0100 | [diff] [blame] | 52 | /* Place pubsub sections for events */ |
| 53 | . = ALIGN(8); |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 54 | #include <lib/el3_runtime/pubsub_events.h> |
Jeenu Viswambharan | e3f2200 | 2017-09-22 08:32:10 +0100 | [diff] [blame] | 55 | |
Roberto Vargas | d93fde3 | 2018-04-11 11:53:31 +0100 | [diff] [blame] | 56 | . = ALIGN(PAGE_SIZE); |
Sandrine Bailleux | f91f144 | 2016-07-08 14:37:40 +0100 | [diff] [blame] | 57 | __RODATA_END__ = .; |
| 58 | } >RAM |
| 59 | #else |
Sandrine Bailleux | 8d69a03 | 2013-11-27 09:38:52 +0000 | [diff] [blame] | 60 | ro . : { |
| 61 | __RO_START__ = .; |
Andrew Thoelke | e01ea34 | 2014-03-18 07:13:52 +0000 | [diff] [blame] | 62 | *bl31_entrypoint.o(.text*) |
Samuel Holland | 23f5e54 | 2019-10-20 16:11:25 -0500 | [diff] [blame] | 63 | *(SORT_BY_ALIGNMENT(.text*)) |
| 64 | *(SORT_BY_ALIGNMENT(.rodata*)) |
Achin Gupta | 7421b46 | 2014-02-01 18:53:26 +0000 | [diff] [blame] | 65 | |
Masahiro Yamada | 583f8dd | 2020-03-26 10:57:12 +0900 | [diff] [blame] | 66 | RODATA_COMMON |
Soby Mathew | 2b3fc1d | 2018-12-12 14:33:11 +0000 | [diff] [blame] | 67 | |
Jeenu Viswambharan | e3f2200 | 2017-09-22 08:32:10 +0100 | [diff] [blame] | 68 | /* Place pubsub sections for events */ |
| 69 | . = ALIGN(8); |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 70 | #include <lib/el3_runtime/pubsub_events.h> |
Jeenu Viswambharan | e3f2200 | 2017-09-22 08:32:10 +0100 | [diff] [blame] | 71 | |
Achin Gupta | b739f22 | 2014-01-18 16:50:09 +0000 | [diff] [blame] | 72 | *(.vectors) |
Sandrine Bailleux | 8d69a03 | 2013-11-27 09:38:52 +0000 | [diff] [blame] | 73 | __RO_END_UNALIGNED__ = .; |
| 74 | /* |
| 75 | * Memory page(s) mapped to this section will be marked as read-only, |
| 76 | * executable. No RW data from the next section must creep in. |
| 77 | * Ensure the rest of the current memory page is unused. |
| 78 | */ |
Roberto Vargas | d93fde3 | 2018-04-11 11:53:31 +0100 | [diff] [blame] | 79 | . = ALIGN(PAGE_SIZE); |
Sandrine Bailleux | 8d69a03 | 2013-11-27 09:38:52 +0000 | [diff] [blame] | 80 | __RO_END__ = .; |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 81 | } >RAM |
Sandrine Bailleux | f91f144 | 2016-07-08 14:37:40 +0100 | [diff] [blame] | 82 | #endif |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 83 | |
Soby Mathew | c704cbc | 2014-08-14 11:33:56 +0100 | [diff] [blame] | 84 | ASSERT(__CPU_OPS_END__ > __CPU_OPS_START__, |
| 85 | "cpu_ops not defined for this platform.") |
| 86 | |
Paul Beesley | db4e25a | 2019-10-14 15:27:12 +0000 | [diff] [blame] | 87 | #if SPM_MM |
Ard Biesheuvel | 447d56f | 2019-01-06 10:07:24 +0100 | [diff] [blame] | 88 | #ifndef SPM_SHIM_EXCEPTIONS_VMA |
| 89 | #define SPM_SHIM_EXCEPTIONS_VMA RAM |
| 90 | #endif |
| 91 | |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 92 | /* |
| 93 | * Exception vectors of the SPM shim layer. They must be aligned to a 2K |
| 94 | * address, but we need to place them in a separate page so that we can set |
| 95 | * individual permissions to them, so the actual alignment needed is 4K. |
| 96 | * |
| 97 | * There's no need to include this into the RO section of BL31 because it |
| 98 | * doesn't need to be accessed by BL31. |
| 99 | */ |
Antonio Nino Diaz | 2ce2b09 | 2017-11-15 11:45:35 +0000 | [diff] [blame] | 100 | spm_shim_exceptions : ALIGN(PAGE_SIZE) { |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 101 | __SPM_SHIM_EXCEPTIONS_START__ = .; |
| 102 | *(.spm_shim_exceptions) |
Roberto Vargas | d93fde3 | 2018-04-11 11:53:31 +0100 | [diff] [blame] | 103 | . = ALIGN(PAGE_SIZE); |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 104 | __SPM_SHIM_EXCEPTIONS_END__ = .; |
Ard Biesheuvel | 447d56f | 2019-01-06 10:07:24 +0100 | [diff] [blame] | 105 | } >SPM_SHIM_EXCEPTIONS_VMA AT>RAM |
| 106 | |
| 107 | PROVIDE(__SPM_SHIM_EXCEPTIONS_LMA__ = LOADADDR(spm_shim_exceptions)); |
| 108 | . = LOADADDR(spm_shim_exceptions) + SIZEOF(spm_shim_exceptions); |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 109 | #endif |
| 110 | |
Achin Gupta | e9c4a64 | 2015-09-11 16:03:13 +0100 | [diff] [blame] | 111 | /* |
| 112 | * Define a linker symbol to mark start of the RW memory area for this |
| 113 | * image. |
| 114 | */ |
| 115 | __RW_START__ = . ; |
| 116 | |
Masahiro Yamada | c5864d8 | 2020-04-22 10:50:12 +0900 | [diff] [blame] | 117 | DATA_SECTION >RAM |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 118 | |
Soby Mathew | 4e28c20 | 2018-10-14 08:09:22 +0100 | [diff] [blame] | 119 | /* |
| 120 | * .rela.dyn needs to come after .data for the read-elf utility to parse |
Soby Mathew | 2b3fc1d | 2018-12-12 14:33:11 +0000 | [diff] [blame] | 121 | * this section correctly. Ensure 8-byte alignment so that the fields of |
| 122 | * RELA data structure are aligned. |
Soby Mathew | 4e28c20 | 2018-10-14 08:09:22 +0100 | [diff] [blame] | 123 | */ |
Soby Mathew | 2b3fc1d | 2018-12-12 14:33:11 +0000 | [diff] [blame] | 124 | . = ALIGN(8); |
Soby Mathew | 4e28c20 | 2018-10-14 08:09:22 +0100 | [diff] [blame] | 125 | __RELA_START__ = .; |
| 126 | .rela.dyn . : { |
| 127 | } >RAM |
| 128 | __RELA_END__ = .; |
| 129 | |
Sandrine Bailleux | e2e0c65 | 2014-06-16 16:12:27 +0100 | [diff] [blame] | 130 | #ifdef BL31_PROGBITS_LIMIT |
Juan Castillo | 7d19941 | 2015-12-14 09:35:25 +0000 | [diff] [blame] | 131 | ASSERT(. <= BL31_PROGBITS_LIMIT, "BL31 progbits has exceeded its limit.") |
Sandrine Bailleux | e2e0c65 | 2014-06-16 16:12:27 +0100 | [diff] [blame] | 132 | #endif |
| 133 | |
Samuel Holland | 31a14e1 | 2018-10-17 21:40:18 -0500 | [diff] [blame] | 134 | #if SEPARATE_NOBITS_REGION |
| 135 | /* |
| 136 | * Define a linker symbol to mark end of the RW memory area for this |
| 137 | * image. |
| 138 | */ |
Madhukar Pappireddy | f4e6ea6 | 2020-01-27 15:32:15 -0600 | [diff] [blame] | 139 | . = ALIGN(PAGE_SIZE); |
Samuel Holland | 31a14e1 | 2018-10-17 21:40:18 -0500 | [diff] [blame] | 140 | __RW_END__ = .; |
| 141 | __BL31_END__ = .; |
| 142 | |
| 143 | ASSERT(. <= BL31_LIMIT, "BL31 image has exceeded its limit.") |
| 144 | |
| 145 | . = BL31_NOBITS_BASE; |
| 146 | ASSERT(. == ALIGN(PAGE_SIZE), |
| 147 | "BL31 NOBITS base address is not aligned on a page boundary.") |
| 148 | |
| 149 | __NOBITS_START__ = .; |
| 150 | #endif |
| 151 | |
Masahiro Yamada | 403990e | 2020-04-07 13:04:24 +0900 | [diff] [blame] | 152 | STACK_SECTION >NOBITS |
Masahiro Yamada | dd053b6 | 2020-03-26 13:16:33 +0900 | [diff] [blame] | 153 | BSS_SECTION >NOBITS |
Masahiro Yamada | 0b67e56 | 2020-03-09 17:39:48 +0900 | [diff] [blame] | 154 | XLAT_TABLE_SECTION >NOBITS |
Achin Gupta | a0cd989 | 2014-02-09 13:30:38 +0000 | [diff] [blame] | 155 | |
Soby Mathew | 2ae2043 | 2015-01-08 18:02:44 +0000 | [diff] [blame] | 156 | #if USE_COHERENT_MEM |
Achin Gupta | a0cd989 | 2014-02-09 13:30:38 +0000 | [diff] [blame] | 157 | /* |
Sandrine Bailleux | 8d69a03 | 2013-11-27 09:38:52 +0000 | [diff] [blame] | 158 | * The base address of the coherent memory section must be page-aligned (4K) |
| 159 | * to guarantee that the coherent data are stored on their own pages and |
| 160 | * are not mixed with normal data. This is required to set up the correct |
| 161 | * memory attributes for the coherent data page tables. |
| 162 | */ |
Antonio Nino Diaz | 2ce2b09 | 2017-11-15 11:45:35 +0000 | [diff] [blame] | 163 | coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) { |
Sandrine Bailleux | 8d69a03 | 2013-11-27 09:38:52 +0000 | [diff] [blame] | 164 | __COHERENT_RAM_START__ = .; |
Andrew Thoelke | e466c9f | 2015-09-10 11:39:36 +0100 | [diff] [blame] | 165 | /* |
| 166 | * Bakery locks are stored in coherent memory |
| 167 | * |
| 168 | * Each lock's data is contiguous and fully allocated by the compiler |
| 169 | */ |
| 170 | *(bakery_lock) |
Sandrine Bailleux | 8d69a03 | 2013-11-27 09:38:52 +0000 | [diff] [blame] | 171 | *(tzfw_coherent_mem) |
| 172 | __COHERENT_RAM_END_UNALIGNED__ = .; |
| 173 | /* |
| 174 | * Memory page(s) mapped to this section will be marked |
| 175 | * as device memory. No other unexpected data must creep in. |
| 176 | * Ensure the rest of the current memory page is unused. |
| 177 | */ |
Roberto Vargas | d93fde3 | 2018-04-11 11:53:31 +0100 | [diff] [blame] | 178 | . = ALIGN(PAGE_SIZE); |
Sandrine Bailleux | 8d69a03 | 2013-11-27 09:38:52 +0000 | [diff] [blame] | 179 | __COHERENT_RAM_END__ = .; |
Samuel Holland | 31a14e1 | 2018-10-17 21:40:18 -0500 | [diff] [blame] | 180 | } >NOBITS |
Soby Mathew | 2ae2043 | 2015-01-08 18:02:44 +0000 | [diff] [blame] | 181 | #endif |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 182 | |
Samuel Holland | 31a14e1 | 2018-10-17 21:40:18 -0500 | [diff] [blame] | 183 | #if SEPARATE_NOBITS_REGION |
| 184 | /* |
| 185 | * Define a linker symbol to mark end of the NOBITS memory area for this |
| 186 | * image. |
| 187 | */ |
| 188 | __NOBITS_END__ = .; |
| 189 | |
| 190 | ASSERT(. <= BL31_NOBITS_LIMIT, "BL31 NOBITS region has exceeded its limit.") |
| 191 | #else |
Achin Gupta | e9c4a64 | 2015-09-11 16:03:13 +0100 | [diff] [blame] | 192 | /* |
| 193 | * Define a linker symbol to mark end of the RW memory area for this |
| 194 | * image. |
| 195 | */ |
| 196 | __RW_END__ = .; |
Sandrine Bailleux | 8d69a03 | 2013-11-27 09:38:52 +0000 | [diff] [blame] | 197 | __BL31_END__ = .; |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 198 | |
Masahiro Yamada | d3e7baa | 2020-01-17 13:44:50 +0900 | [diff] [blame] | 199 | /DISCARD/ : { |
| 200 | *(.dynsym .dynstr .hash .gnu.hash) |
| 201 | } |
| 202 | |
Juan Castillo | 7d19941 | 2015-12-14 09:35:25 +0000 | [diff] [blame] | 203 | ASSERT(. <= BL31_LIMIT, "BL31 image has exceeded its limit.") |
Samuel Holland | 31a14e1 | 2018-10-17 21:40:18 -0500 | [diff] [blame] | 204 | #endif |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 205 | } |