Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 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 | |
Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 19 | #include <asm/variant/core.h> |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 20 | OUTPUT_ARCH(xtensa) |
| 21 | ENTRY(_start) |
| 22 | |
Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 23 | #ifdef __XTENSA_EB__ |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 24 | jiffies = jiffies_64 + 4; |
| 25 | #else |
| 26 | jiffies = jiffies_64; |
| 27 | #endif |
| 28 | |
Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 29 | #define KERNELOFFSET 0xd0001000 |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 30 | |
| 31 | /* Note: In the following macros, it would be nice to specify only the |
| 32 | vector name and section kind and construct "sym" and "section" using |
| 33 | CPP concatenation, but that does not work reliably. Concatenating a |
| 34 | string with "." produces an invalid token. CPP will not print a |
| 35 | warning because it thinks this is an assembly file, but it leaves |
| 36 | them as multiple tokens and there may or may not be whitespace |
| 37 | between them. */ |
| 38 | |
| 39 | /* Macro for a relocation entry */ |
| 40 | |
| 41 | #define RELOCATE_ENTRY(sym, section) \ |
| 42 | LONG(sym ## _start); \ |
| 43 | LONG(sym ## _end); \ |
| 44 | LONG(LOADADDR(section)) |
| 45 | |
| 46 | /* Macro to define a section for a vector. |
| 47 | * |
| 48 | * Use of the MIN function catches the types of errors illustrated in |
| 49 | * the following example: |
| 50 | * |
| 51 | * Assume the section .DoubleExceptionVector.literal is completely |
| 52 | * full. Then a programmer adds code to .DoubleExceptionVector.text |
| 53 | * that produces another literal. The final literal position will |
| 54 | * overlay onto the first word of the adjacent code section |
| 55 | * .DoubleExceptionVector.text. (In practice, the literals will |
| 56 | * overwrite the code, and the first few instructions will be |
| 57 | * garbage.) |
| 58 | */ |
| 59 | |
| 60 | #define SECTION_VECTOR(sym, section, addr, max_prevsec_size, prevsec) \ |
| 61 | section addr : AT((MIN(LOADADDR(prevsec) + max_prevsec_size, \ |
| 62 | LOADADDR(prevsec) + SIZEOF(prevsec)) + 3) & ~ 3) \ |
| 63 | { \ |
| 64 | . = ALIGN(4); \ |
| 65 | sym ## _start = ABSOLUTE(.); \ |
| 66 | *(section) \ |
| 67 | sym ## _end = ABSOLUTE(.); \ |
| 68 | } |
| 69 | |
| 70 | /* |
| 71 | * Mapping of input sections to output sections when linking. |
| 72 | */ |
| 73 | |
| 74 | SECTIONS |
| 75 | { |
Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 76 | . = KERNELOFFSET; |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 77 | /* .text section */ |
| 78 | |
| 79 | _text = .; |
| 80 | _stext = .; |
| 81 | _ftext = .; |
| 82 | |
| 83 | .text : |
| 84 | { |
| 85 | /* The .head.text section must be the first section! */ |
| 86 | *(.head.text) |
Sam Ravnborg | 7664709 | 2007-05-13 00:31:33 +0200 | [diff] [blame^] | 87 | *(.literal) |
| 88 | TEXT_TEXT |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 89 | *(.srom.text) |
| 90 | VMLINUX_SYMBOL(__sched_text_start) = .; |
Chris Zankel | 813e678 | 2005-07-12 13:58:25 -0700 | [diff] [blame] | 91 | *(.sched.literal .sched.text) |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 92 | VMLINUX_SYMBOL(__sched_text_end) = .; |
| 93 | VMLINUX_SYMBOL(__lock_text_start) = .; |
Chris Zankel | 813e678 | 2005-07-12 13:58:25 -0700 | [diff] [blame] | 94 | *(.spinlock.literal .spinlock.text) |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 95 | VMLINUX_SYMBOL(__lock_text_end) = .; |
| 96 | |
| 97 | } |
| 98 | _etext = .; |
| 99 | |
| 100 | . = ALIGN(16); |
| 101 | |
| 102 | RODATA |
| 103 | |
| 104 | /* Relocation table */ |
| 105 | |
| 106 | . = ALIGN(16); |
| 107 | __boot_reloc_table_start = ABSOLUTE(.); |
| 108 | |
| 109 | __relocate : { |
| 110 | |
| 111 | RELOCATE_ENTRY(_WindowVectors_text, |
| 112 | .WindowVectors.text); |
| 113 | #if 0 |
| 114 | RELOCATE_ENTRY(_KernelExceptionVector_literal, |
| 115 | .KernelExceptionVector.literal); |
| 116 | #endif |
| 117 | RELOCATE_ENTRY(_KernelExceptionVector_text, |
| 118 | .KernelExceptionVector.text); |
| 119 | #if 0 |
| 120 | RELOCATE_ENTRY(_UserExceptionVector_literal, |
| 121 | .UserExceptionVector.literal); |
| 122 | #endif |
| 123 | RELOCATE_ENTRY(_UserExceptionVector_text, |
| 124 | .UserExceptionVector.text); |
| 125 | RELOCATE_ENTRY(_DoubleExceptionVector_literal, |
| 126 | .DoubleExceptionVector.literal); |
| 127 | RELOCATE_ENTRY(_DoubleExceptionVector_text, |
| 128 | .DoubleExceptionVector.text); |
| 129 | } |
| 130 | __boot_reloc_table_end = ABSOLUTE(.) ; |
| 131 | |
| 132 | .fixup : { *(.fixup) } |
| 133 | |
| 134 | . = ALIGN(16); |
| 135 | |
| 136 | __ex_table : { |
| 137 | __start___ex_table = .; |
| 138 | *(__ex_table) |
| 139 | __stop___ex_table = .; |
| 140 | } |
| 141 | |
| 142 | /* Data section */ |
| 143 | |
| 144 | . = ALIGN(XCHAL_ICACHE_LINESIZE); |
| 145 | _fdata = .; |
| 146 | .data : |
| 147 | { |
| 148 | *(.data) CONSTRUCTORS |
| 149 | . = ALIGN(XCHAL_ICACHE_LINESIZE); |
| 150 | *(.data.cacheline_aligned) |
| 151 | } |
| 152 | |
| 153 | _edata = .; |
| 154 | |
| 155 | /* The initial task */ |
| 156 | . = ALIGN(8192); |
| 157 | .data.init_task : { *(.data.init_task) } |
| 158 | |
| 159 | /* Initialization code and data: */ |
| 160 | |
Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 161 | . = ALIGN(1 << 12); |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 162 | __init_begin = .; |
| 163 | .init.text : { |
| 164 | _sinittext = .; |
Chris Zankel | 813e678 | 2005-07-12 13:58:25 -0700 | [diff] [blame] | 165 | *(.init.literal) *(.init.text) |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 166 | _einittext = .; |
| 167 | } |
| 168 | |
| 169 | .init.data : |
| 170 | { |
| 171 | *(.init.data) |
| 172 | . = ALIGN(0x4); |
| 173 | __tagtable_begin = .; |
| 174 | *(.taglist) |
| 175 | __tagtable_end = .; |
| 176 | } |
| 177 | |
| 178 | . = ALIGN(XCHAL_ICACHE_LINESIZE); |
| 179 | |
| 180 | __setup_start = .; |
| 181 | .init.setup : { *(.init.setup) } |
| 182 | __setup_end = .; |
| 183 | |
| 184 | __initcall_start = .; |
| 185 | .initcall.init : { |
Andrew Morton | 61ce1ef | 2006-10-27 11:41:44 -0700 | [diff] [blame] | 186 | INITCALLS |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 187 | } |
| 188 | __initcall_end = .; |
| 189 | |
| 190 | __con_initcall_start = .; |
| 191 | .con_initcall.init : { *(.con_initcall.init) } |
| 192 | __con_initcall_end = .; |
| 193 | |
| 194 | SECURITY_INIT |
| 195 | |
| 196 | . = ALIGN(4); |
| 197 | |
| 198 | __start___ftr_fixup = .; |
| 199 | __ftr_fixup : { *(__ftr_fixup) } |
| 200 | __stop___ftr_fixup = .; |
| 201 | |
Jeremy Fitzhardinge | b6e3590 | 2007-05-02 19:27:12 +0200 | [diff] [blame] | 202 | . = ALIGN(4096); |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 203 | __per_cpu_start = .; |
| 204 | .data.percpu : { *(.data.percpu) } |
| 205 | __per_cpu_end = .; |
| 206 | |
Jean-Paul Saman | 67d3822 | 2007-02-10 01:44:44 -0800 | [diff] [blame] | 207 | #ifdef CONFIG_BLK_DEV_INITRD |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 208 | . = ALIGN(4096); |
| 209 | __initramfs_start =.; |
| 210 | .init.ramfs : { *(.init.ramfs) } |
| 211 | __initramfs_end = .; |
Jean-Paul Saman | 67d3822 | 2007-02-10 01:44:44 -0800 | [diff] [blame] | 212 | #endif |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 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, |
Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 227 | XCHAL_DEBUG_VECTOR_VADDR - 4, |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 228 | SIZEOF(.WindowVectors.text), |
| 229 | .WindowVectors.text) |
| 230 | SECTION_VECTOR (_DebugInterruptVector_text, |
| 231 | .DebugInterruptVector.text, |
Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 232 | XCHAL_DEBUG_VECTOR_VADDR, |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 233 | 4, |
| 234 | .DebugInterruptVector.literal) |
| 235 | SECTION_VECTOR (_KernelExceptionVector_literal, |
| 236 | .KernelExceptionVector.literal, |
Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 237 | XCHAL_KERNEL_VECTOR_VADDR - 4, |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 238 | SIZEOF(.DebugInterruptVector.text), |
| 239 | .DebugInterruptVector.text) |
| 240 | SECTION_VECTOR (_KernelExceptionVector_text, |
| 241 | .KernelExceptionVector.text, |
Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 242 | XCHAL_KERNEL_VECTOR_VADDR, |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 243 | 4, |
| 244 | .KernelExceptionVector.literal) |
| 245 | SECTION_VECTOR (_UserExceptionVector_literal, |
| 246 | .UserExceptionVector.literal, |
Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 247 | XCHAL_USER_VECTOR_VADDR - 4, |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 248 | SIZEOF(.KernelExceptionVector.text), |
| 249 | .KernelExceptionVector.text) |
| 250 | SECTION_VECTOR (_UserExceptionVector_text, |
| 251 | .UserExceptionVector.text, |
Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 252 | XCHAL_USER_VECTOR_VADDR, |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 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; |
Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 267 | . = ALIGN(1 << 12); |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 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 | } |