blob: b16c07914b55bb0215592a7727e0974b62108dd6 [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
Nelson Elhage78d75302009-10-02 16:32:47 -040046 INIT_CALLS
47 CON_INITCALL
48 SECURITY_INITCALL
49 INIT_RAM_FS
50
Linus Torvalds1da177e2005-04-16 15:20:36 -070051#ifndef CONFIG_XIP_KERNEL
52 __init_begin = _stext;
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +010053 INIT_DATA
Linus Torvalds1da177e2005-04-16 15:20:36 -070054#endif
55 }
56
Nelson Elhage78d75302009-10-02 16:32:47 -040057 PERCPU(PAGE_SIZE)
58
59#ifndef CONFIG_XIP_KERNEL
60 . = ALIGN(PAGE_SIZE);
61 __init_end = .;
62#endif
63
Alan Jenkinse3f28c12009-11-07 21:03:52 +000064 /*
65 * unwind exit sections must be discarded before the rest of the
66 * unwind sections get included.
67 */
68 /DISCARD/ : {
Catalin Marinasbff595c2009-02-16 11:41:36 +010069 *(.ARM.exidx.exit.text)
70 *(.ARM.extab.exit.text)
Catalin Marinas74361272009-06-19 16:39:29 +010071#ifndef CONFIG_HOTPLUG_CPU
72 *(.ARM.exidx.cpuexit.text)
73 *(.ARM.extab.cpuexit.text)
74#endif
75#ifndef CONFIG_HOTPLUG
76 *(.ARM.exidx.devexit.text)
77 *(.ARM.extab.devexit.text)
78#endif
Russell King9641c7c2006-06-21 20:38:17 +010079#ifndef CONFIG_MMU
80 *(.fixup)
81 *(__ex_table)
82#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 }
84
85 .text : { /* Real text segment */
86 _text = .; /* Text and read-only data */
Russell King7ab3f8d2007-03-02 15:01:36 +000087 __exception_text_start = .;
88 *(.exception.text)
89 __exception_text_end = .;
Sam Ravnborg76647092007-05-13 00:31:33 +020090 TEXT_TEXT
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 SCHED_TEXT
92 LOCK_TEXT
Nicolas Pitre785d3cd2007-12-03 15:27:56 -050093 KPROBES_TEXT
Russell King9641c7c2006-06-21 20:38:17 +010094#ifdef CONFIG_MMU
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 *(.fixup)
Russell King9641c7c2006-06-21 20:38:17 +010096#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 *(.gnu.warning)
98 *(.rodata)
99 *(.rodata.*)
100 *(.glue_7)
101 *(.glue_7t)
102 *(.got) /* Global offset table */
103 }
104
Linus Walleijf6430a92009-06-24 23:38:56 +0100105 RO_DATA(PAGE_SIZE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106
107 _etext = .; /* End of text and rodata section */
108
Catalin Marinasbff595c2009-02-16 11:41:36 +0100109#ifdef CONFIG_ARM_UNWIND
110 /*
111 * Stack unwinding tables
112 */
113 . = ALIGN(8);
114 .ARM.unwind_idx : {
115 __start_unwind_idx = .;
116 *(.ARM.exidx*)
117 __stop_unwind_idx = .;
118 }
119 .ARM.unwind_tab : {
120 __start_unwind_tab = .;
121 *(.ARM.extab*)
122 __stop_unwind_tab = .;
123 }
124#endif
125
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126#ifdef CONFIG_XIP_KERNEL
127 __data_loc = ALIGN(4); /* location in binary */
Russell King9d4f13e2006-01-03 17:28:33 +0000128 . = PAGE_OFFSET + TEXT_OFFSET;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129#else
Russell King4f7a1812005-05-05 13:11:00 +0100130 . = ALIGN(THREAD_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 __data_loc = .;
132#endif
133
134 .data : AT(__data_loc) {
Russell King37efe642008-12-01 11:53:07 +0000135 _data = .; /* address in memory */
Catalin Marinas8c7e6572009-05-30 14:00:17 +0100136 _sdata = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137
138 /*
139 * first, the init task union, aligned
140 * to an 8192 byte boundary.
141 */
Nelson Elhage78d75302009-10-02 16:32:47 -0400142 INIT_TASK_DATA(THREAD_SIZE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143
144#ifdef CONFIG_XIP_KERNEL
Linus Walleijf6430a92009-06-24 23:38:56 +0100145 . = ALIGN(PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 __init_begin = .;
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100147 INIT_DATA
Linus Walleijf6430a92009-06-24 23:38:56 +0100148 . = ALIGN(PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149 __init_end = .;
150#endif
151
Nelson Elhage78d75302009-10-02 16:32:47 -0400152 NOSAVE_DATA
153 CACHELINE_ALIGNED_DATA(32)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154
155 /*
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100156 * The exception fixup table (might need resorting at runtime)
157 */
158 . = ALIGN(32);
159 __start___ex_table = .;
Russell King9641c7c2006-06-21 20:38:17 +0100160#ifdef CONFIG_MMU
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100161 *(__ex_table)
Russell King9641c7c2006-06-21 20:38:17 +0100162#endif
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100163 __stop___ex_table = .;
164
165 /*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166 * and the usual data section
167 */
Sam Ravnborgca967252007-05-17 13:38:44 +0200168 DATA_DATA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169 CONSTRUCTORS
170
171 _edata = .;
172 }
Nicolas Pitree98ff7f2007-02-22 16:18:09 +0100173 _edata_loc = __data_loc + SIZEOF(.data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174
Linus Walleijbc581772009-09-15 17:30:37 +0100175#ifdef CONFIG_HAVE_TCM
176 /*
177 * We align everything to a page boundary so we can
178 * free it after init has commenced and TCM contents have
179 * been copied to its destination.
180 */
181 .tcm_start : {
182 . = ALIGN(PAGE_SIZE);
183 __tcm_start = .;
184 __itcm_start = .;
185 }
186
187 /*
188 * Link these to the ITCM RAM
189 * Put VMA to the TCM address and LMA to the common RAM
190 * and we'll upload the contents from RAM to TCM and free
191 * the used RAM after that.
192 */
193 .text_itcm ITCM_OFFSET : AT(__itcm_start)
194 {
195 __sitcm_text = .;
196 *(.tcm.text)
197 *(.tcm.rodata)
198 . = ALIGN(4);
199 __eitcm_text = .;
200 }
201
202 /*
203 * Reset the dot pointer, this is needed to create the
204 * relative __dtcm_start below (to be used as extern in code).
205 */
206 . = ADDR(.tcm_start) + SIZEOF(.tcm_start) + SIZEOF(.text_itcm);
207
208 .dtcm_start : {
209 __dtcm_start = .;
210 }
211
212 /* TODO: add remainder of ITCM as well, that can be used for data! */
213 .data_dtcm DTCM_OFFSET : AT(__dtcm_start)
214 {
215 . = ALIGN(4);
216 __sdtcm_data = .;
217 *(.tcm.data)
218 . = ALIGN(4);
219 __edtcm_data = .;
220 }
221
222 /* Reset the dot pointer or the linker gets confused */
223 . = ADDR(.dtcm_start) + SIZEOF(.data_dtcm);
224
225 /* End marker for freeing TCM copy in linked object */
226 .tcm_end : AT(ADDR(.dtcm_start) + SIZEOF(.data_dtcm)){
227 . = ALIGN(PAGE_SIZE);
228 __tcm_end = .;
229 }
230#endif
231
Nelson Elhage78d75302009-10-02 16:32:47 -0400232 BSS_SECTION(0, 0, 0)
233 _end = .;
234
235 STABS_DEBUG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236 .comment 0 : { *(.comment) }
Alan Jenkinse3f28c12009-11-07 21:03:52 +0000237
238 /* Default discards */
239 DISCARDS
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240}
241
Russell King728f5c02005-11-17 16:43:14 +0000242/*
243 * These must never be empty
244 * If you have to comment these two assert statements out, your
245 * binutils is too old (for other reasons as well)
246 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")
248ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")