Commit | Line | Data |
---|---|---|
5a0015d6 CZ |
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> | |
cd3db323 TA |
18 | #include <asm/page.h> |
19 | #include <asm/thread_info.h> | |
5a0015d6 | 20 | |
367b8112 | 21 | #include <variant/core.h> |
6770fa02 | 22 | #include <platform/hardware.h> |
5a0015d6 CZ |
23 | OUTPUT_ARCH(xtensa) |
24 | ENTRY(_start) | |
25 | ||
173d6681 | 26 | #ifdef __XTENSA_EB__ |
5a0015d6 CZ |
27 | jiffies = jiffies_64 + 4; |
28 | #else | |
29 | jiffies = jiffies_64; | |
30 | #endif | |
31 | ||
6770fa02 | 32 | #ifndef KERNELOFFSET |
173d6681 | 33 | #define KERNELOFFSET 0xd0001000 |
6770fa02 | 34 | #endif |
5a0015d6 CZ |
35 | |
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 | ||
79 | SECTIONS | |
80 | { | |
173d6681 | 81 | . = KERNELOFFSET; |
5a0015d6 CZ |
82 | /* .text section */ |
83 | ||
84 | _text = .; | |
85 | _stext = .; | |
5a0015d6 CZ |
86 | |
87 | .text : | |
88 | { | |
0ebdcb4d TA |
89 | /* The HEAD_TEXT section must be the first section! */ |
90 | HEAD_TEXT | |
78f3cdfa | 91 | TEXT_TEXT |
5a0015d6 | 92 | VMLINUX_SYMBOL(__sched_text_start) = .; |
813e6783 | 93 | *(.sched.literal .sched.text) |
5a0015d6 CZ |
94 | VMLINUX_SYMBOL(__sched_text_end) = .; |
95 | VMLINUX_SYMBOL(__lock_text_start) = .; | |
813e6783 | 96 | *(.spinlock.literal .spinlock.text) |
5a0015d6 CZ |
97 | VMLINUX_SYMBOL(__lock_text_end) = .; |
98 | ||
99 | } | |
100 | _etext = .; | |
de4f6e5b | 101 | PROVIDE (etext = .); |
5a0015d6 CZ |
102 | |
103 | . = ALIGN(16); | |
104 | ||
105 | RODATA | |
106 | ||
107 | /* Relocation table */ | |
108 | ||
5a0015d6 CZ |
109 | .fixup : { *(.fixup) } |
110 | ||
cd3db323 | 111 | EXCEPTION_TABLE(16) |
5a0015d6 CZ |
112 | /* Data section */ |
113 | ||
5e7b6ed8 | 114 | _sdata = .; |
cd3db323 | 115 | RW_DATA_SECTION(XCHAL_ICACHE_LINESIZE, PAGE_SIZE, THREAD_SIZE) |
5a0015d6 CZ |
116 | _edata = .; |
117 | ||
5a0015d6 CZ |
118 | /* Initialization code and data: */ |
119 | ||
cd3db323 | 120 | . = ALIGN(PAGE_SIZE); |
5a0015d6 | 121 | __init_begin = .; |
cd3db323 | 122 | INIT_TEXT_SECTION(PAGE_SIZE) |
5a0015d6 CZ |
123 | |
124 | .init.data : | |
125 | { | |
01ba2bdc | 126 | INIT_DATA |
5a0015d6 CZ |
127 | . = ALIGN(0x4); |
128 | __tagtable_begin = .; | |
129 | *(.taglist) | |
130 | __tagtable_end = .; | |
de4f6e5b CZ |
131 | |
132 | . = ALIGN(16); | |
133 | __boot_reloc_table_start = ABSOLUTE(.); | |
134 | ||
135 | RELOCATE_ENTRY(_WindowVectors_text, | |
136 | .WindowVectors.text); | |
137 | RELOCATE_ENTRY(_KernelExceptionVector_text, | |
138 | .KernelExceptionVector.text); | |
139 | RELOCATE_ENTRY(_UserExceptionVector_text, | |
140 | .UserExceptionVector.text); | |
141 | RELOCATE_ENTRY(_DoubleExceptionVector_literal, | |
142 | .DoubleExceptionVector.literal); | |
143 | RELOCATE_ENTRY(_DoubleExceptionVector_text, | |
144 | .DoubleExceptionVector.text); | |
6d15d109 MG |
145 | RELOCATE_ENTRY(_DebugInterruptVector_text, |
146 | .DebugInterruptVector.text); | |
de4f6e5b CZ |
147 | |
148 | __boot_reloc_table_end = ABSOLUTE(.) ; | |
5a0015d6 | 149 | |
cd3db323 TA |
150 | INIT_SETUP(XCHAL_ICACHE_LINESIZE) |
151 | INIT_CALLS | |
152 | CON_INITCALL | |
153 | SECURITY_INITCALL | |
154 | INIT_RAM_FS | |
5a0015d6 | 155 | } |
de4f6e5b | 156 | |
0415b00d | 157 | PERCPU_SECTION(XCHAL_ICACHE_LINESIZE) |
de4f6e5b | 158 | |
5a0015d6 CZ |
159 | /* We need this dummy segment here */ |
160 | ||
161 | . = ALIGN(4); | |
162 | .dummy : { LONG(0) } | |
163 | ||
164 | /* The vectors are relocated to the real position at startup time */ | |
165 | ||
166 | SECTION_VECTOR (_WindowVectors_text, | |
167 | .WindowVectors.text, | |
168 | XCHAL_WINDOW_VECTORS_VADDR, 4, | |
169 | .dummy) | |
170 | SECTION_VECTOR (_DebugInterruptVector_literal, | |
171 | .DebugInterruptVector.literal, | |
173d6681 | 172 | XCHAL_DEBUG_VECTOR_VADDR - 4, |
5a0015d6 CZ |
173 | SIZEOF(.WindowVectors.text), |
174 | .WindowVectors.text) | |
175 | SECTION_VECTOR (_DebugInterruptVector_text, | |
176 | .DebugInterruptVector.text, | |
173d6681 | 177 | XCHAL_DEBUG_VECTOR_VADDR, |
5a0015d6 CZ |
178 | 4, |
179 | .DebugInterruptVector.literal) | |
180 | SECTION_VECTOR (_KernelExceptionVector_literal, | |
181 | .KernelExceptionVector.literal, | |
173d6681 | 182 | XCHAL_KERNEL_VECTOR_VADDR - 4, |
5a0015d6 CZ |
183 | SIZEOF(.DebugInterruptVector.text), |
184 | .DebugInterruptVector.text) | |
185 | SECTION_VECTOR (_KernelExceptionVector_text, | |
186 | .KernelExceptionVector.text, | |
173d6681 | 187 | XCHAL_KERNEL_VECTOR_VADDR, |
5a0015d6 CZ |
188 | 4, |
189 | .KernelExceptionVector.literal) | |
190 | SECTION_VECTOR (_UserExceptionVector_literal, | |
191 | .UserExceptionVector.literal, | |
173d6681 | 192 | XCHAL_USER_VECTOR_VADDR - 4, |
5a0015d6 CZ |
193 | SIZEOF(.KernelExceptionVector.text), |
194 | .KernelExceptionVector.text) | |
195 | SECTION_VECTOR (_UserExceptionVector_text, | |
196 | .UserExceptionVector.text, | |
173d6681 | 197 | XCHAL_USER_VECTOR_VADDR, |
5a0015d6 CZ |
198 | 4, |
199 | .UserExceptionVector.literal) | |
200 | SECTION_VECTOR (_DoubleExceptionVector_literal, | |
201 | .DoubleExceptionVector.literal, | |
202 | XCHAL_DOUBLEEXC_VECTOR_VADDR - 16, | |
203 | SIZEOF(.UserExceptionVector.text), | |
204 | .UserExceptionVector.text) | |
205 | SECTION_VECTOR (_DoubleExceptionVector_text, | |
206 | .DoubleExceptionVector.text, | |
207 | XCHAL_DOUBLEEXC_VECTOR_VADDR, | |
208 | 32, | |
209 | .DoubleExceptionVector.literal) | |
210 | ||
211 | . = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3; | |
cd3db323 | 212 | . = ALIGN(PAGE_SIZE); |
5a0015d6 CZ |
213 | |
214 | __init_end = .; | |
215 | ||
cd3db323 | 216 | BSS_SECTION(0, 8192, 0) |
de4f6e5b | 217 | |
5a0015d6 CZ |
218 | _end = .; |
219 | ||
220 | /* only used by the boot loader */ | |
221 | ||
222 | . = ALIGN(0x10); | |
223 | .bootstrap : { *(.bootstrap.literal .bootstrap.text .bootstrap.data) } | |
224 | ||
5a0015d6 CZ |
225 | .ResetVector.text XCHAL_RESET_VECTOR_VADDR : |
226 | { | |
227 | *(.ResetVector.text) | |
228 | } | |
229 | ||
de4f6e5b CZ |
230 | .xt.lit : { *(.xt.lit) } |
231 | .xt.prop : { *(.xt.prop) } | |
5a0015d6 CZ |
232 | |
233 | .debug 0 : { *(.debug) } | |
234 | .line 0 : { *(.line) } | |
235 | .debug_srcinfo 0 : { *(.debug_srcinfo) } | |
236 | .debug_sfnames 0 : { *(.debug_sfnames) } | |
237 | .debug_aranges 0 : { *(.debug_aranges) } | |
238 | .debug_pubnames 0 : { *(.debug_pubnames) } | |
239 | .debug_info 0 : { *(.debug_info) } | |
240 | .debug_abbrev 0 : { *(.debug_abbrev) } | |
241 | .debug_line 0 : { *(.debug_line) } | |
242 | .debug_frame 0 : { *(.debug_frame) } | |
243 | .debug_str 0 : { *(.debug_str) } | |
244 | .debug_loc 0 : { *(.debug_loc) } | |
245 | .debug_macinfo 0 : { *(.debug_macinfo) } | |
246 | .debug_weaknames 0 : { *(.debug_weaknames) } | |
247 | .debug_funcnames 0 : { *(.debug_funcnames) } | |
248 | .debug_typenames 0 : { *(.debug_typenames) } | |
249 | .debug_varnames 0 : { *(.debug_varnames) } | |
250 | ||
251 | .xt.insn 0 : | |
252 | { | |
253 | *(.xt.insn) | |
254 | *(.gnu.linkonce.x*) | |
255 | } | |
256 | ||
257 | .xt.lit 0 : | |
258 | { | |
259 | *(.xt.lit) | |
260 | *(.gnu.linkonce.p*) | |
261 | } | |
023bf6f1 TH |
262 | |
263 | /* Sections to be discarded */ | |
264 | DISCARDS | |
265 | /DISCARD/ : { *(.exit.literal) } | |
5a0015d6 | 266 | } |