vmlinux.lds.S 8.8 KB

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