vmlinux.lds.S 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  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. #include <asm-generic/vmlinux.lds.h>
  17. #include <asm/variant/core.h>
  18. OUTPUT_ARCH(xtensa)
  19. ENTRY(_start)
  20. #ifdef __XTENSA_EB__
  21. jiffies = jiffies_64 + 4;
  22. #else
  23. jiffies = jiffies_64;
  24. #endif
  25. #define KERNELOFFSET 0xd0001000
  26. /* Note: In the following macros, it would be nice to specify only the
  27. vector name and section kind and construct "sym" and "section" using
  28. CPP concatenation, but that does not work reliably. Concatenating a
  29. string with "." produces an invalid token. CPP will not print a
  30. warning because it thinks this is an assembly file, but it leaves
  31. them as multiple tokens and there may or may not be whitespace
  32. between them. */
  33. /* Macro for a relocation entry */
  34. #define RELOCATE_ENTRY(sym, section) \
  35. LONG(sym ## _start); \
  36. LONG(sym ## _end); \
  37. LONG(LOADADDR(section))
  38. /* Macro to define a section for a vector.
  39. *
  40. * Use of the MIN function catches the types of errors illustrated in
  41. * the following example:
  42. *
  43. * Assume the section .DoubleExceptionVector.literal is completely
  44. * full. Then a programmer adds code to .DoubleExceptionVector.text
  45. * that produces another literal. The final literal position will
  46. * overlay onto the first word of the adjacent code section
  47. * .DoubleExceptionVector.text. (In practice, the literals will
  48. * overwrite the code, and the first few instructions will be
  49. * garbage.)
  50. */
  51. #define SECTION_VECTOR(sym, section, addr, max_prevsec_size, prevsec) \
  52. section addr : AT((MIN(LOADADDR(prevsec) + max_prevsec_size, \
  53. LOADADDR(prevsec) + SIZEOF(prevsec)) + 3) & ~ 3) \
  54. { \
  55. . = ALIGN(4); \
  56. sym ## _start = ABSOLUTE(.); \
  57. *(section) \
  58. sym ## _end = ABSOLUTE(.); \
  59. }
  60. /*
  61. * Mapping of input sections to output sections when linking.
  62. */
  63. SECTIONS
  64. {
  65. . = KERNELOFFSET;
  66. /* .text section */
  67. _text = .;
  68. _stext = .;
  69. _ftext = .;
  70. .text :
  71. {
  72. /* The .head.text section must be the first section! */
  73. *(.head.text)
  74. *(.literal .text)
  75. VMLINUX_SYMBOL(__sched_text_start) = .;
  76. *(.sched.literal .sched.text)
  77. VMLINUX_SYMBOL(__sched_text_end) = .;
  78. VMLINUX_SYMBOL(__lock_text_start) = .;
  79. *(.spinlock.literal .spinlock.text)
  80. VMLINUX_SYMBOL(__lock_text_end) = .;
  81. }
  82. _etext = .;
  83. PROVIDE (etext = .);
  84. . = ALIGN(16);
  85. RODATA
  86. /* Relocation table */
  87. .fixup : { *(.fixup) }
  88. . = ALIGN(16);
  89. __ex_table : {
  90. __start___ex_table = .;
  91. *(__ex_table)
  92. __stop___ex_table = .;
  93. }
  94. /* Data section */
  95. . = ALIGN(XCHAL_ICACHE_LINESIZE);
  96. _fdata = .;
  97. .data :
  98. {
  99. DATA_DATA
  100. CONSTRUCTORS
  101. . = ALIGN(XCHAL_ICACHE_LINESIZE);
  102. *(.data.cacheline_aligned)
  103. }
  104. _edata = .;
  105. /* The initial task */
  106. . = ALIGN(8192);
  107. .data.init_task : { *(.data.init_task) }
  108. /* Initialization code and data: */
  109. . = ALIGN(1 << 12);
  110. __init_begin = .;
  111. .init.text : {
  112. _sinittext = .;
  113. *(.init.literal) *(.cpuinit.literal)
  114. *(.devinit.literal) *(.meminit.literal)
  115. INIT_TEXT
  116. _einittext = .;
  117. }
  118. .init.data :
  119. {
  120. INIT_DATA
  121. . = ALIGN(0x4);
  122. __tagtable_begin = .;
  123. *(.taglist)
  124. __tagtable_end = .;
  125. . = ALIGN(16);
  126. __boot_reloc_table_start = ABSOLUTE(.);
  127. RELOCATE_ENTRY(_WindowVectors_text,
  128. .WindowVectors.text);
  129. RELOCATE_ENTRY(_KernelExceptionVector_text,
  130. .KernelExceptionVector.text);
  131. RELOCATE_ENTRY(_UserExceptionVector_text,
  132. .UserExceptionVector.text);
  133. RELOCATE_ENTRY(_DoubleExceptionVector_literal,
  134. .DoubleExceptionVector.literal);
  135. RELOCATE_ENTRY(_DoubleExceptionVector_text,
  136. .DoubleExceptionVector.text);
  137. RELOCATE_ENTRY(_DebugInterruptVector_text,
  138. .DebugInterruptVector.text);
  139. __boot_reloc_table_end = ABSOLUTE(.) ;
  140. }
  141. . = ALIGN(XCHAL_ICACHE_LINESIZE);
  142. __setup_start = .;
  143. .init.setup : { *(.init.setup) }
  144. __setup_end = .;
  145. __initcall_start = .;
  146. .initcall.init : {
  147. INITCALLS
  148. }
  149. __initcall_end = .;
  150. __con_initcall_start = .;
  151. .con_initcall.init : { *(.con_initcall.init) }
  152. __con_initcall_end = .;
  153. SECURITY_INIT
  154. #ifdef CONFIG_BLK_DEV_INITRD
  155. . = ALIGN(4096);
  156. __initramfs_start =.;
  157. .init.ramfs : { *(.init.ramfs) }
  158. __initramfs_end = .;
  159. #endif
  160. PERCPU(4096)
  161. /* We need this dummy segment here */
  162. . = ALIGN(4);
  163. .dummy : { LONG(0) }
  164. /* The vectors are relocated to the real position at startup time */
  165. SECTION_VECTOR (_WindowVectors_text,
  166. .WindowVectors.text,
  167. XCHAL_WINDOW_VECTORS_VADDR, 4,
  168. .dummy)
  169. SECTION_VECTOR (_DebugInterruptVector_literal,
  170. .DebugInterruptVector.literal,
  171. XCHAL_DEBUG_VECTOR_VADDR - 4,
  172. SIZEOF(.WindowVectors.text),
  173. .WindowVectors.text)
  174. SECTION_VECTOR (_DebugInterruptVector_text,
  175. .DebugInterruptVector.text,
  176. XCHAL_DEBUG_VECTOR_VADDR,
  177. 4,
  178. .DebugInterruptVector.literal)
  179. SECTION_VECTOR (_KernelExceptionVector_literal,
  180. .KernelExceptionVector.literal,
  181. XCHAL_KERNEL_VECTOR_VADDR - 4,
  182. SIZEOF(.DebugInterruptVector.text),
  183. .DebugInterruptVector.text)
  184. SECTION_VECTOR (_KernelExceptionVector_text,
  185. .KernelExceptionVector.text,
  186. XCHAL_KERNEL_VECTOR_VADDR,
  187. 4,
  188. .KernelExceptionVector.literal)
  189. SECTION_VECTOR (_UserExceptionVector_literal,
  190. .UserExceptionVector.literal,
  191. XCHAL_USER_VECTOR_VADDR - 4,
  192. SIZEOF(.KernelExceptionVector.text),
  193. .KernelExceptionVector.text)
  194. SECTION_VECTOR (_UserExceptionVector_text,
  195. .UserExceptionVector.text,
  196. XCHAL_USER_VECTOR_VADDR,
  197. 4,
  198. .UserExceptionVector.literal)
  199. SECTION_VECTOR (_DoubleExceptionVector_literal,
  200. .DoubleExceptionVector.literal,
  201. XCHAL_DOUBLEEXC_VECTOR_VADDR - 16,
  202. SIZEOF(.UserExceptionVector.text),
  203. .UserExceptionVector.text)
  204. SECTION_VECTOR (_DoubleExceptionVector_text,
  205. .DoubleExceptionVector.text,
  206. XCHAL_DOUBLEEXC_VECTOR_VADDR,
  207. 32,
  208. .DoubleExceptionVector.literal)
  209. . = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3;
  210. . = ALIGN(1 << 12);
  211. __init_end = .;
  212. . = ALIGN(8192);
  213. /* BSS section */
  214. _bss_start = .;
  215. .bss : { *(.bss.page_aligned) *(.bss) }
  216. _bss_end = .;
  217. _end = .;
  218. /* only used by the boot loader */
  219. . = ALIGN(0x10);
  220. .bootstrap : { *(.bootstrap.literal .bootstrap.text .bootstrap.data) }
  221. . = ALIGN(0x1000);
  222. __initrd_start = .;
  223. .initrd : { *(.initrd) }
  224. __initrd_end = .;
  225. .ResetVector.text XCHAL_RESET_VECTOR_VADDR :
  226. {
  227. *(.ResetVector.text)
  228. }
  229. /* Sections to be discarded */
  230. /DISCARD/ :
  231. {
  232. *(.exit.literal)
  233. EXIT_TEXT
  234. EXIT_DATA
  235. *(.exitcall.exit)
  236. }
  237. .xt.lit : { *(.xt.lit) }
  238. .xt.prop : { *(.xt.prop) }
  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. .xt.insn 0 :
  257. {
  258. *(.xt.insn)
  259. *(.gnu.linkonce.x*)
  260. }
  261. .xt.lit 0 :
  262. {
  263. *(.xt.lit)
  264. *(.gnu.linkonce.p*)
  265. }
  266. }