blob: 8652d45255ecbe6f0065c67cb17ecb20a9473779 [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
Russell Kinga9ad21f2011-02-21 10:13:36 +000027#if defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)
28#define ARM_EXIT_KEEP(x) x
29#else
30#define ARM_EXIT_KEEP(x)
31#endif
32
Linus Torvalds1da177e2005-04-16 15:20:36 -070033OUTPUT_ARCH(arm)
34ENTRY(stext)
Nicolas Pitre37d07b72005-10-29 21:44:56 +010035
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#ifndef __ARMEB__
37jiffies = jiffies_64;
38#else
39jiffies = jiffies_64 + 4;
40#endif
Nicolas Pitre37d07b72005-10-29 21:44:56 +010041
Linus Torvalds1da177e2005-04-16 15:20:36 -070042SECTIONS
43{
Russell King9d4f13e2006-01-03 17:28:33 +000044#ifdef CONFIG_XIP_KERNEL
45 . = XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR);
46#else
47 . = PAGE_OFFSET + TEXT_OFFSET;
48#endif
Russell King08fdffd2007-05-08 15:15:45 +010049
50 .init : { /* Init code and data */
Tim Abbott2abc1c52009-10-02 16:32:46 -040051 _stext = .;
52 _sinittext = .;
53 HEAD_TEXT
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +010054 INIT_TEXT
Russell Kinga9ad21f2011-02-21 10:13:36 +000055 ARM_EXIT_KEEP(EXIT_TEXT)
Russell King08fdffd2007-05-08 15:15:45 +010056 _einittext = .;
Russell King5085f3f2010-10-01 15:37:05 +010057 ARM_CPU_DISCARD(PROC_INFO)
Linus Torvalds1da177e2005-04-16 15:20:36 -070058 __arch_info_begin = .;
Ben Dooks9d0fd1e2005-09-20 16:45:20 +010059 *(.arch.info.init)
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 __arch_info_end = .;
61 __tagtable_begin = .;
Ben Dooks95060572005-09-20 16:20:49 +010062 *(.taglist.init)
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 __tagtable_end = .;
Russell Kingf00ec482010-09-04 10:47:48 +010064#ifdef CONFIG_SMP_ON_UP
65 __smpalt_begin = .;
66 *(.alt.smp.init)
67 __smpalt_end = .;
68#endif
Nelson Elhage78d75302009-10-02 16:32:47 -040069
Russell Kingdc21af92011-01-04 19:09:43 +000070 __pv_table_begin = .;
71 *(.pv_table)
72 __pv_table_end = .;
73
Nelson Elhage78d75302009-10-02 16:32:47 -040074 INIT_SETUP(16)
75
Nelson Elhage78d75302009-10-02 16:32:47 -040076 INIT_CALLS
77 CON_INITCALL
78 SECURITY_INITCALL
79 INIT_RAM_FS
80
Linus Torvalds1da177e2005-04-16 15:20:36 -070081#ifndef CONFIG_XIP_KERNEL
82 __init_begin = _stext;
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +010083 INIT_DATA
Russell Kinga9ad21f2011-02-21 10:13:36 +000084 ARM_EXIT_KEEP(EXIT_DATA)
Linus Torvalds1da177e2005-04-16 15:20:36 -070085#endif
86 }
87
Tejun Heo0415b002011-03-24 18:50:09 +010088 PERCPU_SECTION(32)
Nelson Elhage78d75302009-10-02 16:32:47 -040089
90#ifndef CONFIG_XIP_KERNEL
91 . = ALIGN(PAGE_SIZE);
92 __init_end = .;
93#endif
94
Alan Jenkinse3f28c12009-11-07 21:03:52 +000095 /*
96 * unwind exit sections must be discarded before the rest of the
97 * unwind sections get included.
98 */
99 /DISCARD/ : {
Catalin Marinasbff595c2009-02-16 11:41:36 +0100100 *(.ARM.exidx.exit.text)
101 *(.ARM.extab.exit.text)
Russell King5085f3f2010-10-01 15:37:05 +0100102 ARM_CPU_DISCARD(*(.ARM.exidx.cpuexit.text))
103 ARM_CPU_DISCARD(*(.ARM.extab.cpuexit.text))
Catalin Marinas74361272009-06-19 16:39:29 +0100104#ifndef CONFIG_HOTPLUG
105 *(.ARM.exidx.devexit.text)
106 *(.ARM.extab.devexit.text)
107#endif
Russell King9641c7c2006-06-21 20:38:17 +0100108#ifndef CONFIG_MMU
109 *(.fixup)
110 *(__ex_table)
111#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112 }
113
Jin Honga2440b52011-07-19 12:43:26 -0700114#ifdef CONFIG_STRICT_MEMORY_RWX
115 . = ALIGN(1<<SECTION_SHIFT);
116#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117 .text : { /* Real text segment */
118 _text = .; /* Text and read-only data */
Russell King7ab3f8d2007-03-02 15:01:36 +0000119 __exception_text_start = .;
120 *(.exception.text)
121 __exception_text_end = .;
Rabin Vincent61b5cb12010-10-07 20:51:58 +0530122 IRQENTRY_TEXT
Sam Ravnborg76647092007-05-13 00:31:33 +0200123 TEXT_TEXT
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124 SCHED_TEXT
125 LOCK_TEXT
Nicolas Pitre785d3cd2007-12-03 15:27:56 -0500126 KPROBES_TEXT
Russell King9641c7c2006-06-21 20:38:17 +0100127#ifdef CONFIG_MMU
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128 *(.fixup)
Russell King9641c7c2006-06-21 20:38:17 +0100129#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 *(.gnu.warning)
131 *(.rodata)
132 *(.rodata.*)
133 *(.glue_7)
134 *(.glue_7t)
Tony Lindgren88d927e2010-10-26 19:52:21 +0100135 . = ALIGN(4);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136 *(.got) /* Global offset table */
Russell King5085f3f2010-10-01 15:37:05 +0100137 ARM_CPU_KEEP(PROC_INFO)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 }
Jin Honga2440b52011-07-19 12:43:26 -0700139#ifdef CONFIG_STRICT_MEMORY_RWX
140 . = ALIGN(1<<SECTION_SHIFT);
141#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142
Linus Walleijf6430a92009-06-24 23:38:56 +0100143 RO_DATA(PAGE_SIZE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144
Catalin Marinasbff595c2009-02-16 11:41:36 +0100145#ifdef CONFIG_ARM_UNWIND
146 /*
147 * Stack unwinding tables
148 */
149 . = ALIGN(8);
150 .ARM.unwind_idx : {
151 __start_unwind_idx = .;
152 *(.ARM.exidx*)
153 __stop_unwind_idx = .;
154 }
155 .ARM.unwind_tab : {
156 __start_unwind_tab = .;
157 *(.ARM.extab*)
158 __stop_unwind_tab = .;
159 }
160#endif
161
Russell King74b0ec02010-10-01 14:26:56 +0100162 _etext = .; /* End of text and rodata section */
163
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164#ifdef CONFIG_XIP_KERNEL
165 __data_loc = ALIGN(4); /* location in binary */
Russell King9d4f13e2006-01-03 17:28:33 +0000166 . = PAGE_OFFSET + TEXT_OFFSET;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167#else
Jin Honga2440b52011-07-19 12:43:26 -0700168#ifdef CONFIG_STRICT_MEMORY_RWX
169 . = ALIGN(1<<SECTION_SHIFT);
170#else
Russell King4f7a1812005-05-05 13:11:00 +0100171 . = ALIGN(THREAD_SIZE);
Jin Honga2440b52011-07-19 12:43:26 -0700172#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173 __data_loc = .;
174#endif
175
176 .data : AT(__data_loc) {
Russell King37efe642008-12-01 11:53:07 +0000177 _data = .; /* address in memory */
Catalin Marinas8c7e6572009-05-30 14:00:17 +0100178 _sdata = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179
180 /*
181 * first, the init task union, aligned
182 * to an 8192 byte boundary.
183 */
Nelson Elhage78d75302009-10-02 16:32:47 -0400184 INIT_TASK_DATA(THREAD_SIZE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185
186#ifdef CONFIG_XIP_KERNEL
Linus Walleijf6430a92009-06-24 23:38:56 +0100187 . = ALIGN(PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188 __init_begin = .;
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100189 INIT_DATA
Russell Kinga9ad21f2011-02-21 10:13:36 +0000190 ARM_EXIT_KEEP(EXIT_DATA)
Linus Walleijf6430a92009-06-24 23:38:56 +0100191 . = ALIGN(PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 __init_end = .;
193#endif
194
Nelson Elhage78d75302009-10-02 16:32:47 -0400195 NOSAVE_DATA
196 CACHELINE_ALIGNED_DATA(32)
Russell Kingdaf87412010-12-04 17:08:32 +0000197 READ_MOSTLY_DATA(32)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198
199 /*
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100200 * The exception fixup table (might need resorting at runtime)
201 */
202 . = ALIGN(32);
203 __start___ex_table = .;
Russell King9641c7c2006-06-21 20:38:17 +0100204#ifdef CONFIG_MMU
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100205 *(__ex_table)
Russell King9641c7c2006-06-21 20:38:17 +0100206#endif
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100207 __stop___ex_table = .;
208
209 /*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 * and the usual data section
211 */
Sam Ravnborgca967252007-05-17 13:38:44 +0200212 DATA_DATA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 CONSTRUCTORS
214
215 _edata = .;
216 }
Nicolas Pitree98ff7f2007-02-22 16:18:09 +0100217 _edata_loc = __data_loc + SIZEOF(.data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218
Linus Walleijbc581772009-09-15 17:30:37 +0100219#ifdef CONFIG_HAVE_TCM
220 /*
221 * We align everything to a page boundary so we can
222 * free it after init has commenced and TCM contents have
223 * been copied to its destination.
224 */
225 .tcm_start : {
226 . = ALIGN(PAGE_SIZE);
227 __tcm_start = .;
228 __itcm_start = .;
229 }
230
231 /*
232 * Link these to the ITCM RAM
233 * Put VMA to the TCM address and LMA to the common RAM
234 * and we'll upload the contents from RAM to TCM and free
235 * the used RAM after that.
236 */
237 .text_itcm ITCM_OFFSET : AT(__itcm_start)
238 {
239 __sitcm_text = .;
240 *(.tcm.text)
241 *(.tcm.rodata)
242 . = ALIGN(4);
243 __eitcm_text = .;
244 }
245
246 /*
247 * Reset the dot pointer, this is needed to create the
248 * relative __dtcm_start below (to be used as extern in code).
249 */
250 . = ADDR(.tcm_start) + SIZEOF(.tcm_start) + SIZEOF(.text_itcm);
251
252 .dtcm_start : {
253 __dtcm_start = .;
254 }
255
256 /* TODO: add remainder of ITCM as well, that can be used for data! */
257 .data_dtcm DTCM_OFFSET : AT(__dtcm_start)
258 {
259 . = ALIGN(4);
260 __sdtcm_data = .;
261 *(.tcm.data)
262 . = ALIGN(4);
263 __edtcm_data = .;
264 }
265
266 /* Reset the dot pointer or the linker gets confused */
267 . = ADDR(.dtcm_start) + SIZEOF(.data_dtcm);
268
269 /* End marker for freeing TCM copy in linked object */
270 .tcm_end : AT(ADDR(.dtcm_start) + SIZEOF(.data_dtcm)){
271 . = ALIGN(PAGE_SIZE);
272 __tcm_end = .;
273 }
274#endif
275
Pawel Molldc810ef2011-02-16 18:54:01 +0100276 NOTES
277
Nelson Elhage78d75302009-10-02 16:32:47 -0400278 BSS_SECTION(0, 0, 0)
279 _end = .;
280
281 STABS_DEBUG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282 .comment 0 : { *(.comment) }
Alan Jenkinse3f28c12009-11-07 21:03:52 +0000283
284 /* Default discards */
285 DISCARDS
Russell Kingf00ec482010-09-04 10:47:48 +0100286
287#ifndef CONFIG_SMP_ON_UP
288 /DISCARD/ : {
289 *(.alt.smp.init)
290 }
291#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292}
293
Russell King728f5c02005-11-17 16:43:14 +0000294/*
295 * These must never be empty
296 * If you have to comment these two assert statements out, your
297 * binutils is too old (for other reasons as well)
298 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")
300ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")