blob: 065d35de0e01739b914e2ff6192bd13d1c561f61 [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 = .;
Russell Kingf00ec482010-09-04 10:47:48 +010043#ifdef CONFIG_SMP_ON_UP
44 __smpalt_begin = .;
45 *(.alt.smp.init)
46 __smpalt_end = .;
47#endif
Nelson Elhage78d75302009-10-02 16:32:47 -040048
49 INIT_SETUP(16)
50
Nelson Elhage78d75302009-10-02 16:32:47 -040051 INIT_CALLS
52 CON_INITCALL
53 SECURITY_INITCALL
54 INIT_RAM_FS
55
Linus Torvalds1da177e2005-04-16 15:20:36 -070056#ifndef CONFIG_XIP_KERNEL
57 __init_begin = _stext;
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +010058 INIT_DATA
Linus Torvalds1da177e2005-04-16 15:20:36 -070059#endif
60 }
61
Nelson Elhage78d75302009-10-02 16:32:47 -040062 PERCPU(PAGE_SIZE)
63
64#ifndef CONFIG_XIP_KERNEL
65 . = ALIGN(PAGE_SIZE);
66 __init_end = .;
67#endif
68
Alan Jenkinse3f28c12009-11-07 21:03:52 +000069 /*
70 * unwind exit sections must be discarded before the rest of the
71 * unwind sections get included.
72 */
73 /DISCARD/ : {
Catalin Marinasbff595c2009-02-16 11:41:36 +010074 *(.ARM.exidx.exit.text)
75 *(.ARM.extab.exit.text)
Catalin Marinas74361272009-06-19 16:39:29 +010076#ifndef CONFIG_HOTPLUG_CPU
77 *(.ARM.exidx.cpuexit.text)
78 *(.ARM.extab.cpuexit.text)
79#endif
80#ifndef CONFIG_HOTPLUG
81 *(.ARM.exidx.devexit.text)
82 *(.ARM.extab.devexit.text)
83#endif
Russell King9641c7c2006-06-21 20:38:17 +010084#ifndef CONFIG_MMU
85 *(.fixup)
86 *(__ex_table)
87#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070088 }
89
90 .text : { /* Real text segment */
91 _text = .; /* Text and read-only data */
Russell King7ab3f8d2007-03-02 15:01:36 +000092 __exception_text_start = .;
93 *(.exception.text)
94 __exception_text_end = .;
Sam Ravnborg76647092007-05-13 00:31:33 +020095 TEXT_TEXT
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 SCHED_TEXT
97 LOCK_TEXT
Nicolas Pitre785d3cd2007-12-03 15:27:56 -050098 KPROBES_TEXT
Russell King9641c7c2006-06-21 20:38:17 +010099#ifdef CONFIG_MMU
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 *(.fixup)
Russell King9641c7c2006-06-21 20:38:17 +0100101#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 *(.gnu.warning)
103 *(.rodata)
104 *(.rodata.*)
105 *(.glue_7)
106 *(.glue_7t)
107 *(.got) /* Global offset table */
108 }
109
Linus Walleijf6430a92009-06-24 23:38:56 +0100110 RO_DATA(PAGE_SIZE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111
Catalin Marinasbff595c2009-02-16 11:41:36 +0100112#ifdef CONFIG_ARM_UNWIND
113 /*
114 * Stack unwinding tables
115 */
116 . = ALIGN(8);
117 .ARM.unwind_idx : {
118 __start_unwind_idx = .;
119 *(.ARM.exidx*)
120 __stop_unwind_idx = .;
121 }
122 .ARM.unwind_tab : {
123 __start_unwind_tab = .;
124 *(.ARM.extab*)
125 __stop_unwind_tab = .;
126 }
127#endif
128
Russell King74b0ec02010-10-01 14:26:56 +0100129 _etext = .; /* End of text and rodata section */
130
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131#ifdef CONFIG_XIP_KERNEL
132 __data_loc = ALIGN(4); /* location in binary */
Russell King9d4f13e2006-01-03 17:28:33 +0000133 . = PAGE_OFFSET + TEXT_OFFSET;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134#else
Russell King4f7a1812005-05-05 13:11:00 +0100135 . = ALIGN(THREAD_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136 __data_loc = .;
137#endif
138
139 .data : AT(__data_loc) {
Russell King37efe642008-12-01 11:53:07 +0000140 _data = .; /* address in memory */
Catalin Marinas8c7e6572009-05-30 14:00:17 +0100141 _sdata = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142
143 /*
144 * first, the init task union, aligned
145 * to an 8192 byte boundary.
146 */
Nelson Elhage78d75302009-10-02 16:32:47 -0400147 INIT_TASK_DATA(THREAD_SIZE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148
149#ifdef CONFIG_XIP_KERNEL
Linus Walleijf6430a92009-06-24 23:38:56 +0100150 . = ALIGN(PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 __init_begin = .;
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100152 INIT_DATA
Linus Walleijf6430a92009-06-24 23:38:56 +0100153 . = ALIGN(PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154 __init_end = .;
155#endif
156
Nelson Elhage78d75302009-10-02 16:32:47 -0400157 NOSAVE_DATA
158 CACHELINE_ALIGNED_DATA(32)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159
160 /*
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100161 * The exception fixup table (might need resorting at runtime)
162 */
163 . = ALIGN(32);
164 __start___ex_table = .;
Russell King9641c7c2006-06-21 20:38:17 +0100165#ifdef CONFIG_MMU
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100166 *(__ex_table)
Russell King9641c7c2006-06-21 20:38:17 +0100167#endif
Nicolas Pitre13b1f642005-10-13 22:04:37 +0100168 __stop___ex_table = .;
169
170 /*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171 * and the usual data section
172 */
Sam Ravnborgca967252007-05-17 13:38:44 +0200173 DATA_DATA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174 CONSTRUCTORS
175
176 _edata = .;
177 }
Nicolas Pitree98ff7f2007-02-22 16:18:09 +0100178 _edata_loc = __data_loc + SIZEOF(.data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179
Linus Walleijbc581772009-09-15 17:30:37 +0100180#ifdef CONFIG_HAVE_TCM
181 /*
182 * We align everything to a page boundary so we can
183 * free it after init has commenced and TCM contents have
184 * been copied to its destination.
185 */
186 .tcm_start : {
187 . = ALIGN(PAGE_SIZE);
188 __tcm_start = .;
189 __itcm_start = .;
190 }
191
192 /*
193 * Link these to the ITCM RAM
194 * Put VMA to the TCM address and LMA to the common RAM
195 * and we'll upload the contents from RAM to TCM and free
196 * the used RAM after that.
197 */
198 .text_itcm ITCM_OFFSET : AT(__itcm_start)
199 {
200 __sitcm_text = .;
201 *(.tcm.text)
202 *(.tcm.rodata)
203 . = ALIGN(4);
204 __eitcm_text = .;
205 }
206
207 /*
208 * Reset the dot pointer, this is needed to create the
209 * relative __dtcm_start below (to be used as extern in code).
210 */
211 . = ADDR(.tcm_start) + SIZEOF(.tcm_start) + SIZEOF(.text_itcm);
212
213 .dtcm_start : {
214 __dtcm_start = .;
215 }
216
217 /* TODO: add remainder of ITCM as well, that can be used for data! */
218 .data_dtcm DTCM_OFFSET : AT(__dtcm_start)
219 {
220 . = ALIGN(4);
221 __sdtcm_data = .;
222 *(.tcm.data)
223 . = ALIGN(4);
224 __edtcm_data = .;
225 }
226
227 /* Reset the dot pointer or the linker gets confused */
228 . = ADDR(.dtcm_start) + SIZEOF(.data_dtcm);
229
230 /* End marker for freeing TCM copy in linked object */
231 .tcm_end : AT(ADDR(.dtcm_start) + SIZEOF(.data_dtcm)){
232 . = ALIGN(PAGE_SIZE);
233 __tcm_end = .;
234 }
235#endif
236
Nelson Elhage78d75302009-10-02 16:32:47 -0400237 BSS_SECTION(0, 0, 0)
238 _end = .;
239
240 STABS_DEBUG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 .comment 0 : { *(.comment) }
Alan Jenkinse3f28c12009-11-07 21:03:52 +0000242
243 /* Default discards */
244 DISCARDS
Russell Kingf00ec482010-09-04 10:47:48 +0100245
246#ifndef CONFIG_SMP_ON_UP
247 /DISCARD/ : {
248 *(.alt.smp.init)
249 }
250#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251}
252
Russell King728f5c02005-11-17 16:43:14 +0000253/*
254 * These must never be empty
255 * If you have to comment these two assert statements out, your
256 * binutils is too old (for other reasons as well)
257 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")
259ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")