GNU Linux-libre 4.4.288-gnu1
[releases.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 - 2008 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 #include <asm/page.h>
19 #include <asm/thread_info.h>
20
21 #include <asm/vectors.h>
22 #include <variant/core.h>
23 #include <platform/hardware.h>
24 OUTPUT_ARCH(xtensa)
25 ENTRY(_start)
26
27 #ifdef __XTENSA_EB__
28 jiffies = jiffies_64 + 4;
29 #else
30 jiffies = jiffies_64;
31 #endif
32
33 #ifndef KERNELOFFSET
34 #define KERNELOFFSET 0xd0003000
35 #endif
36
37 /* Note: In the following macros, it would be nice to specify only the
38    vector name and section kind and construct "sym" and "section" using
39    CPP concatenation, but that does not work reliably.  Concatenating a
40    string with "." produces an invalid token.  CPP will not print a
41    warning because it thinks this is an assembly file, but it leaves
42    them as multiple tokens and there may or may not be whitespace
43    between them.  */
44
45 /* Macro for a relocation entry */
46
47 #define RELOCATE_ENTRY(sym, section)            \
48         LONG(sym ## _start);                    \
49         LONG(sym ## _end);                      \
50         LONG(LOADADDR(section))
51
52 /* Macro to define a section for a vector.
53  *
54  * Use of the MIN function catches the types of errors illustrated in
55  * the following example:
56  *
57  * Assume the section .DoubleExceptionVector.literal is completely
58  * full.  Then a programmer adds code to .DoubleExceptionVector.text
59  * that produces another literal.  The final literal position will
60  * overlay onto the first word of the adjacent code section
61  * .DoubleExceptionVector.text.  (In practice, the literals will
62  * overwrite the code, and the first few instructions will be
63  * garbage.)
64  */
65
66 #define SECTION_VECTOR(sym, section, addr, max_prevsec_size, prevsec)       \
67   section addr : AT((MIN(LOADADDR(prevsec) + max_prevsec_size,              \
68                          LOADADDR(prevsec) + SIZEOF(prevsec)) + 3) & ~ 3)   \
69   {                                                                         \
70     . = ALIGN(4);                                                           \
71     sym ## _start = ABSOLUTE(.);                                            \
72     *(section)                                                              \
73     sym ## _end = ABSOLUTE(.);                                              \
74   }
75
76 /*
77  *  Mapping of input sections to output sections when linking.
78  */
79
80 SECTIONS
81 {
82   . = KERNELOFFSET;
83   /* .text section */
84
85   _text = .;
86   _stext = .;
87
88   .text :
89   {
90     /* The HEAD_TEXT section must be the first section! */
91     HEAD_TEXT
92     TEXT_TEXT
93     VMLINUX_SYMBOL(__sched_text_start) = .;
94     *(.sched.literal .sched.text)
95     VMLINUX_SYMBOL(__sched_text_end) = .;
96     VMLINUX_SYMBOL(__lock_text_start) = .;
97     *(.spinlock.literal .spinlock.text)
98     VMLINUX_SYMBOL(__lock_text_end) = .;
99
100   }
101   _etext = .;
102   PROVIDE (etext = .);
103
104   . = ALIGN(16);
105
106   RODATA
107
108   /*  Relocation table */
109
110   .fixup   : { *(.fixup) }
111
112   EXCEPTION_TABLE(16)
113   NOTES
114   /* Data section */
115
116   _sdata = .;
117   RW_DATA_SECTION(XCHAL_ICACHE_LINESIZE, PAGE_SIZE, THREAD_SIZE)
118   _edata = .;
119
120   /* Initialization code and data: */
121
122   . = ALIGN(PAGE_SIZE);
123   __init_begin = .;
124   INIT_TEXT_SECTION(PAGE_SIZE)
125
126   .init.data :
127   {
128     INIT_DATA
129     . = ALIGN(0x4);
130     __tagtable_begin = .;
131     *(.taglist)
132     __tagtable_end = .;
133
134     . = ALIGN(16);
135     __boot_reloc_table_start = ABSOLUTE(.);
136
137     RELOCATE_ENTRY(_WindowVectors_text,
138                    .WindowVectors.text);
139 #if XCHAL_EXCM_LEVEL >= 2
140     RELOCATE_ENTRY(_Level2InterruptVector_text,
141                    .Level2InterruptVector.text);
142 #endif
143 #if XCHAL_EXCM_LEVEL >= 3
144     RELOCATE_ENTRY(_Level3InterruptVector_text,
145                    .Level3InterruptVector.text);
146 #endif
147 #if XCHAL_EXCM_LEVEL >= 4
148     RELOCATE_ENTRY(_Level4InterruptVector_text,
149                    .Level4InterruptVector.text);
150 #endif
151 #if XCHAL_EXCM_LEVEL >= 5
152     RELOCATE_ENTRY(_Level5InterruptVector_text,
153                    .Level5InterruptVector.text);
154 #endif
155 #if XCHAL_EXCM_LEVEL >= 6
156     RELOCATE_ENTRY(_Level6InterruptVector_text,
157                    .Level6InterruptVector.text);
158 #endif
159     RELOCATE_ENTRY(_KernelExceptionVector_text,
160                    .KernelExceptionVector.text);
161     RELOCATE_ENTRY(_UserExceptionVector_text,
162                    .UserExceptionVector.text);
163     RELOCATE_ENTRY(_DoubleExceptionVector_literal,
164                    .DoubleExceptionVector.literal);
165     RELOCATE_ENTRY(_DoubleExceptionVector_text,
166                    .DoubleExceptionVector.text);
167     RELOCATE_ENTRY(_DebugInterruptVector_text,
168                    .DebugInterruptVector.text);
169 #if defined(CONFIG_SMP)
170     RELOCATE_ENTRY(_SecondaryResetVector_text,
171                    .SecondaryResetVector.text);
172 #endif
173
174   
175     __boot_reloc_table_end = ABSOLUTE(.) ;
176
177     INIT_SETUP(XCHAL_ICACHE_LINESIZE)
178     INIT_CALLS
179     CON_INITCALL
180     SECURITY_INITCALL
181     INIT_RAM_FS
182   }
183
184   PERCPU_SECTION(XCHAL_ICACHE_LINESIZE)
185
186   /* We need this dummy segment here */
187
188   . = ALIGN(4);
189   .dummy : { LONG(0) }
190
191   /* The vectors are relocated to the real position at startup time */
192
193   SECTION_VECTOR (_WindowVectors_text,
194                   .WindowVectors.text,
195                   WINDOW_VECTORS_VADDR, 4,
196                   .dummy)
197   SECTION_VECTOR (_DebugInterruptVector_literal,
198                   .DebugInterruptVector.literal,
199                   DEBUG_VECTOR_VADDR - 4,
200                   SIZEOF(.WindowVectors.text),
201                   .WindowVectors.text)
202   SECTION_VECTOR (_DebugInterruptVector_text,
203                   .DebugInterruptVector.text,
204                   DEBUG_VECTOR_VADDR,
205                   4,
206                   .DebugInterruptVector.literal)
207 #undef LAST
208 #define LAST    .DebugInterruptVector.text
209 #if XCHAL_EXCM_LEVEL >= 2
210   SECTION_VECTOR (_Level2InterruptVector_text,
211                   .Level2InterruptVector.text,
212                   INTLEVEL2_VECTOR_VADDR,
213                   SIZEOF(LAST), LAST)
214 # undef LAST
215 # define LAST   .Level2InterruptVector.text
216 #endif
217 #if XCHAL_EXCM_LEVEL >= 3
218   SECTION_VECTOR (_Level3InterruptVector_text,
219                   .Level3InterruptVector.text,
220                   INTLEVEL3_VECTOR_VADDR,
221                   SIZEOF(LAST), LAST)
222 # undef LAST
223 # define LAST   .Level3InterruptVector.text
224 #endif
225 #if XCHAL_EXCM_LEVEL >= 4
226   SECTION_VECTOR (_Level4InterruptVector_text,
227                   .Level4InterruptVector.text,
228                   INTLEVEL4_VECTOR_VADDR,
229                   SIZEOF(LAST), LAST)
230 # undef LAST
231 # define LAST   .Level4InterruptVector.text
232 #endif
233 #if XCHAL_EXCM_LEVEL >= 5
234   SECTION_VECTOR (_Level5InterruptVector_text,
235                   .Level5InterruptVector.text,
236                   INTLEVEL5_VECTOR_VADDR,
237                   SIZEOF(LAST), LAST)
238 # undef LAST
239 # define LAST   .Level5InterruptVector.text
240 #endif
241 #if XCHAL_EXCM_LEVEL >= 6
242   SECTION_VECTOR (_Level6InterruptVector_text,
243                   .Level6InterruptVector.text,
244                   INTLEVEL6_VECTOR_VADDR,
245                   SIZEOF(LAST), LAST)
246 # undef LAST
247 # define LAST   .Level6InterruptVector.text
248 #endif
249   SECTION_VECTOR (_KernelExceptionVector_literal,
250                   .KernelExceptionVector.literal,
251                   KERNEL_VECTOR_VADDR - 4,
252                   SIZEOF(LAST), LAST)
253 #undef LAST
254   SECTION_VECTOR (_KernelExceptionVector_text,
255                   .KernelExceptionVector.text,
256                   KERNEL_VECTOR_VADDR,
257                   4,
258                   .KernelExceptionVector.literal)
259   SECTION_VECTOR (_UserExceptionVector_literal,
260                   .UserExceptionVector.literal,
261                   USER_VECTOR_VADDR - 4,
262                   SIZEOF(.KernelExceptionVector.text),
263                   .KernelExceptionVector.text)
264   SECTION_VECTOR (_UserExceptionVector_text,
265                   .UserExceptionVector.text,
266                   USER_VECTOR_VADDR,
267                   4,
268                   .UserExceptionVector.literal)
269   SECTION_VECTOR (_DoubleExceptionVector_literal,
270                   .DoubleExceptionVector.literal,
271                   DOUBLEEXC_VECTOR_VADDR - 48,
272                   SIZEOF(.UserExceptionVector.text),
273                   .UserExceptionVector.text)
274   SECTION_VECTOR (_DoubleExceptionVector_text,
275                   .DoubleExceptionVector.text,
276                   DOUBLEEXC_VECTOR_VADDR,
277                   48,
278                   .DoubleExceptionVector.literal)
279
280   . = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3;
281
282 #if defined(CONFIG_SMP)
283
284   SECTION_VECTOR (_SecondaryResetVector_text,
285                   .SecondaryResetVector.text,
286                   RESET_VECTOR1_VADDR,
287                   SIZEOF(.DoubleExceptionVector.text),
288                   .DoubleExceptionVector.text)
289
290   . = LOADADDR(.SecondaryResetVector.text)+SIZEOF(.SecondaryResetVector.text);
291
292 #endif
293
294   . = ALIGN(PAGE_SIZE);
295
296   __init_end = .;
297
298   BSS_SECTION(0, 8192, 0)
299
300   _end = .;
301
302   .xt.lit : { *(.xt.lit) }
303   .xt.prop : { *(.xt.prop) }
304
305   .debug  0 :  { *(.debug) }
306   .line  0 :  { *(.line) }
307   .debug_srcinfo  0 :  { *(.debug_srcinfo) }
308   .debug_sfnames  0 :  { *(.debug_sfnames) }
309   .debug_aranges  0 :  { *(.debug_aranges) }
310   .debug_pubnames  0 :  { *(.debug_pubnames) }
311   .debug_info  0 :  { *(.debug_info) }
312   .debug_abbrev  0 :  { *(.debug_abbrev) }
313   .debug_line  0 :  { *(.debug_line) }
314   .debug_frame  0 :  { *(.debug_frame) }
315   .debug_str  0 :  { *(.debug_str) }
316   .debug_loc  0 :  { *(.debug_loc) }
317   .debug_macinfo  0 :  { *(.debug_macinfo) }
318   .debug_weaknames  0 :  { *(.debug_weaknames) }
319   .debug_funcnames  0 :  { *(.debug_funcnames) }
320   .debug_typenames  0 :  { *(.debug_typenames) }
321   .debug_varnames  0 :  { *(.debug_varnames) }
322
323   .xt.insn 0 :
324   {
325     *(.xt.insn)
326     *(.gnu.linkonce.x*)
327   }
328
329   .xt.lit 0 :
330   {
331     *(.xt.lit)
332     *(.gnu.linkonce.p*)
333   }
334
335   /* Sections to be discarded */
336   DISCARDS
337   /DISCARD/ : { *(.exit.literal) }
338 }