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