blob: 14695240536d3b906282eefa2ce550a5ae8e5771 [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 *
Marc Gauthier2d1c6452013-01-05 04:57:17 +040010 * Copyright (C) 2001 - 2008 Tensilica Inc.
Chris Zankel5a0015d2005-06-23 22:01:16 -070011 *
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>
Tim Abbottcd3db322009-09-24 10:36:19 -040018#include <asm/page.h>
19#include <asm/thread_info.h>
Chris Zankel5a0015d2005-06-23 22:01:16 -070020
Chris Zankel367b8112008-11-06 06:40:46 -080021#include <variant/core.h>
Johannes Weiner6770fa02009-03-04 16:21:32 +010022#include <platform/hardware.h>
Chris Zankel5a0015d2005-06-23 22:01:16 -070023OUTPUT_ARCH(xtensa)
24ENTRY(_start)
25
Chris Zankel173d6682006-12-10 02:18:48 -080026#ifdef __XTENSA_EB__
Chris Zankel5a0015d2005-06-23 22:01:16 -070027jiffies = jiffies_64 + 4;
28#else
29jiffies = jiffies_64;
30#endif
31
Johannes Weiner6770fa02009-03-04 16:21:32 +010032#ifndef KERNELOFFSET
Chris Zankel173d6682006-12-10 02:18:48 -080033#define KERNELOFFSET 0xd0001000
Johannes Weiner6770fa02009-03-04 16:21:32 +010034#endif
Chris Zankel5a0015d2005-06-23 22:01:16 -070035
36/* Note: In the following macros, it would be nice to specify only the
37 vector name and section kind and construct "sym" and "section" using
38 CPP concatenation, but that does not work reliably. Concatenating a
39 string with "." produces an invalid token. CPP will not print a
40 warning because it thinks this is an assembly file, but it leaves
41 them as multiple tokens and there may or may not be whitespace
42 between them. */
43
44/* Macro for a relocation entry */
45
46#define RELOCATE_ENTRY(sym, section) \
47 LONG(sym ## _start); \
48 LONG(sym ## _end); \
49 LONG(LOADADDR(section))
50
51/* Macro to define a section for a vector.
52 *
53 * Use of the MIN function catches the types of errors illustrated in
54 * the following example:
55 *
56 * Assume the section .DoubleExceptionVector.literal is completely
57 * full. Then a programmer adds code to .DoubleExceptionVector.text
58 * that produces another literal. The final literal position will
59 * overlay onto the first word of the adjacent code section
60 * .DoubleExceptionVector.text. (In practice, the literals will
61 * overwrite the code, and the first few instructions will be
62 * garbage.)
63 */
64
65#define SECTION_VECTOR(sym, section, addr, max_prevsec_size, prevsec) \
66 section addr : AT((MIN(LOADADDR(prevsec) + max_prevsec_size, \
67 LOADADDR(prevsec) + SIZEOF(prevsec)) + 3) & ~ 3) \
68 { \
69 . = ALIGN(4); \
70 sym ## _start = ABSOLUTE(.); \
71 *(section) \
72 sym ## _end = ABSOLUTE(.); \
73 }
74
75/*
76 * Mapping of input sections to output sections when linking.
77 */
78
79SECTIONS
80{
Chris Zankel173d6682006-12-10 02:18:48 -080081 . = KERNELOFFSET;
Chris Zankel5a0015d2005-06-23 22:01:16 -070082 /* .text section */
83
84 _text = .;
85 _stext = .;
Chris Zankel5a0015d2005-06-23 22:01:16 -070086
87 .text :
88 {
Tim Abbott0ebdcb42009-04-25 22:10:57 -040089 /* The HEAD_TEXT section must be the first section! */
90 HEAD_TEXT
Chris Zankel78f3cdf2009-04-21 00:34:15 -070091 TEXT_TEXT
Chris Zankel5a0015d2005-06-23 22:01:16 -070092 VMLINUX_SYMBOL(__sched_text_start) = .;
Chris Zankel813e6782005-07-12 13:58:25 -070093 *(.sched.literal .sched.text)
Chris Zankel5a0015d2005-06-23 22:01:16 -070094 VMLINUX_SYMBOL(__sched_text_end) = .;
95 VMLINUX_SYMBOL(__lock_text_start) = .;
Chris Zankel813e6782005-07-12 13:58:25 -070096 *(.spinlock.literal .spinlock.text)
Chris Zankel5a0015d2005-06-23 22:01:16 -070097 VMLINUX_SYMBOL(__lock_text_end) = .;
98
99 }
100 _etext = .;
Chris Zankelde4f6e52007-05-31 17:47:01 -0700101 PROVIDE (etext = .);
Chris Zankel5a0015d2005-06-23 22:01:16 -0700102
103 . = ALIGN(16);
104
105 RODATA
106
107 /* Relocation table */
108
Chris Zankel5a0015d2005-06-23 22:01:16 -0700109 .fixup : { *(.fixup) }
110
Tim Abbottcd3db322009-09-24 10:36:19 -0400111 EXCEPTION_TABLE(16)
Chris Zankel5a0015d2005-06-23 22:01:16 -0700112 /* Data section */
113
Geert Uytterhoeven5e7b6ed2012-06-20 12:52:58 -0700114 _sdata = .;
Tim Abbottcd3db322009-09-24 10:36:19 -0400115 RW_DATA_SECTION(XCHAL_ICACHE_LINESIZE, PAGE_SIZE, THREAD_SIZE)
Chris Zankel5a0015d2005-06-23 22:01:16 -0700116 _edata = .;
117
Chris Zankel5a0015d2005-06-23 22:01:16 -0700118 /* Initialization code and data: */
119
Tim Abbottcd3db322009-09-24 10:36:19 -0400120 . = ALIGN(PAGE_SIZE);
Chris Zankel5a0015d2005-06-23 22:01:16 -0700121 __init_begin = .;
Tim Abbottcd3db322009-09-24 10:36:19 -0400122 INIT_TEXT_SECTION(PAGE_SIZE)
Chris Zankel5a0015d2005-06-23 22:01:16 -0700123
124 .init.data :
125 {
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100126 INIT_DATA
Chris Zankel5a0015d2005-06-23 22:01:16 -0700127 . = ALIGN(0x4);
128 __tagtable_begin = .;
129 *(.taglist)
130 __tagtable_end = .;
Chris Zankelde4f6e52007-05-31 17:47:01 -0700131
132 . = ALIGN(16);
133 __boot_reloc_table_start = ABSOLUTE(.);
134
135 RELOCATE_ENTRY(_WindowVectors_text,
136 .WindowVectors.text);
Marc Gauthier2d1c6452013-01-05 04:57:17 +0400137#if XCHAL_EXCM_LEVEL >= 2
138 RELOCATE_ENTRY(_Level2InterruptVector_text,
139 .Level2InterruptVector.text);
140#endif
141#if XCHAL_EXCM_LEVEL >= 3
142 RELOCATE_ENTRY(_Level3InterruptVector_text,
143 .Level3InterruptVector.text);
144#endif
145#if XCHAL_EXCM_LEVEL >= 4
146 RELOCATE_ENTRY(_Level4InterruptVector_text,
147 .Level4InterruptVector.text);
148#endif
149#if XCHAL_EXCM_LEVEL >= 5
150 RELOCATE_ENTRY(_Level5InterruptVector_text,
151 .Level5InterruptVector.text);
152#endif
153#if XCHAL_EXCM_LEVEL >= 6
154 RELOCATE_ENTRY(_Level6InterruptVector_text,
155 .Level6InterruptVector.text);
156#endif
Chris Zankelde4f6e52007-05-31 17:47:01 -0700157 RELOCATE_ENTRY(_KernelExceptionVector_text,
158 .KernelExceptionVector.text);
159 RELOCATE_ENTRY(_UserExceptionVector_text,
160 .UserExceptionVector.text);
161 RELOCATE_ENTRY(_DoubleExceptionVector_literal,
162 .DoubleExceptionVector.literal);
163 RELOCATE_ENTRY(_DoubleExceptionVector_text,
164 .DoubleExceptionVector.text);
Marc Gauthier6d15d102007-12-30 22:00:54 -0800165 RELOCATE_ENTRY(_DebugInterruptVector_text,
166 .DebugInterruptVector.text);
Chris Zankelde4f6e52007-05-31 17:47:01 -0700167
168 __boot_reloc_table_end = ABSOLUTE(.) ;
Tim Abbottcd3db322009-09-24 10:36:19 -0400169
170 INIT_SETUP(XCHAL_ICACHE_LINESIZE)
171 INIT_CALLS
172 CON_INITCALL
173 SECURITY_INITCALL
174 INIT_RAM_FS
Chris Zankel5a0015d2005-06-23 22:01:16 -0700175 }
176
Tejun Heo0415b00d12011-03-24 18:50:09 +0100177 PERCPU_SECTION(XCHAL_ICACHE_LINESIZE)
Chris Zankelde4f6e52007-05-31 17:47:01 -0700178
Chris Zankel5a0015d2005-06-23 22:01:16 -0700179 /* We need this dummy segment here */
180
181 . = ALIGN(4);
182 .dummy : { LONG(0) }
183
184 /* The vectors are relocated to the real position at startup time */
185
186 SECTION_VECTOR (_WindowVectors_text,
187 .WindowVectors.text,
188 XCHAL_WINDOW_VECTORS_VADDR, 4,
189 .dummy)
190 SECTION_VECTOR (_DebugInterruptVector_literal,
191 .DebugInterruptVector.literal,
Chris Zankel173d6682006-12-10 02:18:48 -0800192 XCHAL_DEBUG_VECTOR_VADDR - 4,
Chris Zankel5a0015d2005-06-23 22:01:16 -0700193 SIZEOF(.WindowVectors.text),
194 .WindowVectors.text)
195 SECTION_VECTOR (_DebugInterruptVector_text,
196 .DebugInterruptVector.text,
Chris Zankel173d6682006-12-10 02:18:48 -0800197 XCHAL_DEBUG_VECTOR_VADDR,
Chris Zankel5a0015d2005-06-23 22:01:16 -0700198 4,
199 .DebugInterruptVector.literal)
Marc Gauthier2d1c6452013-01-05 04:57:17 +0400200#undef LAST
201#define LAST .DebugInterruptVector.text
202#if XCHAL_EXCM_LEVEL >= 2
203 SECTION_VECTOR (_Level2InterruptVector_text,
204 .Level2InterruptVector.text,
205 XCHAL_INTLEVEL2_VECTOR_VADDR,
206 SIZEOF(LAST), LAST)
207# undef LAST
208# define LAST .Level2InterruptVector.text
209#endif
210#if XCHAL_EXCM_LEVEL >= 3
211 SECTION_VECTOR (_Level3InterruptVector_text,
212 .Level3InterruptVector.text,
213 XCHAL_INTLEVEL3_VECTOR_VADDR,
214 SIZEOF(LAST), LAST)
215# undef LAST
216# define LAST .Level3InterruptVector.text
217#endif
218#if XCHAL_EXCM_LEVEL >= 4
219 SECTION_VECTOR (_Level4InterruptVector_text,
220 .Level4InterruptVector.text,
221 XCHAL_INTLEVEL4_VECTOR_VADDR,
222 SIZEOF(LAST), LAST)
223# undef LAST
224# define LAST .Level4InterruptVector.text
225#endif
226#if XCHAL_EXCM_LEVEL >= 5
227 SECTION_VECTOR (_Level5InterruptVector_text,
228 .Level5InterruptVector.text,
229 XCHAL_INTLEVEL5_VECTOR_VADDR,
230 SIZEOF(LAST), LAST)
231# undef LAST
232# define LAST .Level5InterruptVector.text
233#endif
234#if XCHAL_EXCM_LEVEL >= 6
235 SECTION_VECTOR (_Level6InterruptVector_text,
236 .Level6InterruptVector.text,
237 XCHAL_INTLEVEL6_VECTOR_VADDR,
238 SIZEOF(LAST), LAST)
239# undef LAST
240# define LAST .Level6InterruptVector.text
241#endif
Chris Zankel5a0015d2005-06-23 22:01:16 -0700242 SECTION_VECTOR (_KernelExceptionVector_literal,
243 .KernelExceptionVector.literal,
Chris Zankel173d6682006-12-10 02:18:48 -0800244 XCHAL_KERNEL_VECTOR_VADDR - 4,
Marc Gauthier2d1c6452013-01-05 04:57:17 +0400245 SIZEOF(LAST), LAST)
246#undef LAST
Chris Zankel5a0015d2005-06-23 22:01:16 -0700247 SECTION_VECTOR (_KernelExceptionVector_text,
248 .KernelExceptionVector.text,
Chris Zankel173d6682006-12-10 02:18:48 -0800249 XCHAL_KERNEL_VECTOR_VADDR,
Chris Zankel5a0015d2005-06-23 22:01:16 -0700250 4,
251 .KernelExceptionVector.literal)
252 SECTION_VECTOR (_UserExceptionVector_literal,
253 .UserExceptionVector.literal,
Chris Zankel173d6682006-12-10 02:18:48 -0800254 XCHAL_USER_VECTOR_VADDR - 4,
Chris Zankel5a0015d2005-06-23 22:01:16 -0700255 SIZEOF(.KernelExceptionVector.text),
256 .KernelExceptionVector.text)
257 SECTION_VECTOR (_UserExceptionVector_text,
258 .UserExceptionVector.text,
Chris Zankel173d6682006-12-10 02:18:48 -0800259 XCHAL_USER_VECTOR_VADDR,
Chris Zankel5a0015d2005-06-23 22:01:16 -0700260 4,
261 .UserExceptionVector.literal)
262 SECTION_VECTOR (_DoubleExceptionVector_literal,
263 .DoubleExceptionVector.literal,
264 XCHAL_DOUBLEEXC_VECTOR_VADDR - 16,
265 SIZEOF(.UserExceptionVector.text),
266 .UserExceptionVector.text)
267 SECTION_VECTOR (_DoubleExceptionVector_text,
268 .DoubleExceptionVector.text,
269 XCHAL_DOUBLEEXC_VECTOR_VADDR,
270 32,
271 .DoubleExceptionVector.literal)
272
273 . = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3;
Tim Abbottcd3db322009-09-24 10:36:19 -0400274 . = ALIGN(PAGE_SIZE);
Chris Zankel5a0015d2005-06-23 22:01:16 -0700275
276 __init_end = .;
277
Tim Abbottcd3db322009-09-24 10:36:19 -0400278 BSS_SECTION(0, 8192, 0)
Chris Zankelde4f6e52007-05-31 17:47:01 -0700279
Chris Zankel5a0015d2005-06-23 22:01:16 -0700280 _end = .;
281
282 /* only used by the boot loader */
283
284 . = ALIGN(0x10);
285 .bootstrap : { *(.bootstrap.literal .bootstrap.text .bootstrap.data) }
286
Chris Zankel5a0015d2005-06-23 22:01:16 -0700287 .ResetVector.text XCHAL_RESET_VECTOR_VADDR :
288 {
289 *(.ResetVector.text)
290 }
291
Chris Zankelde4f6e52007-05-31 17:47:01 -0700292 .xt.lit : { *(.xt.lit) }
293 .xt.prop : { *(.xt.prop) }
Chris Zankel5a0015d2005-06-23 22:01:16 -0700294
295 .debug 0 : { *(.debug) }
296 .line 0 : { *(.line) }
297 .debug_srcinfo 0 : { *(.debug_srcinfo) }
298 .debug_sfnames 0 : { *(.debug_sfnames) }
299 .debug_aranges 0 : { *(.debug_aranges) }
300 .debug_pubnames 0 : { *(.debug_pubnames) }
301 .debug_info 0 : { *(.debug_info) }
302 .debug_abbrev 0 : { *(.debug_abbrev) }
303 .debug_line 0 : { *(.debug_line) }
304 .debug_frame 0 : { *(.debug_frame) }
305 .debug_str 0 : { *(.debug_str) }
306 .debug_loc 0 : { *(.debug_loc) }
307 .debug_macinfo 0 : { *(.debug_macinfo) }
308 .debug_weaknames 0 : { *(.debug_weaknames) }
309 .debug_funcnames 0 : { *(.debug_funcnames) }
310 .debug_typenames 0 : { *(.debug_typenames) }
311 .debug_varnames 0 : { *(.debug_varnames) }
312
313 .xt.insn 0 :
314 {
315 *(.xt.insn)
316 *(.gnu.linkonce.x*)
317 }
318
319 .xt.lit 0 :
320 {
321 *(.xt.lit)
322 *(.gnu.linkonce.p*)
323 }
Tejun Heo023bf6f2009-07-09 11:27:40 +0900324
325 /* Sections to be discarded */
326 DISCARDS
327 /DISCARD/ : { *(.exit.literal) }
Chris Zankel5a0015d2005-06-23 22:01:16 -0700328}