Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 1 | /* |
Louis Mayencourt | 944ade8 | 2019-08-08 12:03:26 +0100 | [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 | |
Dan Handley | ed6ff95 | 2014-05-14 17:44:19 +0100 | [diff] [blame] | 7 | #include <platform_def.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 8 | |
| 9 | #include <lib/xlat_tables/xlat_tables_defs.h> |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 10 | |
| 11 | OUTPUT_FORMAT(PLATFORM_LINKER_FORMAT) |
| 12 | OUTPUT_ARCH(PLATFORM_LINKER_ARCH) |
Jeenu Viswambharan | 2a30a75 | 2014-03-11 11:06:45 +0000 | [diff] [blame] | 13 | ENTRY(bl2_entrypoint) |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 14 | |
| 15 | MEMORY { |
Juan Castillo | fd8c077 | 2014-09-16 10:40:35 +0100 | [diff] [blame] | 16 | RAM (rwx): ORIGIN = BL2_BASE, LENGTH = BL2_LIMIT - BL2_BASE |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 17 | } |
| 18 | |
| 19 | |
| 20 | SECTIONS |
| 21 | { |
| 22 | . = BL2_BASE; |
Antonio Nino Diaz | 2ce2b09 | 2017-11-15 11:45:35 +0000 | [diff] [blame] | 23 | ASSERT(. == ALIGN(PAGE_SIZE), |
Sandrine Bailleux | 8d69a03 | 2013-11-27 09:38:52 +0000 | [diff] [blame] | 24 | "BL2_BASE address is not aligned on a page boundary.") |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 25 | |
Sandrine Bailleux | f91f144 | 2016-07-08 14:37:40 +0100 | [diff] [blame] | 26 | #if SEPARATE_CODE_AND_RODATA |
| 27 | .text . : { |
| 28 | __TEXT_START__ = .; |
| 29 | *bl2_entrypoint.o(.text*) |
Samuel Holland | 23f5e54 | 2019-10-20 16:11:25 -0500 | [diff] [blame] | 30 | *(SORT_BY_ALIGNMENT(.text*)) |
Sandrine Bailleux | f91f144 | 2016-07-08 14:37:40 +0100 | [diff] [blame] | 31 | *(.vectors) |
Roberto Vargas | d93fde3 | 2018-04-11 11:53:31 +0100 | [diff] [blame] | 32 | . = ALIGN(PAGE_SIZE); |
Sandrine Bailleux | f91f144 | 2016-07-08 14:37:40 +0100 | [diff] [blame] | 33 | __TEXT_END__ = .; |
| 34 | } >RAM |
| 35 | |
Roberto Vargas | 1d04c63 | 2018-05-10 11:01:16 +0100 | [diff] [blame] | 36 | /* .ARM.extab and .ARM.exidx are only added because Clang need them */ |
| 37 | .ARM.extab . : { |
| 38 | *(.ARM.extab* .gnu.linkonce.armextab.*) |
| 39 | } >RAM |
| 40 | |
| 41 | .ARM.exidx . : { |
| 42 | *(.ARM.exidx* .gnu.linkonce.armexidx.*) |
| 43 | } >RAM |
| 44 | |
Sandrine Bailleux | f91f144 | 2016-07-08 14:37:40 +0100 | [diff] [blame] | 45 | .rodata . : { |
| 46 | __RODATA_START__ = .; |
Samuel Holland | 23f5e54 | 2019-10-20 16:11:25 -0500 | [diff] [blame] | 47 | *(SORT_BY_ALIGNMENT(.rodata*)) |
Sandrine Bailleux | f91f144 | 2016-07-08 14:37:40 +0100 | [diff] [blame] | 48 | |
Louis Mayencourt | 944ade8 | 2019-08-08 12:03:26 +0100 | [diff] [blame] | 49 | . = ALIGN(8); |
| 50 | __FCONF_POPULATOR_START__ = .; |
| 51 | KEEP(*(.fconf_populator)) |
| 52 | __FCONF_POPULATOR_END__ = .; |
| 53 | |
Sandrine Bailleux | f91f144 | 2016-07-08 14:37:40 +0100 | [diff] [blame] | 54 | /* Ensure 8-byte alignment for descriptors and ensure inclusion */ |
| 55 | . = ALIGN(8); |
| 56 | __PARSER_LIB_DESCS_START__ = .; |
| 57 | KEEP(*(.img_parser_lib_descs)) |
| 58 | __PARSER_LIB_DESCS_END__ = .; |
| 59 | |
Roberto Vargas | d93fde3 | 2018-04-11 11:53:31 +0100 | [diff] [blame] | 60 | . = ALIGN(PAGE_SIZE); |
Sandrine Bailleux | f91f144 | 2016-07-08 14:37:40 +0100 | [diff] [blame] | 61 | __RODATA_END__ = .; |
| 62 | } >RAM |
| 63 | #else |
Sandrine Bailleux | 8d69a03 | 2013-11-27 09:38:52 +0000 | [diff] [blame] | 64 | ro . : { |
| 65 | __RO_START__ = .; |
Andrew Thoelke | e01ea34 | 2014-03-18 07:13:52 +0000 | [diff] [blame] | 66 | *bl2_entrypoint.o(.text*) |
Samuel Holland | 23f5e54 | 2019-10-20 16:11:25 -0500 | [diff] [blame] | 67 | *(SORT_BY_ALIGNMENT(.text*)) |
| 68 | *(SORT_BY_ALIGNMENT(.rodata*)) |
Juan Castillo | 8e55d93 | 2015-04-02 09:48:16 +0100 | [diff] [blame] | 69 | |
Louis Mayencourt | 944ade8 | 2019-08-08 12:03:26 +0100 | [diff] [blame] | 70 | . = ALIGN(8); |
| 71 | __FCONF_POPULATOR_START__ = .; |
| 72 | KEEP(*(.fconf_populator)) |
| 73 | __FCONF_POPULATOR_END__ = .; |
| 74 | |
Juan Castillo | 8e55d93 | 2015-04-02 09:48:16 +0100 | [diff] [blame] | 75 | /* Ensure 8-byte alignment for descriptors and ensure inclusion */ |
| 76 | . = ALIGN(8); |
| 77 | __PARSER_LIB_DESCS_START__ = .; |
| 78 | KEEP(*(.img_parser_lib_descs)) |
| 79 | __PARSER_LIB_DESCS_END__ = .; |
| 80 | |
Achin Gupta | b739f22 | 2014-01-18 16:50:09 +0000 | [diff] [blame] | 81 | *(.vectors) |
Sandrine Bailleux | 8d69a03 | 2013-11-27 09:38:52 +0000 | [diff] [blame] | 82 | __RO_END_UNALIGNED__ = .; |
| 83 | /* |
| 84 | * Memory page(s) mapped to this section will be marked as |
| 85 | * read-only, executable. No RW data from the next section must |
| 86 | * creep in. Ensure the rest of the current memory page is unused. |
| 87 | */ |
Roberto Vargas | d93fde3 | 2018-04-11 11:53:31 +0100 | [diff] [blame] | 88 | . = ALIGN(PAGE_SIZE); |
Sandrine Bailleux | 8d69a03 | 2013-11-27 09:38:52 +0000 | [diff] [blame] | 89 | __RO_END__ = .; |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 90 | } >RAM |
Sandrine Bailleux | f91f144 | 2016-07-08 14:37:40 +0100 | [diff] [blame] | 91 | #endif |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 92 | |
Achin Gupta | e9c4a64 | 2015-09-11 16:03:13 +0100 | [diff] [blame] | 93 | /* |
| 94 | * Define a linker symbol to mark start of the RW memory area for this |
| 95 | * image. |
| 96 | */ |
| 97 | __RW_START__ = . ; |
| 98 | |
Douglas Raillard | 306593d | 2017-02-24 18:14:15 +0000 | [diff] [blame] | 99 | /* |
| 100 | * .data must be placed at a lower address than the stacks if the stack |
| 101 | * protector is enabled. Alternatively, the .data.stack_protector_canary |
| 102 | * section can be placed independently of the main .data section. |
| 103 | */ |
Sandrine Bailleux | 8d69a03 | 2013-11-27 09:38:52 +0000 | [diff] [blame] | 104 | .data . : { |
| 105 | __DATA_START__ = .; |
Samuel Holland | 23f5e54 | 2019-10-20 16:11:25 -0500 | [diff] [blame] | 106 | *(SORT_BY_ALIGNMENT(.data*)) |
Sandrine Bailleux | 8d69a03 | 2013-11-27 09:38:52 +0000 | [diff] [blame] | 107 | __DATA_END__ = .; |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 108 | } >RAM |
| 109 | |
Sandrine Bailleux | 8d69a03 | 2013-11-27 09:38:52 +0000 | [diff] [blame] | 110 | stacks (NOLOAD) : { |
| 111 | __STACKS_START__ = .; |
| 112 | *(tzfw_normal_stacks) |
| 113 | __STACKS_END__ = .; |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 114 | } >RAM |
| 115 | |
Sandrine Bailleux | 8d69a03 | 2013-11-27 09:38:52 +0000 | [diff] [blame] | 116 | /* |
| 117 | * The .bss section gets initialised to 0 at runtime. |
Douglas Raillard | 21362a9 | 2016-12-02 13:51:54 +0000 | [diff] [blame] | 118 | * Its base address should be 16-byte aligned for better performance of the |
| 119 | * zero-initialization code. |
Sandrine Bailleux | 8d69a03 | 2013-11-27 09:38:52 +0000 | [diff] [blame] | 120 | */ |
| 121 | .bss : ALIGN(16) { |
| 122 | __BSS_START__ = .; |
Andrew Thoelke | e01ea34 | 2014-03-18 07:13:52 +0000 | [diff] [blame] | 123 | *(SORT_BY_ALIGNMENT(.bss*)) |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 124 | *(COMMON) |
Sandrine Bailleux | 8d69a03 | 2013-11-27 09:38:52 +0000 | [diff] [blame] | 125 | __BSS_END__ = .; |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 126 | } >RAM |
| 127 | |
Sandrine Bailleux | 8d69a03 | 2013-11-27 09:38:52 +0000 | [diff] [blame] | 128 | /* |
Jeenu Viswambharan | 97cc9ee | 2014-02-24 15:20:28 +0000 | [diff] [blame] | 129 | * The xlat_table section is for full, aligned page tables (4K). |
Achin Gupta | a0cd989 | 2014-02-09 13:30:38 +0000 | [diff] [blame] | 130 | * Removing them from .bss avoids forcing 4K alignment on |
Antonio Nino Diaz | 7c2a3ca | 2018-02-23 15:07:54 +0000 | [diff] [blame] | 131 | * the .bss section. The tables are initialized to zero by the translation |
| 132 | * tables library. |
Achin Gupta | a0cd989 | 2014-02-09 13:30:38 +0000 | [diff] [blame] | 133 | */ |
| 134 | xlat_table (NOLOAD) : { |
| 135 | *(xlat_table) |
| 136 | } >RAM |
| 137 | |
Soby Mathew | 2ae2043 | 2015-01-08 18:02:44 +0000 | [diff] [blame] | 138 | #if USE_COHERENT_MEM |
Achin Gupta | a0cd989 | 2014-02-09 13:30:38 +0000 | [diff] [blame] | 139 | /* |
Sandrine Bailleux | 8d69a03 | 2013-11-27 09:38:52 +0000 | [diff] [blame] | 140 | * The base address of the coherent memory section must be page-aligned (4K) |
| 141 | * to guarantee that the coherent data are stored on their own pages and |
| 142 | * are not mixed with normal data. This is required to set up the correct |
| 143 | * memory attributes for the coherent data page tables. |
| 144 | */ |
Antonio Nino Diaz | 2ce2b09 | 2017-11-15 11:45:35 +0000 | [diff] [blame] | 145 | coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) { |
Sandrine Bailleux | 8d69a03 | 2013-11-27 09:38:52 +0000 | [diff] [blame] | 146 | __COHERENT_RAM_START__ = .; |
| 147 | *(tzfw_coherent_mem) |
| 148 | __COHERENT_RAM_END_UNALIGNED__ = .; |
| 149 | /* |
| 150 | * Memory page(s) mapped to this section will be marked |
| 151 | * as device memory. No other unexpected data must creep in. |
| 152 | * Ensure the rest of the current memory page is unused. |
| 153 | */ |
Roberto Vargas | d93fde3 | 2018-04-11 11:53:31 +0100 | [diff] [blame] | 154 | . = ALIGN(PAGE_SIZE); |
Sandrine Bailleux | 8d69a03 | 2013-11-27 09:38:52 +0000 | [diff] [blame] | 155 | __COHERENT_RAM_END__ = .; |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 156 | } >RAM |
Soby Mathew | 2ae2043 | 2015-01-08 18:02:44 +0000 | [diff] [blame] | 157 | #endif |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 158 | |
Achin Gupta | e9c4a64 | 2015-09-11 16:03:13 +0100 | [diff] [blame] | 159 | /* |
| 160 | * Define a linker symbol to mark end of the RW memory area for this |
| 161 | * image. |
| 162 | */ |
| 163 | __RW_END__ = .; |
Sandrine Bailleux | 8d69a03 | 2013-11-27 09:38:52 +0000 | [diff] [blame] | 164 | __BL2_END__ = .; |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 165 | |
Sandrine Bailleux | 8d69a03 | 2013-11-27 09:38:52 +0000 | [diff] [blame] | 166 | __BSS_SIZE__ = SIZEOF(.bss); |
Soby Mathew | 2ae2043 | 2015-01-08 18:02:44 +0000 | [diff] [blame] | 167 | |
| 168 | #if USE_COHERENT_MEM |
Sandrine Bailleux | 8d69a03 | 2013-11-27 09:38:52 +0000 | [diff] [blame] | 169 | __COHERENT_RAM_UNALIGNED_SIZE__ = |
| 170 | __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__; |
Soby Mathew | 2ae2043 | 2015-01-08 18:02:44 +0000 | [diff] [blame] | 171 | #endif |
Sandrine Bailleux | 6c8b359 | 2014-05-22 15:28:26 +0100 | [diff] [blame] | 172 | |
| 173 | ASSERT(. <= BL2_LIMIT, "BL2 image has exceeded its limit.") |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 174 | } |