blob: 4957e13ef55ba6be1d396f5dc72d3eebb2b43450 [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 = .;
Nelson Elhage78d75302009-10-02 16:32:47 -040043
44 INIT_SETUP(16)
45
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 __early_begin = .;
Ben Dooksbfe68152005-09-20 16:25:12 +010047 *(.early_param.init)
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 __early_end = .;
Nelson Elhage78d75302009-10-02 16:32:47 -040049
50 INIT_CALLS
51 CON_INITCALL
52 SECURITY_INITCALL
53 INIT_RAM_FS
54
Linus Torvalds1da177e2005-04-16 15:20:36 -070055#ifndef CONFIG_XIP_KERNEL
56 __init_begin = _stext;
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +010057 INIT_DATA
Linus Torvalds1da177e2005-04-16 15:20:36 -070058#endif
59 }
60
Nelson Elhage78d75302009-10-02 16:32:47 -040061 PERCPU(PAGE_SIZE)
62
63#ifndef CONFIG_XIP_KERNEL
64 . = ALIGN(PAGE_SIZE);
65 __init_end = .;
66#endif
67
Alan Jenkinse3f28c12009-11-07 21:03:52 +000068 /*
69 * unwind exit sections must be discarded before the rest of the
70 * unwind sections get included.
71 */
72 /DISCARD/ : {
Catalin Marinasbff595c2009-02-16 11:41:36 +010073 *(.ARM.exidx.exit.text)
74 *(.ARM.extab.exit.text)
Catalin Marinas74361272009-06-19 16:39:29 +010075#ifndef CONFIG_HOTPLUG_CPU
76 *(.ARM.exidx.cpuexit.text)
77 *(.ARM.extab.cpuexit.text)
78#endif
79#ifndef CONFIG_HOTPLUG
80 *(.ARM.exidx.devexit.text)
81 *(.ARM.extab.devexit.text)
82#endif
Russell King9641c7c2006-06-21 20:38:17 +010083#ifndef CONFIG_MMU
84 *(.fixup)
85 *(__ex_table)
86#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070087 }
88
89 .text : { /* Real text segment */
90 _text = .; /* Text and read-only data */
Russell King7ab3f8d2007-03-02 15:01:36 +000091 __exception_text_start = .;
92 *(.exception.text)
93 __exception_text_end = .;
Sam Ravnborg76647092007-05-13 00:31:33 +020094 TEXT_TEXT
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 SCHED_TEXT
96 LOCK_TEXT
Nicolas Pitre785d3cd2007-12-03 15:27:56 -050097 KPROBES_TEXT
Russell King9641c7c2006-06-21 20:38:17 +010098#ifdef CONFIG_MMU
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 *(.fixup)
Russell King9641c7c2006-06-21 20:38:17 +0100100#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101 *(.gnu.warning)
102 *(.rodata)
103 *(.rodata.*)
104 *(.glue_7)
105 *(.glue_7t)
106 *(.got) /* Global offset table */
107 }
108
Linus Walleijf6430a92009-06-24 23:38:56 +0100109 RO_DATA(PAGE_SIZE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110
111 _etext = .; /* End of text and rodata section */
112
Catalin Marinasbff595c2009-02-16 11:41:36 +0100113#ifdef CONFIG_ARM_UNWIND
114 /*
115 * Stack unwinding tables
116 */
117 . = ALIGN(8);
118 .ARM.unwind_idx : {
119 __start_unwind_idx = .;
120 *(.ARM.exidx*)
121 __stop_unwind_idx = .;
122 }
123 .ARM.unwind_tab : {
124 __start_unwind_tab = .;
125 *(.ARM.extab*)
126 __stop_unwind_tab = .;
127 }
128#endif
129
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130#ifdef CONFIG_XIP_KERNEL
131 __data_loc = ALIGN(4); /* location in binary */
Russell King9d4f13e2006-01-03 17:28:33 +0000132 . = PAGE_OFFSET + TEXT_OFFSET;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133#else
Russell King4f7a1812005-05-05 13:11:00 +0100134 . = ALIGN(THREAD_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 __data_loc = .;
136#endif
137
138 .data : AT(__data_loc) {
Russell King37efe642008-12-01 11:53:07 +0000139 _data = .; /* address in memory */
Catalin Marinas8c7e6572009-05-30 14:00:17 +0100140 _sdata = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141
142 /*
143 * first, the init task union, aligned
144 * to an 8192 byte boundary.
145 */
Nelson Elhage78d75302009-10-02 16:32:47 -0400146 INIT_TASK_DATA(THREAD_SIZE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147
148#ifdef CONFIG_XIP_KERNEL
Linus Walleijf6430a92009-06-24 23:38:56 +0100149 . = ALIGN(PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 __init_begin = .;
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100151 INIT_DATA
Linus Walleijf6430a92009-06-24 23:38:56 +0100152 . = ALIGN(PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 __init_end = .;
154#endif
155
Nelson Elhage78d75302009-10-02 16:32:47 -0400156 NOSAVE_DATA
157 CACHELINE_ALIGNED_DATA(32)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158
159 /*
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100160 * The exception fixup table (might need resorting at runtime)
161 */
162 . = ALIGN(32);
163 __start___ex_table = .;
Russell King9641c7c2006-06-21 20:38:17 +0100164#ifdef CONFIG_MMU
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100165 *(__ex_table)
Russell King9641c7c2006-06-21 20:38:17 +0100166#endif
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100167 __stop___ex_table = .;
168
169 /*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 * and the usual data section
171 */
Sam Ravnborgca967252007-05-17 13:38:44 +0200172 DATA_DATA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173 CONSTRUCTORS
174
175 _edata = .;
176 }
Nicolas Pitree98ff7f2007-02-22 16:18:09 +0100177 _edata_loc = __data_loc + SIZEOF(.data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178
Linus Walleijbc581772009-09-15 17:30:37 +0100179#ifdef CONFIG_HAVE_TCM
180 /*
181 * We align everything to a page boundary so we can
182 * free it after init has commenced and TCM contents have
183 * been copied to its destination.
184 */
185 .tcm_start : {
186 . = ALIGN(PAGE_SIZE);
187 __tcm_start = .;
188 __itcm_start = .;
189 }
190
191 /*
192 * Link these to the ITCM RAM
193 * Put VMA to the TCM address and LMA to the common RAM
194 * and we'll upload the contents from RAM to TCM and free
195 * the used RAM after that.
196 */
197 .text_itcm ITCM_OFFSET : AT(__itcm_start)
198 {
199 __sitcm_text = .;
200 *(.tcm.text)
201 *(.tcm.rodata)
202 . = ALIGN(4);
203 __eitcm_text = .;
204 }
205
206 /*
207 * Reset the dot pointer, this is needed to create the
208 * relative __dtcm_start below (to be used as extern in code).
209 */
210 . = ADDR(.tcm_start) + SIZEOF(.tcm_start) + SIZEOF(.text_itcm);
211
212 .dtcm_start : {
213 __dtcm_start = .;
214 }
215
216 /* TODO: add remainder of ITCM as well, that can be used for data! */
217 .data_dtcm DTCM_OFFSET : AT(__dtcm_start)
218 {
219 . = ALIGN(4);
220 __sdtcm_data = .;
221 *(.tcm.data)
222 . = ALIGN(4);
223 __edtcm_data = .;
224 }
225
226 /* Reset the dot pointer or the linker gets confused */
227 . = ADDR(.dtcm_start) + SIZEOF(.data_dtcm);
228
229 /* End marker for freeing TCM copy in linked object */
230 .tcm_end : AT(ADDR(.dtcm_start) + SIZEOF(.data_dtcm)){
231 . = ALIGN(PAGE_SIZE);
232 __tcm_end = .;
233 }
234#endif
235
Nelson Elhage78d75302009-10-02 16:32:47 -0400236 BSS_SECTION(0, 0, 0)
237 _end = .;
238
239 STABS_DEBUG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 .comment 0 : { *(.comment) }
Alan Jenkinse3f28c12009-11-07 21:03:52 +0000241
242 /* Default discards */
243 DISCARDS
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244}
245
Russell King728f5c02005-11-17 16:43:14 +0000246/*
247 * These must never be empty
248 * If you have to comment these two assert statements out, your
249 * binutils is too old (for other reasons as well)
250 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")
252ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")