Prepare v2023.10
[platform/kernel/u-boot.git] / arch / arm / cpu / u-boot.lds
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright (c) 2004-2008 Texas Instruments
4  *
5  * (C) Copyright 2002
6  * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
7  */
8
9 #include <config.h>
10 #include <asm/psci.h>
11
12 OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
13 OUTPUT_ARCH(arm)
14 ENTRY(_start)
15 SECTIONS
16 {
17 #ifndef CONFIG_CMDLINE
18         /DISCARD/ : { *(__u_boot_list_2_cmd_*) }
19 #endif
20 #if defined(CONFIG_ARMV7_SECURE_BASE) && defined(CONFIG_ARMV7_NONSEC)
21         /*
22          * If CONFIG_ARMV7_SECURE_BASE is true, secure code will not
23          * bundle with u-boot, and code offsets are fixed. Secure zone
24          * only needs to be copied from the loading address to
25          * CONFIG_ARMV7_SECURE_BASE, which is the linking and running
26          * address for secure code.
27          *
28          * If CONFIG_ARMV7_SECURE_BASE is undefined, the secure zone will
29          * be included in u-boot address space, and some absolute address
30          * were used in secure code. The absolute addresses of the secure
31          * code also needs to be relocated along with the accompanying u-boot
32          * code.
33          *
34          * So DISCARD is only for CONFIG_ARMV7_SECURE_BASE.
35          */
36         /DISCARD/ : { *(.rel._secure*) }
37 #endif
38         . = 0x00000000;
39
40         . = ALIGN(4);
41         .text :
42         {
43                 *(.__image_copy_start)
44                 *(.vectors)
45                 CPUDIR/start.o (.text*)
46         }
47
48         /* This needs to come before *(.text*) */
49         .__efi_runtime_start : {
50                 *(.__efi_runtime_start)
51         }
52
53         .efi_runtime : {
54                 *(.text.efi_runtime*)
55                 *(.rodata.efi_runtime*)
56                 *(.data.efi_runtime*)
57         }
58
59         .__efi_runtime_stop : {
60                 *(.__efi_runtime_stop)
61         }
62
63         .text_rest :
64         {
65                 *(.text*)
66         }
67
68 #ifdef CONFIG_ARMV7_NONSEC
69
70         /* Align the secure section only if we're going to use it in situ */
71         .__secure_start
72 #ifndef CONFIG_ARMV7_SECURE_BASE
73                 ALIGN(CONSTANT(COMMONPAGESIZE))
74 #endif
75         : {
76                 KEEP(*(.__secure_start))
77         }
78
79 #ifndef CONFIG_ARMV7_SECURE_BASE
80 #define __ARMV7_SECURE_BASE
81 #define __ARMV7_PSCI_STACK_IN_RAM
82 #else
83 #define __ARMV7_SECURE_BASE     CONFIG_ARMV7_SECURE_BASE
84 #endif
85
86         .secure_text __ARMV7_SECURE_BASE :
87                 AT(ADDR(.__secure_start) + SIZEOF(.__secure_start))
88         {
89                 *(._secure.text)
90         }
91
92         .secure_data : AT(LOADADDR(.secure_text) + SIZEOF(.secure_text))
93         {
94                 *(._secure.data)
95         }
96
97 #ifdef CONFIG_ARMV7_PSCI
98         .secure_stack ALIGN(ADDR(.secure_data) + SIZEOF(.secure_data),
99                             CONSTANT(COMMONPAGESIZE)) (NOLOAD) :
100 #ifdef __ARMV7_PSCI_STACK_IN_RAM
101                 AT(ADDR(.secure_stack))
102 #else
103                 AT(LOADADDR(.secure_data) + SIZEOF(.secure_data))
104 #endif
105         {
106                 KEEP(*(.__secure_stack_start))
107
108                 /* Skip addreses for stack */
109                 . = . + CONFIG_ARMV7_PSCI_NR_CPUS * ARM_PSCI_STACK_SIZE;
110
111                 /* Align end of stack section to page boundary */
112                 . = ALIGN(CONSTANT(COMMONPAGESIZE));
113
114                 KEEP(*(.__secure_stack_end))
115
116 #ifdef CONFIG_ARMV7_SECURE_MAX_SIZE
117                 /*
118                  * We are not checking (__secure_end - __secure_start) here,
119                  * as these are the load addresses, and do not include the
120                  * stack section. Instead, use the end of the stack section
121                  * and the start of the text section.
122                  */
123                 ASSERT((. - ADDR(.secure_text)) <= CONFIG_ARMV7_SECURE_MAX_SIZE,
124                        "Error: secure section exceeds secure memory size");
125 #endif
126         }
127
128 #ifndef __ARMV7_PSCI_STACK_IN_RAM
129         /* Reset VMA but don't allocate space if we have secure SRAM */
130         . = LOADADDR(.secure_stack);
131 #endif
132
133 #endif
134
135         .__secure_end : AT(ADDR(.__secure_end)) {
136                 *(.__secure_end)
137                 LONG(0x1d1071c);        /* Must output something to reset LMA */
138         }
139 #endif
140
141         . = ALIGN(4);
142         .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
143
144         . = ALIGN(4);
145         .data : {
146                 *(.data*)
147         }
148
149         . = ALIGN(4);
150
151         . = .;
152
153         . = ALIGN(4);
154         __u_boot_list : {
155                 KEEP(*(SORT(__u_boot_list*)));
156         }
157
158         . = ALIGN(4);
159
160         .efi_runtime_rel_start :
161         {
162                 *(.__efi_runtime_rel_start)
163         }
164
165         .efi_runtime_rel : {
166                 *(.rel*.efi_runtime)
167                 *(.rel*.efi_runtime.*)
168         }
169
170         .efi_runtime_rel_stop :
171         {
172                 *(.__efi_runtime_rel_stop)
173         }
174
175         . = ALIGN(4);
176
177         .image_copy_end :
178         {
179                 *(.__image_copy_end)
180         }
181
182         .rel_dyn_start :
183         {
184                 *(.__rel_dyn_start)
185         }
186
187         .rel.dyn : {
188                 *(.rel*)
189         }
190
191         .rel_dyn_end :
192         {
193                 *(.__rel_dyn_end)
194         }
195
196         .end :
197         {
198                 *(.__end)
199         }
200
201         _image_binary_end = .;
202
203         /*
204          * Deprecated: this MMU section is used by pxa at present but
205          * should not be used by new boards/CPUs.
206          */
207         . = ALIGN(4096);
208         .mmutable : {
209                 *(.mmutable)
210         }
211
212 /*
213  * Compiler-generated __bss_start and __bss_end, see arch/arm/lib/bss.c
214  * __bss_base and __bss_limit are for linker only (overlay ordering)
215  */
216
217         .bss_start __rel_dyn_start (OVERLAY) : {
218                 KEEP(*(.__bss_start));
219                 __bss_base = .;
220         }
221
222         .bss __bss_base (OVERLAY) : {
223                 *(.bss*)
224                  . = ALIGN(4);
225                  __bss_limit = .;
226         }
227
228         .bss_end __bss_limit (OVERLAY) : {
229                 KEEP(*(.__bss_end));
230         }
231
232         .dynsym _image_binary_end : { *(.dynsym) }
233         .dynbss : { *(.dynbss) }
234         .dynstr : { *(.dynstr*) }
235         .dynamic : { *(.dynamic*) }
236         .plt : { *(.plt*) }
237         .interp : { *(.interp*) }
238         .gnu.hash : { *(.gnu.hash) }
239         .gnu : { *(.gnu*) }
240         .ARM.exidx : { *(.ARM.exidx*) }
241         .gnu.linkonce.armexidx : { *(.gnu.linkonce.armexidx.*) }
242 }