blob: 18574b7dbc14f2c8b6bbdfdeea5030fcb469cc13 [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 King39df8882011-05-26 11:25:33 +010041 /*
42 * unwind exit sections must be discarded before the rest of the
43 * unwind sections get included.
44 */
45 /DISCARD/ : {
46 *(.ARM.exidx.exit.text)
47 *(.ARM.extab.exit.text)
48 ARM_CPU_DISCARD(*(.ARM.exidx.cpuexit.text))
49 ARM_CPU_DISCARD(*(.ARM.extab.cpuexit.text))
50#ifndef CONFIG_HOTPLUG
51 *(.ARM.exidx.devexit.text)
52 *(.ARM.extab.devexit.text)
53#endif
54#ifndef CONFIG_MMU
55 *(.fixup)
56 *(__ex_table)
57#endif
58#ifndef CONFIG_SMP_ON_UP
59 *(.alt.smp.init)
60#endif
61 }
62
Russell King9d4f13e2006-01-03 17:28:33 +000063#ifdef CONFIG_XIP_KERNEL
64 . = XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR);
65#else
66 . = PAGE_OFFSET + TEXT_OFFSET;
67#endif
Russell King1604d792011-07-05 22:56:41 +010068 .head.text : {
Tim Abbott2abc1c52009-10-02 16:32:46 -040069 _stext = .;
Russell King1604d792011-07-05 22:56:41 +010070 HEAD_TEXT
71 }
Russell King3835d692011-07-06 10:39:34 +010072 .text : { /* Real text segment */
73 _text = .; /* Text and read-only data */
74 __exception_text_start = .;
75 *(.exception.text)
76 __exception_text_end = .;
77 IRQENTRY_TEXT
78 TEXT_TEXT
79 SCHED_TEXT
80 LOCK_TEXT
81 KPROBES_TEXT
82#ifdef CONFIG_MMU
83 *(.fixup)
84#endif
85 *(.gnu.warning)
86 *(.glue_7)
87 *(.glue_7t)
88 . = ALIGN(4);
89 *(.got) /* Global offset table */
90 ARM_CPU_KEEP(PROC_INFO)
91 }
92
93 RO_DATA(PAGE_SIZE)
94
95#ifdef CONFIG_ARM_UNWIND
96 /*
97 * Stack unwinding tables
98 */
99 . = ALIGN(8);
100 .ARM.unwind_idx : {
101 __start_unwind_idx = .;
102 *(.ARM.exidx*)
103 __stop_unwind_idx = .;
104 }
105 .ARM.unwind_tab : {
106 __start_unwind_tab = .;
107 *(.ARM.extab*)
108 __stop_unwind_tab = .;
109 }
110#endif
111
112 _etext = .; /* End of text and rodata section */
113
114#ifndef CONFIG_XIP_KERNEL
115 . = ALIGN(PAGE_SIZE);
116 __init_begin = .;
117#endif
118
Russell King1604d792011-07-05 22:56:41 +0100119 INIT_TEXT_SECTION(8)
120 .exit.text : {
121 ARM_EXIT_KEEP(EXIT_TEXT)
122 }
123 .init.proc.info : {
Russell King5085f3f2010-10-01 15:37:05 +0100124 ARM_CPU_DISCARD(PROC_INFO)
Russell King1604d792011-07-05 22:56:41 +0100125 }
126 .init.arch.info : {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 __arch_info_begin = .;
Russell King1604d792011-07-05 22:56:41 +0100128 *(.arch.info.init)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 __arch_info_end = .;
Russell King1604d792011-07-05 22:56:41 +0100130 }
131 .init.tagtable : {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132 __tagtable_begin = .;
Russell King1604d792011-07-05 22:56:41 +0100133 *(.taglist.init)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134 __tagtable_end = .;
Russell King1604d792011-07-05 22:56:41 +0100135 }
Russell Kingf00ec482010-09-04 10:47:48 +0100136#ifdef CONFIG_SMP_ON_UP
Russell King1604d792011-07-05 22:56:41 +0100137 .init.smpalt : {
Russell Kingf00ec482010-09-04 10:47:48 +0100138 __smpalt_begin = .;
Russell King1604d792011-07-05 22:56:41 +0100139 *(.alt.smp.init)
Russell Kingf00ec482010-09-04 10:47:48 +0100140 __smpalt_end = .;
Russell King1604d792011-07-05 22:56:41 +0100141 }
Russell Kingf00ec482010-09-04 10:47:48 +0100142#endif
Russell King1604d792011-07-05 22:56:41 +0100143 .init.pv_table : {
Russell Kingdc21af92011-01-04 19:09:43 +0000144 __pv_table_begin = .;
Russell King1604d792011-07-05 22:56:41 +0100145 *(.pv_table)
Russell Kingdc21af92011-01-04 19:09:43 +0000146 __pv_table_end = .;
Russell King1604d792011-07-05 22:56:41 +0100147 }
148 .init.data : {
149#ifndef CONFIG_XIP_KERNEL
150 INIT_DATA
151#endif
Nelson Elhage78d75302009-10-02 16:32:47 -0400152 INIT_SETUP(16)
Nelson Elhage78d75302009-10-02 16:32:47 -0400153 INIT_CALLS
154 CON_INITCALL
155 SECURITY_INITCALL
156 INIT_RAM_FS
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 }
Russell King1604d792011-07-05 22:56:41 +0100158#ifndef CONFIG_XIP_KERNEL
159 .exit.data : {
160 ARM_EXIT_KEEP(EXIT_DATA)
161 }
162#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163
Tejun Heo0415b00d12011-03-24 18:50:09 +0100164 PERCPU_SECTION(32)
Nelson Elhage78d75302009-10-02 16:32:47 -0400165
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166#ifdef CONFIG_XIP_KERNEL
167 __data_loc = ALIGN(4); /* location in binary */
Russell King9d4f13e2006-01-03 17:28:33 +0000168 . = PAGE_OFFSET + TEXT_OFFSET;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169#else
Russell King3835d692011-07-06 10:39:34 +0100170 __init_end = .;
Russell King4f7a1812005-05-05 13:11:00 +0100171 . = ALIGN(THREAD_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 __data_loc = .;
173#endif
174
175 .data : AT(__data_loc) {
Russell King37efe642008-12-01 11:53:07 +0000176 _data = .; /* address in memory */
Catalin Marinas8c7e6572009-05-30 14:00:17 +0100177 _sdata = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178
179 /*
180 * first, the init task union, aligned
181 * to an 8192 byte boundary.
182 */
Nelson Elhage78d75302009-10-02 16:32:47 -0400183 INIT_TASK_DATA(THREAD_SIZE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184
185#ifdef CONFIG_XIP_KERNEL
Linus Walleijf6430a92009-06-24 23:38:56 +0100186 . = ALIGN(PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187 __init_begin = .;
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100188 INIT_DATA
Russell Kinga9ad21f2011-02-21 10:13:36 +0000189 ARM_EXIT_KEEP(EXIT_DATA)
Linus Walleijf6430a92009-06-24 23:38:56 +0100190 . = ALIGN(PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 __init_end = .;
192#endif
193
Nelson Elhage78d75302009-10-02 16:32:47 -0400194 NOSAVE_DATA
195 CACHELINE_ALIGNED_DATA(32)
Russell Kingdaf87412010-12-04 17:08:32 +0000196 READ_MOSTLY_DATA(32)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197
198 /*
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100199 * The exception fixup table (might need resorting at runtime)
200 */
201 . = ALIGN(32);
202 __start___ex_table = .;
Russell King9641c7c2006-06-21 20:38:17 +0100203#ifdef CONFIG_MMU
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100204 *(__ex_table)
Russell King9641c7c2006-06-21 20:38:17 +0100205#endif
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100206 __stop___ex_table = .;
207
208 /*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209 * and the usual data section
210 */
Sam Ravnborgca967252007-05-17 13:38:44 +0200211 DATA_DATA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 CONSTRUCTORS
213
214 _edata = .;
215 }
Nicolas Pitree98ff7f2007-02-22 16:18:09 +0100216 _edata_loc = __data_loc + SIZEOF(.data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217
Linus Walleijbc581772009-09-15 17:30:37 +0100218#ifdef CONFIG_HAVE_TCM
219 /*
220 * We align everything to a page boundary so we can
221 * free it after init has commenced and TCM contents have
222 * been copied to its destination.
223 */
224 .tcm_start : {
225 . = ALIGN(PAGE_SIZE);
226 __tcm_start = .;
227 __itcm_start = .;
228 }
229
230 /*
231 * Link these to the ITCM RAM
232 * Put VMA to the TCM address and LMA to the common RAM
233 * and we'll upload the contents from RAM to TCM and free
234 * the used RAM after that.
235 */
236 .text_itcm ITCM_OFFSET : AT(__itcm_start)
237 {
238 __sitcm_text = .;
239 *(.tcm.text)
240 *(.tcm.rodata)
241 . = ALIGN(4);
242 __eitcm_text = .;
243 }
244
245 /*
246 * Reset the dot pointer, this is needed to create the
247 * relative __dtcm_start below (to be used as extern in code).
248 */
249 . = ADDR(.tcm_start) + SIZEOF(.tcm_start) + SIZEOF(.text_itcm);
250
251 .dtcm_start : {
252 __dtcm_start = .;
253 }
254
255 /* TODO: add remainder of ITCM as well, that can be used for data! */
256 .data_dtcm DTCM_OFFSET : AT(__dtcm_start)
257 {
258 . = ALIGN(4);
259 __sdtcm_data = .;
260 *(.tcm.data)
261 . = ALIGN(4);
262 __edtcm_data = .;
263 }
264
265 /* Reset the dot pointer or the linker gets confused */
266 . = ADDR(.dtcm_start) + SIZEOF(.data_dtcm);
267
268 /* End marker for freeing TCM copy in linked object */
269 .tcm_end : AT(ADDR(.dtcm_start) + SIZEOF(.data_dtcm)){
270 . = ALIGN(PAGE_SIZE);
271 __tcm_end = .;
272 }
273#endif
274
Pawel Molldc810ef2011-02-16 18:54:01 +0100275 NOTES
276
Nelson Elhage78d75302009-10-02 16:32:47 -0400277 BSS_SECTION(0, 0, 0)
278 _end = .;
279
280 STABS_DEBUG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281 .comment 0 : { *(.comment) }
Alan Jenkinse3f28c12009-11-07 21:03:52 +0000282
283 /* Default discards */
284 DISCARDS
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285}
286
Russell King728f5c02005-11-17 16:43:14 +0000287/*
288 * These must never be empty
289 * If you have to comment these two assert statements out, your
290 * binutils is too old (for other reasons as well)
291 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")
293ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")