Merge to Fedora kernel-2.6.18-1.2224_FC5 patched with stable patch-2.6.18.1-vs2.0...
[linux-2.6.git] / arch / xtensa / kernel / vmlinux.lds.S
1 /*
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
19 #define _NOCLANGUAGE
20 #include <xtensa/config/core.h>
21 #include <xtensa/config/system.h>
22 OUTPUT_ARCH(xtensa)
23 ENTRY(_start)
24
25 #if XCHAL_MEMORY_ORDER == XTHAL_BIGENDIAN
26 jiffies = jiffies_64 + 4;
27 #else
28 jiffies = jiffies_64;
29 #endif
30
31 #define KERNELOFFSET 0x1000
32
33 /* Note: In the following macros, it would be nice to specify only the
34    vector name and section kind and construct "sym" and "section" using
35    CPP concatenation, but that does not work reliably.  Concatenating a
36    string with "." produces an invalid token.  CPP will not print a
37    warning because it thinks this is an assembly file, but it leaves
38    them as multiple tokens and there may or may not be whitespace
39    between them.  */
40
41 /* Macro for a relocation entry */
42
43 #define RELOCATE_ENTRY(sym, section)            \
44         LONG(sym ## _start);                    \
45         LONG(sym ## _end);                      \
46         LONG(LOADADDR(section))
47
48 /* Macro to define a section for a vector.
49  *
50  * Use of the MIN function catches the types of errors illustrated in
51  * the following example:
52  *
53  * Assume the section .DoubleExceptionVector.literal is completely
54  * full.  Then a programmer adds code to .DoubleExceptionVector.text
55  * that produces another literal.  The final literal position will
56  * overlay onto the first word of the adjacent code section
57  * .DoubleExceptionVector.text.  (In practice, the literals will
58  * overwrite the code, and the first few instructions will be
59  * garbage.)
60  */
61
62 #define SECTION_VECTOR(sym, section, addr, max_prevsec_size, prevsec)       \
63   section addr : AT((MIN(LOADADDR(prevsec) + max_prevsec_size,              \
64                          LOADADDR(prevsec) + SIZEOF(prevsec)) + 3) & ~ 3)   \
65   {                                                                         \
66     . = ALIGN(4);                                                           \
67     sym ## _start = ABSOLUTE(.);                                            \
68     *(section)                                                              \
69     sym ## _end = ABSOLUTE(.);                                              \
70   }
71
72 /*
73  *  Mapping of input sections to output sections when linking.
74  */
75
76 SECTIONS
77 {
78   . = XCHAL_KSEG_CACHED_VADDR + KERNELOFFSET;
79   /* .text section */
80
81   _text = .;
82   _stext = .;
83   _ftext = .;
84
85   .text :
86   {
87     /* The .head.text section must be the first section! */
88     *(.head.text)
89     *(.literal .text)
90     *(.srom.text)
91     VMLINUX_SYMBOL(__sched_text_start) = .;
92     *(.sched.literal .sched.text)
93     VMLINUX_SYMBOL(__sched_text_end) = .;
94     VMLINUX_SYMBOL(__lock_text_start) = .;
95     *(.spinlock.literal .spinlock.text)
96     VMLINUX_SYMBOL(__lock_text_end) = .;
97
98   }
99   _etext = .;
100
101   . = ALIGN(16);
102
103   RODATA
104
105   /*  Relocation table */
106
107   . = ALIGN(16);
108   __boot_reloc_table_start = ABSOLUTE(.);
109
110   __relocate : {
111
112     RELOCATE_ENTRY(_WindowVectors_text,
113                    .WindowVectors.text);
114 #if 0
115     RELOCATE_ENTRY(_KernelExceptionVector_literal,
116                    .KernelExceptionVector.literal);
117 #endif
118     RELOCATE_ENTRY(_KernelExceptionVector_text,
119                    .KernelExceptionVector.text);
120 #if 0
121     RELOCATE_ENTRY(_UserExceptionVector_literal,
122                    .UserExceptionVector.literal);
123 #endif
124     RELOCATE_ENTRY(_UserExceptionVector_text,
125                    .UserExceptionVector.text);
126     RELOCATE_ENTRY(_DoubleExceptionVector_literal,
127                    .DoubleExceptionVector.literal);
128     RELOCATE_ENTRY(_DoubleExceptionVector_text,
129                    .DoubleExceptionVector.text);
130   }
131   __boot_reloc_table_end = ABSOLUTE(.) ;
132
133   .fixup   : { *(.fixup) }
134
135   . = ALIGN(16);
136
137   __ex_table : {
138     __start___ex_table = .;
139     *(__ex_table)
140     __stop___ex_table = .;
141   }
142
143   /* Data section */
144
145   . = ALIGN(XCHAL_ICACHE_LINESIZE);
146   _fdata = .;
147   .data :
148   {
149     *(.data) CONSTRUCTORS
150     . = ALIGN(XCHAL_ICACHE_LINESIZE);
151     *(.data.cacheline_aligned)
152   }
153
154   _edata = .;
155
156   /* The initial task */
157   . = ALIGN(8192);
158   .data.init_task : { *(.data.init_task) }
159
160   /* Initialization code and data: */
161
162   . = ALIGN(1<<XCHAL_MMU_MIN_PTE_PAGE_SIZE);
163   __init_begin = .;
164   .init.text : {
165         _sinittext = .;
166         *(.init.literal) *(.init.text)
167         _einittext = .;
168   }
169
170   .init.data :
171   {
172     *(.init.data)
173     . = ALIGN(0x4);
174     __tagtable_begin = .;
175     *(.taglist)
176     __tagtable_end = .;
177   }
178
179   . = ALIGN(XCHAL_ICACHE_LINESIZE);
180
181   __setup_start = .;
182   .init.setup : { *(.init.setup) }
183   __setup_end = .;
184
185   __initcall_start = .;
186   .initcall.init : {
187         *(.initcall1.init)
188         *(.initcall2.init)
189         *(.initcall3.init)
190         *(.initcall4.init)
191         *(.initcall5.init)
192         *(.initcall6.init)
193         *(.initcall7.init)
194   }
195   __initcall_end = .;
196
197   __con_initcall_start = .;
198   .con_initcall.init : { *(.con_initcall.init) }
199   __con_initcall_end = .;
200
201   SECURITY_INIT
202
203   . = ALIGN(4);
204
205   __start___ftr_fixup = .;
206   __ftr_fixup : { *(__ftr_fixup) }
207   __stop___ftr_fixup = .;
208
209   . = ALIGN(32);
210   __per_cpu_start = .;
211   .data.percpu  : { *(.data.percpu) }
212   __per_cpu_end = .;
213
214   . = ALIGN(4096);
215   __initramfs_start =.;
216   .init.ramfs : { *(.init.ramfs) }
217   __initramfs_end = .;
218
219   /* We need this dummy segment here */
220
221   . = ALIGN(4);
222   .dummy : { LONG(0) }
223
224   /* The vectors are relocated to the real position at startup time */
225
226   SECTION_VECTOR (_WindowVectors_text,
227                   .WindowVectors.text,
228                   XCHAL_WINDOW_VECTORS_VADDR, 4,
229                   .dummy)
230   SECTION_VECTOR (_DebugInterruptVector_literal,
231                   .DebugInterruptVector.literal,
232                   XCHAL_INTLEVEL_VECTOR_VADDR(XCHAL_DEBUGLEVEL) - 4,
233                   SIZEOF(.WindowVectors.text),
234                   .WindowVectors.text)
235   SECTION_VECTOR (_DebugInterruptVector_text,
236                   .DebugInterruptVector.text,
237                   XCHAL_INTLEVEL_VECTOR_VADDR(XCHAL_DEBUGLEVEL),
238                   4,
239                   .DebugInterruptVector.literal)
240   SECTION_VECTOR (_KernelExceptionVector_literal,
241                   .KernelExceptionVector.literal,
242                   XCHAL_KERNELEXC_VECTOR_VADDR - 4,
243                   SIZEOF(.DebugInterruptVector.text),
244                   .DebugInterruptVector.text)
245   SECTION_VECTOR (_KernelExceptionVector_text,
246                   .KernelExceptionVector.text,
247                   XCHAL_KERNELEXC_VECTOR_VADDR,
248                   4,
249                   .KernelExceptionVector.literal)
250   SECTION_VECTOR (_UserExceptionVector_literal,
251                   .UserExceptionVector.literal,
252                   XCHAL_USEREXC_VECTOR_VADDR - 4,
253                   SIZEOF(.KernelExceptionVector.text),
254                   .KernelExceptionVector.text)
255   SECTION_VECTOR (_UserExceptionVector_text,
256                   .UserExceptionVector.text,
257                   XCHAL_USEREXC_VECTOR_VADDR,
258                   4,
259                   .UserExceptionVector.literal)
260   SECTION_VECTOR (_DoubleExceptionVector_literal,
261                   .DoubleExceptionVector.literal,
262                   XCHAL_DOUBLEEXC_VECTOR_VADDR - 16,
263                   SIZEOF(.UserExceptionVector.text),
264                   .UserExceptionVector.text)
265   SECTION_VECTOR (_DoubleExceptionVector_text,
266                   .DoubleExceptionVector.text,
267                   XCHAL_DOUBLEEXC_VECTOR_VADDR,
268                   32,
269                   .DoubleExceptionVector.literal)
270
271   . = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3;
272   . = ALIGN(1<<XCHAL_MMU_MIN_PTE_PAGE_SIZE);
273
274   __init_end = .;
275
276   . = ALIGN(8192);
277
278   /* BSS section */
279   _bss_start = .;
280   .sbss : { *(.sbss) *(.scommon) }
281   .bss : { *(COMMON) *(.bss) }
282   _bss_end = .;
283   _end = .;
284
285   /* only used by the boot loader  */
286
287   . = ALIGN(0x10);
288   .bootstrap : { *(.bootstrap.literal .bootstrap.text .bootstrap.data) }
289
290   . = ALIGN(0x1000);
291   __initrd_start = .;
292   .initrd : { *(.initrd) }
293   __initrd_end = .;
294
295   .ResetVector.text XCHAL_RESET_VECTOR_VADDR :
296   {
297     *(.ResetVector.text)
298   }
299
300
301   /* Sections to be discarded */
302   /DISCARD/ :
303   {
304         *(.text.exit)
305         *(.text.exit.literal)
306         *(.data.exit)
307         *(.exitcall.exit)
308   }
309
310
311   .debug  0 :  { *(.debug) }
312   .line  0 :  { *(.line) }
313   .debug_srcinfo  0 :  { *(.debug_srcinfo) }
314   .debug_sfnames  0 :  { *(.debug_sfnames) }
315   .debug_aranges  0 :  { *(.debug_aranges) }
316   .debug_pubnames  0 :  { *(.debug_pubnames) }
317   .debug_info  0 :  { *(.debug_info) }
318   .debug_abbrev  0 :  { *(.debug_abbrev) }
319   .debug_line  0 :  { *(.debug_line) }
320   .debug_frame  0 :  { *(.debug_frame) }
321   .debug_str  0 :  { *(.debug_str) }
322   .debug_loc  0 :  { *(.debug_loc) }
323   .debug_macinfo  0 :  { *(.debug_macinfo) }
324   .debug_weaknames  0 :  { *(.debug_weaknames) }
325   .debug_funcnames  0 :  { *(.debug_funcnames) }
326   .debug_typenames  0 :  { *(.debug_typenames) }
327   .debug_varnames  0 :  { *(.debug_varnames) }
328
329   .xt.insn 0 :
330   {
331     *(.xt.insn)
332     *(.gnu.linkonce.x*)
333   }
334
335   .xt.lit 0 :
336   {
337     *(.xt.lit)
338     *(.gnu.linkonce.p*)
339   }
340 }