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