]> git.ipfire.org Git - thirdparty/kernel/linux.git/blame - arch/arm/kernel/vmlinux.lds.S
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[thirdparty/kernel/linux.git] / arch / arm / kernel / vmlinux.lds.S
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
1da177e4
LT
2/* ld script to make ARM Linux kernel
3 * taken from the i386 version by Russell King
4 * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
5 */
6
538bf469
CB
7#ifdef CONFIG_XIP_KERNEL
8#include "vmlinux-xip.lds.S"
9#else
10
1da177e4 11#include <asm-generic/vmlinux.lds.h>
f0d5375e 12#include <asm/cache.h>
4f7a1812 13#include <asm/thread_info.h>
37d07b72 14#include <asm/memory.h>
f6430a93 15#include <asm/page.h>
1e6b4811 16#include <asm/pgtable.h>
e60a1fec 17
5085f3ff 18#define PROC_INFO \
b8b9987f 19 . = ALIGN(4); \
5085f3ff
RK
20 VMLINUX_SYMBOL(__proc_info_begin) = .; \
21 *(.proc.info.init) \
22 VMLINUX_SYMBOL(__proc_info_end) = .;
23
1a61ae7a
MZ
24#define HYPERVISOR_TEXT \
25 VMLINUX_SYMBOL(__hyp_text_start) = .; \
26 *(.hyp.text) \
27 VMLINUX_SYMBOL(__hyp_text_end) = .;
28
8903826d
WD
29#define IDMAP_TEXT \
30 ALIGN_FUNCTION(); \
31 VMLINUX_SYMBOL(__idmap_text_start) = .; \
32 *(.idmap.text) \
9e9a367c 33 VMLINUX_SYMBOL(__idmap_text_end) = .; \
a9fea8b3 34 . = ALIGN(PAGE_SIZE); \
9e9a367c
CD
35 VMLINUX_SYMBOL(__hyp_idmap_text_start) = .; \
36 *(.hyp.idmap.text) \
37 VMLINUX_SYMBOL(__hyp_idmap_text_end) = .;
8903826d 38
5085f3ff
RK
39#ifdef CONFIG_HOTPLUG_CPU
40#define ARM_CPU_DISCARD(x)
41#define ARM_CPU_KEEP(x) x
42#else
43#define ARM_CPU_DISCARD(x) x
44#define ARM_CPU_KEEP(x)
45#endif
46
87e040b6 47#if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || \
ddb45306 48 defined(CONFIG_GENERIC_BUG) || defined(CONFIG_JUMP_LABEL)
a9ad21fe 49#define ARM_EXIT_KEEP(x) x
6760b109 50#define ARM_EXIT_DISCARD(x)
a9ad21fe
RK
51#else
52#define ARM_EXIT_KEEP(x)
6760b109 53#define ARM_EXIT_DISCARD(x) x
a9ad21fe
RK
54#endif
55
1da177e4
LT
56OUTPUT_ARCH(arm)
57ENTRY(stext)
37d07b72 58
1da177e4
LT
59#ifndef __ARMEB__
60jiffies = jiffies_64;
61#else
62jiffies = jiffies_64 + 4;
63#endif
37d07b72 64
9d4f13e5
RK
65SECTIONS
66{
39df8887 67 /*
6760b109
RK
68 * XXX: The linker does not define how output sections are
69 * assigned to input sections when there are multiple statements
70 * matching the same input section name. There is no documented
71 * order of matching.
72 *
39df8887
RK
73 * unwind exit sections must be discarded before the rest of the
74 * unwind sections get included.
75 */
76 /DISCARD/ : {
77 *(.ARM.exidx.exit.text)
78 *(.ARM.extab.exit.text)
79 ARM_CPU_DISCARD(*(.ARM.exidx.cpuexit.text))
80 ARM_CPU_DISCARD(*(.ARM.extab.cpuexit.text))
6760b109
RK
81 ARM_EXIT_DISCARD(EXIT_TEXT)
82 ARM_EXIT_DISCARD(EXIT_DATA)
83 EXIT_CALL
39df8887 84#ifndef CONFIG_MMU
c4a84ae3 85 *(.text.fixup)
39df8887
RK
86 *(__ex_table)
87#endif
88#ifndef CONFIG_SMP_ON_UP
89 *(.alt.smp.init)
90#endif
6760b109
RK
91 *(.discard)
92 *(.discard.*)
39df8887
RK
93 }
94
9d4f13e5 95 . = PAGE_OFFSET + TEXT_OFFSET;
1604d79d 96 .head.text : {
e2f81844 97 _text = .;
1604d79d
RK
98 HEAD_TEXT
99 }
1e6b4811 100
0f5bf6d0 101#ifdef CONFIG_STRICT_KERNEL_RWX
1e6b4811
KC
102 . = ALIGN(1<<SECTION_SHIFT);
103#endif
104
3835d69a 105 .text : { /* Real text segment */
e2f81844 106 _stext = .; /* Text and read-only data */
eb765c1c 107 IDMAP_TEXT
3835d69a
RK
108 __exception_text_start = .;
109 *(.exception.text)
110 __exception_text_end = .;
111 IRQENTRY_TEXT
be7635e7 112 SOFTIRQENTRY_TEXT
3835d69a
RK
113 TEXT_TEXT
114 SCHED_TEXT
6727ad9e 115 CPUIDLE_TEXT
3835d69a 116 LOCK_TEXT
1a61ae7a 117 HYPERVISOR_TEXT
3835d69a 118 KPROBES_TEXT
3835d69a
RK
119 *(.gnu.warning)
120 *(.glue_7)
121 *(.glue_7t)
122 . = ALIGN(4);
123 *(.got) /* Global offset table */
124 ARM_CPU_KEEP(PROC_INFO)
125 }
126
25362dc4 127#ifdef CONFIG_DEBUG_ALIGN_RODATA
80d6b0c2
KC
128 . = ALIGN(1<<SECTION_SHIFT);
129#endif
14c4a533
KC
130 _etext = .; /* End of text section */
131
3835d69a
RK
132 RO_DATA(PAGE_SIZE)
133
ee951c63
SB
134 . = ALIGN(4);
135 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
136 __start___ex_table = .;
137#ifdef CONFIG_MMU
138 *(__ex_table)
139#endif
140 __stop___ex_table = .;
141 }
142
3835d69a
RK
143#ifdef CONFIG_ARM_UNWIND
144 /*
145 * Stack unwinding tables
146 */
147 . = ALIGN(8);
148 .ARM.unwind_idx : {
149 __start_unwind_idx = .;
150 *(.ARM.exidx*)
151 __stop_unwind_idx = .;
152 }
153 .ARM.unwind_tab : {
154 __start_unwind_tab = .;
155 *(.ARM.extab*)
156 __stop_unwind_tab = .;
157 }
158#endif
159
dad5451a
PM
160 NOTES
161
0f5bf6d0 162#ifdef CONFIG_STRICT_KERNEL_RWX
1e6b4811 163 . = ALIGN(1<<SECTION_SHIFT);
538bf469 164#else
3835d69a 165 . = ALIGN(PAGE_SIZE);
3835d69a 166#endif
538bf469
CB
167 __init_begin = .;
168
b9b32bf7
RK
169 /*
170 * The vectors and stubs are relocatable code, and the
171 * only thing that matters is their relative offsets
172 */
173 __vectors_start = .;
31b96cae 174 .vectors 0xffff0000 : AT(__vectors_start) {
b9b32bf7
RK
175 *(.vectors)
176 }
177 . = __vectors_start + SIZEOF(.vectors);
178 __vectors_end = .;
179
180 __stubs_start = .;
31b96cae 181 .stubs ADDR(.vectors) + 0x1000 : AT(__stubs_start) {
b9b32bf7
RK
182 *(.stubs)
183 }
184 . = __stubs_start + SIZEOF(.stubs);
185 __stubs_end = .;
3835d69a 186
31b96cae
AB
187 PROVIDE(vector_fiq_offset = vector_fiq - ADDR(.vectors));
188
1604d79d
RK
189 INIT_TEXT_SECTION(8)
190 .exit.text : {
191 ARM_EXIT_KEEP(EXIT_TEXT)
192 }
193 .init.proc.info : {
5085f3ff 194 ARM_CPU_DISCARD(PROC_INFO)
1604d79d
RK
195 }
196 .init.arch.info : {
1da177e4 197 __arch_info_begin = .;
1604d79d 198 *(.arch.info.init)
1da177e4 199 __arch_info_end = .;
1604d79d
RK
200 }
201 .init.tagtable : {
1da177e4 202 __tagtable_begin = .;
1604d79d 203 *(.taglist.init)
1da177e4 204 __tagtable_end = .;
1604d79d 205 }
f00ec48f 206#ifdef CONFIG_SMP_ON_UP
1604d79d 207 .init.smpalt : {
f00ec48f 208 __smpalt_begin = .;
1604d79d 209 *(.alt.smp.init)
f00ec48f 210 __smpalt_end = .;
1604d79d 211 }
f00ec48f 212#endif
1604d79d 213 .init.pv_table : {
dc21af99 214 __pv_table_begin = .;
1604d79d 215 *(.pv_table)
dc21af99 216 __pv_table_end = .;
1604d79d
RK
217 }
218 .init.data : {
1604d79d 219 INIT_DATA
78d7530a 220 INIT_SETUP(16)
78d7530a
NE
221 INIT_CALLS
222 CON_INITCALL
223 SECURITY_INITCALL
224 INIT_RAM_FS
1604d79d 225 }
1604d79d 226 .exit.data : {
a9ad21fe 227 ARM_EXIT_KEEP(EXIT_DATA)
1da177e4
LT
228 }
229
9973290c 230#ifdef CONFIG_SMP
f0d5375e 231 PERCPU_SECTION(L1_CACHE_BYTES)
9973290c 232#endif
78d7530a 233
0f5bf6d0 234#ifdef CONFIG_STRICT_KERNEL_RWX
1e6b4811 235 . = ALIGN(1<<SECTION_SHIFT);
1da177e4 236#else
4f7a1812 237 . = ALIGN(THREAD_SIZE);
1e6b4811 238#endif
562c85ca 239 __init_end = .;
1da177e4 240 __data_loc = .;
1da177e4
LT
241
242 .data : AT(__data_loc) {
37efe642 243 _data = .; /* address in memory */
8c7e6574 244 _sdata = .;
1da177e4
LT
245
246 /*
247 * first, the init task union, aligned
248 * to an 8192 byte boundary.
249 */
78d7530a 250 INIT_TASK_DATA(THREAD_SIZE)
1da177e4 251
78d7530a 252 NOSAVE_DATA
f0d5375e
WD
253 CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES)
254 READ_MOSTLY_DATA(L1_CACHE_BYTES)
1da177e4
LT
255
256 /*
257 * and the usual data section
258 */
ca967258 259 DATA_DATA
1da177e4
LT
260 CONSTRUCTORS
261
262 _edata = .;
263 }
e98ff7f6 264 _edata_loc = __data_loc + SIZEOF(.data);
1da177e4 265
b5effd38
PZ
266 BUG_TABLE
267
bc581770
LW
268#ifdef CONFIG_HAVE_TCM
269 /*
270 * We align everything to a page boundary so we can
271 * free it after init has commenced and TCM contents have
272 * been copied to its destination.
273 */
274 .tcm_start : {
275 . = ALIGN(PAGE_SIZE);
276 __tcm_start = .;
277 __itcm_start = .;
278 }
279
280 /*
281 * Link these to the ITCM RAM
282 * Put VMA to the TCM address and LMA to the common RAM
283 * and we'll upload the contents from RAM to TCM and free
284 * the used RAM after that.
285 */
286 .text_itcm ITCM_OFFSET : AT(__itcm_start)
287 {
288 __sitcm_text = .;
289 *(.tcm.text)
290 *(.tcm.rodata)
291 . = ALIGN(4);
292 __eitcm_text = .;
293 }
294
295 /*
296 * Reset the dot pointer, this is needed to create the
297 * relative __dtcm_start below (to be used as extern in code).
298 */
299 . = ADDR(.tcm_start) + SIZEOF(.tcm_start) + SIZEOF(.text_itcm);
300
301 .dtcm_start : {
302 __dtcm_start = .;
303 }
304
305 /* TODO: add remainder of ITCM as well, that can be used for data! */
306 .data_dtcm DTCM_OFFSET : AT(__dtcm_start)
307 {
308 . = ALIGN(4);
309 __sdtcm_data = .;
310 *(.tcm.data)
311 . = ALIGN(4);
312 __edtcm_data = .;
313 }
314
315 /* Reset the dot pointer or the linker gets confused */
316 . = ADDR(.dtcm_start) + SIZEOF(.data_dtcm);
317
318 /* End marker for freeing TCM copy in linked object */
319 .tcm_end : AT(ADDR(.dtcm_start) + SIZEOF(.data_dtcm)){
320 . = ALIGN(PAGE_SIZE);
321 __tcm_end = .;
322 }
323#endif
324
78d7530a
NE
325 BSS_SECTION(0, 0, 0)
326 _end = .;
327
328 STABS_DEBUG
1da177e4
LT
329}
330
0f5bf6d0 331#ifdef CONFIG_STRICT_KERNEL_RWX
64ac2e74
KC
332/*
333 * Without CONFIG_DEBUG_ALIGN_RODATA, __start_rodata_section_aligned will
334 * be the first section-aligned location after __start_rodata. Otherwise,
335 * it will be equal to __start_rodata.
336 */
337__start_rodata_section_aligned = ALIGN(__start_rodata, 1 << SECTION_SHIFT);
91c617d7 338#endif
64ac2e74 339
728f5c07
RK
340/*
341 * These must never be empty
342 * If you have to comment these two assert statements out, your
343 * binutils is too old (for other reasons as well)
344 */
1da177e4
LT
345ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")
346ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")
06f75a1f 347
0394e1f6 348/*
06f75a1f
AB
349 * The HYP init code can't be more than a page long,
350 * and should not cross a page boundary.
0394e1f6
MZ
351 * The above comment applies as well.
352 */
12eb3e83 353ASSERT(__hyp_idmap_text_end - (__hyp_idmap_text_start & PAGE_MASK) <= PAGE_SIZE,
06f75a1f 354 "HYP init code too big or misaligned")
538bf469
CB
355
356#endif /* CONFIG_XIP_KERNEL */