blob: 4b717bf48fb78e3ea4906fcc74a6a2b294ea2ca5 [file] [log] [blame]
Chris Zankel5a0015d2005-06-23 22:01:16 -07001/*
2 * arch/xtensa/kernel/vmlinux.lds.S
3 *
4 * Xtensa linker script
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 *
10 * Copyright (C) 2001 - 2005 Tensilica Inc.
11 *
12 * Chris Zankel <chris@zankel.net>
13 * Marc Gauthier <marc@tensilica.com, marc@alumni.uwaterloo.ca>
14 * Joe Taylor <joe@tensilica.com, joetylr@yahoo.com>
15 */
16
17#include <asm-generic/vmlinux.lds.h>
18
Chris Zankel173d6682006-12-10 02:18:48 -080019#include <asm/variant/core.h>
Chris Zankel5a0015d2005-06-23 22:01:16 -070020OUTPUT_ARCH(xtensa)
21ENTRY(_start)
22
Chris Zankel173d6682006-12-10 02:18:48 -080023#ifdef __XTENSA_EB__
Chris Zankel5a0015d2005-06-23 22:01:16 -070024jiffies = jiffies_64 + 4;
25#else
26jiffies = jiffies_64;
27#endif
28
Chris Zankel173d6682006-12-10 02:18:48 -080029#define KERNELOFFSET 0xd0001000
Chris Zankel5a0015d2005-06-23 22:01:16 -070030
31/* Note: In the following macros, it would be nice to specify only the
32 vector name and section kind and construct "sym" and "section" using
33 CPP concatenation, but that does not work reliably. Concatenating a
34 string with "." produces an invalid token. CPP will not print a
35 warning because it thinks this is an assembly file, but it leaves
36 them as multiple tokens and there may or may not be whitespace
37 between them. */
38
39/* Macro for a relocation entry */
40
41#define RELOCATE_ENTRY(sym, section) \
42 LONG(sym ## _start); \
43 LONG(sym ## _end); \
44 LONG(LOADADDR(section))
45
46/* Macro to define a section for a vector.
47 *
48 * Use of the MIN function catches the types of errors illustrated in
49 * the following example:
50 *
51 * Assume the section .DoubleExceptionVector.literal is completely
52 * full. Then a programmer adds code to .DoubleExceptionVector.text
53 * that produces another literal. The final literal position will
54 * overlay onto the first word of the adjacent code section
55 * .DoubleExceptionVector.text. (In practice, the literals will
56 * overwrite the code, and the first few instructions will be
57 * garbage.)
58 */
59
60#define SECTION_VECTOR(sym, section, addr, max_prevsec_size, prevsec) \
61 section addr : AT((MIN(LOADADDR(prevsec) + max_prevsec_size, \
62 LOADADDR(prevsec) + SIZEOF(prevsec)) + 3) & ~ 3) \
63 { \
64 . = ALIGN(4); \
65 sym ## _start = ABSOLUTE(.); \
66 *(section) \
67 sym ## _end = ABSOLUTE(.); \
68 }
69
70/*
71 * Mapping of input sections to output sections when linking.
72 */
73
74SECTIONS
75{
Chris Zankel173d6682006-12-10 02:18:48 -080076 . = KERNELOFFSET;
Chris Zankel5a0015d2005-06-23 22:01:16 -070077 /* .text section */
78
79 _text = .;
80 _stext = .;
81 _ftext = .;
82
83 .text :
84 {
85 /* The .head.text section must be the first section! */
86 *(.head.text)
Chris Zankelde4f6e52007-05-31 17:47:01 -070087 *(.literal .text)
Chris Zankel5a0015d2005-06-23 22:01:16 -070088 VMLINUX_SYMBOL(__sched_text_start) = .;
Chris Zankel813e6782005-07-12 13:58:25 -070089 *(.sched.literal .sched.text)
Chris Zankel5a0015d2005-06-23 22:01:16 -070090 VMLINUX_SYMBOL(__sched_text_end) = .;
91 VMLINUX_SYMBOL(__lock_text_start) = .;
Chris Zankel813e6782005-07-12 13:58:25 -070092 *(.spinlock.literal .spinlock.text)
Chris Zankel5a0015d2005-06-23 22:01:16 -070093 VMLINUX_SYMBOL(__lock_text_end) = .;
94
95 }
96 _etext = .;
Chris Zankelde4f6e52007-05-31 17:47:01 -070097 PROVIDE (etext = .);
Chris Zankel5a0015d2005-06-23 22:01:16 -070098
99 . = ALIGN(16);
100
101 RODATA
102
103 /* Relocation table */
104
Chris Zankel5a0015d2005-06-23 22:01:16 -0700105 .fixup : { *(.fixup) }
106
107 . = ALIGN(16);
108
109 __ex_table : {
110 __start___ex_table = .;
111 *(__ex_table)
112 __stop___ex_table = .;
113 }
114
115 /* Data section */
116
117 . = ALIGN(XCHAL_ICACHE_LINESIZE);
118 _fdata = .;
119 .data :
120 {
Mathieu Desnoyersb8243252007-06-16 22:29:39 -0400121 DATA_DATA
122 CONSTRUCTORS
Chris Zankel5a0015d2005-06-23 22:01:16 -0700123 . = ALIGN(XCHAL_ICACHE_LINESIZE);
124 *(.data.cacheline_aligned)
125 }
126
127 _edata = .;
128
129 /* The initial task */
130 . = ALIGN(8192);
131 .data.init_task : { *(.data.init_task) }
132
133 /* Initialization code and data: */
134
Chris Zankel173d6682006-12-10 02:18:48 -0800135 . = ALIGN(1 << 12);
Chris Zankel5a0015d2005-06-23 22:01:16 -0700136 __init_begin = .;
137 .init.text : {
138 _sinittext = .;
Chris Zankel4f8d98f2008-02-13 16:44:19 -0800139 *(.init.literal) *(.cpuinit.literal)
140 *(.devinit.literal) *(.meminit.literal)
141 INIT_TEXT
Chris Zankel5a0015d2005-06-23 22:01:16 -0700142 _einittext = .;
143 }
144
145 .init.data :
146 {
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100147 INIT_DATA
Chris Zankel5a0015d2005-06-23 22:01:16 -0700148 . = ALIGN(0x4);
149 __tagtable_begin = .;
150 *(.taglist)
151 __tagtable_end = .;
Chris Zankelde4f6e52007-05-31 17:47:01 -0700152
153 . = ALIGN(16);
154 __boot_reloc_table_start = ABSOLUTE(.);
155
156 RELOCATE_ENTRY(_WindowVectors_text,
157 .WindowVectors.text);
158 RELOCATE_ENTRY(_KernelExceptionVector_text,
159 .KernelExceptionVector.text);
160 RELOCATE_ENTRY(_UserExceptionVector_text,
161 .UserExceptionVector.text);
162 RELOCATE_ENTRY(_DoubleExceptionVector_literal,
163 .DoubleExceptionVector.literal);
164 RELOCATE_ENTRY(_DoubleExceptionVector_text,
165 .DoubleExceptionVector.text);
166
167 __boot_reloc_table_end = ABSOLUTE(.) ;
Chris Zankel5a0015d2005-06-23 22:01:16 -0700168 }
169
170 . = ALIGN(XCHAL_ICACHE_LINESIZE);
171
172 __setup_start = .;
173 .init.setup : { *(.init.setup) }
174 __setup_end = .;
175
176 __initcall_start = .;
177 .initcall.init : {
Andrew Morton61ce1ef2006-10-27 11:41:44 -0700178 INITCALLS
Chris Zankel5a0015d2005-06-23 22:01:16 -0700179 }
180 __initcall_end = .;
181
182 __con_initcall_start = .;
183 .con_initcall.init : { *(.con_initcall.init) }
184 __con_initcall_end = .;
185
186 SECURITY_INIT
187
Chris Zankel5a0015d2005-06-23 22:01:16 -0700188
Jean-Paul Saman67d38222007-02-10 01:44:44 -0800189#ifdef CONFIG_BLK_DEV_INITRD
Chris Zankel5a0015d2005-06-23 22:01:16 -0700190 . = ALIGN(4096);
191 __initramfs_start =.;
192 .init.ramfs : { *(.init.ramfs) }
193 __initramfs_end = .;
Jean-Paul Saman67d38222007-02-10 01:44:44 -0800194#endif
Chris Zankel5a0015d2005-06-23 22:01:16 -0700195
Fenghua Yu5fb7dc32007-07-19 01:48:12 -0700196 PERCPU(4096)
Chris Zankelde4f6e52007-05-31 17:47:01 -0700197
198
Chris Zankel5a0015d2005-06-23 22:01:16 -0700199 /* We need this dummy segment here */
200
201 . = ALIGN(4);
202 .dummy : { LONG(0) }
203
204 /* The vectors are relocated to the real position at startup time */
205
206 SECTION_VECTOR (_WindowVectors_text,
207 .WindowVectors.text,
208 XCHAL_WINDOW_VECTORS_VADDR, 4,
209 .dummy)
210 SECTION_VECTOR (_DebugInterruptVector_literal,
211 .DebugInterruptVector.literal,
Chris Zankel173d6682006-12-10 02:18:48 -0800212 XCHAL_DEBUG_VECTOR_VADDR - 4,
Chris Zankel5a0015d2005-06-23 22:01:16 -0700213 SIZEOF(.WindowVectors.text),
214 .WindowVectors.text)
215 SECTION_VECTOR (_DebugInterruptVector_text,
216 .DebugInterruptVector.text,
Chris Zankel173d6682006-12-10 02:18:48 -0800217 XCHAL_DEBUG_VECTOR_VADDR,
Chris Zankel5a0015d2005-06-23 22:01:16 -0700218 4,
219 .DebugInterruptVector.literal)
220 SECTION_VECTOR (_KernelExceptionVector_literal,
221 .KernelExceptionVector.literal,
Chris Zankel173d6682006-12-10 02:18:48 -0800222 XCHAL_KERNEL_VECTOR_VADDR - 4,
Chris Zankel5a0015d2005-06-23 22:01:16 -0700223 SIZEOF(.DebugInterruptVector.text),
224 .DebugInterruptVector.text)
225 SECTION_VECTOR (_KernelExceptionVector_text,
226 .KernelExceptionVector.text,
Chris Zankel173d6682006-12-10 02:18:48 -0800227 XCHAL_KERNEL_VECTOR_VADDR,
Chris Zankel5a0015d2005-06-23 22:01:16 -0700228 4,
229 .KernelExceptionVector.literal)
230 SECTION_VECTOR (_UserExceptionVector_literal,
231 .UserExceptionVector.literal,
Chris Zankel173d6682006-12-10 02:18:48 -0800232 XCHAL_USER_VECTOR_VADDR - 4,
Chris Zankel5a0015d2005-06-23 22:01:16 -0700233 SIZEOF(.KernelExceptionVector.text),
234 .KernelExceptionVector.text)
235 SECTION_VECTOR (_UserExceptionVector_text,
236 .UserExceptionVector.text,
Chris Zankel173d6682006-12-10 02:18:48 -0800237 XCHAL_USER_VECTOR_VADDR,
Chris Zankel5a0015d2005-06-23 22:01:16 -0700238 4,
239 .UserExceptionVector.literal)
240 SECTION_VECTOR (_DoubleExceptionVector_literal,
241 .DoubleExceptionVector.literal,
242 XCHAL_DOUBLEEXC_VECTOR_VADDR - 16,
243 SIZEOF(.UserExceptionVector.text),
244 .UserExceptionVector.text)
245 SECTION_VECTOR (_DoubleExceptionVector_text,
246 .DoubleExceptionVector.text,
247 XCHAL_DOUBLEEXC_VECTOR_VADDR,
248 32,
249 .DoubleExceptionVector.literal)
250
251 . = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3;
Chris Zankel173d6682006-12-10 02:18:48 -0800252 . = ALIGN(1 << 12);
Chris Zankel5a0015d2005-06-23 22:01:16 -0700253
254 __init_end = .;
255
256 . = ALIGN(8192);
257
258 /* BSS section */
259 _bss_start = .;
Chris Zankelde4f6e52007-05-31 17:47:01 -0700260 .bss : { *(.bss.page_aligned) *(.bss) }
Chris Zankel5a0015d2005-06-23 22:01:16 -0700261 _bss_end = .;
Chris Zankelde4f6e52007-05-31 17:47:01 -0700262
Chris Zankel5a0015d2005-06-23 22:01:16 -0700263 _end = .;
264
265 /* only used by the boot loader */
266
267 . = ALIGN(0x10);
268 .bootstrap : { *(.bootstrap.literal .bootstrap.text .bootstrap.data) }
269
270 . = ALIGN(0x1000);
271 __initrd_start = .;
272 .initrd : { *(.initrd) }
273 __initrd_end = .;
274
275 .ResetVector.text XCHAL_RESET_VECTOR_VADDR :
276 {
277 *(.ResetVector.text)
278 }
279
Chris Zankel5a0015d2005-06-23 22:01:16 -0700280 /* Sections to be discarded */
281 /DISCARD/ :
282 {
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100283 *(.exit.literal)
284 EXIT_TEXT
285 EXIT_DATA
Chris Zankel5a0015d2005-06-23 22:01:16 -0700286 *(.exitcall.exit)
287 }
288
Chris Zankelde4f6e52007-05-31 17:47:01 -0700289 .xt.lit : { *(.xt.lit) }
290 .xt.prop : { *(.xt.prop) }
Chris Zankel5a0015d2005-06-23 22:01:16 -0700291
292 .debug 0 : { *(.debug) }
293 .line 0 : { *(.line) }
294 .debug_srcinfo 0 : { *(.debug_srcinfo) }
295 .debug_sfnames 0 : { *(.debug_sfnames) }
296 .debug_aranges 0 : { *(.debug_aranges) }
297 .debug_pubnames 0 : { *(.debug_pubnames) }
298 .debug_info 0 : { *(.debug_info) }
299 .debug_abbrev 0 : { *(.debug_abbrev) }
300 .debug_line 0 : { *(.debug_line) }
301 .debug_frame 0 : { *(.debug_frame) }
302 .debug_str 0 : { *(.debug_str) }
303 .debug_loc 0 : { *(.debug_loc) }
304 .debug_macinfo 0 : { *(.debug_macinfo) }
305 .debug_weaknames 0 : { *(.debug_weaknames) }
306 .debug_funcnames 0 : { *(.debug_funcnames) }
307 .debug_typenames 0 : { *(.debug_typenames) }
308 .debug_varnames 0 : { *(.debug_varnames) }
309
310 .xt.insn 0 :
311 {
312 *(.xt.insn)
313 *(.gnu.linkonce.x*)
314 }
315
316 .xt.lit 0 :
317 {
318 *(.xt.lit)
319 *(.gnu.linkonce.p*)
320 }
321}