xref: /linux/arch/arm/kernel/vmlinux.lds.S (revision 092e0e7e520a1fca03e13c9f2d157432a8657ff2)
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/thread_info.h>
8#include <asm/memory.h>
9#include <asm/page.h>
10
11#define PROC_INFO							\
12	VMLINUX_SYMBOL(__proc_info_begin) = .;				\
13	*(.proc.info.init)						\
14	VMLINUX_SYMBOL(__proc_info_end) = .;
15
16#ifdef CONFIG_HOTPLUG_CPU
17#define ARM_CPU_DISCARD(x)
18#define ARM_CPU_KEEP(x)		x
19#else
20#define ARM_CPU_DISCARD(x)	x
21#define ARM_CPU_KEEP(x)
22#endif
23
24OUTPUT_ARCH(arm)
25ENTRY(stext)
26
27#ifndef __ARMEB__
28jiffies = jiffies_64;
29#else
30jiffies = jiffies_64 + 4;
31#endif
32
33SECTIONS
34{
35#ifdef CONFIG_XIP_KERNEL
36	. = XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR);
37#else
38	. = PAGE_OFFSET + TEXT_OFFSET;
39#endif
40
41	.init : {			/* Init code and data		*/
42		_stext = .;
43		_sinittext = .;
44			HEAD_TEXT
45			INIT_TEXT
46		_einittext = .;
47		ARM_CPU_DISCARD(PROC_INFO)
48		__arch_info_begin = .;
49			*(.arch.info.init)
50		__arch_info_end = .;
51		__tagtable_begin = .;
52			*(.taglist.init)
53		__tagtable_end = .;
54#ifdef CONFIG_SMP_ON_UP
55		__smpalt_begin = .;
56			*(.alt.smp.init)
57		__smpalt_end = .;
58#endif
59
60		INIT_SETUP(16)
61
62		INIT_CALLS
63		CON_INITCALL
64		SECURITY_INITCALL
65		INIT_RAM_FS
66
67#ifndef CONFIG_XIP_KERNEL
68		__init_begin = _stext;
69		INIT_DATA
70#endif
71	}
72
73	PERCPU(PAGE_SIZE)
74
75#ifndef CONFIG_XIP_KERNEL
76	. = ALIGN(PAGE_SIZE);
77	__init_end = .;
78#endif
79
80	/*
81	 * unwind exit sections must be discarded before the rest of the
82	 * unwind sections get included.
83	 */
84	/DISCARD/ : {
85		*(.ARM.exidx.exit.text)
86		*(.ARM.extab.exit.text)
87		ARM_CPU_DISCARD(*(.ARM.exidx.cpuexit.text))
88		ARM_CPU_DISCARD(*(.ARM.extab.cpuexit.text))
89#ifndef CONFIG_HOTPLUG
90		*(.ARM.exidx.devexit.text)
91		*(.ARM.extab.devexit.text)
92#endif
93#ifndef CONFIG_MMU
94		*(.fixup)
95		*(__ex_table)
96#endif
97	}
98
99	.text : {			/* Real text segment		*/
100		_text = .;		/* Text and read-only data	*/
101			__exception_text_start = .;
102			*(.exception.text)
103			__exception_text_end = .;
104			TEXT_TEXT
105			SCHED_TEXT
106			LOCK_TEXT
107			KPROBES_TEXT
108#ifdef CONFIG_MMU
109			*(.fixup)
110#endif
111			*(.gnu.warning)
112			*(.rodata)
113			*(.rodata.*)
114			*(.glue_7)
115			*(.glue_7t)
116		*(.got)			/* Global offset table		*/
117			ARM_CPU_KEEP(PROC_INFO)
118	}
119
120	RO_DATA(PAGE_SIZE)
121
122#ifdef CONFIG_ARM_UNWIND
123	/*
124	 * Stack unwinding tables
125	 */
126	. = ALIGN(8);
127	.ARM.unwind_idx : {
128		__start_unwind_idx = .;
129		*(.ARM.exidx*)
130		__stop_unwind_idx = .;
131	}
132	.ARM.unwind_tab : {
133		__start_unwind_tab = .;
134		*(.ARM.extab*)
135		__stop_unwind_tab = .;
136	}
137#endif
138
139	_etext = .;			/* End of text and rodata section */
140
141#ifdef CONFIG_XIP_KERNEL
142	__data_loc = ALIGN(4);		/* location in binary */
143	. = PAGE_OFFSET + TEXT_OFFSET;
144#else
145	. = ALIGN(THREAD_SIZE);
146	__data_loc = .;
147#endif
148
149	.data : AT(__data_loc) {
150		_data = .;		/* address in memory */
151		_sdata = .;
152
153		/*
154		 * first, the init task union, aligned
155		 * to an 8192 byte boundary.
156		 */
157		INIT_TASK_DATA(THREAD_SIZE)
158
159#ifdef CONFIG_XIP_KERNEL
160		. = ALIGN(PAGE_SIZE);
161		__init_begin = .;
162		INIT_DATA
163		. = ALIGN(PAGE_SIZE);
164		__init_end = .;
165#endif
166
167		NOSAVE_DATA
168		CACHELINE_ALIGNED_DATA(32)
169
170		/*
171		 * The exception fixup table (might need resorting at runtime)
172		 */
173		. = ALIGN(32);
174		__start___ex_table = .;
175#ifdef CONFIG_MMU
176		*(__ex_table)
177#endif
178		__stop___ex_table = .;
179
180		/*
181		 * and the usual data section
182		 */
183		DATA_DATA
184		CONSTRUCTORS
185
186		_edata = .;
187	}
188	_edata_loc = __data_loc + SIZEOF(.data);
189
190#ifdef CONFIG_HAVE_TCM
191        /*
192	 * We align everything to a page boundary so we can
193	 * free it after init has commenced and TCM contents have
194	 * been copied to its destination.
195	 */
196	.tcm_start : {
197		. = ALIGN(PAGE_SIZE);
198		__tcm_start = .;
199		__itcm_start = .;
200	}
201
202	/*
203	 * Link these to the ITCM RAM
204	 * Put VMA to the TCM address and LMA to the common RAM
205	 * and we'll upload the contents from RAM to TCM and free
206	 * the used RAM after that.
207	 */
208	.text_itcm ITCM_OFFSET : AT(__itcm_start)
209	{
210		__sitcm_text = .;
211		*(.tcm.text)
212		*(.tcm.rodata)
213		. = ALIGN(4);
214		__eitcm_text = .;
215	}
216
217	/*
218	 * Reset the dot pointer, this is needed to create the
219	 * relative __dtcm_start below (to be used as extern in code).
220	 */
221	. = ADDR(.tcm_start) + SIZEOF(.tcm_start) + SIZEOF(.text_itcm);
222
223	.dtcm_start : {
224		__dtcm_start = .;
225	}
226
227	/* TODO: add remainder of ITCM as well, that can be used for data! */
228	.data_dtcm DTCM_OFFSET : AT(__dtcm_start)
229	{
230		. = ALIGN(4);
231		__sdtcm_data = .;
232		*(.tcm.data)
233		. = ALIGN(4);
234		__edtcm_data = .;
235	}
236
237	/* Reset the dot pointer or the linker gets confused */
238	. = ADDR(.dtcm_start) + SIZEOF(.data_dtcm);
239
240	/* End marker for freeing TCM copy in linked object */
241	.tcm_end : AT(ADDR(.dtcm_start) + SIZEOF(.data_dtcm)){
242		. = ALIGN(PAGE_SIZE);
243		__tcm_end = .;
244	}
245#endif
246
247	BSS_SECTION(0, 0, 0)
248	_end = .;
249
250	STABS_DEBUG
251	.comment 0 : { *(.comment) }
252
253	/* Default discards */
254	DISCARDS
255
256#ifndef CONFIG_SMP_ON_UP
257	/DISCARD/ : {
258		*(.alt.smp.init)
259	}
260#endif
261}
262
263/*
264 * These must never be empty
265 * If you have to comment these two assert statements out, your
266 * binutils is too old (for other reasons as well)
267 */
268ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")
269ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")
270