blob: 0902f806cd37ba3929c9d32b513df260cd7f103d [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
11OUTPUT_ARCH(arm)
12ENTRY(stext)
Nicolas Pitre37d07b72005-10-29 21:44:56 +010013
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#ifndef __ARMEB__
15jiffies = jiffies_64;
16#else
17jiffies = jiffies_64 + 4;
18#endif
Nicolas Pitre37d07b72005-10-29 21:44:56 +010019
Linus Torvalds1da177e2005-04-16 15:20:36 -070020SECTIONS
21{
Russell King9d4f13e2006-01-03 17:28:33 +000022#ifdef CONFIG_XIP_KERNEL
23 . = XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR);
24#else
25 . = PAGE_OFFSET + TEXT_OFFSET;
26#endif
Russell King08fdffd2007-05-08 15:15:45 +010027
28 .init : { /* Init code and data */
Tim Abbott2abc1c52009-10-02 16:32:46 -040029 _stext = .;
30 _sinittext = .;
31 HEAD_TEXT
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +010032 INIT_TEXT
Russell King08fdffd2007-05-08 15:15:45 +010033 _einittext = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -070034 __proc_info_begin = .;
Ben Dooks02b7dd12005-09-20 16:35:03 +010035 *(.proc.info.init)
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 __proc_info_end = .;
37 __arch_info_begin = .;
Ben Dooks9d0fd1e2005-09-20 16:45:20 +010038 *(.arch.info.init)
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 __arch_info_end = .;
40 __tagtable_begin = .;
Ben Dooks95060572005-09-20 16:20:49 +010041 *(.taglist.init)
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 __tagtable_end = .;
43 . = ALIGN(16);
44 __setup_start = .;
45 *(.init.setup)
46 __setup_end = .;
47 __early_begin = .;
Ben Dooksbfe68152005-09-20 16:25:12 +010048 *(.early_param.init)
Linus Torvalds1da177e2005-04-16 15:20:36 -070049 __early_end = .;
50 __initcall_start = .;
Andrew Morton61ce1ef2006-10-27 11:41:44 -070051 INITCALLS
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 __initcall_end = .;
53 __con_initcall_start = .;
54 *(.con_initcall.init)
55 __con_initcall_end = .;
56 __security_initcall_start = .;
57 *(.security_initcall.init)
58 __security_initcall_end = .;
Jean-Paul Saman67d38222007-02-10 01:44:44 -080059#ifdef CONFIG_BLK_DEV_INITRD
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 . = ALIGN(32);
61 __initramfs_start = .;
62 usr/built-in.o(.init.ramfs)
63 __initramfs_end = .;
Jean-Paul Saman67d38222007-02-10 01:44:44 -080064#endif
Linus Walleijf6430a92009-06-24 23:38:56 +010065 . = ALIGN(PAGE_SIZE);
Tejun Heo19390c42009-03-10 16:27:48 +090066 __per_cpu_load = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 __per_cpu_start = .;
Tejun Heo74e79042009-01-17 15:26:32 +090068 *(.data.percpu.page_aligned)
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 *(.data.percpu)
Fenghua Yu5fb7dc32007-07-19 01:48:12 -070070 *(.data.percpu.shared_aligned)
Linus Torvalds1da177e2005-04-16 15:20:36 -070071 __per_cpu_end = .;
72#ifndef CONFIG_XIP_KERNEL
73 __init_begin = _stext;
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +010074 INIT_DATA
Linus Walleijf6430a92009-06-24 23:38:56 +010075 . = ALIGN(PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 __init_end = .;
77#endif
78 }
79
80 /DISCARD/ : { /* Exit code and data */
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +010081 EXIT_TEXT
82 EXIT_DATA
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 *(.exitcall.exit)
Tejun Heo405d9672009-06-24 15:13:38 +090084 *(.discard)
Catalin Marinasbff595c2009-02-16 11:41:36 +010085 *(.ARM.exidx.exit.text)
86 *(.ARM.extab.exit.text)
Catalin Marinas74361272009-06-19 16:39:29 +010087#ifndef CONFIG_HOTPLUG_CPU
88 *(.ARM.exidx.cpuexit.text)
89 *(.ARM.extab.cpuexit.text)
90#endif
91#ifndef CONFIG_HOTPLUG
92 *(.ARM.exidx.devexit.text)
93 *(.ARM.extab.devexit.text)
94#endif
Russell King9641c7c2006-06-21 20:38:17 +010095#ifndef CONFIG_MMU
96 *(.fixup)
97 *(__ex_table)
98#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 }
100
101 .text : { /* Real text segment */
102 _text = .; /* Text and read-only data */
Russell King7ab3f8d2007-03-02 15:01:36 +0000103 __exception_text_start = .;
104 *(.exception.text)
105 __exception_text_end = .;
Sam Ravnborg76647092007-05-13 00:31:33 +0200106 TEXT_TEXT
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107 SCHED_TEXT
108 LOCK_TEXT
Nicolas Pitre785d3cd2007-12-03 15:27:56 -0500109 KPROBES_TEXT
Russell King9641c7c2006-06-21 20:38:17 +0100110#ifdef CONFIG_MMU
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111 *(.fixup)
Russell King9641c7c2006-06-21 20:38:17 +0100112#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113 *(.gnu.warning)
114 *(.rodata)
115 *(.rodata.*)
116 *(.glue_7)
117 *(.glue_7t)
118 *(.got) /* Global offset table */
119 }
120
Linus Walleijf6430a92009-06-24 23:38:56 +0100121 RO_DATA(PAGE_SIZE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122
123 _etext = .; /* End of text and rodata section */
124
Catalin Marinasbff595c2009-02-16 11:41:36 +0100125#ifdef CONFIG_ARM_UNWIND
126 /*
127 * Stack unwinding tables
128 */
129 . = ALIGN(8);
130 .ARM.unwind_idx : {
131 __start_unwind_idx = .;
132 *(.ARM.exidx*)
133 __stop_unwind_idx = .;
134 }
135 .ARM.unwind_tab : {
136 __start_unwind_tab = .;
137 *(.ARM.extab*)
138 __stop_unwind_tab = .;
139 }
140#endif
141
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142#ifdef CONFIG_XIP_KERNEL
143 __data_loc = ALIGN(4); /* location in binary */
Russell King9d4f13e2006-01-03 17:28:33 +0000144 . = PAGE_OFFSET + TEXT_OFFSET;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145#else
Russell King4f7a1812005-05-05 13:11:00 +0100146 . = ALIGN(THREAD_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 __data_loc = .;
148#endif
149
150 .data : AT(__data_loc) {
Russell King37efe642008-12-01 11:53:07 +0000151 _data = .; /* address in memory */
Catalin Marinas8c7e6572009-05-30 14:00:17 +0100152 _sdata = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153
154 /*
155 * first, the init task union, aligned
156 * to an 8192 byte boundary.
157 */
Russell King4efb4482007-05-08 12:39:37 +0100158 *(.data.init_task)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159
160#ifdef CONFIG_XIP_KERNEL
Linus Walleijf6430a92009-06-24 23:38:56 +0100161 . = ALIGN(PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162 __init_begin = .;
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100163 INIT_DATA
Linus Walleijf6430a92009-06-24 23:38:56 +0100164 . = ALIGN(PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165 __init_end = .;
166#endif
167
Linus Walleijf6430a92009-06-24 23:38:56 +0100168 . = ALIGN(PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169 __nosave_begin = .;
170 *(.data.nosave)
Linus Walleijf6430a92009-06-24 23:38:56 +0100171 . = ALIGN(PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 __nosave_end = .;
173
174 /*
175 * then the cacheline aligned data
176 */
177 . = ALIGN(32);
178 *(.data.cacheline_aligned)
179
180 /*
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100181 * The exception fixup table (might need resorting at runtime)
182 */
183 . = ALIGN(32);
184 __start___ex_table = .;
Russell King9641c7c2006-06-21 20:38:17 +0100185#ifdef CONFIG_MMU
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100186 *(__ex_table)
Russell King9641c7c2006-06-21 20:38:17 +0100187#endif
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100188 __stop___ex_table = .;
189
190 /*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 * and the usual data section
192 */
Sam Ravnborgca967252007-05-17 13:38:44 +0200193 DATA_DATA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194 CONSTRUCTORS
195
196 _edata = .;
197 }
Nicolas Pitree98ff7f2007-02-22 16:18:09 +0100198 _edata_loc = __data_loc + SIZEOF(.data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199
Linus Walleijbc581772009-09-15 17:30:37 +0100200#ifdef CONFIG_HAVE_TCM
201 /*
202 * We align everything to a page boundary so we can
203 * free it after init has commenced and TCM contents have
204 * been copied to its destination.
205 */
206 .tcm_start : {
207 . = ALIGN(PAGE_SIZE);
208 __tcm_start = .;
209 __itcm_start = .;
210 }
211
212 /*
213 * Link these to the ITCM RAM
214 * Put VMA to the TCM address and LMA to the common RAM
215 * and we'll upload the contents from RAM to TCM and free
216 * the used RAM after that.
217 */
218 .text_itcm ITCM_OFFSET : AT(__itcm_start)
219 {
220 __sitcm_text = .;
221 *(.tcm.text)
222 *(.tcm.rodata)
223 . = ALIGN(4);
224 __eitcm_text = .;
225 }
226
227 /*
228 * Reset the dot pointer, this is needed to create the
229 * relative __dtcm_start below (to be used as extern in code).
230 */
231 . = ADDR(.tcm_start) + SIZEOF(.tcm_start) + SIZEOF(.text_itcm);
232
233 .dtcm_start : {
234 __dtcm_start = .;
235 }
236
237 /* TODO: add remainder of ITCM as well, that can be used for data! */
238 .data_dtcm DTCM_OFFSET : AT(__dtcm_start)
239 {
240 . = ALIGN(4);
241 __sdtcm_data = .;
242 *(.tcm.data)
243 . = ALIGN(4);
244 __edtcm_data = .;
245 }
246
247 /* Reset the dot pointer or the linker gets confused */
248 . = ADDR(.dtcm_start) + SIZEOF(.data_dtcm);
249
250 /* End marker for freeing TCM copy in linked object */
251 .tcm_end : AT(ADDR(.dtcm_start) + SIZEOF(.data_dtcm)){
252 . = ALIGN(PAGE_SIZE);
253 __tcm_end = .;
254 }
255#endif
256
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257 .bss : {
258 __bss_start = .; /* BSS */
259 *(.bss)
260 *(COMMON)
Catalin Marinas8c7e6572009-05-30 14:00:17 +0100261 __bss_stop = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262 _end = .;
263 }
264 /* Stabs debugging sections. */
265 .stab 0 : { *(.stab) }
266 .stabstr 0 : { *(.stabstr) }
267 .stab.excl 0 : { *(.stab.excl) }
268 .stab.exclstr 0 : { *(.stab.exclstr) }
269 .stab.index 0 : { *(.stab.index) }
270 .stab.indexstr 0 : { *(.stab.indexstr) }
271 .comment 0 : { *(.comment) }
272}
273
Russell King728f5c02005-11-17 16:43:14 +0000274/*
275 * These must never be empty
276 * If you have to comment these two assert statements out, your
277 * binutils is too old (for other reasons as well)
278 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")
280ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")