vmlinux.lds.S 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  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 - 2008 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/page.h>
  18. #include <asm/thread_info.h>
  19. #include <asm/vectors.h>
  20. #include <variant/core.h>
  21. OUTPUT_ARCH(xtensa)
  22. ENTRY(_start)
  23. #ifdef __XTENSA_EB__
  24. jiffies = jiffies_64 + 4;
  25. #else
  26. jiffies = jiffies_64;
  27. #endif
  28. /* Note: In the following macros, it would be nice to specify only the
  29. vector name and section kind and construct "sym" and "section" using
  30. CPP concatenation, but that does not work reliably. Concatenating a
  31. string with "." produces an invalid token. CPP will not print a
  32. warning because it thinks this is an assembly file, but it leaves
  33. them as multiple tokens and there may or may not be whitespace
  34. between them. */
  35. /* Macro for a relocation entry */
  36. #define RELOCATE_ENTRY(sym, section) \
  37. LONG(sym ## _start); \
  38. LONG(sym ## _end); \
  39. LONG(LOADADDR(section))
  40. /*
  41. * Macro to define a section for a vector. When CONFIG_VECTORS_OFFSET is
  42. * defined code for every vector is located with other init data. At startup
  43. * time head.S copies code for every vector to its final position according
  44. * to description recorded in the corresponding RELOCATE_ENTRY.
  45. */
  46. #ifdef CONFIG_VECTORS_OFFSET
  47. #define SECTION_VECTOR(sym, section, addr, prevsec) \
  48. section addr : AT(((LOADADDR(prevsec) + SIZEOF(prevsec)) + 3) & ~ 3) \
  49. { \
  50. . = ALIGN(4); \
  51. sym ## _start = ABSOLUTE(.); \
  52. *(section) \
  53. sym ## _end = ABSOLUTE(.); \
  54. }
  55. #else
  56. #define SECTION_VECTOR(section, addr) \
  57. . = addr; \
  58. *(section)
  59. #endif
  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. .text :
  70. {
  71. /* The HEAD_TEXT section must be the first section! */
  72. HEAD_TEXT
  73. #ifndef CONFIG_VECTORS_OFFSET
  74. . = ALIGN(PAGE_SIZE);
  75. _vecbase = .;
  76. SECTION_VECTOR (.WindowVectors.text, WINDOW_VECTORS_VADDR)
  77. #if XCHAL_EXCM_LEVEL >= 2
  78. SECTION_VECTOR (.Level2InterruptVector.text, INTLEVEL2_VECTOR_VADDR)
  79. #endif
  80. #if XCHAL_EXCM_LEVEL >= 3
  81. SECTION_VECTOR (.Level3InterruptVector.text, INTLEVEL3_VECTOR_VADDR)
  82. #endif
  83. #if XCHAL_EXCM_LEVEL >= 4
  84. SECTION_VECTOR (.Level4InterruptVector.text, INTLEVEL4_VECTOR_VADDR)
  85. #endif
  86. #if XCHAL_EXCM_LEVEL >= 5
  87. SECTION_VECTOR (.Level5InterruptVector.text, INTLEVEL5_VECTOR_VADDR)
  88. #endif
  89. #if XCHAL_EXCM_LEVEL >= 6
  90. SECTION_VECTOR (.Level6InterruptVector.text, INTLEVEL6_VECTOR_VADDR)
  91. #endif
  92. SECTION_VECTOR (.DebugInterruptVector.text, DEBUG_VECTOR_VADDR)
  93. SECTION_VECTOR (.KernelExceptionVector.text, KERNEL_VECTOR_VADDR)
  94. SECTION_VECTOR (.UserExceptionVector.text, USER_VECTOR_VADDR)
  95. SECTION_VECTOR (.DoubleExceptionVector.text, DOUBLEEXC_VECTOR_VADDR)
  96. #endif
  97. IRQENTRY_TEXT
  98. SOFTIRQENTRY_TEXT
  99. ENTRY_TEXT
  100. TEXT_TEXT
  101. SCHED_TEXT
  102. CPUIDLE_TEXT
  103. LOCK_TEXT
  104. }
  105. _etext = .;
  106. PROVIDE (etext = .);
  107. . = ALIGN(16);
  108. RODATA
  109. /* Relocation table */
  110. .fixup : { *(.fixup) }
  111. EXCEPTION_TABLE(16)
  112. NOTES
  113. /* Data section */
  114. _sdata = .;
  115. RW_DATA_SECTION(XCHAL_ICACHE_LINESIZE, PAGE_SIZE, THREAD_SIZE)
  116. _edata = .;
  117. /* Initialization code and data: */
  118. . = ALIGN(PAGE_SIZE);
  119. __init_begin = .;
  120. INIT_TEXT_SECTION(PAGE_SIZE)
  121. .init.data :
  122. {
  123. INIT_DATA
  124. . = ALIGN(0x4);
  125. __tagtable_begin = .;
  126. *(.taglist)
  127. __tagtable_end = .;
  128. . = ALIGN(16);
  129. __boot_reloc_table_start = ABSOLUTE(.);
  130. #ifdef CONFIG_VECTORS_OFFSET
  131. RELOCATE_ENTRY(_WindowVectors_text,
  132. .WindowVectors.text);
  133. #if XCHAL_EXCM_LEVEL >= 2
  134. RELOCATE_ENTRY(_Level2InterruptVector_text,
  135. .Level2InterruptVector.text);
  136. #endif
  137. #if XCHAL_EXCM_LEVEL >= 3
  138. RELOCATE_ENTRY(_Level3InterruptVector_text,
  139. .Level3InterruptVector.text);
  140. #endif
  141. #if XCHAL_EXCM_LEVEL >= 4
  142. RELOCATE_ENTRY(_Level4InterruptVector_text,
  143. .Level4InterruptVector.text);
  144. #endif
  145. #if XCHAL_EXCM_LEVEL >= 5
  146. RELOCATE_ENTRY(_Level5InterruptVector_text,
  147. .Level5InterruptVector.text);
  148. #endif
  149. #if XCHAL_EXCM_LEVEL >= 6
  150. RELOCATE_ENTRY(_Level6InterruptVector_text,
  151. .Level6InterruptVector.text);
  152. #endif
  153. RELOCATE_ENTRY(_KernelExceptionVector_text,
  154. .KernelExceptionVector.text);
  155. RELOCATE_ENTRY(_UserExceptionVector_text,
  156. .UserExceptionVector.text);
  157. RELOCATE_ENTRY(_DoubleExceptionVector_text,
  158. .DoubleExceptionVector.text);
  159. RELOCATE_ENTRY(_DebugInterruptVector_text,
  160. .DebugInterruptVector.text);
  161. #endif
  162. #if defined(CONFIG_SMP)
  163. RELOCATE_ENTRY(_SecondaryResetVector_text,
  164. .SecondaryResetVector.text);
  165. #endif
  166. __boot_reloc_table_end = ABSOLUTE(.) ;
  167. INIT_SETUP(XCHAL_ICACHE_LINESIZE)
  168. INIT_CALLS
  169. CON_INITCALL
  170. SECURITY_INITCALL
  171. INIT_RAM_FS
  172. }
  173. PERCPU_SECTION(XCHAL_ICACHE_LINESIZE)
  174. /* We need this dummy segment here */
  175. . = ALIGN(4);
  176. .dummy : { LONG(0) }
  177. #ifdef CONFIG_VECTORS_OFFSET
  178. /* The vectors are relocated to the real position at startup time */
  179. SECTION_VECTOR (_WindowVectors_text,
  180. .WindowVectors.text,
  181. WINDOW_VECTORS_VADDR,
  182. .dummy)
  183. SECTION_VECTOR (_DebugInterruptVector_text,
  184. .DebugInterruptVector.text,
  185. DEBUG_VECTOR_VADDR,
  186. .WindowVectors.text)
  187. #undef LAST
  188. #define LAST .DebugInterruptVector.text
  189. #if XCHAL_EXCM_LEVEL >= 2
  190. SECTION_VECTOR (_Level2InterruptVector_text,
  191. .Level2InterruptVector.text,
  192. INTLEVEL2_VECTOR_VADDR,
  193. LAST)
  194. # undef LAST
  195. # define LAST .Level2InterruptVector.text
  196. #endif
  197. #if XCHAL_EXCM_LEVEL >= 3
  198. SECTION_VECTOR (_Level3InterruptVector_text,
  199. .Level3InterruptVector.text,
  200. INTLEVEL3_VECTOR_VADDR,
  201. LAST)
  202. # undef LAST
  203. # define LAST .Level3InterruptVector.text
  204. #endif
  205. #if XCHAL_EXCM_LEVEL >= 4
  206. SECTION_VECTOR (_Level4InterruptVector_text,
  207. .Level4InterruptVector.text,
  208. INTLEVEL4_VECTOR_VADDR,
  209. LAST)
  210. # undef LAST
  211. # define LAST .Level4InterruptVector.text
  212. #endif
  213. #if XCHAL_EXCM_LEVEL >= 5
  214. SECTION_VECTOR (_Level5InterruptVector_text,
  215. .Level5InterruptVector.text,
  216. INTLEVEL5_VECTOR_VADDR,
  217. LAST)
  218. # undef LAST
  219. # define LAST .Level5InterruptVector.text
  220. #endif
  221. #if XCHAL_EXCM_LEVEL >= 6
  222. SECTION_VECTOR (_Level6InterruptVector_text,
  223. .Level6InterruptVector.text,
  224. INTLEVEL6_VECTOR_VADDR,
  225. LAST)
  226. # undef LAST
  227. # define LAST .Level6InterruptVector.text
  228. #endif
  229. SECTION_VECTOR (_KernelExceptionVector_text,
  230. .KernelExceptionVector.text,
  231. KERNEL_VECTOR_VADDR,
  232. LAST)
  233. #undef LAST
  234. SECTION_VECTOR (_UserExceptionVector_text,
  235. .UserExceptionVector.text,
  236. USER_VECTOR_VADDR,
  237. .KernelExceptionVector.text)
  238. SECTION_VECTOR (_DoubleExceptionVector_text,
  239. .DoubleExceptionVector.text,
  240. DOUBLEEXC_VECTOR_VADDR,
  241. .UserExceptionVector.text)
  242. . = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3;
  243. #endif
  244. #if defined(CONFIG_SMP)
  245. SECTION_VECTOR (_SecondaryResetVector_text,
  246. .SecondaryResetVector.text,
  247. RESET_VECTOR1_VADDR,
  248. .DoubleExceptionVector.text)
  249. . = LOADADDR(.SecondaryResetVector.text)+SIZEOF(.SecondaryResetVector.text);
  250. #endif
  251. . = ALIGN(PAGE_SIZE);
  252. __init_end = .;
  253. BSS_SECTION(0, 8192, 0)
  254. _end = .;
  255. .xt.lit : { *(.xt.lit) }
  256. .xt.prop : { *(.xt.prop) }
  257. .debug 0 : { *(.debug) }
  258. .line 0 : { *(.line) }
  259. .debug_srcinfo 0 : { *(.debug_srcinfo) }
  260. .debug_sfnames 0 : { *(.debug_sfnames) }
  261. .debug_aranges 0 : { *(.debug_aranges) }
  262. .debug_pubnames 0 : { *(.debug_pubnames) }
  263. .debug_info 0 : { *(.debug_info) }
  264. .debug_abbrev 0 : { *(.debug_abbrev) }
  265. .debug_line 0 : { *(.debug_line) }
  266. .debug_frame 0 : { *(.debug_frame) }
  267. .debug_str 0 : { *(.debug_str) }
  268. .debug_loc 0 : { *(.debug_loc) }
  269. .debug_macinfo 0 : { *(.debug_macinfo) }
  270. .debug_weaknames 0 : { *(.debug_weaknames) }
  271. .debug_funcnames 0 : { *(.debug_funcnames) }
  272. .debug_typenames 0 : { *(.debug_typenames) }
  273. .debug_varnames 0 : { *(.debug_varnames) }
  274. .xt.insn 0 :
  275. {
  276. *(.xt.insn)
  277. *(.gnu.linkonce.x*)
  278. }
  279. .xt.lit 0 :
  280. {
  281. *(.xt.lit)
  282. *(.gnu.linkonce.p*)
  283. }
  284. /* Sections to be discarded */
  285. DISCARDS
  286. }