blob: cead8893b46bc2d91ac156b9c8382c8aa4ebc71f [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
Linus Torvalds1da177e2005-04-16 15:20:36 -070024OUTPUT_ARCH(arm)
25ENTRY(stext)
Nicolas Pitre37d07b72005-10-29 21:44:56 +010026
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#ifndef __ARMEB__
28jiffies = jiffies_64;
29#else
30jiffies = jiffies_64 + 4;
31#endif
Nicolas Pitre37d07b72005-10-29 21:44:56 +010032
Linus Torvalds1da177e2005-04-16 15:20:36 -070033SECTIONS
34{
Russell King9d4f13e2006-01-03 17:28:33 +000035#ifdef CONFIG_XIP_KERNEL
36 . = XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR);
37#else
38 . = PAGE_OFFSET + TEXT_OFFSET;
39#endif
Russell King08fdffd2007-05-08 15:15:45 +010040
41 .init : { /* Init code and data */
Tim Abbott2abc1c52009-10-02 16:32:46 -040042 _stext = .;
43 _sinittext = .;
44 HEAD_TEXT
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +010045 INIT_TEXT
Russell King08fdffd2007-05-08 15:15:45 +010046 _einittext = .;
Russell King5085f3f2010-10-01 15:37:05 +010047 ARM_CPU_DISCARD(PROC_INFO)
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 __arch_info_begin = .;
Ben Dooks9d0fd1e2005-09-20 16:45:20 +010049 *(.arch.info.init)
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 __arch_info_end = .;
51 __tagtable_begin = .;
Ben Dooks95060572005-09-20 16:20:49 +010052 *(.taglist.init)
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 __tagtable_end = .;
Russell Kingf00ec482010-09-04 10:47:48 +010054#ifdef CONFIG_SMP_ON_UP
55 __smpalt_begin = .;
56 *(.alt.smp.init)
57 __smpalt_end = .;
58#endif
Nelson Elhage78d75302009-10-02 16:32:47 -040059
60 INIT_SETUP(16)
61
Nelson Elhage78d75302009-10-02 16:32:47 -040062 INIT_CALLS
63 CON_INITCALL
64 SECURITY_INITCALL
65 INIT_RAM_FS
66
Linus Torvalds1da177e2005-04-16 15:20:36 -070067#ifndef CONFIG_XIP_KERNEL
68 __init_begin = _stext;
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +010069 INIT_DATA
Linus Torvalds1da177e2005-04-16 15:20:36 -070070#endif
71 }
72
Nelson Elhage78d75302009-10-02 16:32:47 -040073 PERCPU(PAGE_SIZE)
74
75#ifndef CONFIG_XIP_KERNEL
76 . = ALIGN(PAGE_SIZE);
77 __init_end = .;
78#endif
79
Alan Jenkinse3f28c12009-11-07 21:03:52 +000080 /*
81 * unwind exit sections must be discarded before the rest of the
82 * unwind sections get included.
83 */
84 /DISCARD/ : {
Catalin Marinasbff595c2009-02-16 11:41:36 +010085 *(.ARM.exidx.exit.text)
86 *(.ARM.extab.exit.text)
Russell King5085f3f2010-10-01 15:37:05 +010087 ARM_CPU_DISCARD(*(.ARM.exidx.cpuexit.text))
88 ARM_CPU_DISCARD(*(.ARM.extab.cpuexit.text))
Catalin Marinas74361272009-06-19 16:39:29 +010089#ifndef CONFIG_HOTPLUG
90 *(.ARM.exidx.devexit.text)
91 *(.ARM.extab.devexit.text)
92#endif
Russell King9641c7c2006-06-21 20:38:17 +010093#ifndef CONFIG_MMU
94 *(.fixup)
95 *(__ex_table)
96#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 }
98
99 .text : { /* Real text segment */
100 _text = .; /* Text and read-only data */
Russell King7ab3f8d2007-03-02 15:01:36 +0000101 __exception_text_start = .;
102 *(.exception.text)
103 __exception_text_end = .;
Sam Ravnborg76647092007-05-13 00:31:33 +0200104 TEXT_TEXT
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105 SCHED_TEXT
106 LOCK_TEXT
Nicolas Pitre785d3cd2007-12-03 15:27:56 -0500107 KPROBES_TEXT
Russell King9641c7c2006-06-21 20:38:17 +0100108#ifdef CONFIG_MMU
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 *(.fixup)
Russell King9641c7c2006-06-21 20:38:17 +0100110#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111 *(.gnu.warning)
112 *(.rodata)
113 *(.rodata.*)
114 *(.glue_7)
115 *(.glue_7t)
Tony Lindgren88d927e2010-10-26 19:52:21 +0100116 . = ALIGN(4);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117 *(.got) /* Global offset table */
Russell King5085f3f2010-10-01 15:37:05 +0100118 ARM_CPU_KEEP(PROC_INFO)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 }
120
Linus Walleijf6430a92009-06-24 23:38:56 +0100121 RO_DATA(PAGE_SIZE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122
Catalin Marinasbff595c2009-02-16 11:41:36 +0100123#ifdef CONFIG_ARM_UNWIND
124 /*
125 * Stack unwinding tables
126 */
127 . = ALIGN(8);
128 .ARM.unwind_idx : {
129 __start_unwind_idx = .;
130 *(.ARM.exidx*)
131 __stop_unwind_idx = .;
132 }
133 .ARM.unwind_tab : {
134 __start_unwind_tab = .;
135 *(.ARM.extab*)
136 __stop_unwind_tab = .;
137 }
138#endif
139
Russell King74b0ec02010-10-01 14:26:56 +0100140 _etext = .; /* End of text and rodata section */
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 */
Nelson Elhage78d75302009-10-02 16:32:47 -0400158 INIT_TASK_DATA(THREAD_SIZE)
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
Nelson Elhage78d75302009-10-02 16:32:47 -0400168 NOSAVE_DATA
169 CACHELINE_ALIGNED_DATA(32)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170
171 /*
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100172 * The exception fixup table (might need resorting at runtime)
173 */
174 . = ALIGN(32);
175 __start___ex_table = .;
Russell King9641c7c2006-06-21 20:38:17 +0100176#ifdef CONFIG_MMU
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100177 *(__ex_table)
Russell King9641c7c2006-06-21 20:38:17 +0100178#endif
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100179 __stop___ex_table = .;
180
181 /*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182 * and the usual data section
183 */
Sam Ravnborgca967252007-05-17 13:38:44 +0200184 DATA_DATA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 CONSTRUCTORS
186
187 _edata = .;
188 }
Nicolas Pitree98ff7f2007-02-22 16:18:09 +0100189 _edata_loc = __data_loc + SIZEOF(.data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190
Linus Walleijbc581772009-09-15 17:30:37 +0100191#ifdef CONFIG_HAVE_TCM
192 /*
193 * We align everything to a page boundary so we can
194 * free it after init has commenced and TCM contents have
195 * been copied to its destination.
196 */
197 .tcm_start : {
198 . = ALIGN(PAGE_SIZE);
199 __tcm_start = .;
200 __itcm_start = .;
201 }
202
203 /*
204 * Link these to the ITCM RAM
205 * Put VMA to the TCM address and LMA to the common RAM
206 * and we'll upload the contents from RAM to TCM and free
207 * the used RAM after that.
208 */
209 .text_itcm ITCM_OFFSET : AT(__itcm_start)
210 {
211 __sitcm_text = .;
212 *(.tcm.text)
213 *(.tcm.rodata)
214 . = ALIGN(4);
215 __eitcm_text = .;
216 }
217
218 /*
219 * Reset the dot pointer, this is needed to create the
220 * relative __dtcm_start below (to be used as extern in code).
221 */
222 . = ADDR(.tcm_start) + SIZEOF(.tcm_start) + SIZEOF(.text_itcm);
223
224 .dtcm_start : {
225 __dtcm_start = .;
226 }
227
228 /* TODO: add remainder of ITCM as well, that can be used for data! */
229 .data_dtcm DTCM_OFFSET : AT(__dtcm_start)
230 {
231 . = ALIGN(4);
232 __sdtcm_data = .;
233 *(.tcm.data)
234 . = ALIGN(4);
235 __edtcm_data = .;
236 }
237
238 /* Reset the dot pointer or the linker gets confused */
239 . = ADDR(.dtcm_start) + SIZEOF(.data_dtcm);
240
241 /* End marker for freeing TCM copy in linked object */
242 .tcm_end : AT(ADDR(.dtcm_start) + SIZEOF(.data_dtcm)){
243 . = ALIGN(PAGE_SIZE);
244 __tcm_end = .;
245 }
246#endif
247
Nelson Elhage78d75302009-10-02 16:32:47 -0400248 BSS_SECTION(0, 0, 0)
249 _end = .;
250
251 STABS_DEBUG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252 .comment 0 : { *(.comment) }
Alan Jenkinse3f28c12009-11-07 21:03:52 +0000253
254 /* Default discards */
255 DISCARDS
Russell Kingf00ec482010-09-04 10:47:48 +0100256
257#ifndef CONFIG_SMP_ON_UP
258 /DISCARD/ : {
259 *(.alt.smp.init)
260 }
261#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262}
263
Russell King728f5c02005-11-17 16:43:14 +0000264/*
265 * These must never be empty
266 * If you have to comment these two assert statements out, your
267 * binutils is too old (for other reasons as well)
268 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")
270ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")