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