• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/* SPDX-License-Identifier: GPL-2.0 */
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
7#ifdef CONFIG_XIP_KERNEL
8#include "vmlinux-xip.lds.S"
9#else
10
11#include <linux/pgtable.h>
12#include <asm/vmlinux.lds.h>
13#include <asm/cache.h>
14#include <asm/thread_info.h>
15#include <asm/memory.h>
16#include <asm/mpu.h>
17#include <asm/page.h>
18
19OUTPUT_ARCH(arm)
20ENTRY(stext)
21
22#ifndef __ARMEB__
23jiffies = jiffies_64;
24#else
25jiffies = jiffies_64 + 4;
26#endif
27
28SECTIONS
29{
30	/*
31	 * XXX: The linker does not define how output sections are
32	 * assigned to input sections when there are multiple statements
33	 * matching the same input section name.  There is no documented
34	 * order of matching.
35	 *
36	 * unwind exit sections must be discarded before the rest of the
37	 * unwind sections get included.
38	 */
39	/DISCARD/ : {
40		ARM_DISCARD
41#ifndef CONFIG_SMP_ON_UP
42		*(.alt.smp.init)
43#endif
44#ifndef CONFIG_ARM_UNWIND
45		*(.ARM.exidx) *(.ARM.exidx.*)
46		*(.ARM.extab) *(.ARM.extab.*)
47#endif
48	}
49
50	. = PAGE_OFFSET + TEXT_OFFSET;
51	.head.text : {
52		_text = .;
53		HEAD_TEXT
54	}
55
56#ifdef CONFIG_STRICT_KERNEL_RWX
57	. = ALIGN(1<<SECTION_SHIFT);
58#endif
59
60#ifdef CONFIG_ARM_MPU
61	. = ALIGN(PMSAv8_MINALIGN);
62#endif
63	.text : {			/* Real text segment		*/
64		_stext = .;		/* Text and read-only data	*/
65		ARM_TEXT
66	}
67
68#ifdef CONFIG_DEBUG_ALIGN_RODATA
69	. = ALIGN(1<<SECTION_SHIFT);
70#endif
71	_etext = .;			/* End of text section */
72
73	.gnu.hash : {
74		*(.gnu.hash)
75	}
76
77	RO_DATA(PAGE_SIZE)
78
79	. = ALIGN(4);
80	__ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
81		__start___ex_table = .;
82		ARM_MMU_KEEP(*(__ex_table))
83		__stop___ex_table = .;
84	}
85
86#ifdef CONFIG_ARM_UNWIND
87	ARM_UNWIND_SECTIONS
88#endif
89
90#ifdef CONFIG_STRICT_KERNEL_RWX
91	. = ALIGN(1<<SECTION_SHIFT);
92#else
93	. = ALIGN(PAGE_SIZE);
94#endif
95	__init_begin = .;
96
97	ARM_VECTORS
98	INIT_TEXT_SECTION(8)
99	.exit.text : {
100		ARM_EXIT_KEEP(EXIT_TEXT)
101	}
102	.init.proc.info : {
103		ARM_CPU_DISCARD(PROC_INFO)
104	}
105	.init.arch.info : {
106		__arch_info_begin = .;
107		*(.arch.info.init)
108		__arch_info_end = .;
109	}
110	.init.tagtable : {
111		__tagtable_begin = .;
112		*(.taglist.init)
113		__tagtable_end = .;
114	}
115#ifdef CONFIG_SMP_ON_UP
116	.init.smpalt : {
117		__smpalt_begin = .;
118		*(.alt.smp.init)
119		__smpalt_end = .;
120	}
121#endif
122	.rel.dyn : ALIGN(8) {
123		__rel_begin = .;
124		*(.rel .rel.* .rel.dyn .rel*)
125	}
126	__rel_end = ADDR(.rel.dyn) + SIZEOF(.rel.dyn);
127
128	.init.pv_table : {
129		__pv_table_begin = .;
130		*(.pv_table)
131		__pv_table_end = .;
132	}
133
134	INIT_DATA_SECTION(16)
135
136	.exit.data : {
137		ARM_EXIT_KEEP(EXIT_DATA)
138	}
139
140#ifdef CONFIG_SMP
141	PERCPU_SECTION(L1_CACHE_BYTES)
142#endif
143
144#ifdef CONFIG_HAVE_TCM
145	ARM_TCM
146#endif
147
148#ifdef CONFIG_STRICT_KERNEL_RWX
149	. = ALIGN(1<<SECTION_SHIFT);
150#else
151	. = ALIGN(THREAD_SIZE);
152#endif
153	__init_end = .;
154
155	_sdata = .;
156	RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
157
158	.data.rel.local : {
159		*(.data.rel.local)
160	}
161
162	.data.rel.ro : {
163		*(.data.rel.ro)
164	}
165
166	_edata = .;
167
168	BSS_SECTION(0, 0, 0)
169#ifdef CONFIG_ARM_MPU
170	. = ALIGN(PMSAv8_MINALIGN);
171#endif
172	_end = .;
173
174	STABS_DEBUG
175	DWARF_DEBUG
176	ARM_DETAILS
177
178	ARM_ASSERTS
179}
180
181#ifdef CONFIG_STRICT_KERNEL_RWX
182/*
183 * Without CONFIG_DEBUG_ALIGN_RODATA, __start_rodata_section_aligned will
184 * be the first section-aligned location after __start_rodata. Otherwise,
185 * it will be equal to __start_rodata.
186 */
187__start_rodata_section_aligned = ALIGN(__start_rodata, 1 << SECTION_SHIFT);
188#endif
189
190/*
191 * These must never be empty
192 * If you have to comment these two assert statements out, your
193 * binutils is too old (for other reasons as well)
194 */
195ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")
196ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")
197
198#endif /* CONFIG_XIP_KERNEL */
199