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 19#include <asm/variant/core.h> 20OUTPUT_ARCH(xtensa) 21ENTRY(_start) 22 23#ifdef __XTENSA_EB__ 24jiffies = jiffies_64 + 4; 25#else 26jiffies = jiffies_64; 27#endif 28 29#define KERNELOFFSET 0xd0001000 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 74SECTIONS 75{ 76 . = KERNELOFFSET; 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) 87 *(.literal) 88 TEXT_TEXT 89 *(.srom.text) 90 VMLINUX_SYMBOL(__sched_text_start) = .; 91 *(.sched.literal .sched.text) 92 VMLINUX_SYMBOL(__sched_text_end) = .; 93 VMLINUX_SYMBOL(__lock_text_start) = .; 94 *(.spinlock.literal .spinlock.text) 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_DATA 149 CONSTRUCTORS 150 . = ALIGN(XCHAL_ICACHE_LINESIZE); 151 *(.data.cacheline_aligned) 152 } 153 154 _edata = .; 155 156 /* The initial task */ 157 . = ALIGN(8192); 158 .data.init_task : { *(.data.init_task) } 159 160 /* Initialization code and data: */ 161 162 . = ALIGN(1 << 12); 163 __init_begin = .; 164 .init.text : { 165 _sinittext = .; 166 *(.init.literal) *(.init.text) 167 _einittext = .; 168 } 169 170 .init.data : 171 { 172 *(.init.data) 173 . = ALIGN(0x4); 174 __tagtable_begin = .; 175 *(.taglist) 176 __tagtable_end = .; 177 } 178 179 . = ALIGN(XCHAL_ICACHE_LINESIZE); 180 181 __setup_start = .; 182 .init.setup : { *(.init.setup) } 183 __setup_end = .; 184 185 __initcall_start = .; 186 .initcall.init : { 187 INITCALLS 188 } 189 __initcall_end = .; 190 191 __con_initcall_start = .; 192 .con_initcall.init : { *(.con_initcall.init) } 193 __con_initcall_end = .; 194 195 SECURITY_INIT 196 197 . = ALIGN(4); 198 199 __start___ftr_fixup = .; 200 __ftr_fixup : { *(__ftr_fixup) } 201 __stop___ftr_fixup = .; 202 203 . = ALIGN(4096); 204 __per_cpu_start = .; 205 .data.percpu : { *(.data.percpu) } 206 __per_cpu_end = .; 207 208#ifdef CONFIG_BLK_DEV_INITRD 209 . = ALIGN(4096); 210 __initramfs_start =.; 211 .init.ramfs : { *(.init.ramfs) } 212 __initramfs_end = .; 213#endif 214 215 /* We need this dummy segment here */ 216 217 . = ALIGN(4); 218 .dummy : { LONG(0) } 219 220 /* The vectors are relocated to the real position at startup time */ 221 222 SECTION_VECTOR (_WindowVectors_text, 223 .WindowVectors.text, 224 XCHAL_WINDOW_VECTORS_VADDR, 4, 225 .dummy) 226 SECTION_VECTOR (_DebugInterruptVector_literal, 227 .DebugInterruptVector.literal, 228 XCHAL_DEBUG_VECTOR_VADDR - 4, 229 SIZEOF(.WindowVectors.text), 230 .WindowVectors.text) 231 SECTION_VECTOR (_DebugInterruptVector_text, 232 .DebugInterruptVector.text, 233 XCHAL_DEBUG_VECTOR_VADDR, 234 4, 235 .DebugInterruptVector.literal) 236 SECTION_VECTOR (_KernelExceptionVector_literal, 237 .KernelExceptionVector.literal, 238 XCHAL_KERNEL_VECTOR_VADDR - 4, 239 SIZEOF(.DebugInterruptVector.text), 240 .DebugInterruptVector.text) 241 SECTION_VECTOR (_KernelExceptionVector_text, 242 .KernelExceptionVector.text, 243 XCHAL_KERNEL_VECTOR_VADDR, 244 4, 245 .KernelExceptionVector.literal) 246 SECTION_VECTOR (_UserExceptionVector_literal, 247 .UserExceptionVector.literal, 248 XCHAL_USER_VECTOR_VADDR - 4, 249 SIZEOF(.KernelExceptionVector.text), 250 .KernelExceptionVector.text) 251 SECTION_VECTOR (_UserExceptionVector_text, 252 .UserExceptionVector.text, 253 XCHAL_USER_VECTOR_VADDR, 254 4, 255 .UserExceptionVector.literal) 256 SECTION_VECTOR (_DoubleExceptionVector_literal, 257 .DoubleExceptionVector.literal, 258 XCHAL_DOUBLEEXC_VECTOR_VADDR - 16, 259 SIZEOF(.UserExceptionVector.text), 260 .UserExceptionVector.text) 261 SECTION_VECTOR (_DoubleExceptionVector_text, 262 .DoubleExceptionVector.text, 263 XCHAL_DOUBLEEXC_VECTOR_VADDR, 264 32, 265 .DoubleExceptionVector.literal) 266 267 . = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3; 268 . = ALIGN(1 << 12); 269 270 __init_end = .; 271 272 . = ALIGN(8192); 273 274 /* BSS section */ 275 _bss_start = .; 276 .sbss : { *(.sbss) *(.scommon) } 277 .bss : { *(COMMON) *(.bss) } 278 _bss_end = .; 279 _end = .; 280 281 /* only used by the boot loader */ 282 283 . = ALIGN(0x10); 284 .bootstrap : { *(.bootstrap.literal .bootstrap.text .bootstrap.data) } 285 286 . = ALIGN(0x1000); 287 __initrd_start = .; 288 .initrd : { *(.initrd) } 289 __initrd_end = .; 290 291 .ResetVector.text XCHAL_RESET_VECTOR_VADDR : 292 { 293 *(.ResetVector.text) 294 } 295 296 297 /* Sections to be discarded */ 298 /DISCARD/ : 299 { 300 *(.text.exit) 301 *(.text.exit.literal) 302 *(.data.exit) 303 *(.exitcall.exit) 304 } 305 306 307 .debug 0 : { *(.debug) } 308 .line 0 : { *(.line) } 309 .debug_srcinfo 0 : { *(.debug_srcinfo) } 310 .debug_sfnames 0 : { *(.debug_sfnames) } 311 .debug_aranges 0 : { *(.debug_aranges) } 312 .debug_pubnames 0 : { *(.debug_pubnames) } 313 .debug_info 0 : { *(.debug_info) } 314 .debug_abbrev 0 : { *(.debug_abbrev) } 315 .debug_line 0 : { *(.debug_line) } 316 .debug_frame 0 : { *(.debug_frame) } 317 .debug_str 0 : { *(.debug_str) } 318 .debug_loc 0 : { *(.debug_loc) } 319 .debug_macinfo 0 : { *(.debug_macinfo) } 320 .debug_weaknames 0 : { *(.debug_weaknames) } 321 .debug_funcnames 0 : { *(.debug_funcnames) } 322 .debug_typenames 0 : { *(.debug_typenames) } 323 .debug_varnames 0 : { *(.debug_varnames) } 324 325 .xt.insn 0 : 326 { 327 *(.xt.insn) 328 *(.gnu.linkonce.x*) 329 } 330 331 .xt.lit 0 : 332 { 333 *(.xt.lit) 334 *(.gnu.linkonce.p*) 335 } 336} 337