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> |
Tim Abbott | cd3db32 | 2009-09-24 10:36:19 -0400 | [diff] [blame] | 18 | #include <asm/page.h> |
| 19 | #include <asm/thread_info.h> |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 20 | |
Chris Zankel | 367b811 | 2008-11-06 06:40:46 -0800 | [diff] [blame] | 21 | #include <variant/core.h> |
Johannes Weiner | 6770fa0 | 2009-03-04 16:21:32 +0100 | [diff] [blame] | 22 | #include <platform/hardware.h> |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 23 | OUTPUT_ARCH(xtensa) |
| 24 | ENTRY(_start) |
| 25 | |
Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 26 | #ifdef __XTENSA_EB__ |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 27 | jiffies = jiffies_64 + 4; |
| 28 | #else |
| 29 | jiffies = jiffies_64; |
| 30 | #endif |
| 31 | |
Johannes Weiner | 6770fa0 | 2009-03-04 16:21:32 +0100 | [diff] [blame] | 32 | #ifndef KERNELOFFSET |
Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 33 | #define KERNELOFFSET 0xd0001000 |
Johannes Weiner | 6770fa0 | 2009-03-04 16:21:32 +0100 | [diff] [blame] | 34 | #endif |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 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 | { |
Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 81 | . = KERNELOFFSET; |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 82 | /* .text section */ |
| 83 | |
| 84 | _text = .; |
| 85 | _stext = .; |
| 86 | _ftext = .; |
| 87 | |
| 88 | .text : |
| 89 | { |
Tim Abbott | 0ebdcb4 | 2009-04-25 22:10:57 -0400 | [diff] [blame] | 90 | /* The HEAD_TEXT section must be the first section! */ |
| 91 | HEAD_TEXT |
Chris Zankel | 78f3cdf | 2009-04-21 00:34:15 -0700 | [diff] [blame] | 92 | TEXT_TEXT |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 93 | VMLINUX_SYMBOL(__sched_text_start) = .; |
Chris Zankel | 813e678 | 2005-07-12 13:58:25 -0700 | [diff] [blame] | 94 | *(.sched.literal .sched.text) |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 95 | VMLINUX_SYMBOL(__sched_text_end) = .; |
| 96 | VMLINUX_SYMBOL(__lock_text_start) = .; |
Chris Zankel | 813e678 | 2005-07-12 13:58:25 -0700 | [diff] [blame] | 97 | *(.spinlock.literal .spinlock.text) |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 98 | VMLINUX_SYMBOL(__lock_text_end) = .; |
| 99 | |
| 100 | } |
| 101 | _etext = .; |
Chris Zankel | de4f6e5 | 2007-05-31 17:47:01 -0700 | [diff] [blame] | 102 | PROVIDE (etext = .); |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 103 | |
| 104 | . = ALIGN(16); |
| 105 | |
| 106 | RODATA |
| 107 | |
| 108 | /* Relocation table */ |
| 109 | |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 110 | .fixup : { *(.fixup) } |
| 111 | |
Tim Abbott | cd3db32 | 2009-09-24 10:36:19 -0400 | [diff] [blame] | 112 | EXCEPTION_TABLE(16) |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 113 | /* Data section */ |
| 114 | |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 115 | _fdata = .; |
Tim Abbott | cd3db32 | 2009-09-24 10:36:19 -0400 | [diff] [blame] | 116 | RW_DATA_SECTION(XCHAL_ICACHE_LINESIZE, PAGE_SIZE, THREAD_SIZE) |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 117 | _edata = .; |
| 118 | |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 119 | /* Initialization code and data: */ |
| 120 | |
Tim Abbott | cd3db32 | 2009-09-24 10:36:19 -0400 | [diff] [blame] | 121 | . = ALIGN(PAGE_SIZE); |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 122 | __init_begin = .; |
Tim Abbott | cd3db32 | 2009-09-24 10:36:19 -0400 | [diff] [blame] | 123 | INIT_TEXT_SECTION(PAGE_SIZE) |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 124 | |
| 125 | .init.data : |
| 126 | { |
Sam Ravnborg | 01ba2bd | 2008-01-20 14:15:03 +0100 | [diff] [blame] | 127 | INIT_DATA |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 128 | . = ALIGN(0x4); |
| 129 | __tagtable_begin = .; |
| 130 | *(.taglist) |
| 131 | __tagtable_end = .; |
Chris Zankel | de4f6e5 | 2007-05-31 17:47:01 -0700 | [diff] [blame] | 132 | |
| 133 | . = ALIGN(16); |
| 134 | __boot_reloc_table_start = ABSOLUTE(.); |
| 135 | |
| 136 | RELOCATE_ENTRY(_WindowVectors_text, |
| 137 | .WindowVectors.text); |
| 138 | RELOCATE_ENTRY(_KernelExceptionVector_text, |
| 139 | .KernelExceptionVector.text); |
| 140 | RELOCATE_ENTRY(_UserExceptionVector_text, |
| 141 | .UserExceptionVector.text); |
| 142 | RELOCATE_ENTRY(_DoubleExceptionVector_literal, |
| 143 | .DoubleExceptionVector.literal); |
| 144 | RELOCATE_ENTRY(_DoubleExceptionVector_text, |
| 145 | .DoubleExceptionVector.text); |
Marc Gauthier | 6d15d10 | 2007-12-30 22:00:54 -0800 | [diff] [blame] | 146 | RELOCATE_ENTRY(_DebugInterruptVector_text, |
| 147 | .DebugInterruptVector.text); |
Chris Zankel | de4f6e5 | 2007-05-31 17:47:01 -0700 | [diff] [blame] | 148 | |
| 149 | __boot_reloc_table_end = ABSOLUTE(.) ; |
Tim Abbott | cd3db32 | 2009-09-24 10:36:19 -0400 | [diff] [blame] | 150 | |
| 151 | INIT_SETUP(XCHAL_ICACHE_LINESIZE) |
| 152 | INIT_CALLS |
| 153 | CON_INITCALL |
| 154 | SECURITY_INITCALL |
| 155 | INIT_RAM_FS |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 156 | } |
| 157 | |
Tim Abbott | cd3db32 | 2009-09-24 10:36:19 -0400 | [diff] [blame] | 158 | PERCPU(PAGE_SIZE) |
Chris Zankel | de4f6e5 | 2007-05-31 17:47:01 -0700 | [diff] [blame] | 159 | |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 160 | /* We need this dummy segment here */ |
| 161 | |
| 162 | . = ALIGN(4); |
| 163 | .dummy : { LONG(0) } |
| 164 | |
| 165 | /* The vectors are relocated to the real position at startup time */ |
| 166 | |
| 167 | SECTION_VECTOR (_WindowVectors_text, |
| 168 | .WindowVectors.text, |
| 169 | XCHAL_WINDOW_VECTORS_VADDR, 4, |
| 170 | .dummy) |
| 171 | SECTION_VECTOR (_DebugInterruptVector_literal, |
| 172 | .DebugInterruptVector.literal, |
Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 173 | XCHAL_DEBUG_VECTOR_VADDR - 4, |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 174 | SIZEOF(.WindowVectors.text), |
| 175 | .WindowVectors.text) |
| 176 | SECTION_VECTOR (_DebugInterruptVector_text, |
| 177 | .DebugInterruptVector.text, |
Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 178 | XCHAL_DEBUG_VECTOR_VADDR, |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 179 | 4, |
| 180 | .DebugInterruptVector.literal) |
| 181 | SECTION_VECTOR (_KernelExceptionVector_literal, |
| 182 | .KernelExceptionVector.literal, |
Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 183 | XCHAL_KERNEL_VECTOR_VADDR - 4, |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 184 | SIZEOF(.DebugInterruptVector.text), |
| 185 | .DebugInterruptVector.text) |
| 186 | SECTION_VECTOR (_KernelExceptionVector_text, |
| 187 | .KernelExceptionVector.text, |
Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 188 | XCHAL_KERNEL_VECTOR_VADDR, |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 189 | 4, |
| 190 | .KernelExceptionVector.literal) |
| 191 | SECTION_VECTOR (_UserExceptionVector_literal, |
| 192 | .UserExceptionVector.literal, |
Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 193 | XCHAL_USER_VECTOR_VADDR - 4, |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 194 | SIZEOF(.KernelExceptionVector.text), |
| 195 | .KernelExceptionVector.text) |
| 196 | SECTION_VECTOR (_UserExceptionVector_text, |
| 197 | .UserExceptionVector.text, |
Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 198 | XCHAL_USER_VECTOR_VADDR, |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 199 | 4, |
| 200 | .UserExceptionVector.literal) |
| 201 | SECTION_VECTOR (_DoubleExceptionVector_literal, |
| 202 | .DoubleExceptionVector.literal, |
| 203 | XCHAL_DOUBLEEXC_VECTOR_VADDR - 16, |
| 204 | SIZEOF(.UserExceptionVector.text), |
| 205 | .UserExceptionVector.text) |
| 206 | SECTION_VECTOR (_DoubleExceptionVector_text, |
| 207 | .DoubleExceptionVector.text, |
| 208 | XCHAL_DOUBLEEXC_VECTOR_VADDR, |
| 209 | 32, |
| 210 | .DoubleExceptionVector.literal) |
| 211 | |
| 212 | . = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3; |
Tim Abbott | cd3db32 | 2009-09-24 10:36:19 -0400 | [diff] [blame] | 213 | . = ALIGN(PAGE_SIZE); |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 214 | |
| 215 | __init_end = .; |
| 216 | |
Tim Abbott | cd3db32 | 2009-09-24 10:36:19 -0400 | [diff] [blame] | 217 | BSS_SECTION(0, 8192, 0) |
Chris Zankel | de4f6e5 | 2007-05-31 17:47:01 -0700 | [diff] [blame] | 218 | |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 219 | _end = .; |
| 220 | |
| 221 | /* only used by the boot loader */ |
| 222 | |
| 223 | . = ALIGN(0x10); |
| 224 | .bootstrap : { *(.bootstrap.literal .bootstrap.text .bootstrap.data) } |
| 225 | |
| 226 | . = ALIGN(0x1000); |
| 227 | __initrd_start = .; |
| 228 | .initrd : { *(.initrd) } |
| 229 | __initrd_end = .; |
| 230 | |
| 231 | .ResetVector.text XCHAL_RESET_VECTOR_VADDR : |
| 232 | { |
| 233 | *(.ResetVector.text) |
| 234 | } |
| 235 | |
Chris Zankel | de4f6e5 | 2007-05-31 17:47:01 -0700 | [diff] [blame] | 236 | .xt.lit : { *(.xt.lit) } |
| 237 | .xt.prop : { *(.xt.prop) } |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 238 | |
| 239 | .debug 0 : { *(.debug) } |
| 240 | .line 0 : { *(.line) } |
| 241 | .debug_srcinfo 0 : { *(.debug_srcinfo) } |
| 242 | .debug_sfnames 0 : { *(.debug_sfnames) } |
| 243 | .debug_aranges 0 : { *(.debug_aranges) } |
| 244 | .debug_pubnames 0 : { *(.debug_pubnames) } |
| 245 | .debug_info 0 : { *(.debug_info) } |
| 246 | .debug_abbrev 0 : { *(.debug_abbrev) } |
| 247 | .debug_line 0 : { *(.debug_line) } |
| 248 | .debug_frame 0 : { *(.debug_frame) } |
| 249 | .debug_str 0 : { *(.debug_str) } |
| 250 | .debug_loc 0 : { *(.debug_loc) } |
| 251 | .debug_macinfo 0 : { *(.debug_macinfo) } |
| 252 | .debug_weaknames 0 : { *(.debug_weaknames) } |
| 253 | .debug_funcnames 0 : { *(.debug_funcnames) } |
| 254 | .debug_typenames 0 : { *(.debug_typenames) } |
| 255 | .debug_varnames 0 : { *(.debug_varnames) } |
| 256 | |
| 257 | .xt.insn 0 : |
| 258 | { |
| 259 | *(.xt.insn) |
| 260 | *(.gnu.linkonce.x*) |
| 261 | } |
| 262 | |
| 263 | .xt.lit 0 : |
| 264 | { |
| 265 | *(.xt.lit) |
| 266 | *(.gnu.linkonce.p*) |
| 267 | } |
Tejun Heo | 023bf6f | 2009-07-09 11:27:40 +0900 | [diff] [blame] | 268 | |
| 269 | /* Sections to be discarded */ |
| 270 | DISCARDS |
| 271 | /DISCARD/ : { *(.exit.literal) } |
Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 272 | } |