Commit | Line | Data |
---|---|---|
1da177e4 LT |
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> | |
f0d5375e | 7 | #include <asm/cache.h> |
4f7a1812 | 8 | #include <asm/thread_info.h> |
37d07b72 | 9 | #include <asm/memory.h> |
f6430a93 | 10 | #include <asm/page.h> |
1e6b4811 KC |
11 | #ifdef CONFIG_ARM_KERNMEM_PERMS |
12 | #include <asm/pgtable.h> | |
13 | #endif | |
e60a1fec | 14 | |
5085f3ff | 15 | #define PROC_INFO \ |
b8b9987f | 16 | . = ALIGN(4); \ |
5085f3ff RK |
17 | VMLINUX_SYMBOL(__proc_info_begin) = .; \ |
18 | *(.proc.info.init) \ | |
19 | VMLINUX_SYMBOL(__proc_info_end) = .; | |
20 | ||
1a61ae7a MZ |
21 | #define HYPERVISOR_TEXT \ |
22 | VMLINUX_SYMBOL(__hyp_text_start) = .; \ | |
23 | *(.hyp.text) \ | |
24 | VMLINUX_SYMBOL(__hyp_text_end) = .; | |
25 | ||
8903826d WD |
26 | #define IDMAP_TEXT \ |
27 | ALIGN_FUNCTION(); \ | |
28 | VMLINUX_SYMBOL(__idmap_text_start) = .; \ | |
29 | *(.idmap.text) \ | |
9e9a367c | 30 | VMLINUX_SYMBOL(__idmap_text_end) = .; \ |
a9fea8b3 | 31 | . = ALIGN(PAGE_SIZE); \ |
9e9a367c CD |
32 | VMLINUX_SYMBOL(__hyp_idmap_text_start) = .; \ |
33 | *(.hyp.idmap.text) \ | |
34 | VMLINUX_SYMBOL(__hyp_idmap_text_end) = .; | |
8903826d | 35 | |
5085f3ff RK |
36 | #ifdef CONFIG_HOTPLUG_CPU |
37 | #define ARM_CPU_DISCARD(x) | |
38 | #define ARM_CPU_KEEP(x) x | |
39 | #else | |
40 | #define ARM_CPU_DISCARD(x) x | |
41 | #define ARM_CPU_KEEP(x) | |
42 | #endif | |
43 | ||
87e040b6 SG |
44 | #if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || \ |
45 | defined(CONFIG_GENERIC_BUG) | |
a9ad21fe | 46 | #define ARM_EXIT_KEEP(x) x |
6760b109 | 47 | #define ARM_EXIT_DISCARD(x) |
a9ad21fe RK |
48 | #else |
49 | #define ARM_EXIT_KEEP(x) | |
6760b109 | 50 | #define ARM_EXIT_DISCARD(x) x |
a9ad21fe RK |
51 | #endif |
52 | ||
1da177e4 LT |
53 | OUTPUT_ARCH(arm) |
54 | ENTRY(stext) | |
37d07b72 | 55 | |
1da177e4 LT |
56 | #ifndef __ARMEB__ |
57 | jiffies = jiffies_64; | |
58 | #else | |
59 | jiffies = jiffies_64 + 4; | |
60 | #endif | |
37d07b72 | 61 | |
9d4f13e5 RK |
62 | SECTIONS |
63 | { | |
39df8887 | 64 | /* |
6760b109 RK |
65 | * XXX: The linker does not define how output sections are |
66 | * assigned to input sections when there are multiple statements | |
67 | * matching the same input section name. There is no documented | |
68 | * order of matching. | |
69 | * | |
39df8887 RK |
70 | * unwind exit sections must be discarded before the rest of the |
71 | * unwind sections get included. | |
72 | */ | |
73 | /DISCARD/ : { | |
74 | *(.ARM.exidx.exit.text) | |
75 | *(.ARM.extab.exit.text) | |
76 | ARM_CPU_DISCARD(*(.ARM.exidx.cpuexit.text)) | |
77 | ARM_CPU_DISCARD(*(.ARM.extab.cpuexit.text)) | |
6760b109 RK |
78 | ARM_EXIT_DISCARD(EXIT_TEXT) |
79 | ARM_EXIT_DISCARD(EXIT_DATA) | |
80 | EXIT_CALL | |
39df8887 | 81 | #ifndef CONFIG_MMU |
c4a84ae3 | 82 | *(.text.fixup) |
39df8887 RK |
83 | *(__ex_table) |
84 | #endif | |
85 | #ifndef CONFIG_SMP_ON_UP | |
86 | *(.alt.smp.init) | |
87 | #endif | |
6760b109 RK |
88 | *(.discard) |
89 | *(.discard.*) | |
39df8887 RK |
90 | } |
91 | ||
37d07b72 | 92 | #ifdef CONFIG_XIP_KERNEL |
9d4f13e5 | 93 | . = XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR); |
37d07b72 | 94 | #else |
9d4f13e5 | 95 | . = PAGE_OFFSET + TEXT_OFFSET; |
37d07b72 | 96 | #endif |
1604d79d | 97 | .head.text : { |
e2f81844 | 98 | _text = .; |
1604d79d RK |
99 | HEAD_TEXT |
100 | } | |
1e6b4811 KC |
101 | |
102 | #ifdef CONFIG_ARM_KERNMEM_PERMS | |
103 | . = ALIGN(1<<SECTION_SHIFT); | |
104 | #endif | |
105 | ||
3835d69a | 106 | .text : { /* Real text segment */ |
e2f81844 | 107 | _stext = .; /* Text and read-only data */ |
eb765c1c | 108 | IDMAP_TEXT |
3835d69a RK |
109 | __exception_text_start = .; |
110 | *(.exception.text) | |
111 | __exception_text_end = .; | |
112 | IRQENTRY_TEXT | |
113 | TEXT_TEXT | |
114 | SCHED_TEXT | |
115 | LOCK_TEXT | |
1a61ae7a | 116 | HYPERVISOR_TEXT |
3835d69a | 117 | KPROBES_TEXT |
3835d69a RK |
118 | *(.gnu.warning) |
119 | *(.glue_7) | |
120 | *(.glue_7t) | |
121 | . = ALIGN(4); | |
122 | *(.got) /* Global offset table */ | |
123 | ARM_CPU_KEEP(PROC_INFO) | |
124 | } | |
125 | ||
80d6b0c2 KC |
126 | #ifdef CONFIG_DEBUG_RODATA |
127 | . = ALIGN(1<<SECTION_SHIFT); | |
128 | #endif | |
3835d69a RK |
129 | RO_DATA(PAGE_SIZE) |
130 | ||
ee951c63 SB |
131 | . = ALIGN(4); |
132 | __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { | |
133 | __start___ex_table = .; | |
134 | #ifdef CONFIG_MMU | |
135 | *(__ex_table) | |
136 | #endif | |
137 | __stop___ex_table = .; | |
138 | } | |
139 | ||
3835d69a RK |
140 | #ifdef CONFIG_ARM_UNWIND |
141 | /* | |
142 | * Stack unwinding tables | |
143 | */ | |
144 | . = ALIGN(8); | |
145 | .ARM.unwind_idx : { | |
146 | __start_unwind_idx = .; | |
147 | *(.ARM.exidx*) | |
148 | __stop_unwind_idx = .; | |
149 | } | |
150 | .ARM.unwind_tab : { | |
151 | __start_unwind_tab = .; | |
152 | *(.ARM.extab*) | |
153 | __stop_unwind_tab = .; | |
154 | } | |
155 | #endif | |
156 | ||
dad5451a PM |
157 | NOTES |
158 | ||
3835d69a RK |
159 | _etext = .; /* End of text and rodata section */ |
160 | ||
161 | #ifndef CONFIG_XIP_KERNEL | |
1e6b4811 KC |
162 | # ifdef CONFIG_ARM_KERNMEM_PERMS |
163 | . = ALIGN(1<<SECTION_SHIFT); | |
164 | # else | |
3835d69a | 165 | . = ALIGN(PAGE_SIZE); |
1e6b4811 | 166 | # endif |
3835d69a RK |
167 | __init_begin = .; |
168 | #endif | |
b9b32bf7 RK |
169 | /* |
170 | * The vectors and stubs are relocatable code, and the | |
171 | * only thing that matters is their relative offsets | |
172 | */ | |
173 | __vectors_start = .; | |
174 | .vectors 0 : AT(__vectors_start) { | |
175 | *(.vectors) | |
176 | } | |
177 | . = __vectors_start + SIZEOF(.vectors); | |
178 | __vectors_end = .; | |
179 | ||
180 | __stubs_start = .; | |
181 | .stubs 0x1000 : AT(__stubs_start) { | |
182 | *(.stubs) | |
183 | } | |
184 | . = __stubs_start + SIZEOF(.stubs); | |
185 | __stubs_end = .; | |
3835d69a | 186 | |
1604d79d RK |
187 | INIT_TEXT_SECTION(8) |
188 | .exit.text : { | |
189 | ARM_EXIT_KEEP(EXIT_TEXT) | |
190 | } | |
191 | .init.proc.info : { | |
5085f3ff | 192 | ARM_CPU_DISCARD(PROC_INFO) |
1604d79d RK |
193 | } |
194 | .init.arch.info : { | |
1da177e4 | 195 | __arch_info_begin = .; |
1604d79d | 196 | *(.arch.info.init) |
1da177e4 | 197 | __arch_info_end = .; |
1604d79d RK |
198 | } |
199 | .init.tagtable : { | |
1da177e4 | 200 | __tagtable_begin = .; |
1604d79d | 201 | *(.taglist.init) |
1da177e4 | 202 | __tagtable_end = .; |
1604d79d | 203 | } |
f00ec48f | 204 | #ifdef CONFIG_SMP_ON_UP |
1604d79d | 205 | .init.smpalt : { |
f00ec48f | 206 | __smpalt_begin = .; |
1604d79d | 207 | *(.alt.smp.init) |
f00ec48f | 208 | __smpalt_end = .; |
1604d79d | 209 | } |
f00ec48f | 210 | #endif |
1604d79d | 211 | .init.pv_table : { |
dc21af99 | 212 | __pv_table_begin = .; |
1604d79d | 213 | *(.pv_table) |
dc21af99 | 214 | __pv_table_end = .; |
1604d79d RK |
215 | } |
216 | .init.data : { | |
217 | #ifndef CONFIG_XIP_KERNEL | |
218 | INIT_DATA | |
219 | #endif | |
78d7530a | 220 | INIT_SETUP(16) |
78d7530a NE |
221 | INIT_CALLS |
222 | CON_INITCALL | |
223 | SECURITY_INITCALL | |
224 | INIT_RAM_FS | |
1604d79d | 225 | } |
1da177e4 | 226 | #ifndef CONFIG_XIP_KERNEL |
1604d79d | 227 | .exit.data : { |
a9ad21fe | 228 | ARM_EXIT_KEEP(EXIT_DATA) |
1da177e4 | 229 | } |
1604d79d | 230 | #endif |
1da177e4 | 231 | |
9973290c | 232 | #ifdef CONFIG_SMP |
f0d5375e | 233 | PERCPU_SECTION(L1_CACHE_BYTES) |
9973290c | 234 | #endif |
78d7530a | 235 | |
1da177e4 LT |
236 | #ifdef CONFIG_XIP_KERNEL |
237 | __data_loc = ALIGN(4); /* location in binary */ | |
9d4f13e5 | 238 | . = PAGE_OFFSET + TEXT_OFFSET; |
1da177e4 | 239 | #else |
1e6b4811 KC |
240 | #ifdef CONFIG_ARM_KERNMEM_PERMS |
241 | . = ALIGN(1<<SECTION_SHIFT); | |
1da177e4 | 242 | #else |
4f7a1812 | 243 | . = ALIGN(THREAD_SIZE); |
1e6b4811 | 244 | #endif |
562c85ca | 245 | __init_end = .; |
1da177e4 LT |
246 | __data_loc = .; |
247 | #endif | |
248 | ||
249 | .data : AT(__data_loc) { | |
37efe642 | 250 | _data = .; /* address in memory */ |
8c7e6574 | 251 | _sdata = .; |
1da177e4 LT |
252 | |
253 | /* | |
254 | * first, the init task union, aligned | |
255 | * to an 8192 byte boundary. | |
256 | */ | |
78d7530a | 257 | INIT_TASK_DATA(THREAD_SIZE) |
1da177e4 LT |
258 | |
259 | #ifdef CONFIG_XIP_KERNEL | |
f6430a93 | 260 | . = ALIGN(PAGE_SIZE); |
1da177e4 | 261 | __init_begin = .; |
01ba2bdc | 262 | INIT_DATA |
a9ad21fe | 263 | ARM_EXIT_KEEP(EXIT_DATA) |
f6430a93 | 264 | . = ALIGN(PAGE_SIZE); |
1da177e4 LT |
265 | __init_end = .; |
266 | #endif | |
267 | ||
78d7530a | 268 | NOSAVE_DATA |
f0d5375e WD |
269 | CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES) |
270 | READ_MOSTLY_DATA(L1_CACHE_BYTES) | |
1da177e4 LT |
271 | |
272 | /* | |
273 | * and the usual data section | |
274 | */ | |
ca967258 | 275 | DATA_DATA |
1da177e4 LT |
276 | CONSTRUCTORS |
277 | ||
278 | _edata = .; | |
279 | } | |
e98ff7f6 | 280 | _edata_loc = __data_loc + SIZEOF(.data); |
1da177e4 | 281 | |
bc581770 LW |
282 | #ifdef CONFIG_HAVE_TCM |
283 | /* | |
284 | * We align everything to a page boundary so we can | |
285 | * free it after init has commenced and TCM contents have | |
286 | * been copied to its destination. | |
287 | */ | |
288 | .tcm_start : { | |
289 | . = ALIGN(PAGE_SIZE); | |
290 | __tcm_start = .; | |
291 | __itcm_start = .; | |
292 | } | |
293 | ||
294 | /* | |
295 | * Link these to the ITCM RAM | |
296 | * Put VMA to the TCM address and LMA to the common RAM | |
297 | * and we'll upload the contents from RAM to TCM and free | |
298 | * the used RAM after that. | |
299 | */ | |
300 | .text_itcm ITCM_OFFSET : AT(__itcm_start) | |
301 | { | |
302 | __sitcm_text = .; | |
303 | *(.tcm.text) | |
304 | *(.tcm.rodata) | |
305 | . = ALIGN(4); | |
306 | __eitcm_text = .; | |
307 | } | |
308 | ||
309 | /* | |
310 | * Reset the dot pointer, this is needed to create the | |
311 | * relative __dtcm_start below (to be used as extern in code). | |
312 | */ | |
313 | . = ADDR(.tcm_start) + SIZEOF(.tcm_start) + SIZEOF(.text_itcm); | |
314 | ||
315 | .dtcm_start : { | |
316 | __dtcm_start = .; | |
317 | } | |
318 | ||
319 | /* TODO: add remainder of ITCM as well, that can be used for data! */ | |
320 | .data_dtcm DTCM_OFFSET : AT(__dtcm_start) | |
321 | { | |
322 | . = ALIGN(4); | |
323 | __sdtcm_data = .; | |
324 | *(.tcm.data) | |
325 | . = ALIGN(4); | |
326 | __edtcm_data = .; | |
327 | } | |
328 | ||
329 | /* Reset the dot pointer or the linker gets confused */ | |
330 | . = ADDR(.dtcm_start) + SIZEOF(.data_dtcm); | |
331 | ||
332 | /* End marker for freeing TCM copy in linked object */ | |
333 | .tcm_end : AT(ADDR(.dtcm_start) + SIZEOF(.data_dtcm)){ | |
334 | . = ALIGN(PAGE_SIZE); | |
335 | __tcm_end = .; | |
336 | } | |
337 | #endif | |
338 | ||
78d7530a NE |
339 | BSS_SECTION(0, 0, 0) |
340 | _end = .; | |
341 | ||
342 | STABS_DEBUG | |
1da177e4 LT |
343 | } |
344 | ||
728f5c07 RK |
345 | /* |
346 | * These must never be empty | |
347 | * If you have to comment these two assert statements out, your | |
348 | * binutils is too old (for other reasons as well) | |
349 | */ | |
1da177e4 LT |
350 | ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support") |
351 | ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined") | |
06f75a1f | 352 | |
0394e1f6 | 353 | /* |
06f75a1f AB |
354 | * The HYP init code can't be more than a page long, |
355 | * and should not cross a page boundary. | |
0394e1f6 MZ |
356 | * The above comment applies as well. |
357 | */ | |
12eb3e83 | 358 | ASSERT(__hyp_idmap_text_end - (__hyp_idmap_text_start & PAGE_MASK) <= PAGE_SIZE, |
06f75a1f | 359 | "HYP init code too big or misaligned") |