Yatharth Kochar | b1c2fe0 | 2015-10-14 15:27:24 +0100 | [diff] [blame] | 1 | /* |
Antonio Nino Diaz | 7c2a3ca | 2018-02-23 15:07:54 +0000 | [diff] [blame] | 2 | * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. |
Yatharth Kochar | b1c2fe0 | 2015-10-14 15:27:24 +0100 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Yatharth Kochar | b1c2fe0 | 2015-10-14 15:27:24 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
| 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> |
Yatharth Kochar | b1c2fe0 | 2015-10-14 15:27:24 +0100 | [diff] [blame] | 10 | |
| 11 | OUTPUT_FORMAT(PLATFORM_LINKER_FORMAT) |
| 12 | OUTPUT_ARCH(PLATFORM_LINKER_ARCH) |
| 13 | ENTRY(bl2u_entrypoint) |
| 14 | |
| 15 | MEMORY { |
| 16 | RAM (rwx): ORIGIN = BL2U_BASE, LENGTH = BL2U_LIMIT - BL2U_BASE |
| 17 | } |
| 18 | |
| 19 | |
| 20 | SECTIONS |
| 21 | { |
| 22 | . = BL2U_BASE; |
Antonio Nino Diaz | 2ce2b09 | 2017-11-15 11:45:35 +0000 | [diff] [blame] | 23 | ASSERT(. == ALIGN(PAGE_SIZE), |
Yatharth Kochar | b1c2fe0 | 2015-10-14 15:27:24 +0100 | [diff] [blame] | 24 | "BL2U_BASE address is not aligned on a page boundary.") |
| 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 | *bl2u_entrypoint.o(.text*) |
| 30 | *(.text*) |
| 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__ = .; |
| 47 | *(.rodata*) |
Roberto Vargas | d93fde3 | 2018-04-11 11:53:31 +0100 | [diff] [blame] | 48 | . = ALIGN(PAGE_SIZE); |
Sandrine Bailleux | f91f144 | 2016-07-08 14:37:40 +0100 | [diff] [blame] | 49 | __RODATA_END__ = .; |
| 50 | } >RAM |
| 51 | #else |
Yatharth Kochar | b1c2fe0 | 2015-10-14 15:27:24 +0100 | [diff] [blame] | 52 | ro . : { |
| 53 | __RO_START__ = .; |
| 54 | *bl2u_entrypoint.o(.text*) |
| 55 | *(.text*) |
| 56 | *(.rodata*) |
| 57 | |
| 58 | *(.vectors) |
| 59 | __RO_END_UNALIGNED__ = .; |
| 60 | /* |
| 61 | * Memory page(s) mapped to this section will be marked as |
| 62 | * read-only, executable. No RW data from the next section must |
| 63 | * creep in. Ensure the rest of the current memory page is unused. |
| 64 | */ |
Roberto Vargas | d93fde3 | 2018-04-11 11:53:31 +0100 | [diff] [blame] | 65 | . = ALIGN(PAGE_SIZE); |
Yatharth Kochar | b1c2fe0 | 2015-10-14 15:27:24 +0100 | [diff] [blame] | 66 | __RO_END__ = .; |
| 67 | } >RAM |
Sandrine Bailleux | f91f144 | 2016-07-08 14:37:40 +0100 | [diff] [blame] | 68 | #endif |
Yatharth Kochar | b1c2fe0 | 2015-10-14 15:27:24 +0100 | [diff] [blame] | 69 | |
| 70 | /* |
| 71 | * Define a linker symbol to mark start of the RW memory area for this |
| 72 | * image. |
| 73 | */ |
| 74 | __RW_START__ = . ; |
| 75 | |
Douglas Raillard | 306593d | 2017-02-24 18:14:15 +0000 | [diff] [blame] | 76 | /* |
| 77 | * .data must be placed at a lower address than the stacks if the stack |
| 78 | * protector is enabled. Alternatively, the .data.stack_protector_canary |
| 79 | * section can be placed independently of the main .data section. |
| 80 | */ |
Yatharth Kochar | b1c2fe0 | 2015-10-14 15:27:24 +0100 | [diff] [blame] | 81 | .data . : { |
| 82 | __DATA_START__ = .; |
| 83 | *(.data*) |
| 84 | __DATA_END__ = .; |
| 85 | } >RAM |
| 86 | |
| 87 | stacks (NOLOAD) : { |
| 88 | __STACKS_START__ = .; |
| 89 | *(tzfw_normal_stacks) |
| 90 | __STACKS_END__ = .; |
| 91 | } >RAM |
| 92 | |
| 93 | /* |
| 94 | * The .bss section gets initialised to 0 at runtime. |
Douglas Raillard | 21362a9 | 2016-12-02 13:51:54 +0000 | [diff] [blame] | 95 | * Its base address should be 16-byte aligned for better performance of the |
| 96 | * zero-initialization code. |
Yatharth Kochar | b1c2fe0 | 2015-10-14 15:27:24 +0100 | [diff] [blame] | 97 | */ |
| 98 | .bss : ALIGN(16) { |
| 99 | __BSS_START__ = .; |
| 100 | *(SORT_BY_ALIGNMENT(.bss*)) |
| 101 | *(COMMON) |
| 102 | __BSS_END__ = .; |
| 103 | } >RAM |
| 104 | |
| 105 | /* |
| 106 | * The xlat_table section is for full, aligned page tables (4K). |
| 107 | * Removing them from .bss avoids forcing 4K alignment on |
Antonio Nino Diaz | 7c2a3ca | 2018-02-23 15:07:54 +0000 | [diff] [blame] | 108 | * the .bss section. The tables are initialized to zero by the translation |
| 109 | * tables library. |
Yatharth Kochar | b1c2fe0 | 2015-10-14 15:27:24 +0100 | [diff] [blame] | 110 | */ |
| 111 | xlat_table (NOLOAD) : { |
| 112 | *(xlat_table) |
| 113 | } >RAM |
| 114 | |
| 115 | #if USE_COHERENT_MEM |
| 116 | /* |
| 117 | * The base address of the coherent memory section must be page-aligned (4K) |
| 118 | * to guarantee that the coherent data are stored on their own pages and |
| 119 | * are not mixed with normal data. This is required to set up the correct |
| 120 | * memory attributes for the coherent data page tables. |
| 121 | */ |
Antonio Nino Diaz | 2ce2b09 | 2017-11-15 11:45:35 +0000 | [diff] [blame] | 122 | coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) { |
Yatharth Kochar | b1c2fe0 | 2015-10-14 15:27:24 +0100 | [diff] [blame] | 123 | __COHERENT_RAM_START__ = .; |
| 124 | *(tzfw_coherent_mem) |
| 125 | __COHERENT_RAM_END_UNALIGNED__ = .; |
| 126 | /* |
| 127 | * Memory page(s) mapped to this section will be marked |
| 128 | * as device memory. No other unexpected data must creep in. |
| 129 | * Ensure the rest of the current memory page is unused. |
| 130 | */ |
Roberto Vargas | d93fde3 | 2018-04-11 11:53:31 +0100 | [diff] [blame] | 131 | . = ALIGN(PAGE_SIZE); |
Yatharth Kochar | b1c2fe0 | 2015-10-14 15:27:24 +0100 | [diff] [blame] | 132 | __COHERENT_RAM_END__ = .; |
| 133 | } >RAM |
| 134 | #endif |
| 135 | |
| 136 | /* |
| 137 | * Define a linker symbol to mark end of the RW memory area for this |
| 138 | * image. |
| 139 | */ |
| 140 | __RW_END__ = .; |
| 141 | __BL2U_END__ = .; |
| 142 | |
| 143 | __BSS_SIZE__ = SIZEOF(.bss); |
| 144 | |
| 145 | ASSERT(. <= BL2U_LIMIT, "BL2U image has exceeded its limit.") |
| 146 | } |