blob: 8516884ff85e85fd7091bb9406d51e0d10857bc7 [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
Russell King47dcfc22013-07-04 11:40:32 +0100151 /*
152 * The vectors and stubs are relocatable code, and the
153 * only thing that matters is their relative offsets
154 */
155 __vectors_start = .;
156 .vectors 0 : AT(__vectors_start) {
157 *(.vectors)
158 }
159 . = __vectors_start + SIZEOF(.vectors);
160 __vectors_end = .;
161
162 __stubs_start = .;
163 .stubs 0x1000 : AT(__stubs_start) {
164 *(.stubs)
165 }
166 . = __stubs_start + SIZEOF(.stubs);
167 __stubs_end = .;
Russell King3835d692011-07-06 10:39:34 +0100168
Russell King1604d792011-07-05 22:56:41 +0100169 INIT_TEXT_SECTION(8)
170 .exit.text : {
171 ARM_EXIT_KEEP(EXIT_TEXT)
172 }
173 .init.proc.info : {
Russell King5085f3f2010-10-01 15:37:05 +0100174 ARM_CPU_DISCARD(PROC_INFO)
Russell King1604d792011-07-05 22:56:41 +0100175 }
176 .init.arch.info : {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177 __arch_info_begin = .;
Russell King1604d792011-07-05 22:56:41 +0100178 *(.arch.info.init)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 __arch_info_end = .;
Russell King1604d792011-07-05 22:56:41 +0100180 }
181 .init.tagtable : {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182 __tagtable_begin = .;
Russell King1604d792011-07-05 22:56:41 +0100183 *(.taglist.init)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 __tagtable_end = .;
Russell King1604d792011-07-05 22:56:41 +0100185 }
Russell Kingf00ec482010-09-04 10:47:48 +0100186#ifdef CONFIG_SMP_ON_UP
Russell King1604d792011-07-05 22:56:41 +0100187 .init.smpalt : {
Russell Kingf00ec482010-09-04 10:47:48 +0100188 __smpalt_begin = .;
Russell King1604d792011-07-05 22:56:41 +0100189 *(.alt.smp.init)
Russell Kingf00ec482010-09-04 10:47:48 +0100190 __smpalt_end = .;
Russell King1604d792011-07-05 22:56:41 +0100191 }
Russell Kingf00ec482010-09-04 10:47:48 +0100192#endif
Russell King1604d792011-07-05 22:56:41 +0100193 .init.pv_table : {
Russell Kingdc21af92011-01-04 19:09:43 +0000194 __pv_table_begin = .;
Russell King1604d792011-07-05 22:56:41 +0100195 *(.pv_table)
Russell Kingdc21af92011-01-04 19:09:43 +0000196 __pv_table_end = .;
Russell King1604d792011-07-05 22:56:41 +0100197 }
198 .init.data : {
199#ifndef CONFIG_XIP_KERNEL
200 INIT_DATA
201#endif
Nelson Elhage78d75302009-10-02 16:32:47 -0400202 INIT_SETUP(16)
Nelson Elhage78d75302009-10-02 16:32:47 -0400203 INIT_CALLS
204 CON_INITCALL
Laura Abbottd8d0f772012-07-10 10:27:06 -0700205 COMPAT_EXPORTS
Nelson Elhage78d75302009-10-02 16:32:47 -0400206 SECURITY_INITCALL
207 INIT_RAM_FS
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208 }
Russell King1604d792011-07-05 22:56:41 +0100209#ifndef CONFIG_XIP_KERNEL
Sridhar Gujje52f4aa92013-08-21 23:12:29 -0700210#ifdef CONFIG_STRICT_MEMORY_RWX
211 . = ALIGN(1<<SECTION_SHIFT);
212#endif
213 __init_data = .;
Russell King1604d792011-07-05 22:56:41 +0100214 .exit.data : {
215 ARM_EXIT_KEEP(EXIT_DATA)
216 }
217#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218
David Brownda8ba552012-05-31 14:36:23 -0700219#if !defined(CONFIG_SMP) && !defined(CONFIG_XIP_KERNEL)
220 . = ALIGN(THREAD_SIZE);
221#endif
Will Deaconf0d53752012-01-20 11:55:54 +0100222 PERCPU_SECTION(L1_CACHE_BYTES)
Nelson Elhage78d75302009-10-02 16:32:47 -0400223
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224#ifdef CONFIG_XIP_KERNEL
225 __data_loc = ALIGN(4); /* location in binary */
Russell King9d4f13e2006-01-03 17:28:33 +0000226 . = PAGE_OFFSET + TEXT_OFFSET;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227#else
Russell King3835d692011-07-06 10:39:34 +0100228 __init_end = .;
Russell King4f7a1812005-05-05 13:11:00 +0100229 . = ALIGN(THREAD_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230 __data_loc = .;
231#endif
232
233 .data : AT(__data_loc) {
Russell King37efe642008-12-01 11:53:07 +0000234 _data = .; /* address in memory */
Catalin Marinas8c7e6572009-05-30 14:00:17 +0100235 _sdata = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236
237 /*
238 * first, the init task union, aligned
239 * to an 8192 byte boundary.
240 */
Nelson Elhage78d75302009-10-02 16:32:47 -0400241 INIT_TASK_DATA(THREAD_SIZE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242
243#ifdef CONFIG_XIP_KERNEL
Linus Walleijf6430a92009-06-24 23:38:56 +0100244 . = ALIGN(PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 __init_begin = .;
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100246 INIT_DATA
Russell Kinga9ad21f2011-02-21 10:13:36 +0000247 ARM_EXIT_KEEP(EXIT_DATA)
Linus Walleijf6430a92009-06-24 23:38:56 +0100248 . = ALIGN(PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 __init_end = .;
250#endif
251
Nelson Elhage78d75302009-10-02 16:32:47 -0400252 NOSAVE_DATA
Will Deaconf0d53752012-01-20 11:55:54 +0100253 CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES)
254 READ_MOSTLY_DATA(L1_CACHE_BYTES)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255
256 /*
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100257 * The exception fixup table (might need resorting at runtime)
258 */
Stepan Moskovchenkoced0bbe2012-01-05 13:51:00 -0800259 . = ALIGN(L1_CACHE_BYTES);
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100260 __start___ex_table = .;
Russell King9641c7c2006-06-21 20:38:17 +0100261#ifdef CONFIG_MMU
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100262 *(__ex_table)
Russell King9641c7c2006-06-21 20:38:17 +0100263#endif
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100264 __stop___ex_table = .;
265
266 /*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267 * and the usual data section
268 */
Sam Ravnborgca967252007-05-17 13:38:44 +0200269 DATA_DATA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270 CONSTRUCTORS
271
272 _edata = .;
273 }
Nicolas Pitree98ff7f2007-02-22 16:18:09 +0100274 _edata_loc = __data_loc + SIZEOF(.data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275
Linus Walleijbc581772009-09-15 17:30:37 +0100276#ifdef CONFIG_HAVE_TCM
277 /*
278 * We align everything to a page boundary so we can
279 * free it after init has commenced and TCM contents have
280 * been copied to its destination.
281 */
282 .tcm_start : {
283 . = ALIGN(PAGE_SIZE);
284 __tcm_start = .;
285 __itcm_start = .;
286 }
287
288 /*
289 * Link these to the ITCM RAM
290 * Put VMA to the TCM address and LMA to the common RAM
291 * and we'll upload the contents from RAM to TCM and free
292 * the used RAM after that.
293 */
294 .text_itcm ITCM_OFFSET : AT(__itcm_start)
295 {
296 __sitcm_text = .;
297 *(.tcm.text)
298 *(.tcm.rodata)
299 . = ALIGN(4);
300 __eitcm_text = .;
301 }
302
303 /*
304 * Reset the dot pointer, this is needed to create the
305 * relative __dtcm_start below (to be used as extern in code).
306 */
307 . = ADDR(.tcm_start) + SIZEOF(.tcm_start) + SIZEOF(.text_itcm);
308
309 .dtcm_start : {
310 __dtcm_start = .;
311 }
312
313 /* TODO: add remainder of ITCM as well, that can be used for data! */
314 .data_dtcm DTCM_OFFSET : AT(__dtcm_start)
315 {
316 . = ALIGN(4);
317 __sdtcm_data = .;
318 *(.tcm.data)
319 . = ALIGN(4);
320 __edtcm_data = .;
321 }
322
323 /* Reset the dot pointer or the linker gets confused */
324 . = ADDR(.dtcm_start) + SIZEOF(.data_dtcm);
325
326 /* End marker for freeing TCM copy in linked object */
327 .tcm_end : AT(ADDR(.dtcm_start) + SIZEOF(.data_dtcm)){
328 . = ALIGN(PAGE_SIZE);
329 __tcm_end = .;
330 }
331#endif
332
Pawel Molldc810ef2011-02-16 18:54:01 +0100333 NOTES
334
Nelson Elhage78d75302009-10-02 16:32:47 -0400335 BSS_SECTION(0, 0, 0)
336 _end = .;
337
338 STABS_DEBUG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339 .comment 0 : { *(.comment) }
340}
341
Russell King728f5c02005-11-17 16:43:14 +0000342/*
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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")
348ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")