blob: a8f285885e059656136164bda8ee2c528288651e [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
Russell King3835d692011-07-06 10:39:34 +0100121
122 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
188 SECURITY_INITCALL
189 INIT_RAM_FS
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190 }
Russell King1604d792011-07-05 22:56:41 +0100191#ifndef CONFIG_XIP_KERNEL
Steve Mucklef132c6c2012-06-06 18:30:57 -0700192#ifdef CONFIG_STRICT_MEMORY_RWX
193 . = ALIGN(1<<SECTION_SHIFT);
194#endif
195 __init_data = .;
Russell King1604d792011-07-05 22:56:41 +0100196 .exit.data : {
197 ARM_EXIT_KEEP(EXIT_DATA)
198 }
199#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200
David Brownda8ba552012-05-31 14:36:23 -0700201#if !defined(CONFIG_SMP) && !defined(CONFIG_XIP_KERNEL)
202 . = ALIGN(THREAD_SIZE);
203#endif
Will Deaconf0d53752012-01-20 11:55:54 +0100204 PERCPU_SECTION(L1_CACHE_BYTES)
Nelson Elhage78d75302009-10-02 16:32:47 -0400205
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206#ifdef CONFIG_XIP_KERNEL
207 __data_loc = ALIGN(4); /* location in binary */
Russell King9d4f13e2006-01-03 17:28:33 +0000208 . = PAGE_OFFSET + TEXT_OFFSET;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209#else
Russell King3835d692011-07-06 10:39:34 +0100210 __init_end = .;
Russell King4f7a1812005-05-05 13:11:00 +0100211 . = ALIGN(THREAD_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 __data_loc = .;
213#endif
214
215 .data : AT(__data_loc) {
Russell King37efe642008-12-01 11:53:07 +0000216 _data = .; /* address in memory */
Catalin Marinas8c7e6572009-05-30 14:00:17 +0100217 _sdata = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218
219 /*
220 * first, the init task union, aligned
221 * to an 8192 byte boundary.
222 */
Nelson Elhage78d75302009-10-02 16:32:47 -0400223 INIT_TASK_DATA(THREAD_SIZE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224
225#ifdef CONFIG_XIP_KERNEL
Linus Walleijf6430a92009-06-24 23:38:56 +0100226 . = ALIGN(PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227 __init_begin = .;
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100228 INIT_DATA
Russell Kinga9ad21f2011-02-21 10:13:36 +0000229 ARM_EXIT_KEEP(EXIT_DATA)
Linus Walleijf6430a92009-06-24 23:38:56 +0100230 . = ALIGN(PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 __init_end = .;
232#endif
233
Nelson Elhage78d75302009-10-02 16:32:47 -0400234 NOSAVE_DATA
Will Deaconf0d53752012-01-20 11:55:54 +0100235 CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES)
236 READ_MOSTLY_DATA(L1_CACHE_BYTES)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237
238 /*
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100239 * The exception fixup table (might need resorting at runtime)
240 */
Stepan Moskovchenkoced0bbe2012-01-05 13:51:00 -0800241 . = ALIGN(L1_CACHE_BYTES);
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100242 __start___ex_table = .;
Russell King9641c7c2006-06-21 20:38:17 +0100243#ifdef CONFIG_MMU
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100244 *(__ex_table)
Russell King9641c7c2006-06-21 20:38:17 +0100245#endif
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100246 __stop___ex_table = .;
247
248 /*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 * and the usual data section
250 */
Sam Ravnborgca967252007-05-17 13:38:44 +0200251 DATA_DATA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252 CONSTRUCTORS
253
254 _edata = .;
255 }
Nicolas Pitree98ff7f2007-02-22 16:18:09 +0100256 _edata_loc = __data_loc + SIZEOF(.data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257
Linus Walleijbc581772009-09-15 17:30:37 +0100258#ifdef CONFIG_HAVE_TCM
259 /*
260 * We align everything to a page boundary so we can
261 * free it after init has commenced and TCM contents have
262 * been copied to its destination.
263 */
264 .tcm_start : {
265 . = ALIGN(PAGE_SIZE);
266 __tcm_start = .;
267 __itcm_start = .;
268 }
269
270 /*
271 * Link these to the ITCM RAM
272 * Put VMA to the TCM address and LMA to the common RAM
273 * and we'll upload the contents from RAM to TCM and free
274 * the used RAM after that.
275 */
276 .text_itcm ITCM_OFFSET : AT(__itcm_start)
277 {
278 __sitcm_text = .;
279 *(.tcm.text)
280 *(.tcm.rodata)
281 . = ALIGN(4);
282 __eitcm_text = .;
283 }
284
285 /*
286 * Reset the dot pointer, this is needed to create the
287 * relative __dtcm_start below (to be used as extern in code).
288 */
289 . = ADDR(.tcm_start) + SIZEOF(.tcm_start) + SIZEOF(.text_itcm);
290
291 .dtcm_start : {
292 __dtcm_start = .;
293 }
294
295 /* TODO: add remainder of ITCM as well, that can be used for data! */
296 .data_dtcm DTCM_OFFSET : AT(__dtcm_start)
297 {
298 . = ALIGN(4);
299 __sdtcm_data = .;
300 *(.tcm.data)
301 . = ALIGN(4);
302 __edtcm_data = .;
303 }
304
305 /* Reset the dot pointer or the linker gets confused */
306 . = ADDR(.dtcm_start) + SIZEOF(.data_dtcm);
307
308 /* End marker for freeing TCM copy in linked object */
309 .tcm_end : AT(ADDR(.dtcm_start) + SIZEOF(.data_dtcm)){
310 . = ALIGN(PAGE_SIZE);
311 __tcm_end = .;
312 }
313#endif
314
Pawel Molldc810ef2011-02-16 18:54:01 +0100315 NOTES
316
Nelson Elhage78d75302009-10-02 16:32:47 -0400317 BSS_SECTION(0, 0, 0)
318 _end = .;
319
320 STABS_DEBUG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 .comment 0 : { *(.comment) }
322}
323
Russell King728f5c02005-11-17 16:43:14 +0000324/*
325 * These must never be empty
326 * If you have to comment these two assert statements out, your
327 * binutils is too old (for other reasons as well)
328 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")
330ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")