Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Simon Glass | 437e2b8 | 2012-02-23 03:28:41 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2004-2008 Texas Instruments |
| 4 | * |
| 5 | * (C) Copyright 2002 |
| 6 | * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de> |
Simon Glass | 437e2b8 | 2012-02-23 03:28:41 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
Marc Zyngier | c0451ec | 2014-07-12 14:24:02 +0100 | [diff] [blame] | 9 | #include <config.h> |
Chen-Yu Tsai | a00f85d | 2016-06-19 12:38:36 +0800 | [diff] [blame] | 10 | #include <asm/psci.h> |
Marc Zyngier | c0451ec | 2014-07-12 14:24:02 +0100 | [diff] [blame] | 11 | |
Simon Glass | 437e2b8 | 2012-02-23 03:28:41 +0000 | [diff] [blame] | 12 | OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") |
| 13 | OUTPUT_ARCH(arm) |
| 14 | ENTRY(_start) |
| 15 | SECTIONS |
| 16 | { |
Wang Dongsheng | 7eab3a6 | 2016-01-18 11:02:40 +0800 | [diff] [blame] | 17 | #if defined(CONFIG_ARMV7_SECURE_BASE) && defined(CONFIG_ARMV7_NONSEC) |
Peng Fan | 2e9e9a8 | 2015-10-23 10:13:03 +0800 | [diff] [blame] | 18 | /* |
Wang Dongsheng | 7eab3a6 | 2016-01-18 11:02:40 +0800 | [diff] [blame] | 19 | * If CONFIG_ARMV7_SECURE_BASE is true, secure code will not |
| 20 | * bundle with u-boot, and code offsets are fixed. Secure zone |
| 21 | * only needs to be copied from the loading address to |
| 22 | * CONFIG_ARMV7_SECURE_BASE, which is the linking and running |
| 23 | * address for secure code. |
Peng Fan | 2e9e9a8 | 2015-10-23 10:13:03 +0800 | [diff] [blame] | 24 | * |
Wang Dongsheng | 7eab3a6 | 2016-01-18 11:02:40 +0800 | [diff] [blame] | 25 | * If CONFIG_ARMV7_SECURE_BASE is undefined, the secure zone will |
| 26 | * be included in u-boot address space, and some absolute address |
| 27 | * were used in secure code. The absolute addresses of the secure |
| 28 | * code also needs to be relocated along with the accompanying u-boot |
| 29 | * code. |
| 30 | * |
| 31 | * So DISCARD is only for CONFIG_ARMV7_SECURE_BASE. |
Peng Fan | 2e9e9a8 | 2015-10-23 10:13:03 +0800 | [diff] [blame] | 32 | */ |
| 33 | /DISCARD/ : { *(.rel._secure*) } |
Wang Dongsheng | 7eab3a6 | 2016-01-18 11:02:40 +0800 | [diff] [blame] | 34 | #endif |
Simon Glass | 437e2b8 | 2012-02-23 03:28:41 +0000 | [diff] [blame] | 35 | . = 0x00000000; |
| 36 | |
| 37 | . = ALIGN(4); |
Ilias Apalodimas | cdb5839 | 2024-03-15 08:43:50 +0200 | [diff] [blame] | 38 | __image_copy_start = ADDR(.text); |
Simon Glass | 437e2b8 | 2012-02-23 03:28:41 +0000 | [diff] [blame] | 39 | .text : |
| 40 | { |
Albert ARIBAUD | 9852cc6 | 2014-04-15 16:13:51 +0200 | [diff] [blame] | 41 | *(.vectors) |
Stephen Warren | adddf45 | 2012-10-22 06:19:32 +0000 | [diff] [blame] | 42 | CPUDIR/start.o (.text*) |
Alexander Graf | 94a10f2 | 2018-06-12 07:48:37 +0200 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | /* This needs to come before *(.text*) */ |
Ilias Apalodimas | 772acf8 | 2024-03-15 08:43:51 +0200 | [diff] [blame] | 46 | .efi_runtime : { |
Ilias Apalodimas | 048a9ec | 2024-03-15 08:43:49 +0200 | [diff] [blame] | 47 | __efi_runtime_start = .; |
Alexander Graf | 94a10f2 | 2018-06-12 07:48:37 +0200 | [diff] [blame] | 48 | *(.text.efi_runtime*) |
| 49 | *(.rodata.efi_runtime*) |
| 50 | *(.data.efi_runtime*) |
Ilias Apalodimas | 048a9ec | 2024-03-15 08:43:49 +0200 | [diff] [blame] | 51 | __efi_runtime_stop = .; |
Alexander Graf | 94a10f2 | 2018-06-12 07:48:37 +0200 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | .text_rest : |
| 55 | { |
Stephen Warren | adddf45 | 2012-10-22 06:19:32 +0000 | [diff] [blame] | 56 | *(.text*) |
Simon Glass | 437e2b8 | 2012-02-23 03:28:41 +0000 | [diff] [blame] | 57 | } |
Marc Zyngier | c0451ec | 2014-07-12 14:24:02 +0100 | [diff] [blame] | 58 | |
Jan Kiszka | ac31b5a | 2015-04-21 07:18:24 +0200 | [diff] [blame] | 59 | #ifdef CONFIG_ARMV7_NONSEC |
Marc Zyngier | c0451ec | 2014-07-12 14:24:02 +0100 | [diff] [blame] | 60 | |
Chen-Yu Tsai | 277a8f6 | 2016-06-19 12:38:34 +0800 | [diff] [blame] | 61 | /* Align the secure section only if we're going to use it in situ */ |
Chen-Yu Tsai | a7eb9d3 | 2018-09-06 11:56:28 +0800 | [diff] [blame] | 62 | .__secure_start |
Chen-Yu Tsai | 277a8f6 | 2016-06-19 12:38:34 +0800 | [diff] [blame] | 63 | #ifndef CONFIG_ARMV7_SECURE_BASE |
| 64 | ALIGN(CONSTANT(COMMONPAGESIZE)) |
| 65 | #endif |
Chen-Yu Tsai | a7eb9d3 | 2018-09-06 11:56:28 +0800 | [diff] [blame] | 66 | : { |
Chen-Yu Tsai | 277a8f6 | 2016-06-19 12:38:34 +0800 | [diff] [blame] | 67 | KEEP(*(.__secure_start)) |
| 68 | } |
| 69 | |
Marc Zyngier | c0451ec | 2014-07-12 14:24:02 +0100 | [diff] [blame] | 70 | #ifndef CONFIG_ARMV7_SECURE_BASE |
Tom Rini | a17db83 | 2023-01-10 11:19:31 -0500 | [diff] [blame] | 71 | #define __ARMV7_SECURE_BASE |
Chen-Yu Tsai | 72a4800 | 2016-06-07 10:54:27 +0800 | [diff] [blame] | 72 | #define __ARMV7_PSCI_STACK_IN_RAM |
Tom Rini | a17db83 | 2023-01-10 11:19:31 -0500 | [diff] [blame] | 73 | #else |
| 74 | #define __ARMV7_SECURE_BASE CONFIG_ARMV7_SECURE_BASE |
Marc Zyngier | c0451ec | 2014-07-12 14:24:02 +0100 | [diff] [blame] | 75 | #endif |
| 76 | |
Tom Rini | a17db83 | 2023-01-10 11:19:31 -0500 | [diff] [blame] | 77 | .secure_text __ARMV7_SECURE_BASE : |
Marc Zyngier | c0451ec | 2014-07-12 14:24:02 +0100 | [diff] [blame] | 78 | AT(ADDR(.__secure_start) + SIZEOF(.__secure_start)) |
| 79 | { |
| 80 | *(._secure.text) |
| 81 | } |
| 82 | |
Chen-Yu Tsai | 5ed0387 | 2016-07-05 21:45:06 +0800 | [diff] [blame] | 83 | .secure_data : AT(LOADADDR(.secure_text) + SIZEOF(.secure_text)) |
| 84 | { |
| 85 | *(._secure.data) |
| 86 | } |
| 87 | |
Masahiro Yamada | 2aa46c0 | 2016-09-26 14:21:30 +0900 | [diff] [blame] | 88 | #ifdef CONFIG_ARMV7_PSCI |
Chen-Yu Tsai | 5ed0387 | 2016-07-05 21:45:06 +0800 | [diff] [blame] | 89 | .secure_stack ALIGN(ADDR(.secure_data) + SIZEOF(.secure_data), |
Chen-Yu Tsai | a00f85d | 2016-06-19 12:38:36 +0800 | [diff] [blame] | 90 | CONSTANT(COMMONPAGESIZE)) (NOLOAD) : |
Chen-Yu Tsai | 72a4800 | 2016-06-07 10:54:27 +0800 | [diff] [blame] | 91 | #ifdef __ARMV7_PSCI_STACK_IN_RAM |
Chen-Yu Tsai | a00f85d | 2016-06-19 12:38:36 +0800 | [diff] [blame] | 92 | AT(ADDR(.secure_stack)) |
| 93 | #else |
Chen-Yu Tsai | 5ed0387 | 2016-07-05 21:45:06 +0800 | [diff] [blame] | 94 | AT(LOADADDR(.secure_data) + SIZEOF(.secure_data)) |
Chen-Yu Tsai | a00f85d | 2016-06-19 12:38:36 +0800 | [diff] [blame] | 95 | #endif |
| 96 | { |
| 97 | KEEP(*(.__secure_stack_start)) |
Masahiro Yamada | 2aa46c0 | 2016-09-26 14:21:30 +0900 | [diff] [blame] | 98 | |
Chen-Yu Tsai | a00f85d | 2016-06-19 12:38:36 +0800 | [diff] [blame] | 99 | /* Skip addreses for stack */ |
| 100 | . = . + CONFIG_ARMV7_PSCI_NR_CPUS * ARM_PSCI_STACK_SIZE; |
Masahiro Yamada | 2aa46c0 | 2016-09-26 14:21:30 +0900 | [diff] [blame] | 101 | |
Chen-Yu Tsai | a00f85d | 2016-06-19 12:38:36 +0800 | [diff] [blame] | 102 | /* Align end of stack section to page boundary */ |
| 103 | . = ALIGN(CONSTANT(COMMONPAGESIZE)); |
| 104 | |
| 105 | KEEP(*(.__secure_stack_end)) |
Chen-Yu Tsai | 3de210c | 2016-06-19 12:38:39 +0800 | [diff] [blame] | 106 | |
| 107 | #ifdef CONFIG_ARMV7_SECURE_MAX_SIZE |
| 108 | /* |
| 109 | * We are not checking (__secure_end - __secure_start) here, |
| 110 | * as these are the load addresses, and do not include the |
| 111 | * stack section. Instead, use the end of the stack section |
| 112 | * and the start of the text section. |
| 113 | */ |
| 114 | ASSERT((. - ADDR(.secure_text)) <= CONFIG_ARMV7_SECURE_MAX_SIZE, |
| 115 | "Error: secure section exceeds secure memory size"); |
| 116 | #endif |
Chen-Yu Tsai | a00f85d | 2016-06-19 12:38:36 +0800 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | #ifndef __ARMV7_PSCI_STACK_IN_RAM |
| 120 | /* Reset VMA but don't allocate space if we have secure SRAM */ |
| 121 | . = LOADADDR(.secure_stack); |
Chen-Yu Tsai | 72a4800 | 2016-06-07 10:54:27 +0800 | [diff] [blame] | 122 | #endif |
| 123 | |
Masahiro Yamada | 2aa46c0 | 2016-09-26 14:21:30 +0900 | [diff] [blame] | 124 | #endif |
| 125 | |
Chen-Yu Tsai | a00f85d | 2016-06-19 12:38:36 +0800 | [diff] [blame] | 126 | .__secure_end : AT(ADDR(.__secure_end)) { |
Marc Zyngier | c0451ec | 2014-07-12 14:24:02 +0100 | [diff] [blame] | 127 | *(.__secure_end) |
| 128 | LONG(0x1d1071c); /* Must output something to reset LMA */ |
| 129 | } |
| 130 | #endif |
Simon Glass | 437e2b8 | 2012-02-23 03:28:41 +0000 | [diff] [blame] | 131 | |
| 132 | . = ALIGN(4); |
| 133 | .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) } |
| 134 | |
| 135 | . = ALIGN(4); |
| 136 | .data : { |
Stephen Warren | adddf45 | 2012-10-22 06:19:32 +0000 | [diff] [blame] | 137 | *(.data*) |
Simon Glass | 437e2b8 | 2012-02-23 03:28:41 +0000 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | . = ALIGN(4); |
| 141 | |
| 142 | . = .; |
Simon Glass | 437e2b8 | 2012-02-23 03:28:41 +0000 | [diff] [blame] | 143 | |
| 144 | . = ALIGN(4); |
Andrew Scull | 5a9095c | 2022-05-30 10:00:04 +0000 | [diff] [blame] | 145 | __u_boot_list : { |
| 146 | KEEP(*(SORT(__u_boot_list*))); |
Marek Vasut | 607092a | 2012-10-12 10:27:03 +0000 | [diff] [blame] | 147 | } |
| 148 | |
Ilias Apalodimas | 772acf8 | 2024-03-15 08:43:51 +0200 | [diff] [blame] | 149 | .efi_runtime_rel : { |
Ilias Apalodimas | 9b37894 | 2024-03-15 08:43:47 +0200 | [diff] [blame] | 150 | __efi_runtime_rel_start = .; |
Alexander Graf | 94a10f2 | 2018-06-12 07:48:37 +0200 | [diff] [blame] | 151 | *(.rel*.efi_runtime) |
| 152 | *(.rel*.efi_runtime.*) |
Ilias Apalodimas | 9b37894 | 2024-03-15 08:43:47 +0200 | [diff] [blame] | 153 | __efi_runtime_rel_stop = .; |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 154 | } |
| 155 | |
Tom Rini | 06ca0cf | 2017-06-14 09:13:21 -0400 | [diff] [blame] | 156 | . = ALIGN(4); |
Ilias Apalodimas | cdb5839 | 2024-03-15 08:43:50 +0200 | [diff] [blame] | 157 | __image_copy_end = .; |
Simon Glass | 437e2b8 | 2012-02-23 03:28:41 +0000 | [diff] [blame] | 158 | |
Ilias Apalodimas | 772acf8 | 2024-03-15 08:43:51 +0200 | [diff] [blame] | 159 | /* |
| 160 | * if CONFIG_USE_ARCH_MEMSET is not selected __bss_end - __bss_start |
| 161 | * needs to be a multiple of 4 and we overlay .bss with .rel.dyn |
| 162 | */ |
Ilias Apalodimas | 45b1bd9 | 2024-03-15 08:43:48 +0200 | [diff] [blame] | 163 | .rel.dyn ALIGN(4) : { |
| 164 | __rel_dyn_start = .; |
Simon Glass | 437e2b8 | 2012-02-23 03:28:41 +0000 | [diff] [blame] | 165 | *(.rel*) |
Ilias Apalodimas | 45b1bd9 | 2024-03-15 08:43:48 +0200 | [diff] [blame] | 166 | __rel_dyn_end = .; |
Simon Glass | 437e2b8 | 2012-02-23 03:28:41 +0000 | [diff] [blame] | 167 | } |
| 168 | |
Ilias Apalodimas | 8080846 | 2024-05-28 09:18:27 +0300 | [diff] [blame] | 169 | _end = .; |
Albert ARIBAUD | 9d25fa4 | 2014-02-22 17:53:42 +0100 | [diff] [blame] | 170 | _image_binary_end = .; |
Simon Glass | 437e2b8 | 2012-02-23 03:28:41 +0000 | [diff] [blame] | 171 | |
| 172 | /* |
| 173 | * Deprecated: this MMU section is used by pxa at present but |
| 174 | * should not be used by new boards/CPUs. |
| 175 | */ |
| 176 | . = ALIGN(4096); |
| 177 | .mmutable : { |
| 178 | *(.mmutable) |
| 179 | } |
| 180 | |
Albert ARIBAUD | ba5662d | 2013-04-11 05:43:21 +0000 | [diff] [blame] | 181 | /* |
Ilias Apalodimas | 6d1e1b8 | 2024-03-15 08:43:46 +0200 | [diff] [blame] | 182 | * These sections occupy the same memory, but their lifetimes do |
| 183 | * not overlap: U-Boot initializes .bss only after applying dynamic |
| 184 | * relocations and therefore after it doesn't need .rel.dyn any more. |
Albert ARIBAUD | ba5662d | 2013-04-11 05:43:21 +0000 | [diff] [blame] | 185 | */ |
Ilias Apalodimas | 6d1e1b8 | 2024-03-15 08:43:46 +0200 | [diff] [blame] | 186 | .bss ADDR(.rel.dyn) (OVERLAY): { |
| 187 | __bss_start = .; |
Stephen Warren | adddf45 | 2012-10-22 06:19:32 +0000 | [diff] [blame] | 188 | *(.bss*) |
Ilias Apalodimas | 6d1e1b8 | 2024-03-15 08:43:46 +0200 | [diff] [blame] | 189 | . = ALIGN(4); |
| 190 | __bss_end = .; |
Simon Glass | 437e2b8 | 2012-02-23 03:28:41 +0000 | [diff] [blame] | 191 | } |
| 192 | |
Albert ARIBAUD | 9d25fa4 | 2014-02-22 17:53:42 +0100 | [diff] [blame] | 193 | .dynsym _image_binary_end : { *(.dynsym) } |
Albert ARIBAUD | 95fc6d6 | 2013-11-07 14:21:46 +0100 | [diff] [blame] | 194 | .dynbss : { *(.dynbss) } |
| 195 | .dynstr : { *(.dynstr*) } |
| 196 | .dynamic : { *(.dynamic*) } |
| 197 | .plt : { *(.plt*) } |
| 198 | .interp : { *(.interp*) } |
Andreas Färber | 438a167 | 2014-01-27 05:48:11 +0100 | [diff] [blame] | 199 | .gnu.hash : { *(.gnu.hash) } |
Albert ARIBAUD | 95fc6d6 | 2013-11-07 14:21:46 +0100 | [diff] [blame] | 200 | .gnu : { *(.gnu*) } |
| 201 | .ARM.exidx : { *(.ARM.exidx*) } |
Albert ARIBAUD | ddadbed | 2014-01-13 14:57:05 +0100 | [diff] [blame] | 202 | .gnu.linkonce.armexidx : { *(.gnu.linkonce.armexidx.*) } |
Simon Glass | 437e2b8 | 2012-02-23 03:28:41 +0000 | [diff] [blame] | 203 | } |