blob: 7d767c3df282a2402e10b963416431fd67dc31e9 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* 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>
Will Deaconf0d53752012-01-20 11:55:54 +01007#include <asm/cache.h>
Russell King4f7a1812005-05-05 13:11:00 +01008#include <asm/thread_info.h>
Nicolas Pitre37d07b72005-10-29 21:44:56 +01009#include <asm/memory.h>
Linus Walleijf6430a92009-06-24 23:38:56 +010010#include <asm/page.h>
Jin Honga2440b52011-07-19 12:43:26 -070011#ifdef CONFIG_STRICT_MEMORY_RWX
12#include <asm/pgtable.h>
13#endif
Will Deacon6ffd58a2012-01-04 15:20:33 -080014
Russell King5085f3f2010-10-01 15:37:05 +010015#define PROC_INFO \
Marc Zyngierb8b99872012-02-07 02:46:38 +010016 . = ALIGN(4); \
Russell King5085f3f2010-10-01 15:37:05 +010017 VMLINUX_SYMBOL(__proc_info_begin) = .; \
18 *(.proc.info.init) \
19 VMLINUX_SYMBOL(__proc_info_end) = .;
20
Will Deacon89038262011-09-30 11:43:29 +010021#define IDMAP_TEXT \
22 ALIGN_FUNCTION(); \
23 VMLINUX_SYMBOL(__idmap_text_start) = .; \
24 *(.idmap.text) \
25 VMLINUX_SYMBOL(__idmap_text_end) = .;
26
Russell King5085f3f2010-10-01 15:37:05 +010027#ifdef CONFIG_HOTPLUG_CPU
28#define ARM_CPU_DISCARD(x)
29#define ARM_CPU_KEEP(x) x
30#else
31#define ARM_CPU_DISCARD(x) x
32#define ARM_CPU_KEEP(x)
33#endif
34
Simon Glass87e040b2011-08-16 23:44:26 +010035#if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || \
36 defined(CONFIG_GENERIC_BUG)
Russell Kinga9ad21f2011-02-21 10:13:36 +000037#define ARM_EXIT_KEEP(x) x
Russell King6760b102011-09-20 23:35:15 +010038#define ARM_EXIT_DISCARD(x)
Russell Kinga9ad21f2011-02-21 10:13:36 +000039#else
40#define ARM_EXIT_KEEP(x)
Russell King6760b102011-09-20 23:35:15 +010041#define ARM_EXIT_DISCARD(x) x
Russell Kinga9ad21f2011-02-21 10:13:36 +000042#endif
43
Linus Torvalds1da177e2005-04-16 15:20:36 -070044OUTPUT_ARCH(arm)
45ENTRY(stext)
Nicolas Pitre37d07b72005-10-29 21:44:56 +010046
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#ifndef __ARMEB__
48jiffies = jiffies_64;
49#else
50jiffies = jiffies_64 + 4;
51#endif
Nicolas Pitre37d07b72005-10-29 21:44:56 +010052
Linus Torvalds1da177e2005-04-16 15:20:36 -070053SECTIONS
54{
Russell King39df8882011-05-26 11:25:33 +010055 /*
Russell King6760b102011-09-20 23:35:15 +010056 * XXX: The linker does not define how output sections are
57 * assigned to input sections when there are multiple statements
58 * matching the same input section name. There is no documented
59 * order of matching.
60 *
Russell King39df8882011-05-26 11:25:33 +010061 * unwind exit sections must be discarded before the rest of the
62 * unwind sections get included.
63 */
64 /DISCARD/ : {
65 *(.ARM.exidx.exit.text)
66 *(.ARM.extab.exit.text)
67 ARM_CPU_DISCARD(*(.ARM.exidx.cpuexit.text))
68 ARM_CPU_DISCARD(*(.ARM.extab.cpuexit.text))
Russell King6760b102011-09-20 23:35:15 +010069 ARM_EXIT_DISCARD(EXIT_TEXT)
70 ARM_EXIT_DISCARD(EXIT_DATA)
71 EXIT_CALL
Russell King39df8882011-05-26 11:25:33 +010072#ifndef CONFIG_HOTPLUG
73 *(.ARM.exidx.devexit.text)
74 *(.ARM.extab.devexit.text)
75#endif
76#ifndef CONFIG_MMU
77 *(.fixup)
78 *(__ex_table)
79#endif
80#ifndef CONFIG_SMP_ON_UP
81 *(.alt.smp.init)
82#endif
Russell King6760b102011-09-20 23:35:15 +010083 *(.discard)
84 *(.discard.*)
Russell King39df8882011-05-26 11:25:33 +010085 }
86
Russell King9d4f13e2006-01-03 17:28:33 +000087#ifdef CONFIG_XIP_KERNEL
88 . = XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR);
89#else
90 . = PAGE_OFFSET + TEXT_OFFSET;
91#endif
Russell King1604d792011-07-05 22:56:41 +010092 .head.text : {
Russell Kinge2f81842011-07-06 10:53:22 +010093 _text = .;
Russell King1604d792011-07-05 22:56:41 +010094 HEAD_TEXT
95 }
Steve Mucklef132c6c2012-06-06 18:30:57 -070096
Russell King3835d692011-07-06 10:39:34 +010097 .text : { /* Real text segment */
Russell Kinge2f81842011-07-06 10:53:22 +010098 _stext = .; /* Text and read-only data */
Russell King3835d692011-07-06 10:39:34 +010099 __exception_text_start = .;
100 *(.exception.text)
101 __exception_text_end = .;
102 IRQENTRY_TEXT
103 TEXT_TEXT
104 SCHED_TEXT
105 LOCK_TEXT
106 KPROBES_TEXT
Will Deacon89038262011-09-30 11:43:29 +0100107 IDMAP_TEXT
Russell King3835d692011-07-06 10:39:34 +0100108#ifdef CONFIG_MMU
109 *(.fixup)
110#endif
111 *(.gnu.warning)
112 *(.glue_7)
113 *(.glue_7t)
114 . = ALIGN(4);
115 *(.got) /* Global offset table */
116 ARM_CPU_KEEP(PROC_INFO)
117 }
Jin Honga2440b52011-07-19 12:43:26 -0700118#ifdef CONFIG_STRICT_MEMORY_RWX
119 . = ALIGN(1<<SECTION_SHIFT);
120#endif
Sridhar Gujje52f4aa92013-08-21 23:12:29 -0700121
Russell King3835d692011-07-06 10:39:34 +0100122 RO_DATA(PAGE_SIZE)
123
124#ifdef CONFIG_ARM_UNWIND
125 /*
126 * Stack unwinding tables
127 */
128 . = ALIGN(8);
129 .ARM.unwind_idx : {
130 __start_unwind_idx = .;
131 *(.ARM.exidx*)
132 __stop_unwind_idx = .;
133 }
134 .ARM.unwind_tab : {
135 __start_unwind_tab = .;
136 *(.ARM.extab*)
137 __stop_unwind_tab = .;
138 }
139#endif
140
141 _etext = .; /* End of text and rodata section */
142
143#ifndef CONFIG_XIP_KERNEL
Steve Mucklef132c6c2012-06-06 18:30:57 -0700144#ifdef CONFIG_STRICT_MEMORY_RWX
145 . = ALIGN(1<<SECTION_SHIFT);
146#else
Russell King3835d692011-07-06 10:39:34 +0100147 . = ALIGN(PAGE_SIZE);
Steve Mucklef132c6c2012-06-06 18:30:57 -0700148#endif
Russell King3835d692011-07-06 10:39:34 +0100149 __init_begin = .;
150#endif
151
Russell King1604d792011-07-05 22:56:41 +0100152 INIT_TEXT_SECTION(8)
153 .exit.text : {
154 ARM_EXIT_KEEP(EXIT_TEXT)
155 }
156 .init.proc.info : {
Russell King5085f3f2010-10-01 15:37:05 +0100157 ARM_CPU_DISCARD(PROC_INFO)
Russell King1604d792011-07-05 22:56:41 +0100158 }
159 .init.arch.info : {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 __arch_info_begin = .;
Russell King1604d792011-07-05 22:56:41 +0100161 *(.arch.info.init)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162 __arch_info_end = .;
Russell King1604d792011-07-05 22:56:41 +0100163 }
164 .init.tagtable : {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165 __tagtable_begin = .;
Russell King1604d792011-07-05 22:56:41 +0100166 *(.taglist.init)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167 __tagtable_end = .;
Russell King1604d792011-07-05 22:56:41 +0100168 }
Russell Kingf00ec482010-09-04 10:47:48 +0100169#ifdef CONFIG_SMP_ON_UP
Russell King1604d792011-07-05 22:56:41 +0100170 .init.smpalt : {
Russell Kingf00ec482010-09-04 10:47:48 +0100171 __smpalt_begin = .;
Russell King1604d792011-07-05 22:56:41 +0100172 *(.alt.smp.init)
Russell Kingf00ec482010-09-04 10:47:48 +0100173 __smpalt_end = .;
Russell King1604d792011-07-05 22:56:41 +0100174 }
Russell Kingf00ec482010-09-04 10:47:48 +0100175#endif
Russell King1604d792011-07-05 22:56:41 +0100176 .init.pv_table : {
Russell Kingdc21af92011-01-04 19:09:43 +0000177 __pv_table_begin = .;
Russell King1604d792011-07-05 22:56:41 +0100178 *(.pv_table)
Russell Kingdc21af92011-01-04 19:09:43 +0000179 __pv_table_end = .;
Russell King1604d792011-07-05 22:56:41 +0100180 }
181 .init.data : {
182#ifndef CONFIG_XIP_KERNEL
183 INIT_DATA
184#endif
Nelson Elhage78d75302009-10-02 16:32:47 -0400185 INIT_SETUP(16)
Nelson Elhage78d75302009-10-02 16:32:47 -0400186 INIT_CALLS
187 CON_INITCALL
Laura Abbottd8d0f772012-07-10 10:27:06 -0700188 COMPAT_EXPORTS
Nelson Elhage78d75302009-10-02 16:32:47 -0400189 SECURITY_INITCALL
190 INIT_RAM_FS
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 }
Russell King1604d792011-07-05 22:56:41 +0100192#ifndef CONFIG_XIP_KERNEL
Sridhar Gujje52f4aa92013-08-21 23:12:29 -0700193#ifdef CONFIG_STRICT_MEMORY_RWX
194 . = ALIGN(1<<SECTION_SHIFT);
195#endif
196 __init_data = .;
Russell King1604d792011-07-05 22:56:41 +0100197 .exit.data : {
198 ARM_EXIT_KEEP(EXIT_DATA)
199 }
200#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201
David Brownda8ba552012-05-31 14:36:23 -0700202#if !defined(CONFIG_SMP) && !defined(CONFIG_XIP_KERNEL)
203 . = ALIGN(THREAD_SIZE);
204#endif
Will Deaconf0d53752012-01-20 11:55:54 +0100205 PERCPU_SECTION(L1_CACHE_BYTES)
Nelson Elhage78d75302009-10-02 16:32:47 -0400206
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207#ifdef CONFIG_XIP_KERNEL
208 __data_loc = ALIGN(4); /* location in binary */
Russell King9d4f13e2006-01-03 17:28:33 +0000209 . = PAGE_OFFSET + TEXT_OFFSET;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210#else
Russell King3835d692011-07-06 10:39:34 +0100211 __init_end = .;
Russell King4f7a1812005-05-05 13:11:00 +0100212 . = ALIGN(THREAD_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 __data_loc = .;
214#endif
215
216 .data : AT(__data_loc) {
Russell King37efe642008-12-01 11:53:07 +0000217 _data = .; /* address in memory */
Catalin Marinas8c7e6572009-05-30 14:00:17 +0100218 _sdata = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219
220 /*
221 * first, the init task union, aligned
222 * to an 8192 byte boundary.
223 */
Nelson Elhage78d75302009-10-02 16:32:47 -0400224 INIT_TASK_DATA(THREAD_SIZE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225
226#ifdef CONFIG_XIP_KERNEL
Linus Walleijf6430a92009-06-24 23:38:56 +0100227 . = ALIGN(PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 __init_begin = .;
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100229 INIT_DATA
Russell Kinga9ad21f2011-02-21 10:13:36 +0000230 ARM_EXIT_KEEP(EXIT_DATA)
Linus Walleijf6430a92009-06-24 23:38:56 +0100231 . = ALIGN(PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232 __init_end = .;
233#endif
234
Nelson Elhage78d75302009-10-02 16:32:47 -0400235 NOSAVE_DATA
Will Deaconf0d53752012-01-20 11:55:54 +0100236 CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES)
237 READ_MOSTLY_DATA(L1_CACHE_BYTES)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238
239 /*
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100240 * The exception fixup table (might need resorting at runtime)
241 */
Stepan Moskovchenkoced0bbe2012-01-05 13:51:00 -0800242 . = ALIGN(L1_CACHE_BYTES);
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100243 __start___ex_table = .;
Russell King9641c7c2006-06-21 20:38:17 +0100244#ifdef CONFIG_MMU
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100245 *(__ex_table)
Russell King9641c7c2006-06-21 20:38:17 +0100246#endif
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100247 __stop___ex_table = .;
248
249 /*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 * and the usual data section
251 */
Sam Ravnborgca967252007-05-17 13:38:44 +0200252 DATA_DATA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253 CONSTRUCTORS
254
255 _edata = .;
256 }
Nicolas Pitree98ff7f2007-02-22 16:18:09 +0100257 _edata_loc = __data_loc + SIZEOF(.data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258
Linus Walleijbc581772009-09-15 17:30:37 +0100259#ifdef CONFIG_HAVE_TCM
260 /*
261 * We align everything to a page boundary so we can
262 * free it after init has commenced and TCM contents have
263 * been copied to its destination.
264 */
265 .tcm_start : {
266 . = ALIGN(PAGE_SIZE);
267 __tcm_start = .;
268 __itcm_start = .;
269 }
270
271 /*
272 * Link these to the ITCM RAM
273 * Put VMA to the TCM address and LMA to the common RAM
274 * and we'll upload the contents from RAM to TCM and free
275 * the used RAM after that.
276 */
277 .text_itcm ITCM_OFFSET : AT(__itcm_start)
278 {
279 __sitcm_text = .;
280 *(.tcm.text)
281 *(.tcm.rodata)
282 . = ALIGN(4);
283 __eitcm_text = .;
284 }
285
286 /*
287 * Reset the dot pointer, this is needed to create the
288 * relative __dtcm_start below (to be used as extern in code).
289 */
290 . = ADDR(.tcm_start) + SIZEOF(.tcm_start) + SIZEOF(.text_itcm);
291
292 .dtcm_start : {
293 __dtcm_start = .;
294 }
295
296 /* TODO: add remainder of ITCM as well, that can be used for data! */
297 .data_dtcm DTCM_OFFSET : AT(__dtcm_start)
298 {
299 . = ALIGN(4);
300 __sdtcm_data = .;
301 *(.tcm.data)
302 . = ALIGN(4);
303 __edtcm_data = .;
304 }
305
306 /* Reset the dot pointer or the linker gets confused */
307 . = ADDR(.dtcm_start) + SIZEOF(.data_dtcm);
308
309 /* End marker for freeing TCM copy in linked object */
310 .tcm_end : AT(ADDR(.dtcm_start) + SIZEOF(.data_dtcm)){
311 . = ALIGN(PAGE_SIZE);
312 __tcm_end = .;
313 }
314#endif
315
Pawel Molldc810ef2011-02-16 18:54:01 +0100316 NOTES
317
Nelson Elhage78d75302009-10-02 16:32:47 -0400318 BSS_SECTION(0, 0, 0)
319 _end = .;
320
321 STABS_DEBUG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 .comment 0 : { *(.comment) }
323}
324
Russell King728f5c02005-11-17 16:43:14 +0000325/*
326 * These must never be empty
327 * If you have to comment these two assert statements out, your
328 * binutils is too old (for other reasons as well)
329 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")
331ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")