blob: cb46a9bad4f5d8acb00127b57824670ca53e7c5f [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 King08fdffd2007-05-08 15:15:45 +010068
69 .init : { /* Init code and data */
Tim Abbott2abc1c52009-10-02 16:32:46 -040070 _stext = .;
71 _sinittext = .;
72 HEAD_TEXT
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +010073 INIT_TEXT
Russell Kinga9ad21f2011-02-21 10:13:36 +000074 ARM_EXIT_KEEP(EXIT_TEXT)
Russell King08fdffd2007-05-08 15:15:45 +010075 _einittext = .;
Russell King5085f3f2010-10-01 15:37:05 +010076 ARM_CPU_DISCARD(PROC_INFO)
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 __arch_info_begin = .;
Ben Dooks9d0fd1e2005-09-20 16:45:20 +010078 *(.arch.info.init)
Linus Torvalds1da177e2005-04-16 15:20:36 -070079 __arch_info_end = .;
80 __tagtable_begin = .;
Ben Dooks95060572005-09-20 16:20:49 +010081 *(.taglist.init)
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 __tagtable_end = .;
Russell Kingf00ec482010-09-04 10:47:48 +010083#ifdef CONFIG_SMP_ON_UP
84 __smpalt_begin = .;
85 *(.alt.smp.init)
86 __smpalt_end = .;
87#endif
Nelson Elhage78d75302009-10-02 16:32:47 -040088
Russell Kingdc21af92011-01-04 19:09:43 +000089 __pv_table_begin = .;
90 *(.pv_table)
91 __pv_table_end = .;
92
Nelson Elhage78d75302009-10-02 16:32:47 -040093 INIT_SETUP(16)
94
Nelson Elhage78d75302009-10-02 16:32:47 -040095 INIT_CALLS
96 CON_INITCALL
97 SECURITY_INITCALL
98 INIT_RAM_FS
99
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100#ifndef CONFIG_XIP_KERNEL
101 __init_begin = _stext;
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100102 INIT_DATA
Russell Kinga9ad21f2011-02-21 10:13:36 +0000103 ARM_EXIT_KEEP(EXIT_DATA)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104#endif
105 }
106
Tejun Heo0415b002011-03-24 18:50:09 +0100107 PERCPU_SECTION(32)
Nelson Elhage78d75302009-10-02 16:32:47 -0400108
109#ifndef CONFIG_XIP_KERNEL
110 . = ALIGN(PAGE_SIZE);
111 __init_end = .;
112#endif
113
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114 .text : { /* Real text segment */
115 _text = .; /* Text and read-only data */
Russell King7ab3f8d2007-03-02 15:01:36 +0000116 __exception_text_start = .;
117 *(.exception.text)
118 __exception_text_end = .;
Rabin Vincent61b5cb12010-10-07 20:51:58 +0530119 IRQENTRY_TEXT
Sam Ravnborg76647092007-05-13 00:31:33 +0200120 TEXT_TEXT
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121 SCHED_TEXT
122 LOCK_TEXT
Nicolas Pitre785d3cd2007-12-03 15:27:56 -0500123 KPROBES_TEXT
Russell King9641c7c2006-06-21 20:38:17 +0100124#ifdef CONFIG_MMU
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 *(.fixup)
Russell King9641c7c2006-06-21 20:38:17 +0100126#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 *(.gnu.warning)
128 *(.rodata)
129 *(.rodata.*)
130 *(.glue_7)
131 *(.glue_7t)
Tony Lindgren88d927e2010-10-26 19:52:21 +0100132 . = ALIGN(4);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133 *(.got) /* Global offset table */
Russell King5085f3f2010-10-01 15:37:05 +0100134 ARM_CPU_KEEP(PROC_INFO)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 }
136
Linus Walleijf6430a92009-06-24 23:38:56 +0100137 RO_DATA(PAGE_SIZE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138
Catalin Marinasbff595c2009-02-16 11:41:36 +0100139#ifdef CONFIG_ARM_UNWIND
140 /*
141 * Stack unwinding tables
142 */
143 . = ALIGN(8);
144 .ARM.unwind_idx : {
145 __start_unwind_idx = .;
146 *(.ARM.exidx*)
147 __stop_unwind_idx = .;
148 }
149 .ARM.unwind_tab : {
150 __start_unwind_tab = .;
151 *(.ARM.extab*)
152 __stop_unwind_tab = .;
153 }
154#endif
155
Russell King74b0ec02010-10-01 14:26:56 +0100156 _etext = .; /* End of text and rodata section */
157
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158#ifdef CONFIG_XIP_KERNEL
159 __data_loc = ALIGN(4); /* location in binary */
Russell King9d4f13e2006-01-03 17:28:33 +0000160 . = PAGE_OFFSET + TEXT_OFFSET;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161#else
Russell King4f7a1812005-05-05 13:11:00 +0100162 . = ALIGN(THREAD_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163 __data_loc = .;
164#endif
165
166 .data : AT(__data_loc) {
Russell King37efe642008-12-01 11:53:07 +0000167 _data = .; /* address in memory */
Catalin Marinas8c7e6572009-05-30 14:00:17 +0100168 _sdata = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169
170 /*
171 * first, the init task union, aligned
172 * to an 8192 byte boundary.
173 */
Nelson Elhage78d75302009-10-02 16:32:47 -0400174 INIT_TASK_DATA(THREAD_SIZE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175
176#ifdef CONFIG_XIP_KERNEL
Linus Walleijf6430a92009-06-24 23:38:56 +0100177 . = ALIGN(PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178 __init_begin = .;
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100179 INIT_DATA
Russell Kinga9ad21f2011-02-21 10:13:36 +0000180 ARM_EXIT_KEEP(EXIT_DATA)
Linus Walleijf6430a92009-06-24 23:38:56 +0100181 . = ALIGN(PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182 __init_end = .;
183#endif
184
Nelson Elhage78d75302009-10-02 16:32:47 -0400185 NOSAVE_DATA
186 CACHELINE_ALIGNED_DATA(32)
Russell Kingdaf87412010-12-04 17:08:32 +0000187 READ_MOSTLY_DATA(32)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188
189 /*
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100190 * The exception fixup table (might need resorting at runtime)
191 */
192 . = ALIGN(32);
193 __start___ex_table = .;
Russell King9641c7c2006-06-21 20:38:17 +0100194#ifdef CONFIG_MMU
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100195 *(__ex_table)
Russell King9641c7c2006-06-21 20:38:17 +0100196#endif
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100197 __stop___ex_table = .;
198
199 /*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200 * and the usual data section
201 */
Sam Ravnborgca967252007-05-17 13:38:44 +0200202 DATA_DATA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203 CONSTRUCTORS
204
205 _edata = .;
206 }
Nicolas Pitree98ff7f2007-02-22 16:18:09 +0100207 _edata_loc = __data_loc + SIZEOF(.data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208
Linus Walleijbc581772009-09-15 17:30:37 +0100209#ifdef CONFIG_HAVE_TCM
210 /*
211 * We align everything to a page boundary so we can
212 * free it after init has commenced and TCM contents have
213 * been copied to its destination.
214 */
215 .tcm_start : {
216 . = ALIGN(PAGE_SIZE);
217 __tcm_start = .;
218 __itcm_start = .;
219 }
220
221 /*
222 * Link these to the ITCM RAM
223 * Put VMA to the TCM address and LMA to the common RAM
224 * and we'll upload the contents from RAM to TCM and free
225 * the used RAM after that.
226 */
227 .text_itcm ITCM_OFFSET : AT(__itcm_start)
228 {
229 __sitcm_text = .;
230 *(.tcm.text)
231 *(.tcm.rodata)
232 . = ALIGN(4);
233 __eitcm_text = .;
234 }
235
236 /*
237 * Reset the dot pointer, this is needed to create the
238 * relative __dtcm_start below (to be used as extern in code).
239 */
240 . = ADDR(.tcm_start) + SIZEOF(.tcm_start) + SIZEOF(.text_itcm);
241
242 .dtcm_start : {
243 __dtcm_start = .;
244 }
245
246 /* TODO: add remainder of ITCM as well, that can be used for data! */
247 .data_dtcm DTCM_OFFSET : AT(__dtcm_start)
248 {
249 . = ALIGN(4);
250 __sdtcm_data = .;
251 *(.tcm.data)
252 . = ALIGN(4);
253 __edtcm_data = .;
254 }
255
256 /* Reset the dot pointer or the linker gets confused */
257 . = ADDR(.dtcm_start) + SIZEOF(.data_dtcm);
258
259 /* End marker for freeing TCM copy in linked object */
260 .tcm_end : AT(ADDR(.dtcm_start) + SIZEOF(.data_dtcm)){
261 . = ALIGN(PAGE_SIZE);
262 __tcm_end = .;
263 }
264#endif
265
Pawel Molldc810ef2011-02-16 18:54:01 +0100266 NOTES
267
Nelson Elhage78d75302009-10-02 16:32:47 -0400268 BSS_SECTION(0, 0, 0)
269 _end = .;
270
271 STABS_DEBUG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272 .comment 0 : { *(.comment) }
Alan Jenkinse3f28c12009-11-07 21:03:52 +0000273
274 /* Default discards */
275 DISCARDS
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276}
277
Russell King728f5c02005-11-17 16:43:14 +0000278/*
279 * These must never be empty
280 * If you have to comment these two assert statements out, your
281 * binutils is too old (for other reasons as well)
282 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")
284ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")