blob: 5accf51053da3fc25f595dcbcfbef080042a8ca4 [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 Zankel367b8112008-11-06 06:40:46 -080019#include <variant/core.h>
Johannes Weiner6770fa02009-03-04 16:21:32 +010020#include <platform/hardware.h>
Chris Zankel5a0015d2005-06-23 22:01:16 -070021OUTPUT_ARCH(xtensa)
22ENTRY(_start)
23
Chris Zankel173d6682006-12-10 02:18:48 -080024#ifdef __XTENSA_EB__
Chris Zankel5a0015d2005-06-23 22:01:16 -070025jiffies = jiffies_64 + 4;
26#else
27jiffies = jiffies_64;
28#endif
29
Johannes Weiner6770fa02009-03-04 16:21:32 +010030#ifndef KERNELOFFSET
Chris Zankel173d6682006-12-10 02:18:48 -080031#define KERNELOFFSET 0xd0001000
Johannes Weiner6770fa02009-03-04 16:21:32 +010032#endif
Chris Zankel5a0015d2005-06-23 22:01:16 -070033
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
77SECTIONS
78{
Chris Zankel173d6682006-12-10 02:18:48 -080079 . = KERNELOFFSET;
Chris Zankel5a0015d2005-06-23 22:01:16 -070080 /* .text section */
81
82 _text = .;
83 _stext = .;
84 _ftext = .;
85
86 .text :
87 {
Tim Abbott0ebdcb42009-04-25 22:10:57 -040088 /* The HEAD_TEXT section must be the first section! */
89 HEAD_TEXT
Chris Zankelde4f6e52007-05-31 17:47:01 -070090 *(.literal .text)
Chris Zankel5a0015d2005-06-23 22:01:16 -070091 VMLINUX_SYMBOL(__sched_text_start) = .;
Chris Zankel813e6782005-07-12 13:58:25 -070092 *(.sched.literal .sched.text)
Chris Zankel5a0015d2005-06-23 22:01:16 -070093 VMLINUX_SYMBOL(__sched_text_end) = .;
94 VMLINUX_SYMBOL(__lock_text_start) = .;
Chris Zankel813e6782005-07-12 13:58:25 -070095 *(.spinlock.literal .spinlock.text)
Chris Zankel5a0015d2005-06-23 22:01:16 -070096 VMLINUX_SYMBOL(__lock_text_end) = .;
97
98 }
99 _etext = .;
Chris Zankelde4f6e52007-05-31 17:47:01 -0700100 PROVIDE (etext = .);
Chris Zankel5a0015d2005-06-23 22:01:16 -0700101
102 . = ALIGN(16);
103
104 RODATA
105
106 /* Relocation table */
107
Chris Zankel5a0015d2005-06-23 22:01:16 -0700108 .fixup : { *(.fixup) }
109
110 . = ALIGN(16);
111
112 __ex_table : {
113 __start___ex_table = .;
114 *(__ex_table)
115 __stop___ex_table = .;
116 }
117
118 /* Data section */
119
120 . = ALIGN(XCHAL_ICACHE_LINESIZE);
121 _fdata = .;
122 .data :
123 {
Mathieu Desnoyersb8243252007-06-16 22:29:39 -0400124 DATA_DATA
125 CONSTRUCTORS
Chris Zankel5a0015d2005-06-23 22:01:16 -0700126 . = ALIGN(XCHAL_ICACHE_LINESIZE);
127 *(.data.cacheline_aligned)
128 }
129
130 _edata = .;
131
132 /* The initial task */
133 . = ALIGN(8192);
134 .data.init_task : { *(.data.init_task) }
135
136 /* Initialization code and data: */
137
Chris Zankel173d6682006-12-10 02:18:48 -0800138 . = ALIGN(1 << 12);
Chris Zankel5a0015d2005-06-23 22:01:16 -0700139 __init_begin = .;
140 .init.text : {
141 _sinittext = .;
Chris Zankel4f8d98f2008-02-13 16:44:19 -0800142 *(.init.literal) *(.cpuinit.literal)
143 *(.devinit.literal) *(.meminit.literal)
144 INIT_TEXT
Chris Zankel5a0015d2005-06-23 22:01:16 -0700145 _einittext = .;
146 }
147
148 .init.data :
149 {
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100150 INIT_DATA
Chris Zankel5a0015d2005-06-23 22:01:16 -0700151 . = ALIGN(0x4);
152 __tagtable_begin = .;
153 *(.taglist)
154 __tagtable_end = .;
Chris Zankelde4f6e52007-05-31 17:47:01 -0700155
156 . = ALIGN(16);
157 __boot_reloc_table_start = ABSOLUTE(.);
158
159 RELOCATE_ENTRY(_WindowVectors_text,
160 .WindowVectors.text);
161 RELOCATE_ENTRY(_KernelExceptionVector_text,
162 .KernelExceptionVector.text);
163 RELOCATE_ENTRY(_UserExceptionVector_text,
164 .UserExceptionVector.text);
165 RELOCATE_ENTRY(_DoubleExceptionVector_literal,
166 .DoubleExceptionVector.literal);
167 RELOCATE_ENTRY(_DoubleExceptionVector_text,
168 .DoubleExceptionVector.text);
Marc Gauthier6d15d102007-12-30 22:00:54 -0800169 RELOCATE_ENTRY(_DebugInterruptVector_text,
170 .DebugInterruptVector.text);
Chris Zankelde4f6e52007-05-31 17:47:01 -0700171
172 __boot_reloc_table_end = ABSOLUTE(.) ;
Chris Zankel5a0015d2005-06-23 22:01:16 -0700173 }
174
175 . = ALIGN(XCHAL_ICACHE_LINESIZE);
176
177 __setup_start = .;
178 .init.setup : { *(.init.setup) }
179 __setup_end = .;
180
181 __initcall_start = .;
182 .initcall.init : {
Andrew Morton61ce1ef2006-10-27 11:41:44 -0700183 INITCALLS
Chris Zankel5a0015d2005-06-23 22:01:16 -0700184 }
185 __initcall_end = .;
186
187 __con_initcall_start = .;
188 .con_initcall.init : { *(.con_initcall.init) }
189 __con_initcall_end = .;
190
191 SECURITY_INIT
192
Chris Zankel5a0015d2005-06-23 22:01:16 -0700193
Jean-Paul Saman67d38222007-02-10 01:44:44 -0800194#ifdef CONFIG_BLK_DEV_INITRD
Chris Zankel5a0015d2005-06-23 22:01:16 -0700195 . = ALIGN(4096);
196 __initramfs_start =.;
197 .init.ramfs : { *(.init.ramfs) }
198 __initramfs_end = .;
Jean-Paul Saman67d38222007-02-10 01:44:44 -0800199#endif
Chris Zankel5a0015d2005-06-23 22:01:16 -0700200
Fenghua Yu5fb7dc32007-07-19 01:48:12 -0700201 PERCPU(4096)
Chris Zankelde4f6e52007-05-31 17:47:01 -0700202
203
Chris Zankel5a0015d2005-06-23 22:01:16 -0700204 /* We need this dummy segment here */
205
206 . = ALIGN(4);
207 .dummy : { LONG(0) }
208
209 /* The vectors are relocated to the real position at startup time */
210
211 SECTION_VECTOR (_WindowVectors_text,
212 .WindowVectors.text,
213 XCHAL_WINDOW_VECTORS_VADDR, 4,
214 .dummy)
215 SECTION_VECTOR (_DebugInterruptVector_literal,
216 .DebugInterruptVector.literal,
Chris Zankel173d6682006-12-10 02:18:48 -0800217 XCHAL_DEBUG_VECTOR_VADDR - 4,
Chris Zankel5a0015d2005-06-23 22:01:16 -0700218 SIZEOF(.WindowVectors.text),
219 .WindowVectors.text)
220 SECTION_VECTOR (_DebugInterruptVector_text,
221 .DebugInterruptVector.text,
Chris Zankel173d6682006-12-10 02:18:48 -0800222 XCHAL_DEBUG_VECTOR_VADDR,
Chris Zankel5a0015d2005-06-23 22:01:16 -0700223 4,
224 .DebugInterruptVector.literal)
225 SECTION_VECTOR (_KernelExceptionVector_literal,
226 .KernelExceptionVector.literal,
Chris Zankel173d6682006-12-10 02:18:48 -0800227 XCHAL_KERNEL_VECTOR_VADDR - 4,
Chris Zankel5a0015d2005-06-23 22:01:16 -0700228 SIZEOF(.DebugInterruptVector.text),
229 .DebugInterruptVector.text)
230 SECTION_VECTOR (_KernelExceptionVector_text,
231 .KernelExceptionVector.text,
Chris Zankel173d6682006-12-10 02:18:48 -0800232 XCHAL_KERNEL_VECTOR_VADDR,
Chris Zankel5a0015d2005-06-23 22:01:16 -0700233 4,
234 .KernelExceptionVector.literal)
235 SECTION_VECTOR (_UserExceptionVector_literal,
236 .UserExceptionVector.literal,
Chris Zankel173d6682006-12-10 02:18:48 -0800237 XCHAL_USER_VECTOR_VADDR - 4,
Chris Zankel5a0015d2005-06-23 22:01:16 -0700238 SIZEOF(.KernelExceptionVector.text),
239 .KernelExceptionVector.text)
240 SECTION_VECTOR (_UserExceptionVector_text,
241 .UserExceptionVector.text,
Chris Zankel173d6682006-12-10 02:18:48 -0800242 XCHAL_USER_VECTOR_VADDR,
Chris Zankel5a0015d2005-06-23 22:01:16 -0700243 4,
244 .UserExceptionVector.literal)
245 SECTION_VECTOR (_DoubleExceptionVector_literal,
246 .DoubleExceptionVector.literal,
247 XCHAL_DOUBLEEXC_VECTOR_VADDR - 16,
248 SIZEOF(.UserExceptionVector.text),
249 .UserExceptionVector.text)
250 SECTION_VECTOR (_DoubleExceptionVector_text,
251 .DoubleExceptionVector.text,
252 XCHAL_DOUBLEEXC_VECTOR_VADDR,
253 32,
254 .DoubleExceptionVector.literal)
255
256 . = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3;
Chris Zankel173d6682006-12-10 02:18:48 -0800257 . = ALIGN(1 << 12);
Chris Zankel5a0015d2005-06-23 22:01:16 -0700258
259 __init_end = .;
260
261 . = ALIGN(8192);
262
263 /* BSS section */
264 _bss_start = .;
Chris Zankelde4f6e52007-05-31 17:47:01 -0700265 .bss : { *(.bss.page_aligned) *(.bss) }
Chris Zankel5a0015d2005-06-23 22:01:16 -0700266 _bss_end = .;
Chris Zankelde4f6e52007-05-31 17:47:01 -0700267
Chris Zankel5a0015d2005-06-23 22:01:16 -0700268 _end = .;
269
270 /* only used by the boot loader */
271
272 . = ALIGN(0x10);
273 .bootstrap : { *(.bootstrap.literal .bootstrap.text .bootstrap.data) }
274
275 . = ALIGN(0x1000);
276 __initrd_start = .;
277 .initrd : { *(.initrd) }
278 __initrd_end = .;
279
280 .ResetVector.text XCHAL_RESET_VECTOR_VADDR :
281 {
282 *(.ResetVector.text)
283 }
284
Chris Zankel5a0015d2005-06-23 22:01:16 -0700285 /* Sections to be discarded */
286 /DISCARD/ :
287 {
Sam Ravnborg01ba2bd2008-01-20 14:15:03 +0100288 *(.exit.literal)
289 EXIT_TEXT
290 EXIT_DATA
Chris Zankel5a0015d2005-06-23 22:01:16 -0700291 *(.exitcall.exit)
292 }
293
Chris Zankelde4f6e52007-05-31 17:47:01 -0700294 .xt.lit : { *(.xt.lit) }
295 .xt.prop : { *(.xt.prop) }
Chris Zankel5a0015d2005-06-23 22:01:16 -0700296
297 .debug 0 : { *(.debug) }
298 .line 0 : { *(.line) }
299 .debug_srcinfo 0 : { *(.debug_srcinfo) }
300 .debug_sfnames 0 : { *(.debug_sfnames) }
301 .debug_aranges 0 : { *(.debug_aranges) }
302 .debug_pubnames 0 : { *(.debug_pubnames) }
303 .debug_info 0 : { *(.debug_info) }
304 .debug_abbrev 0 : { *(.debug_abbrev) }
305 .debug_line 0 : { *(.debug_line) }
306 .debug_frame 0 : { *(.debug_frame) }
307 .debug_str 0 : { *(.debug_str) }
308 .debug_loc 0 : { *(.debug_loc) }
309 .debug_macinfo 0 : { *(.debug_macinfo) }
310 .debug_weaknames 0 : { *(.debug_weaknames) }
311 .debug_funcnames 0 : { *(.debug_funcnames) }
312 .debug_typenames 0 : { *(.debug_typenames) }
313 .debug_varnames 0 : { *(.debug_varnames) }
314
315 .xt.insn 0 :
316 {
317 *(.xt.insn)
318 *(.gnu.linkonce.x*)
319 }
320
321 .xt.lit 0 :
322 {
323 *(.xt.lit)
324 *(.gnu.linkonce.p*)
325 }
326}