blob: e5287f21badc7e87c3c2e7a2d8953d5fb270ec86 [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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010
Russell King5085f3f2010-10-01 15:37:05 +010011#define PROC_INFO \
12 VMLINUX_SYMBOL(__proc_info_begin) = .; \
13 *(.proc.info.init) \
14 VMLINUX_SYMBOL(__proc_info_end) = .;
15
16#ifdef CONFIG_HOTPLUG_CPU
17#define ARM_CPU_DISCARD(x)
18#define ARM_CPU_KEEP(x) x
19#else
20#define ARM_CPU_DISCARD(x) x
21#define ARM_CPU_KEEP(x)
22#endif
23
Russell Kinga9ad21f2011-02-21 10:13:36 +000024#if defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)
25#define ARM_EXIT_KEEP(x) x
26#else
27#define ARM_EXIT_KEEP(x)
28#endif
29
Linus Torvalds1da177e2005-04-16 15:20:36 -070030OUTPUT_ARCH(arm)
31ENTRY(stext)
Nicolas Pitre37d07b72005-10-29 21:44:56 +010032
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#ifndef __ARMEB__
34jiffies = jiffies_64;
35#else
36jiffies = jiffies_64 + 4;
37#endif
Nicolas Pitre37d07b72005-10-29 21:44:56 +010038
Linus Torvalds1da177e2005-04-16 15:20:36 -070039SECTIONS
40{
Russell King9d4f13e2006-01-03 17:28:33 +000041#ifdef CONFIG_XIP_KERNEL
42 . = XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR);
43#else
44 . = PAGE_OFFSET + TEXT_OFFSET;
45#endif
Russell King08fdffd2007-05-08 15:15:45 +010046
47 .init : { /* Init code and data */
Tim Abbott2abc1c52009-10-02 16:32:46 -040048 _stext = .;
49 _sinittext = .;
50 HEAD_TEXT
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +010051 INIT_TEXT
Russell Kinga9ad21f2011-02-21 10:13:36 +000052 ARM_EXIT_KEEP(EXIT_TEXT)
Russell King08fdffd2007-05-08 15:15:45 +010053 _einittext = .;
Russell King5085f3f2010-10-01 15:37:05 +010054 ARM_CPU_DISCARD(PROC_INFO)
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 __arch_info_begin = .;
Ben Dooks9d0fd1e2005-09-20 16:45:20 +010056 *(.arch.info.init)
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 __arch_info_end = .;
58 __tagtable_begin = .;
Ben Dooks95060572005-09-20 16:20:49 +010059 *(.taglist.init)
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 __tagtable_end = .;
Russell Kingf00ec482010-09-04 10:47:48 +010061#ifdef CONFIG_SMP_ON_UP
62 __smpalt_begin = .;
63 *(.alt.smp.init)
64 __smpalt_end = .;
65#endif
Nelson Elhage78d75302009-10-02 16:32:47 -040066
Russell Kingdc21af92011-01-04 19:09:43 +000067 __pv_table_begin = .;
68 *(.pv_table)
69 __pv_table_end = .;
70
Nelson Elhage78d75302009-10-02 16:32:47 -040071 INIT_SETUP(16)
72
Nelson Elhage78d75302009-10-02 16:32:47 -040073 INIT_CALLS
74 CON_INITCALL
75 SECURITY_INITCALL
76 INIT_RAM_FS
77
Linus Torvalds1da177e2005-04-16 15:20:36 -070078#ifndef CONFIG_XIP_KERNEL
79 __init_begin = _stext;
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +010080 INIT_DATA
Russell Kinga9ad21f2011-02-21 10:13:36 +000081 ARM_EXIT_KEEP(EXIT_DATA)
Linus Torvalds1da177e2005-04-16 15:20:36 -070082#endif
83 }
84
Tejun Heo0415b00d12011-03-24 18:50:09 +010085 PERCPU_SECTION(32)
Nelson Elhage78d75302009-10-02 16:32:47 -040086
87#ifndef CONFIG_XIP_KERNEL
88 . = ALIGN(PAGE_SIZE);
89 __init_end = .;
90#endif
91
Alan Jenkinse3f28c12009-11-07 21:03:52 +000092 /*
93 * unwind exit sections must be discarded before the rest of the
94 * unwind sections get included.
95 */
96 /DISCARD/ : {
Catalin Marinasbff595c2009-02-16 11:41:36 +010097 *(.ARM.exidx.exit.text)
98 *(.ARM.extab.exit.text)
Russell King5085f3f2010-10-01 15:37:05 +010099 ARM_CPU_DISCARD(*(.ARM.exidx.cpuexit.text))
100 ARM_CPU_DISCARD(*(.ARM.extab.cpuexit.text))
Catalin Marinas74361272009-06-19 16:39:29 +0100101#ifndef CONFIG_HOTPLUG
102 *(.ARM.exidx.devexit.text)
103 *(.ARM.extab.devexit.text)
104#endif
Russell King9641c7c2006-06-21 20:38:17 +0100105#ifndef CONFIG_MMU
106 *(.fixup)
107 *(__ex_table)
108#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 }
110
111 .text : { /* Real text segment */
112 _text = .; /* Text and read-only data */
Russell King7ab3f8d2007-03-02 15:01:36 +0000113 __exception_text_start = .;
114 *(.exception.text)
115 __exception_text_end = .;
Rabin Vincent61b5cb12010-10-07 20:51:58 +0530116 IRQENTRY_TEXT
Sam Ravnborg76647092007-05-13 00:31:33 +0200117 TEXT_TEXT
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118 SCHED_TEXT
119 LOCK_TEXT
Nicolas Pitre785d3cd2007-12-03 15:27:56 -0500120 KPROBES_TEXT
Russell King9641c7c2006-06-21 20:38:17 +0100121#ifdef CONFIG_MMU
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122 *(.fixup)
Russell King9641c7c2006-06-21 20:38:17 +0100123#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124 *(.gnu.warning)
125 *(.rodata)
126 *(.rodata.*)
127 *(.glue_7)
128 *(.glue_7t)
Tony Lindgren88d927e2010-10-26 19:52:21 +0100129 . = ALIGN(4);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 *(.got) /* Global offset table */
Russell King5085f3f2010-10-01 15:37:05 +0100131 ARM_CPU_KEEP(PROC_INFO)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132 }
133
Linus Walleijf6430a92009-06-24 23:38:56 +0100134 RO_DATA(PAGE_SIZE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135
Catalin Marinasbff595c2009-02-16 11:41:36 +0100136#ifdef CONFIG_ARM_UNWIND
137 /*
138 * Stack unwinding tables
139 */
140 . = ALIGN(8);
141 .ARM.unwind_idx : {
142 __start_unwind_idx = .;
143 *(.ARM.exidx*)
144 __stop_unwind_idx = .;
145 }
146 .ARM.unwind_tab : {
147 __start_unwind_tab = .;
148 *(.ARM.extab*)
149 __stop_unwind_tab = .;
150 }
151#endif
152
Russell King74b0ec02010-10-01 14:26:56 +0100153 _etext = .; /* End of text and rodata section */
154
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155#ifdef CONFIG_XIP_KERNEL
156 __data_loc = ALIGN(4); /* location in binary */
Russell King9d4f13e2006-01-03 17:28:33 +0000157 . = PAGE_OFFSET + TEXT_OFFSET;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158#else
Russell King4f7a1812005-05-05 13:11:00 +0100159 . = ALIGN(THREAD_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 __data_loc = .;
161#endif
162
163 .data : AT(__data_loc) {
Russell King37efe642008-12-01 11:53:07 +0000164 _data = .; /* address in memory */
Catalin Marinas8c7e6572009-05-30 14:00:17 +0100165 _sdata = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166
167 /*
168 * first, the init task union, aligned
169 * to an 8192 byte boundary.
170 */
Nelson Elhage78d75302009-10-02 16:32:47 -0400171 INIT_TASK_DATA(THREAD_SIZE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172
173#ifdef CONFIG_XIP_KERNEL
Linus Walleijf6430a92009-06-24 23:38:56 +0100174 . = ALIGN(PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175 __init_begin = .;
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100176 INIT_DATA
Russell Kinga9ad21f2011-02-21 10:13:36 +0000177 ARM_EXIT_KEEP(EXIT_DATA)
Linus Walleijf6430a92009-06-24 23:38:56 +0100178 . = ALIGN(PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 __init_end = .;
180#endif
181
Nelson Elhage78d75302009-10-02 16:32:47 -0400182 NOSAVE_DATA
183 CACHELINE_ALIGNED_DATA(32)
Russell Kingdaf87412010-12-04 17:08:32 +0000184 READ_MOSTLY_DATA(32)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185
186 /*
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100187 * The exception fixup table (might need resorting at runtime)
188 */
189 . = ALIGN(32);
190 __start___ex_table = .;
Russell King9641c7c2006-06-21 20:38:17 +0100191#ifdef CONFIG_MMU
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100192 *(__ex_table)
Russell King9641c7c2006-06-21 20:38:17 +0100193#endif
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100194 __stop___ex_table = .;
195
196 /*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 * and the usual data section
198 */
Sam Ravnborgca967252007-05-17 13:38:44 +0200199 DATA_DATA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200 CONSTRUCTORS
201
202 _edata = .;
203 }
Nicolas Pitree98ff7f2007-02-22 16:18:09 +0100204 _edata_loc = __data_loc + SIZEOF(.data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205
Linus Walleijbc581772009-09-15 17:30:37 +0100206#ifdef CONFIG_HAVE_TCM
207 /*
208 * We align everything to a page boundary so we can
209 * free it after init has commenced and TCM contents have
210 * been copied to its destination.
211 */
212 .tcm_start : {
213 . = ALIGN(PAGE_SIZE);
214 __tcm_start = .;
215 __itcm_start = .;
216 }
217
218 /*
219 * Link these to the ITCM RAM
220 * Put VMA to the TCM address and LMA to the common RAM
221 * and we'll upload the contents from RAM to TCM and free
222 * the used RAM after that.
223 */
224 .text_itcm ITCM_OFFSET : AT(__itcm_start)
225 {
226 __sitcm_text = .;
227 *(.tcm.text)
228 *(.tcm.rodata)
229 . = ALIGN(4);
230 __eitcm_text = .;
231 }
232
233 /*
234 * Reset the dot pointer, this is needed to create the
235 * relative __dtcm_start below (to be used as extern in code).
236 */
237 . = ADDR(.tcm_start) + SIZEOF(.tcm_start) + SIZEOF(.text_itcm);
238
239 .dtcm_start : {
240 __dtcm_start = .;
241 }
242
243 /* TODO: add remainder of ITCM as well, that can be used for data! */
244 .data_dtcm DTCM_OFFSET : AT(__dtcm_start)
245 {
246 . = ALIGN(4);
247 __sdtcm_data = .;
248 *(.tcm.data)
249 . = ALIGN(4);
250 __edtcm_data = .;
251 }
252
253 /* Reset the dot pointer or the linker gets confused */
254 . = ADDR(.dtcm_start) + SIZEOF(.data_dtcm);
255
256 /* End marker for freeing TCM copy in linked object */
257 .tcm_end : AT(ADDR(.dtcm_start) + SIZEOF(.data_dtcm)){
258 . = ALIGN(PAGE_SIZE);
259 __tcm_end = .;
260 }
261#endif
262
Pawel Molldc810ef2011-02-16 18:54:01 +0100263 NOTES
264
Nelson Elhage78d75302009-10-02 16:32:47 -0400265 BSS_SECTION(0, 0, 0)
266 _end = .;
267
268 STABS_DEBUG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269 .comment 0 : { *(.comment) }
Alan Jenkinse3f28c12009-11-07 21:03:52 +0000270
271 /* Default discards */
272 DISCARDS
Russell Kingf00ec482010-09-04 10:47:48 +0100273
274#ifndef CONFIG_SMP_ON_UP
275 /DISCARD/ : {
276 *(.alt.smp.init)
277 }
278#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279}
280
Russell King728f5c02005-11-17 16:43:14 +0000281/*
282 * These must never be empty
283 * If you have to comment these two assert statements out, your
284 * binutils is too old (for other reasons as well)
285 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")
287ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")