| 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) | 
| Chris Zankel | de4f6e5 | 2007-05-31 17:47:01 -0700 | [diff] [blame] | 87 |     *(.literal .text) | 
| Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 88 |     VMLINUX_SYMBOL(__sched_text_start) = .; | 
| Chris Zankel | 813e678 | 2005-07-12 13:58:25 -0700 | [diff] [blame] | 89 |     *(.sched.literal .sched.text) | 
| Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 90 |     VMLINUX_SYMBOL(__sched_text_end) = .; | 
 | 91 |     VMLINUX_SYMBOL(__lock_text_start) = .; | 
| Chris Zankel | 813e678 | 2005-07-12 13:58:25 -0700 | [diff] [blame] | 92 |     *(.spinlock.literal .spinlock.text) | 
| Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 93 |     VMLINUX_SYMBOL(__lock_text_end) = .; | 
 | 94 |  | 
 | 95 |   } | 
 | 96 |   _etext = .; | 
| Chris Zankel | de4f6e5 | 2007-05-31 17:47:01 -0700 | [diff] [blame] | 97 |   PROVIDE (etext = .); | 
| Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 98 |  | 
 | 99 |   . = ALIGN(16); | 
 | 100 |  | 
 | 101 |   RODATA | 
 | 102 |  | 
 | 103 |   /*  Relocation table */ | 
 | 104 |  | 
| Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 105 |   .fixup   : { *(.fixup) } | 
 | 106 |  | 
 | 107 |   . = ALIGN(16); | 
 | 108 |  | 
 | 109 |   __ex_table : { | 
 | 110 |     __start___ex_table = .; | 
 | 111 |     *(__ex_table) | 
 | 112 |     __stop___ex_table = .; | 
 | 113 |   } | 
 | 114 |  | 
 | 115 |   /* Data section */ | 
 | 116 |  | 
 | 117 |   . = ALIGN(XCHAL_ICACHE_LINESIZE); | 
 | 118 |   _fdata = .; | 
 | 119 |   .data : | 
 | 120 |   { | 
| Mathieu Desnoyers | b824325 | 2007-06-16 22:29:39 -0400 | [diff] [blame] | 121 |     DATA_DATA | 
 | 122 |     CONSTRUCTORS | 
| Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 123 |     . = ALIGN(XCHAL_ICACHE_LINESIZE); | 
 | 124 |     *(.data.cacheline_aligned) | 
 | 125 |   } | 
 | 126 |  | 
 | 127 |   _edata = .; | 
 | 128 |  | 
 | 129 |   /* The initial task */ | 
 | 130 |   . = ALIGN(8192); | 
 | 131 |   .data.init_task : { *(.data.init_task) } | 
 | 132 |  | 
 | 133 |   /* Initialization code and data: */ | 
 | 134 |  | 
| Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 135 |   . = ALIGN(1 << 12); | 
| Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 136 |   __init_begin = .; | 
 | 137 |   .init.text : { | 
 | 138 |   	_sinittext = .; | 
| Chris Zankel | 4f8d98f | 2008-02-13 16:44:19 -0800 | [diff] [blame] | 139 | 	*(.init.literal) *(.cpuinit.literal)  | 
 | 140 | 	*(.devinit.literal) *(.meminit.literal) | 
 | 141 | 	INIT_TEXT | 
| Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 142 | 	_einittext = .; | 
 | 143 |   } | 
 | 144 |  | 
 | 145 |   .init.data : | 
 | 146 |   { | 
| Sam Ravnborg | 01ba2bd | 2008-01-20 14:15:03 +0100 | [diff] [blame] | 147 |     INIT_DATA | 
| Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 148 |     . = ALIGN(0x4); | 
 | 149 |     __tagtable_begin = .; | 
 | 150 |     *(.taglist) | 
 | 151 |     __tagtable_end = .; | 
| Chris Zankel | de4f6e5 | 2007-05-31 17:47:01 -0700 | [diff] [blame] | 152 |  | 
 | 153 |     . = ALIGN(16); | 
 | 154 |     __boot_reloc_table_start = ABSOLUTE(.); | 
 | 155 |  | 
 | 156 |     RELOCATE_ENTRY(_WindowVectors_text, | 
 | 157 | 		   .WindowVectors.text); | 
 | 158 |     RELOCATE_ENTRY(_KernelExceptionVector_text, | 
 | 159 | 		   .KernelExceptionVector.text); | 
 | 160 |     RELOCATE_ENTRY(_UserExceptionVector_text, | 
 | 161 | 		   .UserExceptionVector.text); | 
 | 162 |     RELOCATE_ENTRY(_DoubleExceptionVector_literal, | 
 | 163 | 		   .DoubleExceptionVector.literal); | 
 | 164 |     RELOCATE_ENTRY(_DoubleExceptionVector_text, | 
 | 165 | 		   .DoubleExceptionVector.text); | 
| Marc Gauthier | 6d15d10 | 2007-12-30 22:00:54 -0800 | [diff] [blame] | 166 |     RELOCATE_ENTRY(_DebugInterruptVector_text, | 
 | 167 | 		   .DebugInterruptVector.text); | 
| Chris Zankel | de4f6e5 | 2007-05-31 17:47:01 -0700 | [diff] [blame] | 168 |    | 
 | 169 |     __boot_reloc_table_end = ABSOLUTE(.) ; | 
| Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 170 |   } | 
 | 171 |  | 
 | 172 |   . = ALIGN(XCHAL_ICACHE_LINESIZE); | 
 | 173 |  | 
 | 174 |   __setup_start = .; | 
 | 175 |   .init.setup : { *(.init.setup) } | 
 | 176 |   __setup_end = .; | 
 | 177 |  | 
 | 178 |   __initcall_start = .; | 
 | 179 |   .initcall.init : { | 
| Andrew Morton | 61ce1ef | 2006-10-27 11:41:44 -0700 | [diff] [blame] | 180 | 	INITCALLS | 
| Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 181 |   } | 
 | 182 |   __initcall_end = .; | 
 | 183 |  | 
 | 184 |   __con_initcall_start = .; | 
 | 185 |   .con_initcall.init : { *(.con_initcall.init) } | 
 | 186 |   __con_initcall_end = .; | 
 | 187 |  | 
 | 188 |   SECURITY_INIT | 
 | 189 |  | 
| Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 190 |  | 
| Jean-Paul Saman | 67d3822 | 2007-02-10 01:44:44 -0800 | [diff] [blame] | 191 | #ifdef CONFIG_BLK_DEV_INITRD | 
| Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 192 |   . = ALIGN(4096); | 
 | 193 |   __initramfs_start =.; | 
 | 194 |   .init.ramfs : { *(.init.ramfs) } | 
 | 195 |   __initramfs_end = .; | 
| Jean-Paul Saman | 67d3822 | 2007-02-10 01:44:44 -0800 | [diff] [blame] | 196 | #endif | 
| Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 197 |  | 
| Fenghua Yu | 5fb7dc3 | 2007-07-19 01:48:12 -0700 | [diff] [blame] | 198 |   PERCPU(4096) | 
| Chris Zankel | de4f6e5 | 2007-05-31 17:47:01 -0700 | [diff] [blame] | 199 |  | 
 | 200 |  | 
| Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 201 |   /* We need this dummy segment here */ | 
 | 202 |  | 
 | 203 |   . = ALIGN(4); | 
 | 204 |   .dummy : { LONG(0) } | 
 | 205 |  | 
 | 206 |   /* The vectors are relocated to the real position at startup time */ | 
 | 207 |  | 
 | 208 |   SECTION_VECTOR (_WindowVectors_text, | 
 | 209 | 		  .WindowVectors.text, | 
 | 210 | 		  XCHAL_WINDOW_VECTORS_VADDR, 4, | 
 | 211 | 		  .dummy) | 
 | 212 |   SECTION_VECTOR (_DebugInterruptVector_literal, | 
 | 213 | 		  .DebugInterruptVector.literal, | 
| Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 214 | 		  XCHAL_DEBUG_VECTOR_VADDR - 4, | 
| Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 215 | 		  SIZEOF(.WindowVectors.text), | 
 | 216 | 		  .WindowVectors.text) | 
 | 217 |   SECTION_VECTOR (_DebugInterruptVector_text, | 
 | 218 | 		  .DebugInterruptVector.text, | 
| Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 219 | 		  XCHAL_DEBUG_VECTOR_VADDR, | 
| Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 220 | 		  4, | 
 | 221 | 		  .DebugInterruptVector.literal) | 
 | 222 |   SECTION_VECTOR (_KernelExceptionVector_literal, | 
 | 223 | 		  .KernelExceptionVector.literal, | 
| Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 224 | 		  XCHAL_KERNEL_VECTOR_VADDR - 4, | 
| Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 225 | 		  SIZEOF(.DebugInterruptVector.text), | 
 | 226 | 		  .DebugInterruptVector.text) | 
 | 227 |   SECTION_VECTOR (_KernelExceptionVector_text, | 
 | 228 | 		  .KernelExceptionVector.text, | 
| Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 229 | 		  XCHAL_KERNEL_VECTOR_VADDR, | 
| Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 230 | 		  4, | 
 | 231 | 		  .KernelExceptionVector.literal) | 
 | 232 |   SECTION_VECTOR (_UserExceptionVector_literal, | 
 | 233 | 		  .UserExceptionVector.literal, | 
| Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 234 | 		  XCHAL_USER_VECTOR_VADDR - 4, | 
| Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 235 | 		  SIZEOF(.KernelExceptionVector.text), | 
 | 236 | 		  .KernelExceptionVector.text) | 
 | 237 |   SECTION_VECTOR (_UserExceptionVector_text, | 
 | 238 | 		  .UserExceptionVector.text, | 
| Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 239 | 		  XCHAL_USER_VECTOR_VADDR, | 
| Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 240 | 		  4, | 
 | 241 | 		  .UserExceptionVector.literal) | 
 | 242 |   SECTION_VECTOR (_DoubleExceptionVector_literal, | 
 | 243 | 		  .DoubleExceptionVector.literal, | 
 | 244 | 		  XCHAL_DOUBLEEXC_VECTOR_VADDR - 16, | 
 | 245 | 		  SIZEOF(.UserExceptionVector.text), | 
 | 246 | 		  .UserExceptionVector.text) | 
 | 247 |   SECTION_VECTOR (_DoubleExceptionVector_text, | 
 | 248 | 		  .DoubleExceptionVector.text, | 
 | 249 | 		  XCHAL_DOUBLEEXC_VECTOR_VADDR, | 
 | 250 | 		  32, | 
 | 251 | 		  .DoubleExceptionVector.literal) | 
 | 252 |  | 
 | 253 |   . = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3; | 
| Chris Zankel | 173d668 | 2006-12-10 02:18:48 -0800 | [diff] [blame] | 254 |   . = ALIGN(1 << 12); | 
| Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 255 |  | 
 | 256 |   __init_end = .; | 
 | 257 |  | 
 | 258 |   . = ALIGN(8192); | 
 | 259 |  | 
 | 260 |   /* BSS section */ | 
 | 261 |   _bss_start = .; | 
| Chris Zankel | de4f6e5 | 2007-05-31 17:47:01 -0700 | [diff] [blame] | 262 |   .bss : { *(.bss.page_aligned) *(.bss) } | 
| Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 263 |   _bss_end = .; | 
| Chris Zankel | de4f6e5 | 2007-05-31 17:47:01 -0700 | [diff] [blame] | 264 |  | 
| Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 265 |   _end = .; | 
 | 266 |  | 
 | 267 |   /* only used by the boot loader  */ | 
 | 268 |  | 
 | 269 |   . = ALIGN(0x10); | 
 | 270 |   .bootstrap : { *(.bootstrap.literal .bootstrap.text .bootstrap.data) } | 
 | 271 |  | 
 | 272 |   . = ALIGN(0x1000); | 
 | 273 |   __initrd_start = .; | 
 | 274 |   .initrd : { *(.initrd) } | 
 | 275 |   __initrd_end = .; | 
 | 276 |  | 
 | 277 |   .ResetVector.text XCHAL_RESET_VECTOR_VADDR : | 
 | 278 |   { | 
 | 279 |     *(.ResetVector.text) | 
 | 280 |   } | 
 | 281 |  | 
| Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 282 |   /* Sections to be discarded */ | 
 | 283 |   /DISCARD/ : | 
 | 284 |   { | 
| Sam Ravnborg | 01ba2bd | 2008-01-20 14:15:03 +0100 | [diff] [blame] | 285 | 	*(.exit.literal) | 
 | 286 | 	EXIT_TEXT | 
 | 287 | 	EXIT_DATA | 
| Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 288 |         *(.exitcall.exit) | 
 | 289 |   } | 
 | 290 |  | 
| Chris Zankel | de4f6e5 | 2007-05-31 17:47:01 -0700 | [diff] [blame] | 291 |   .xt.lit : { *(.xt.lit) } | 
 | 292 |   .xt.prop : { *(.xt.prop) } | 
| Chris Zankel | 5a0015d | 2005-06-23 22:01:16 -0700 | [diff] [blame] | 293 |  | 
 | 294 |   .debug  0 :  { *(.debug) } | 
 | 295 |   .line  0 :  { *(.line) } | 
 | 296 |   .debug_srcinfo  0 :  { *(.debug_srcinfo) } | 
 | 297 |   .debug_sfnames  0 :  { *(.debug_sfnames) } | 
 | 298 |   .debug_aranges  0 :  { *(.debug_aranges) } | 
 | 299 |   .debug_pubnames  0 :  { *(.debug_pubnames) } | 
 | 300 |   .debug_info  0 :  { *(.debug_info) } | 
 | 301 |   .debug_abbrev  0 :  { *(.debug_abbrev) } | 
 | 302 |   .debug_line  0 :  { *(.debug_line) } | 
 | 303 |   .debug_frame  0 :  { *(.debug_frame) } | 
 | 304 |   .debug_str  0 :  { *(.debug_str) } | 
 | 305 |   .debug_loc  0 :  { *(.debug_loc) } | 
 | 306 |   .debug_macinfo  0 :  { *(.debug_macinfo) } | 
 | 307 |   .debug_weaknames  0 :  { *(.debug_weaknames) } | 
 | 308 |   .debug_funcnames  0 :  { *(.debug_funcnames) } | 
 | 309 |   .debug_typenames  0 :  { *(.debug_typenames) } | 
 | 310 |   .debug_varnames  0 :  { *(.debug_varnames) } | 
 | 311 |  | 
 | 312 |   .xt.insn 0 : | 
 | 313 |   { | 
 | 314 |     *(.xt.insn) | 
 | 315 |     *(.gnu.linkonce.x*) | 
 | 316 |   } | 
 | 317 |  | 
 | 318 |   .xt.lit 0 : | 
 | 319 |   { | 
 | 320 |     *(.xt.lit) | 
 | 321 |     *(.gnu.linkonce.p*) | 
 | 322 |   } | 
 | 323 | } |