blob: 6530fa3416a28f661f6f5c799df06446a9b70968 [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>
Russell King4f7a1812005-05-05 13:11:00 +01007#include <asm/thread_info.h>
Nicolas Pitre37d07b72005-10-29 21:44:56 +01008#include <asm/memory.h>
Linus Walleijf6430a92009-06-24 23:38:56 +01009#include <asm/page.h>
Jin Honga2440b52011-07-19 12:43:26 -070010#ifdef CONFIG_STRICT_MEMORY_RWX
11#include <asm/pgtable.h>
12#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
Russell King5085f3f2010-10-01 15:37:05 +010014#define PROC_INFO \
15 VMLINUX_SYMBOL(__proc_info_begin) = .; \
16 *(.proc.info.init) \
17 VMLINUX_SYMBOL(__proc_info_end) = .;
18
19#ifdef CONFIG_HOTPLUG_CPU
20#define ARM_CPU_DISCARD(x)
21#define ARM_CPU_KEEP(x) x
22#else
23#define ARM_CPU_DISCARD(x) x
24#define ARM_CPU_KEEP(x)
25#endif
26
Simon Glassd3dc3062011-08-16 23:44:26 +010027#if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || \
28 defined(CONFIG_GENERIC_BUG)
Russell Kinga9ad21f2011-02-21 10:13:36 +000029#define ARM_EXIT_KEEP(x) x
30#else
31#define ARM_EXIT_KEEP(x)
32#endif
33
Linus Torvalds1da177e2005-04-16 15:20:36 -070034OUTPUT_ARCH(arm)
35ENTRY(stext)
Nicolas Pitre37d07b72005-10-29 21:44:56 +010036
Linus Torvalds1da177e2005-04-16 15:20:36 -070037#ifndef __ARMEB__
38jiffies = jiffies_64;
39#else
40jiffies = jiffies_64 + 4;
41#endif
Nicolas Pitre37d07b72005-10-29 21:44:56 +010042
Linus Torvalds1da177e2005-04-16 15:20:36 -070043SECTIONS
44{
Russell King9d4f13e2006-01-03 17:28:33 +000045#ifdef CONFIG_XIP_KERNEL
46 . = XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR);
47#else
48 . = PAGE_OFFSET + TEXT_OFFSET;
49#endif
Russell King08fdffd2007-05-08 15:15:45 +010050
51 .init : { /* Init code and data */
Tim Abbott2abc1c52009-10-02 16:32:46 -040052 _stext = .;
53 _sinittext = .;
54 HEAD_TEXT
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +010055 INIT_TEXT
Russell Kinga9ad21f2011-02-21 10:13:36 +000056 ARM_EXIT_KEEP(EXIT_TEXT)
Russell King08fdffd2007-05-08 15:15:45 +010057 _einittext = .;
Russell King5085f3f2010-10-01 15:37:05 +010058 ARM_CPU_DISCARD(PROC_INFO)
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 __arch_info_begin = .;
Ben Dooks9d0fd1e2005-09-20 16:45:20 +010060 *(.arch.info.init)
Linus Torvalds1da177e2005-04-16 15:20:36 -070061 __arch_info_end = .;
62 __tagtable_begin = .;
Ben Dooks95060572005-09-20 16:20:49 +010063 *(.taglist.init)
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 __tagtable_end = .;
Russell Kingf00ec482010-09-04 10:47:48 +010065#ifdef CONFIG_SMP_ON_UP
66 __smpalt_begin = .;
67 *(.alt.smp.init)
68 __smpalt_end = .;
69#endif
Nelson Elhage78d75302009-10-02 16:32:47 -040070
Russell Kingdc21af92011-01-04 19:09:43 +000071 __pv_table_begin = .;
72 *(.pv_table)
73 __pv_table_end = .;
74
Nelson Elhage78d75302009-10-02 16:32:47 -040075 INIT_SETUP(16)
76
Nelson Elhage78d75302009-10-02 16:32:47 -040077 INIT_CALLS
78 CON_INITCALL
79 SECURITY_INITCALL
80 INIT_RAM_FS
81
Linus Torvalds1da177e2005-04-16 15:20:36 -070082#ifndef CONFIG_XIP_KERNEL
83 __init_begin = _stext;
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +010084 INIT_DATA
Russell Kinga9ad21f2011-02-21 10:13:36 +000085 ARM_EXIT_KEEP(EXIT_DATA)
Linus Torvalds1da177e2005-04-16 15:20:36 -070086#endif
87 }
88
Tejun Heo0415b002011-03-24 18:50:09 +010089 PERCPU_SECTION(32)
Nelson Elhage78d75302009-10-02 16:32:47 -040090
91#ifndef CONFIG_XIP_KERNEL
92 . = ALIGN(PAGE_SIZE);
93 __init_end = .;
94#endif
95
Alan Jenkinse3f28c12009-11-07 21:03:52 +000096 /*
97 * unwind exit sections must be discarded before the rest of the
98 * unwind sections get included.
99 */
100 /DISCARD/ : {
Catalin Marinasbff595c2009-02-16 11:41:36 +0100101 *(.ARM.exidx.exit.text)
102 *(.ARM.extab.exit.text)
Russell King5085f3f2010-10-01 15:37:05 +0100103 ARM_CPU_DISCARD(*(.ARM.exidx.cpuexit.text))
104 ARM_CPU_DISCARD(*(.ARM.extab.cpuexit.text))
Catalin Marinas74361272009-06-19 16:39:29 +0100105#ifndef CONFIG_HOTPLUG
106 *(.ARM.exidx.devexit.text)
107 *(.ARM.extab.devexit.text)
108#endif
Russell King9641c7c2006-06-21 20:38:17 +0100109#ifndef CONFIG_MMU
110 *(.fixup)
111 *(__ex_table)
112#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113 }
114
Jin Honga2440b52011-07-19 12:43:26 -0700115#ifdef CONFIG_STRICT_MEMORY_RWX
116 . = ALIGN(1<<SECTION_SHIFT);
117#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118 .text : { /* Real text segment */
119 _text = .; /* Text and read-only data */
Russell King7ab3f8d2007-03-02 15:01:36 +0000120 __exception_text_start = .;
121 *(.exception.text)
122 __exception_text_end = .;
Rabin Vincent61b5cb12010-10-07 20:51:58 +0530123 IRQENTRY_TEXT
Sam Ravnborg76647092007-05-13 00:31:33 +0200124 TEXT_TEXT
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 SCHED_TEXT
126 LOCK_TEXT
Nicolas Pitre785d3cd2007-12-03 15:27:56 -0500127 KPROBES_TEXT
Russell King9641c7c2006-06-21 20:38:17 +0100128#ifdef CONFIG_MMU
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 *(.fixup)
Russell King9641c7c2006-06-21 20:38:17 +0100130#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 *(.gnu.warning)
132 *(.rodata)
133 *(.rodata.*)
134 *(.glue_7)
135 *(.glue_7t)
Tony Lindgren88d927e2010-10-26 19:52:21 +0100136 . = ALIGN(4);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 *(.got) /* Global offset table */
Russell King5085f3f2010-10-01 15:37:05 +0100138 ARM_CPU_KEEP(PROC_INFO)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 }
Jin Honga2440b52011-07-19 12:43:26 -0700140#ifdef CONFIG_STRICT_MEMORY_RWX
141 . = ALIGN(1<<SECTION_SHIFT);
142#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143
Linus Walleijf6430a92009-06-24 23:38:56 +0100144 RO_DATA(PAGE_SIZE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145
Catalin Marinasbff595c2009-02-16 11:41:36 +0100146#ifdef CONFIG_ARM_UNWIND
147 /*
148 * Stack unwinding tables
149 */
150 . = ALIGN(8);
151 .ARM.unwind_idx : {
152 __start_unwind_idx = .;
153 *(.ARM.exidx*)
154 __stop_unwind_idx = .;
155 }
156 .ARM.unwind_tab : {
157 __start_unwind_tab = .;
158 *(.ARM.extab*)
159 __stop_unwind_tab = .;
160 }
161#endif
162
Russell King74b0ec02010-10-01 14:26:56 +0100163 _etext = .; /* End of text and rodata section */
164
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165#ifdef CONFIG_XIP_KERNEL
166 __data_loc = ALIGN(4); /* location in binary */
Russell King9d4f13e2006-01-03 17:28:33 +0000167 . = PAGE_OFFSET + TEXT_OFFSET;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168#else
Jin Honga2440b52011-07-19 12:43:26 -0700169#ifdef CONFIG_STRICT_MEMORY_RWX
170 . = ALIGN(1<<SECTION_SHIFT);
171#else
Russell King4f7a1812005-05-05 13:11:00 +0100172 . = ALIGN(THREAD_SIZE);
Jin Honga2440b52011-07-19 12:43:26 -0700173#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174 __data_loc = .;
175#endif
176
177 .data : AT(__data_loc) {
Russell King37efe642008-12-01 11:53:07 +0000178 _data = .; /* address in memory */
Catalin Marinas8c7e6572009-05-30 14:00:17 +0100179 _sdata = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180
181 /*
182 * first, the init task union, aligned
183 * to an 8192 byte boundary.
184 */
Nelson Elhage78d75302009-10-02 16:32:47 -0400185 INIT_TASK_DATA(THREAD_SIZE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186
187#ifdef CONFIG_XIP_KERNEL
Linus Walleijf6430a92009-06-24 23:38:56 +0100188 . = ALIGN(PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189 __init_begin = .;
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100190 INIT_DATA
Russell Kinga9ad21f2011-02-21 10:13:36 +0000191 ARM_EXIT_KEEP(EXIT_DATA)
Linus Walleijf6430a92009-06-24 23:38:56 +0100192 . = ALIGN(PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193 __init_end = .;
194#endif
195
Nelson Elhage78d75302009-10-02 16:32:47 -0400196 NOSAVE_DATA
197 CACHELINE_ALIGNED_DATA(32)
Russell Kingdaf87412010-12-04 17:08:32 +0000198 READ_MOSTLY_DATA(32)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199
200 /*
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100201 * The exception fixup table (might need resorting at runtime)
202 */
203 . = ALIGN(32);
204 __start___ex_table = .;
Russell King9641c7c2006-06-21 20:38:17 +0100205#ifdef CONFIG_MMU
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100206 *(__ex_table)
Russell King9641c7c2006-06-21 20:38:17 +0100207#endif
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100208 __stop___ex_table = .;
209
210 /*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211 * and the usual data section
212 */
Sam Ravnborgca967252007-05-17 13:38:44 +0200213 DATA_DATA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 CONSTRUCTORS
215
216 _edata = .;
217 }
Nicolas Pitree98ff7f2007-02-22 16:18:09 +0100218 _edata_loc = __data_loc + SIZEOF(.data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219
Linus Walleijbc581772009-09-15 17:30:37 +0100220#ifdef CONFIG_HAVE_TCM
221 /*
222 * We align everything to a page boundary so we can
223 * free it after init has commenced and TCM contents have
224 * been copied to its destination.
225 */
226 .tcm_start : {
227 . = ALIGN(PAGE_SIZE);
228 __tcm_start = .;
229 __itcm_start = .;
230 }
231
232 /*
233 * Link these to the ITCM RAM
234 * Put VMA to the TCM address and LMA to the common RAM
235 * and we'll upload the contents from RAM to TCM and free
236 * the used RAM after that.
237 */
238 .text_itcm ITCM_OFFSET : AT(__itcm_start)
239 {
240 __sitcm_text = .;
241 *(.tcm.text)
242 *(.tcm.rodata)
243 . = ALIGN(4);
244 __eitcm_text = .;
245 }
246
247 /*
248 * Reset the dot pointer, this is needed to create the
249 * relative __dtcm_start below (to be used as extern in code).
250 */
251 . = ADDR(.tcm_start) + SIZEOF(.tcm_start) + SIZEOF(.text_itcm);
252
253 .dtcm_start : {
254 __dtcm_start = .;
255 }
256
257 /* TODO: add remainder of ITCM as well, that can be used for data! */
258 .data_dtcm DTCM_OFFSET : AT(__dtcm_start)
259 {
260 . = ALIGN(4);
261 __sdtcm_data = .;
262 *(.tcm.data)
263 . = ALIGN(4);
264 __edtcm_data = .;
265 }
266
267 /* Reset the dot pointer or the linker gets confused */
268 . = ADDR(.dtcm_start) + SIZEOF(.data_dtcm);
269
270 /* End marker for freeing TCM copy in linked object */
271 .tcm_end : AT(ADDR(.dtcm_start) + SIZEOF(.data_dtcm)){
272 . = ALIGN(PAGE_SIZE);
273 __tcm_end = .;
274 }
275#endif
276
Pawel Molldc810ef2011-02-16 18:54:01 +0100277 NOTES
278
Nelson Elhage78d75302009-10-02 16:32:47 -0400279 BSS_SECTION(0, 0, 0)
280 _end = .;
281
282 STABS_DEBUG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283 .comment 0 : { *(.comment) }
Alan Jenkinse3f28c12009-11-07 21:03:52 +0000284
285 /* Default discards */
286 DISCARDS
Russell Kingf00ec482010-09-04 10:47:48 +0100287
288#ifndef CONFIG_SMP_ON_UP
289 /DISCARD/ : {
290 *(.alt.smp.init)
291 }
292#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293}
294
Russell King728f5c02005-11-17 16:43:14 +0000295/*
296 * These must never be empty
297 * If you have to comment these two assert statements out, your
298 * binutils is too old (for other reasons as well)
299 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")
301ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")