blob: a36c104c3a5295a05e89a0ef1eaf1c0d27b8cfd1 [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)
87 *(.literal .text)
88 *(.srom.text)
89 VMLINUX_SYMBOL(__sched_text_start) = .;
Chris Zankel813e6782005-07-12 13:58:25 -070090 *(.sched.literal .sched.text)
Chris Zankel5a0015d2005-06-23 22:01:16 -070091 VMLINUX_SYMBOL(__sched_text_end) = .;
92 VMLINUX_SYMBOL(__lock_text_start) = .;
Chris Zankel813e6782005-07-12 13:58:25 -070093 *(.spinlock.literal .spinlock.text)
Chris Zankel5a0015d2005-06-23 22:01:16 -070094 VMLINUX_SYMBOL(__lock_text_end) = .;
95
96 }
97 _etext = .;
98
99 . = ALIGN(16);
100
101 RODATA
102
103 /* Relocation table */
104
105 . = ALIGN(16);
106 __boot_reloc_table_start = ABSOLUTE(.);
107
108 __relocate : {
109
110 RELOCATE_ENTRY(_WindowVectors_text,
111 .WindowVectors.text);
112#if 0
113 RELOCATE_ENTRY(_KernelExceptionVector_literal,
114 .KernelExceptionVector.literal);
115#endif
116 RELOCATE_ENTRY(_KernelExceptionVector_text,
117 .KernelExceptionVector.text);
118#if 0
119 RELOCATE_ENTRY(_UserExceptionVector_literal,
120 .UserExceptionVector.literal);
121#endif
122 RELOCATE_ENTRY(_UserExceptionVector_text,
123 .UserExceptionVector.text);
124 RELOCATE_ENTRY(_DoubleExceptionVector_literal,
125 .DoubleExceptionVector.literal);
126 RELOCATE_ENTRY(_DoubleExceptionVector_text,
127 .DoubleExceptionVector.text);
128 }
129 __boot_reloc_table_end = ABSOLUTE(.) ;
130
131 .fixup : { *(.fixup) }
132
133 . = ALIGN(16);
134
135 __ex_table : {
136 __start___ex_table = .;
137 *(__ex_table)
138 __stop___ex_table = .;
139 }
140
141 /* Data section */
142
143 . = ALIGN(XCHAL_ICACHE_LINESIZE);
144 _fdata = .;
145 .data :
146 {
147 *(.data) CONSTRUCTORS
148 . = ALIGN(XCHAL_ICACHE_LINESIZE);
149 *(.data.cacheline_aligned)
150 }
151
152 _edata = .;
153
154 /* The initial task */
155 . = ALIGN(8192);
156 .data.init_task : { *(.data.init_task) }
157
158 /* Initialization code and data: */
159
Chris Zankel173d6682006-12-10 02:18:48 -0800160 . = ALIGN(1 << 12);
Chris Zankel5a0015d2005-06-23 22:01:16 -0700161 __init_begin = .;
162 .init.text : {
163 _sinittext = .;
Chris Zankel813e6782005-07-12 13:58:25 -0700164 *(.init.literal) *(.init.text)
Chris Zankel5a0015d2005-06-23 22:01:16 -0700165 _einittext = .;
166 }
167
168 .init.data :
169 {
170 *(.init.data)
171 . = ALIGN(0x4);
172 __tagtable_begin = .;
173 *(.taglist)
174 __tagtable_end = .;
175 }
176
177 . = ALIGN(XCHAL_ICACHE_LINESIZE);
178
179 __setup_start = .;
180 .init.setup : { *(.init.setup) }
181 __setup_end = .;
182
183 __initcall_start = .;
184 .initcall.init : {
Andrew Morton61ce1ef2006-10-27 11:41:44 -0700185 INITCALLS
Chris Zankel5a0015d2005-06-23 22:01:16 -0700186 }
187 __initcall_end = .;
188
189 __con_initcall_start = .;
190 .con_initcall.init : { *(.con_initcall.init) }
191 __con_initcall_end = .;
192
193 SECURITY_INIT
194
195 . = ALIGN(4);
196
197 __start___ftr_fixup = .;
198 __ftr_fixup : { *(__ftr_fixup) }
199 __stop___ftr_fixup = .;
200
201 . = ALIGN(32);
202 __per_cpu_start = .;
203 .data.percpu : { *(.data.percpu) }
204 __per_cpu_end = .;
205
206 . = ALIGN(4096);
207 __initramfs_start =.;
208 .init.ramfs : { *(.init.ramfs) }
209 __initramfs_end = .;
210
211 /* We need this dummy segment here */
212
213 . = ALIGN(4);
214 .dummy : { LONG(0) }
215
216 /* The vectors are relocated to the real position at startup time */
217
218 SECTION_VECTOR (_WindowVectors_text,
219 .WindowVectors.text,
220 XCHAL_WINDOW_VECTORS_VADDR, 4,
221 .dummy)
222 SECTION_VECTOR (_DebugInterruptVector_literal,
223 .DebugInterruptVector.literal,
Chris Zankel173d6682006-12-10 02:18:48 -0800224 XCHAL_DEBUG_VECTOR_VADDR - 4,
Chris Zankel5a0015d2005-06-23 22:01:16 -0700225 SIZEOF(.WindowVectors.text),
226 .WindowVectors.text)
227 SECTION_VECTOR (_DebugInterruptVector_text,
228 .DebugInterruptVector.text,
Chris Zankel173d6682006-12-10 02:18:48 -0800229 XCHAL_DEBUG_VECTOR_VADDR,
Chris Zankel5a0015d2005-06-23 22:01:16 -0700230 4,
231 .DebugInterruptVector.literal)
232 SECTION_VECTOR (_KernelExceptionVector_literal,
233 .KernelExceptionVector.literal,
Chris Zankel173d6682006-12-10 02:18:48 -0800234 XCHAL_KERNEL_VECTOR_VADDR - 4,
Chris Zankel5a0015d2005-06-23 22:01:16 -0700235 SIZEOF(.DebugInterruptVector.text),
236 .DebugInterruptVector.text)
237 SECTION_VECTOR (_KernelExceptionVector_text,
238 .KernelExceptionVector.text,
Chris Zankel173d6682006-12-10 02:18:48 -0800239 XCHAL_KERNEL_VECTOR_VADDR,
Chris Zankel5a0015d2005-06-23 22:01:16 -0700240 4,
241 .KernelExceptionVector.literal)
242 SECTION_VECTOR (_UserExceptionVector_literal,
243 .UserExceptionVector.literal,
Chris Zankel173d6682006-12-10 02:18:48 -0800244 XCHAL_USER_VECTOR_VADDR - 4,
Chris Zankel5a0015d2005-06-23 22:01:16 -0700245 SIZEOF(.KernelExceptionVector.text),
246 .KernelExceptionVector.text)
247 SECTION_VECTOR (_UserExceptionVector_text,
248 .UserExceptionVector.text,
Chris Zankel173d6682006-12-10 02:18:48 -0800249 XCHAL_USER_VECTOR_VADDR,
Chris Zankel5a0015d2005-06-23 22:01:16 -0700250 4,
251 .UserExceptionVector.literal)
252 SECTION_VECTOR (_DoubleExceptionVector_literal,
253 .DoubleExceptionVector.literal,
254 XCHAL_DOUBLEEXC_VECTOR_VADDR - 16,
255 SIZEOF(.UserExceptionVector.text),
256 .UserExceptionVector.text)
257 SECTION_VECTOR (_DoubleExceptionVector_text,
258 .DoubleExceptionVector.text,
259 XCHAL_DOUBLEEXC_VECTOR_VADDR,
260 32,
261 .DoubleExceptionVector.literal)
262
263 . = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3;
Chris Zankel173d6682006-12-10 02:18:48 -0800264 . = ALIGN(1 << 12);
Chris Zankel5a0015d2005-06-23 22:01:16 -0700265
266 __init_end = .;
267
268 . = ALIGN(8192);
269
270 /* BSS section */
271 _bss_start = .;
272 .sbss : { *(.sbss) *(.scommon) }
273 .bss : { *(COMMON) *(.bss) }
274 _bss_end = .;
275 _end = .;
276
277 /* only used by the boot loader */
278
279 . = ALIGN(0x10);
280 .bootstrap : { *(.bootstrap.literal .bootstrap.text .bootstrap.data) }
281
282 . = ALIGN(0x1000);
283 __initrd_start = .;
284 .initrd : { *(.initrd) }
285 __initrd_end = .;
286
287 .ResetVector.text XCHAL_RESET_VECTOR_VADDR :
288 {
289 *(.ResetVector.text)
290 }
291
292
293 /* Sections to be discarded */
294 /DISCARD/ :
295 {
296 *(.text.exit)
297 *(.text.exit.literal)
298 *(.data.exit)
299 *(.exitcall.exit)
300 }
301
302
303 .debug 0 : { *(.debug) }
304 .line 0 : { *(.line) }
305 .debug_srcinfo 0 : { *(.debug_srcinfo) }
306 .debug_sfnames 0 : { *(.debug_sfnames) }
307 .debug_aranges 0 : { *(.debug_aranges) }
308 .debug_pubnames 0 : { *(.debug_pubnames) }
309 .debug_info 0 : { *(.debug_info) }
310 .debug_abbrev 0 : { *(.debug_abbrev) }
311 .debug_line 0 : { *(.debug_line) }
312 .debug_frame 0 : { *(.debug_frame) }
313 .debug_str 0 : { *(.debug_str) }
314 .debug_loc 0 : { *(.debug_loc) }
315 .debug_macinfo 0 : { *(.debug_macinfo) }
316 .debug_weaknames 0 : { *(.debug_weaknames) }
317 .debug_funcnames 0 : { *(.debug_funcnames) }
318 .debug_typenames 0 : { *(.debug_typenames) }
319 .debug_varnames 0 : { *(.debug_varnames) }
320
321 .xt.insn 0 :
322 {
323 *(.xt.insn)
324 *(.gnu.linkonce.x*)
325 }
326
327 .xt.lit 0 :
328 {
329 *(.xt.lit)
330 *(.gnu.linkonce.p*)
331 }
332}