Soby Mathew | ec8ac1c | 2016-05-05 14:32:05 +0100 | [diff] [blame] | 1 | /* |
Yann Gautier | 514e59c | 2020-10-05 11:02:54 +0200 | [diff] [blame] | 2 | * Copyright (c) 2016-2021, ARM Limited and Contributors. All rights reserved. |
Soby Mathew | ec8ac1c | 2016-05-05 14:32:05 +0100 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Soby Mathew | ec8ac1c | 2016-05-05 14:32:05 +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> |
Soby Mathew | ec8ac1c | 2016-05-05 14:32:05 +0100 | [diff] [blame] | 9 | |
| 10 | OUTPUT_FORMAT(elf32-littlearm) |
| 11 | OUTPUT_ARCH(arm) |
| 12 | ENTRY(sp_min_vector_table) |
| 13 | |
| 14 | MEMORY { |
| 15 | RAM (rwx): ORIGIN = BL32_BASE, LENGTH = BL32_LIMIT - BL32_BASE |
| 16 | } |
| 17 | |
Heiko Stuebner | 95ba355 | 2019-04-11 15:26:07 +0200 | [diff] [blame] | 18 | #ifdef PLAT_SP_MIN_EXTRA_LD_SCRIPT |
| 19 | #include <plat_sp_min.ld.S> |
| 20 | #endif |
Soby Mathew | ec8ac1c | 2016-05-05 14:32:05 +0100 | [diff] [blame] | 21 | |
| 22 | SECTIONS |
| 23 | { |
| 24 | . = BL32_BASE; |
Yann Gautier | 876be65 | 2020-10-05 09:54:09 +0200 | [diff] [blame] | 25 | ASSERT(. == ALIGN(PAGE_SIZE), |
| 26 | "BL32_BASE address is not aligned on a page boundary.") |
Soby Mathew | ec8ac1c | 2016-05-05 14:32:05 +0100 | [diff] [blame] | 27 | |
| 28 | #if SEPARATE_CODE_AND_RODATA |
| 29 | .text . : { |
| 30 | __TEXT_START__ = .; |
| 31 | *entrypoint.o(.text*) |
Yann Gautier | 876be65 | 2020-10-05 09:54:09 +0200 | [diff] [blame] | 32 | *(SORT_BY_ALIGNMENT(.text*)) |
Yatharth Kochar | 06460cd | 2016-06-30 15:02:31 +0100 | [diff] [blame] | 33 | *(.vectors) |
Roberto Vargas | d93fde3 | 2018-04-11 11:53:31 +0100 | [diff] [blame] | 34 | . = ALIGN(PAGE_SIZE); |
Soby Mathew | ec8ac1c | 2016-05-05 14:32:05 +0100 | [diff] [blame] | 35 | __TEXT_END__ = .; |
| 36 | } >RAM |
| 37 | |
Roberto Vargas | 1d04c63 | 2018-05-10 11:01:16 +0100 | [diff] [blame] | 38 | /* .ARM.extab and .ARM.exidx are only added because Clang need them */ |
| 39 | .ARM.extab . : { |
| 40 | *(.ARM.extab* .gnu.linkonce.armextab.*) |
| 41 | } >RAM |
| 42 | |
| 43 | .ARM.exidx . : { |
| 44 | *(.ARM.exidx* .gnu.linkonce.armexidx.*) |
| 45 | } >RAM |
| 46 | |
Soby Mathew | ec8ac1c | 2016-05-05 14:32:05 +0100 | [diff] [blame] | 47 | .rodata . : { |
| 48 | __RODATA_START__ = .; |
Yann Gautier | 876be65 | 2020-10-05 09:54:09 +0200 | [diff] [blame] | 49 | *(SORT_BY_ALIGNMENT(.rodata*)) |
Soby Mathew | ec8ac1c | 2016-05-05 14:32:05 +0100 | [diff] [blame] | 50 | |
Masahiro Yamada | 583f8dd | 2020-03-26 10:57:12 +0900 | [diff] [blame] | 51 | RODATA_COMMON |
Soby Mathew | ec8ac1c | 2016-05-05 14:32:05 +0100 | [diff] [blame] | 52 | |
Jeenu Viswambharan | e3f2200 | 2017-09-22 08:32:10 +0100 | [diff] [blame] | 53 | /* Place pubsub sections for events */ |
| 54 | . = ALIGN(8); |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 55 | #include <lib/el3_runtime/pubsub_events.h> |
Jeenu Viswambharan | e3f2200 | 2017-09-22 08:32:10 +0100 | [diff] [blame] | 56 | |
Roberto Vargas | d93fde3 | 2018-04-11 11:53:31 +0100 | [diff] [blame] | 57 | . = ALIGN(PAGE_SIZE); |
Soby Mathew | ec8ac1c | 2016-05-05 14:32:05 +0100 | [diff] [blame] | 58 | __RODATA_END__ = .; |
| 59 | } >RAM |
| 60 | #else |
| 61 | ro . : { |
| 62 | __RO_START__ = .; |
| 63 | *entrypoint.o(.text*) |
Yann Gautier | 876be65 | 2020-10-05 09:54:09 +0200 | [diff] [blame] | 64 | *(SORT_BY_ALIGNMENT(.text*)) |
| 65 | *(SORT_BY_ALIGNMENT(.rodata*)) |
Soby Mathew | ec8ac1c | 2016-05-05 14:32:05 +0100 | [diff] [blame] | 66 | |
Masahiro Yamada | 583f8dd | 2020-03-26 10:57:12 +0900 | [diff] [blame] | 67 | RODATA_COMMON |
Soby Mathew | ec8ac1c | 2016-05-05 14:32:05 +0100 | [diff] [blame] | 68 | |
Jeenu Viswambharan | e3f2200 | 2017-09-22 08:32:10 +0100 | [diff] [blame] | 69 | /* Place pubsub sections for events */ |
| 70 | . = ALIGN(8); |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 71 | #include <lib/el3_runtime/pubsub_events.h> |
Jeenu Viswambharan | e3f2200 | 2017-09-22 08:32:10 +0100 | [diff] [blame] | 72 | |
Yatharth Kochar | 06460cd | 2016-06-30 15:02:31 +0100 | [diff] [blame] | 73 | *(.vectors) |
Soby Mathew | ec8ac1c | 2016-05-05 14:32:05 +0100 | [diff] [blame] | 74 | __RO_END_UNALIGNED__ = .; |
| 75 | |
| 76 | /* |
| 77 | * Memory page(s) mapped to this section will be marked as |
| 78 | * read-only, executable. No RW data from the next section must |
Yann Gautier | 876be65 | 2020-10-05 09:54:09 +0200 | [diff] [blame] | 79 | * creep in. Ensure the rest of the current memory page is unused. |
Soby Mathew | ec8ac1c | 2016-05-05 14:32:05 +0100 | [diff] [blame] | 80 | */ |
Roberto Vargas | d93fde3 | 2018-04-11 11:53:31 +0100 | [diff] [blame] | 81 | . = ALIGN(PAGE_SIZE); |
Soby Mathew | ec8ac1c | 2016-05-05 14:32:05 +0100 | [diff] [blame] | 82 | __RO_END__ = .; |
| 83 | } >RAM |
| 84 | #endif |
| 85 | |
| 86 | ASSERT(__CPU_OPS_END__ > __CPU_OPS_START__, |
| 87 | "cpu_ops not defined for this platform.") |
| 88 | /* |
| 89 | * Define a linker symbol to mark start of the RW memory area for this |
| 90 | * image. |
| 91 | */ |
| 92 | __RW_START__ = . ; |
| 93 | |
Masahiro Yamada | c5864d8 | 2020-04-22 10:50:12 +0900 | [diff] [blame] | 94 | DATA_SECTION >RAM |
Yann Gautier | 514e59c | 2020-10-05 11:02:54 +0200 | [diff] [blame] | 95 | RELA_SECTION >RAM |
Soby Mathew | ec8ac1c | 2016-05-05 14:32:05 +0100 | [diff] [blame] | 96 | |
Soby Mathew | bf16923 | 2017-11-14 14:10:10 +0000 | [diff] [blame] | 97 | #ifdef BL32_PROGBITS_LIMIT |
| 98 | ASSERT(. <= BL32_PROGBITS_LIMIT, "BL32 progbits has exceeded its limit.") |
| 99 | #endif |
| 100 | |
Masahiro Yamada | 403990e | 2020-04-07 13:04:24 +0900 | [diff] [blame] | 101 | STACK_SECTION >RAM |
Masahiro Yamada | dd053b6 | 2020-03-26 13:16:33 +0900 | [diff] [blame] | 102 | BSS_SECTION >RAM |
Masahiro Yamada | 0b67e56 | 2020-03-09 17:39:48 +0900 | [diff] [blame] | 103 | XLAT_TABLE_SECTION >RAM |
Soby Mathew | ec8ac1c | 2016-05-05 14:32:05 +0100 | [diff] [blame] | 104 | |
| 105 | __BSS_SIZE__ = SIZEOF(.bss); |
| 106 | |
| 107 | #if USE_COHERENT_MEM |
| 108 | /* |
| 109 | * The base address of the coherent memory section must be page-aligned (4K) |
| 110 | * to guarantee that the coherent data are stored on their own pages and |
| 111 | * are not mixed with normal data. This is required to set up the correct |
| 112 | * memory attributes for the coherent data page tables. |
| 113 | */ |
Antonio Nino Diaz | 2ce2b09 | 2017-11-15 11:45:35 +0000 | [diff] [blame] | 114 | coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) { |
Soby Mathew | ec8ac1c | 2016-05-05 14:32:05 +0100 | [diff] [blame] | 115 | __COHERENT_RAM_START__ = .; |
| 116 | /* |
| 117 | * Bakery locks are stored in coherent memory |
| 118 | * |
| 119 | * Each lock's data is contiguous and fully allocated by the compiler |
| 120 | */ |
| 121 | *(bakery_lock) |
| 122 | *(tzfw_coherent_mem) |
| 123 | __COHERENT_RAM_END_UNALIGNED__ = .; |
| 124 | /* |
| 125 | * Memory page(s) mapped to this section will be marked |
| 126 | * as device memory. No other unexpected data must creep in. |
| 127 | * Ensure the rest of the current memory page is unused. |
| 128 | */ |
Roberto Vargas | d93fde3 | 2018-04-11 11:53:31 +0100 | [diff] [blame] | 129 | . = ALIGN(PAGE_SIZE); |
Soby Mathew | ec8ac1c | 2016-05-05 14:32:05 +0100 | [diff] [blame] | 130 | __COHERENT_RAM_END__ = .; |
| 131 | } >RAM |
| 132 | |
| 133 | __COHERENT_RAM_UNALIGNED_SIZE__ = |
| 134 | __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__; |
| 135 | #endif |
| 136 | |
| 137 | /* |
Yann Gautier | 876be65 | 2020-10-05 09:54:09 +0200 | [diff] [blame] | 138 | * Define a linker symbol to mark the end of the RW memory area for this |
Soby Mathew | ec8ac1c | 2016-05-05 14:32:05 +0100 | [diff] [blame] | 139 | * image. |
| 140 | */ |
| 141 | __RW_END__ = .; |
| 142 | |
Yann Gautier | 876be65 | 2020-10-05 09:54:09 +0200 | [diff] [blame] | 143 | __BL32_END__ = .; |
Yann Gautier | 1b4d6ae | 2020-10-05 11:39:19 +0200 | [diff] [blame] | 144 | |
Yann Gautier | 514e59c | 2020-10-05 11:02:54 +0200 | [diff] [blame] | 145 | /DISCARD/ : { |
| 146 | *(.dynsym .dynstr .hash .gnu.hash) |
| 147 | } |
| 148 | |
Yann Gautier | 1b4d6ae | 2020-10-05 11:39:19 +0200 | [diff] [blame] | 149 | ASSERT(. <= BL32_LIMIT, "BL32 image has exceeded its limit.") |
Soby Mathew | ec8ac1c | 2016-05-05 14:32:05 +0100 | [diff] [blame] | 150 | } |