Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* 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> | ||||
Will Deacon | 6ffd58a | 2012-01-04 15:20:33 -0800 | [diff] [blame^] | 7 | #include <asm/cache.h> |
Russell King | 4f7a181 | 2005-05-05 13:11:00 +0100 | [diff] [blame] | 8 | #include <asm/thread_info.h> |
Nicolas Pitre | 37d07b7 | 2005-10-29 21:44:56 +0100 | [diff] [blame] | 9 | #include <asm/memory.h> |
Linus Walleij | f6430a9 | 2009-06-24 23:38:56 +0100 | [diff] [blame] | 10 | #include <asm/page.h> |
Jin Hong | a2440b5 | 2011-07-19 12:43:26 -0700 | [diff] [blame] | 11 | #ifdef CONFIG_STRICT_MEMORY_RWX |
12 | #include <asm/pgtable.h> | ||||
13 | #endif | ||||
Will Deacon | 6ffd58a | 2012-01-04 15:20:33 -0800 | [diff] [blame^] | 14 | |
Russell King | 5085f3f | 2010-10-01 15:37:05 +0100 | [diff] [blame] | 15 | #define PROC_INFO \ |
16 | VMLINUX_SYMBOL(__proc_info_begin) = .; \ | ||||
17 | *(.proc.info.init) \ | ||||
18 | VMLINUX_SYMBOL(__proc_info_end) = .; | ||||
19 | |||||
20 | #ifdef CONFIG_HOTPLUG_CPU | ||||
21 | #define ARM_CPU_DISCARD(x) | ||||
22 | #define ARM_CPU_KEEP(x) x | ||||
23 | #else | ||||
24 | #define ARM_CPU_DISCARD(x) x | ||||
25 | #define ARM_CPU_KEEP(x) | ||||
26 | #endif | ||||
27 | |||||
Simon Glass | d3dc306 | 2011-08-16 23:44:26 +0100 | [diff] [blame] | 28 | #if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || \ |
29 | defined(CONFIG_GENERIC_BUG) | ||||
Russell King | a9ad21f | 2011-02-21 10:13:36 +0000 | [diff] [blame] | 30 | #define ARM_EXIT_KEEP(x) x |
31 | #else | ||||
32 | #define ARM_EXIT_KEEP(x) | ||||
33 | #endif | ||||
34 | |||||
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | OUTPUT_ARCH(arm) |
36 | ENTRY(stext) | ||||
Nicolas Pitre | 37d07b7 | 2005-10-29 21:44:56 +0100 | [diff] [blame] | 37 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | #ifndef __ARMEB__ |
39 | jiffies = jiffies_64; | ||||
40 | #else | ||||
41 | jiffies = jiffies_64 + 4; | ||||
42 | #endif | ||||
Nicolas Pitre | 37d07b7 | 2005-10-29 21:44:56 +0100 | [diff] [blame] | 43 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | SECTIONS |
45 | { | ||||
Russell King | 9d4f13e | 2006-01-03 17:28:33 +0000 | [diff] [blame] | 46 | #ifdef CONFIG_XIP_KERNEL |
47 | . = XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR); | ||||
48 | #else | ||||
49 | . = PAGE_OFFSET + TEXT_OFFSET; | ||||
50 | #endif | ||||
Russell King | 08fdffd | 2007-05-08 15:15:45 +0100 | [diff] [blame] | 51 | |
52 | .init : { /* Init code and data */ | ||||
Tim Abbott | 2abc1c5 | 2009-10-02 16:32:46 -0400 | [diff] [blame] | 53 | _stext = .; |
54 | _sinittext = .; | ||||
55 | HEAD_TEXT | ||||
Sam Ravnborg | 01ba2bd | 2008-01-20 14:15:03 +0100 | [diff] [blame] | 56 | INIT_TEXT |
Russell King | a9ad21f | 2011-02-21 10:13:36 +0000 | [diff] [blame] | 57 | ARM_EXIT_KEEP(EXIT_TEXT) |
Russell King | 08fdffd | 2007-05-08 15:15:45 +0100 | [diff] [blame] | 58 | _einittext = .; |
Russell King | 5085f3f | 2010-10-01 15:37:05 +0100 | [diff] [blame] | 59 | ARM_CPU_DISCARD(PROC_INFO) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | __arch_info_begin = .; |
Ben Dooks | 9d0fd1e | 2005-09-20 16:45:20 +0100 | [diff] [blame] | 61 | *(.arch.info.init) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | __arch_info_end = .; |
63 | __tagtable_begin = .; | ||||
Ben Dooks | 9506057 | 2005-09-20 16:20:49 +0100 | [diff] [blame] | 64 | *(.taglist.init) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | __tagtable_end = .; |
Russell King | f00ec48 | 2010-09-04 10:47:48 +0100 | [diff] [blame] | 66 | #ifdef CONFIG_SMP_ON_UP |
67 | __smpalt_begin = .; | ||||
68 | *(.alt.smp.init) | ||||
69 | __smpalt_end = .; | ||||
70 | #endif | ||||
Nelson Elhage | 78d7530 | 2009-10-02 16:32:47 -0400 | [diff] [blame] | 71 | |
Russell King | dc21af9 | 2011-01-04 19:09:43 +0000 | [diff] [blame] | 72 | __pv_table_begin = .; |
73 | *(.pv_table) | ||||
74 | __pv_table_end = .; | ||||
75 | |||||
Nelson Elhage | 78d7530 | 2009-10-02 16:32:47 -0400 | [diff] [blame] | 76 | INIT_SETUP(16) |
77 | |||||
Nelson Elhage | 78d7530 | 2009-10-02 16:32:47 -0400 | [diff] [blame] | 78 | INIT_CALLS |
79 | CON_INITCALL | ||||
80 | SECURITY_INITCALL | ||||
81 | INIT_RAM_FS | ||||
82 | |||||
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | #ifndef CONFIG_XIP_KERNEL |
84 | __init_begin = _stext; | ||||
Sam Ravnborg | 01ba2bd | 2008-01-20 14:15:03 +0100 | [diff] [blame] | 85 | INIT_DATA |
Russell King | a9ad21f | 2011-02-21 10:13:36 +0000 | [diff] [blame] | 86 | ARM_EXIT_KEEP(EXIT_DATA) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | #endif |
88 | } | ||||
89 | |||||
Will Deacon | 6ffd58a | 2012-01-04 15:20:33 -0800 | [diff] [blame^] | 90 | PERCPU_SECTION(L1_CACHE_BYTES) |
Nelson Elhage | 78d7530 | 2009-10-02 16:32:47 -0400 | [diff] [blame] | 91 | |
92 | #ifndef CONFIG_XIP_KERNEL | ||||
93 | . = ALIGN(PAGE_SIZE); | ||||
94 | __init_end = .; | ||||
95 | #endif | ||||
96 | |||||
Alan Jenkins | e3f28c1 | 2009-11-07 21:03:52 +0000 | [diff] [blame] | 97 | /* |
98 | * unwind exit sections must be discarded before the rest of the | ||||
99 | * unwind sections get included. | ||||
100 | */ | ||||
101 | /DISCARD/ : { | ||||
Catalin Marinas | bff595c | 2009-02-16 11:41:36 +0100 | [diff] [blame] | 102 | *(.ARM.exidx.exit.text) |
103 | *(.ARM.extab.exit.text) | ||||
Russell King | 5085f3f | 2010-10-01 15:37:05 +0100 | [diff] [blame] | 104 | ARM_CPU_DISCARD(*(.ARM.exidx.cpuexit.text)) |
105 | ARM_CPU_DISCARD(*(.ARM.extab.cpuexit.text)) | ||||
Catalin Marinas | 7436127 | 2009-06-19 16:39:29 +0100 | [diff] [blame] | 106 | #ifndef CONFIG_HOTPLUG |
107 | *(.ARM.exidx.devexit.text) | ||||
108 | *(.ARM.extab.devexit.text) | ||||
109 | #endif | ||||
Russell King | 9641c7c | 2006-06-21 20:38:17 +0100 | [diff] [blame] | 110 | #ifndef CONFIG_MMU |
111 | *(.fixup) | ||||
112 | *(__ex_table) | ||||
113 | #endif | ||||
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | } |
115 | |||||
Jin Hong | a2440b5 | 2011-07-19 12:43:26 -0700 | [diff] [blame] | 116 | #ifdef CONFIG_STRICT_MEMORY_RWX |
117 | . = ALIGN(1<<SECTION_SHIFT); | ||||
118 | #endif | ||||
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | .text : { /* Real text segment */ |
120 | _text = .; /* Text and read-only data */ | ||||
Russell King | 7ab3f8d | 2007-03-02 15:01:36 +0000 | [diff] [blame] | 121 | __exception_text_start = .; |
122 | *(.exception.text) | ||||
123 | __exception_text_end = .; | ||||
Rabin Vincent | 61b5cb1 | 2010-10-07 20:51:58 +0530 | [diff] [blame] | 124 | IRQENTRY_TEXT |
Sam Ravnborg | 7664709 | 2007-05-13 00:31:33 +0200 | [diff] [blame] | 125 | TEXT_TEXT |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | SCHED_TEXT |
127 | LOCK_TEXT | ||||
Nicolas Pitre | 785d3cd | 2007-12-03 15:27:56 -0500 | [diff] [blame] | 128 | KPROBES_TEXT |
Russell King | 9641c7c | 2006-06-21 20:38:17 +0100 | [diff] [blame] | 129 | #ifdef CONFIG_MMU |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | *(.fixup) |
Russell King | 9641c7c | 2006-06-21 20:38:17 +0100 | [diff] [blame] | 131 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | *(.gnu.warning) |
133 | *(.rodata) | ||||
134 | *(.rodata.*) | ||||
135 | *(.glue_7) | ||||
136 | *(.glue_7t) | ||||
Tony Lindgren | 88d927e | 2010-10-26 19:52:21 +0100 | [diff] [blame] | 137 | . = ALIGN(4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | *(.got) /* Global offset table */ |
Russell King | 5085f3f | 2010-10-01 15:37:05 +0100 | [diff] [blame] | 139 | ARM_CPU_KEEP(PROC_INFO) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | } |
Jin Hong | a2440b5 | 2011-07-19 12:43:26 -0700 | [diff] [blame] | 141 | #ifdef CONFIG_STRICT_MEMORY_RWX |
142 | . = ALIGN(1<<SECTION_SHIFT); | ||||
143 | #endif | ||||
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | |
Linus Walleij | f6430a9 | 2009-06-24 23:38:56 +0100 | [diff] [blame] | 145 | RO_DATA(PAGE_SIZE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | |
Catalin Marinas | bff595c | 2009-02-16 11:41:36 +0100 | [diff] [blame] | 147 | #ifdef CONFIG_ARM_UNWIND |
148 | /* | ||||
149 | * Stack unwinding tables | ||||
150 | */ | ||||
151 | . = ALIGN(8); | ||||
152 | .ARM.unwind_idx : { | ||||
153 | __start_unwind_idx = .; | ||||
154 | *(.ARM.exidx*) | ||||
155 | __stop_unwind_idx = .; | ||||
156 | } | ||||
157 | .ARM.unwind_tab : { | ||||
158 | __start_unwind_tab = .; | ||||
159 | *(.ARM.extab*) | ||||
160 | __stop_unwind_tab = .; | ||||
161 | } | ||||
162 | #endif | ||||
163 | |||||
Russell King | 74b0ec0 | 2010-10-01 14:26:56 +0100 | [diff] [blame] | 164 | _etext = .; /* End of text and rodata section */ |
165 | |||||
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | #ifdef CONFIG_XIP_KERNEL |
167 | __data_loc = ALIGN(4); /* location in binary */ | ||||
Russell King | 9d4f13e | 2006-01-03 17:28:33 +0000 | [diff] [blame] | 168 | . = PAGE_OFFSET + TEXT_OFFSET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | #else |
Jin Hong | a2440b5 | 2011-07-19 12:43:26 -0700 | [diff] [blame] | 170 | #ifdef CONFIG_STRICT_MEMORY_RWX |
171 | . = ALIGN(1<<SECTION_SHIFT); | ||||
172 | #else | ||||
Russell King | 4f7a181 | 2005-05-05 13:11:00 +0100 | [diff] [blame] | 173 | . = ALIGN(THREAD_SIZE); |
Jin Hong | a2440b5 | 2011-07-19 12:43:26 -0700 | [diff] [blame] | 174 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | __data_loc = .; |
176 | #endif | ||||
177 | |||||
178 | .data : AT(__data_loc) { | ||||
Russell King | 37efe64 | 2008-12-01 11:53:07 +0000 | [diff] [blame] | 179 | _data = .; /* address in memory */ |
Catalin Marinas | 8c7e657 | 2009-05-30 14:00:17 +0100 | [diff] [blame] | 180 | _sdata = .; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | |
182 | /* | ||||
183 | * first, the init task union, aligned | ||||
184 | * to an 8192 byte boundary. | ||||
185 | */ | ||||
Nelson Elhage | 78d7530 | 2009-10-02 16:32:47 -0400 | [diff] [blame] | 186 | INIT_TASK_DATA(THREAD_SIZE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | |
188 | #ifdef CONFIG_XIP_KERNEL | ||||
Linus Walleij | f6430a9 | 2009-06-24 23:38:56 +0100 | [diff] [blame] | 189 | . = ALIGN(PAGE_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | __init_begin = .; |
Sam Ravnborg | 01ba2bd | 2008-01-20 14:15:03 +0100 | [diff] [blame] | 191 | INIT_DATA |
Russell King | a9ad21f | 2011-02-21 10:13:36 +0000 | [diff] [blame] | 192 | ARM_EXIT_KEEP(EXIT_DATA) |
Linus Walleij | f6430a9 | 2009-06-24 23:38:56 +0100 | [diff] [blame] | 193 | . = ALIGN(PAGE_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | __init_end = .; |
195 | #endif | ||||
196 | |||||
Nelson Elhage | 78d7530 | 2009-10-02 16:32:47 -0400 | [diff] [blame] | 197 | NOSAVE_DATA |
Will Deacon | 6ffd58a | 2012-01-04 15:20:33 -0800 | [diff] [blame^] | 198 | CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES) |
Russell King | daf8741 | 2010-12-04 17:08:32 +0000 | [diff] [blame] | 199 | READ_MOSTLY_DATA(32) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | |
201 | /* | ||||
Nicolas Pitre | 13b1f64 | 2005-10-13 22:04:37 +0100 | [diff] [blame] | 202 | * The exception fixup table (might need resorting at runtime) |
203 | */ | ||||
204 | . = ALIGN(32); | ||||
205 | __start___ex_table = .; | ||||
Russell King | 9641c7c | 2006-06-21 20:38:17 +0100 | [diff] [blame] | 206 | #ifdef CONFIG_MMU |
Nicolas Pitre | 13b1f64 | 2005-10-13 22:04:37 +0100 | [diff] [blame] | 207 | *(__ex_table) |
Russell King | 9641c7c | 2006-06-21 20:38:17 +0100 | [diff] [blame] | 208 | #endif |
Nicolas Pitre | 13b1f64 | 2005-10-13 22:04:37 +0100 | [diff] [blame] | 209 | __stop___ex_table = .; |
210 | |||||
211 | /* | ||||
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | * and the usual data section |
213 | */ | ||||
Sam Ravnborg | ca96725 | 2007-05-17 13:38:44 +0200 | [diff] [blame] | 214 | DATA_DATA |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | CONSTRUCTORS |
216 | |||||
217 | _edata = .; | ||||
218 | } | ||||
Nicolas Pitre | e98ff7f | 2007-02-22 16:18:09 +0100 | [diff] [blame] | 219 | _edata_loc = __data_loc + SIZEOF(.data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | |
Linus Walleij | bc58177 | 2009-09-15 17:30:37 +0100 | [diff] [blame] | 221 | #ifdef CONFIG_HAVE_TCM |
222 | /* | ||||
223 | * We align everything to a page boundary so we can | ||||
224 | * free it after init has commenced and TCM contents have | ||||
225 | * been copied to its destination. | ||||
226 | */ | ||||
227 | .tcm_start : { | ||||
228 | . = ALIGN(PAGE_SIZE); | ||||
229 | __tcm_start = .; | ||||
230 | __itcm_start = .; | ||||
231 | } | ||||
232 | |||||
233 | /* | ||||
234 | * Link these to the ITCM RAM | ||||
235 | * Put VMA to the TCM address and LMA to the common RAM | ||||
236 | * and we'll upload the contents from RAM to TCM and free | ||||
237 | * the used RAM after that. | ||||
238 | */ | ||||
239 | .text_itcm ITCM_OFFSET : AT(__itcm_start) | ||||
240 | { | ||||
241 | __sitcm_text = .; | ||||
242 | *(.tcm.text) | ||||
243 | *(.tcm.rodata) | ||||
244 | . = ALIGN(4); | ||||
245 | __eitcm_text = .; | ||||
246 | } | ||||
247 | |||||
248 | /* | ||||
249 | * Reset the dot pointer, this is needed to create the | ||||
250 | * relative __dtcm_start below (to be used as extern in code). | ||||
251 | */ | ||||
252 | . = ADDR(.tcm_start) + SIZEOF(.tcm_start) + SIZEOF(.text_itcm); | ||||
253 | |||||
254 | .dtcm_start : { | ||||
255 | __dtcm_start = .; | ||||
256 | } | ||||
257 | |||||
258 | /* TODO: add remainder of ITCM as well, that can be used for data! */ | ||||
259 | .data_dtcm DTCM_OFFSET : AT(__dtcm_start) | ||||
260 | { | ||||
261 | . = ALIGN(4); | ||||
262 | __sdtcm_data = .; | ||||
263 | *(.tcm.data) | ||||
264 | . = ALIGN(4); | ||||
265 | __edtcm_data = .; | ||||
266 | } | ||||
267 | |||||
268 | /* Reset the dot pointer or the linker gets confused */ | ||||
269 | . = ADDR(.dtcm_start) + SIZEOF(.data_dtcm); | ||||
270 | |||||
271 | /* End marker for freeing TCM copy in linked object */ | ||||
272 | .tcm_end : AT(ADDR(.dtcm_start) + SIZEOF(.data_dtcm)){ | ||||
273 | . = ALIGN(PAGE_SIZE); | ||||
274 | __tcm_end = .; | ||||
275 | } | ||||
276 | #endif | ||||
277 | |||||
Pawel Moll | dc810ef | 2011-02-16 18:54:01 +0100 | [diff] [blame] | 278 | NOTES |
279 | |||||
Nelson Elhage | 78d7530 | 2009-10-02 16:32:47 -0400 | [diff] [blame] | 280 | BSS_SECTION(0, 0, 0) |
281 | _end = .; | ||||
282 | |||||
283 | STABS_DEBUG | ||||
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | .comment 0 : { *(.comment) } |
Alan Jenkins | e3f28c1 | 2009-11-07 21:03:52 +0000 | [diff] [blame] | 285 | |
286 | /* Default discards */ | ||||
287 | DISCARDS | ||||
Russell King | f00ec48 | 2010-09-04 10:47:48 +0100 | [diff] [blame] | 288 | |
289 | #ifndef CONFIG_SMP_ON_UP | ||||
290 | /DISCARD/ : { | ||||
291 | *(.alt.smp.init) | ||||
292 | } | ||||
293 | #endif | ||||
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | } |
295 | |||||
Russell King | 728f5c0 | 2005-11-17 16:43:14 +0000 | [diff] [blame] | 296 | /* |
297 | * These must never be empty | ||||
298 | * If you have to comment these two assert statements out, your | ||||
299 | * binutils is too old (for other reasons as well) | ||||
300 | */ | ||||
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support") |
302 | ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined") |