vmlinux.lds.S 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  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. #ifdef CONFIG_VECTORS_OFFSET
  55. #define SECTION_VECTOR(sym, section, addr, max_prevsec_size, prevsec) \
  56. section addr : AT((MIN(LOADADDR(prevsec) + max_prevsec_size, \
  57. LOADADDR(prevsec) + SIZEOF(prevsec)) + 3) & ~ 3) \
  58. { \
  59. . = ALIGN(4); \
  60. sym ## _start = ABSOLUTE(.); \
  61. *(section) \
  62. sym ## _end = ABSOLUTE(.); \
  63. }
  64. #else
  65. #define SECTION_VECTOR(section, addr) \
  66. . = addr; \
  67. *(section)
  68. #endif
  69. /*
  70. * Mapping of input sections to output sections when linking.
  71. */
  72. SECTIONS
  73. {
  74. . = KERNELOFFSET;
  75. /* .text section */
  76. _text = .;
  77. _stext = .;
  78. .text :
  79. {
  80. /* The HEAD_TEXT section must be the first section! */
  81. HEAD_TEXT
  82. #ifndef CONFIG_VECTORS_OFFSET
  83. . = ALIGN(PAGE_SIZE);
  84. _vecbase = .;
  85. SECTION_VECTOR (.WindowVectors.text, WINDOW_VECTORS_VADDR)
  86. #if XCHAL_EXCM_LEVEL >= 2
  87. SECTION_VECTOR (.Level2InterruptVector.text, INTLEVEL2_VECTOR_VADDR)
  88. #endif
  89. #if XCHAL_EXCM_LEVEL >= 3
  90. SECTION_VECTOR (.Level3InterruptVector.text, INTLEVEL3_VECTOR_VADDR)
  91. #endif
  92. #if XCHAL_EXCM_LEVEL >= 4
  93. SECTION_VECTOR (.Level4InterruptVector.text, INTLEVEL4_VECTOR_VADDR)
  94. #endif
  95. #if XCHAL_EXCM_LEVEL >= 5
  96. SECTION_VECTOR (.Level5InterruptVector.text, INTLEVEL5_VECTOR_VADDR)
  97. #endif
  98. #if XCHAL_EXCM_LEVEL >= 6
  99. SECTION_VECTOR (.Level6InterruptVector.text, INTLEVEL6_VECTOR_VADDR)
  100. #endif
  101. SECTION_VECTOR (.DebugInterruptVector.literal, DEBUG_VECTOR_VADDR - 4)
  102. SECTION_VECTOR (.DebugInterruptVector.text, DEBUG_VECTOR_VADDR)
  103. SECTION_VECTOR (.KernelExceptionVector.literal, KERNEL_VECTOR_VADDR - 4)
  104. SECTION_VECTOR (.KernelExceptionVector.text, KERNEL_VECTOR_VADDR)
  105. SECTION_VECTOR (.UserExceptionVector.literal, USER_VECTOR_VADDR - 4)
  106. SECTION_VECTOR (.UserExceptionVector.text, USER_VECTOR_VADDR)
  107. SECTION_VECTOR (.DoubleExceptionVector.literal, DOUBLEEXC_VECTOR_VADDR - 48)
  108. SECTION_VECTOR (.DoubleExceptionVector.text, DOUBLEEXC_VECTOR_VADDR)
  109. #endif
  110. TEXT_TEXT
  111. VMLINUX_SYMBOL(__sched_text_start) = .;
  112. *(.sched.literal .sched.text)
  113. VMLINUX_SYMBOL(__sched_text_end) = .;
  114. VMLINUX_SYMBOL(__cpuidle_text_start) = .;
  115. *(.cpuidle.literal .cpuidle.text)
  116. VMLINUX_SYMBOL(__cpuidle_text_end) = .;
  117. VMLINUX_SYMBOL(__lock_text_start) = .;
  118. *(.spinlock.literal .spinlock.text)
  119. VMLINUX_SYMBOL(__lock_text_end) = .;
  120. }
  121. _etext = .;
  122. PROVIDE (etext = .);
  123. . = ALIGN(16);
  124. RODATA
  125. /* Relocation table */
  126. .fixup : { *(.fixup) }
  127. EXCEPTION_TABLE(16)
  128. /* Data section */
  129. _sdata = .;
  130. RW_DATA_SECTION(XCHAL_ICACHE_LINESIZE, PAGE_SIZE, THREAD_SIZE)
  131. _edata = .;
  132. /* Initialization code and data: */
  133. . = ALIGN(PAGE_SIZE);
  134. __init_begin = .;
  135. INIT_TEXT_SECTION(PAGE_SIZE)
  136. .init.data :
  137. {
  138. INIT_DATA
  139. . = ALIGN(0x4);
  140. __tagtable_begin = .;
  141. *(.taglist)
  142. __tagtable_end = .;
  143. . = ALIGN(16);
  144. __boot_reloc_table_start = ABSOLUTE(.);
  145. #ifdef CONFIG_VECTORS_OFFSET
  146. RELOCATE_ENTRY(_WindowVectors_text,
  147. .WindowVectors.text);
  148. #if XCHAL_EXCM_LEVEL >= 2
  149. RELOCATE_ENTRY(_Level2InterruptVector_text,
  150. .Level2InterruptVector.text);
  151. #endif
  152. #if XCHAL_EXCM_LEVEL >= 3
  153. RELOCATE_ENTRY(_Level3InterruptVector_text,
  154. .Level3InterruptVector.text);
  155. #endif
  156. #if XCHAL_EXCM_LEVEL >= 4
  157. RELOCATE_ENTRY(_Level4InterruptVector_text,
  158. .Level4InterruptVector.text);
  159. #endif
  160. #if XCHAL_EXCM_LEVEL >= 5
  161. RELOCATE_ENTRY(_Level5InterruptVector_text,
  162. .Level5InterruptVector.text);
  163. #endif
  164. #if XCHAL_EXCM_LEVEL >= 6
  165. RELOCATE_ENTRY(_Level6InterruptVector_text,
  166. .Level6InterruptVector.text);
  167. #endif
  168. RELOCATE_ENTRY(_KernelExceptionVector_text,
  169. .KernelExceptionVector.text);
  170. RELOCATE_ENTRY(_UserExceptionVector_text,
  171. .UserExceptionVector.text);
  172. RELOCATE_ENTRY(_DoubleExceptionVector_literal,
  173. .DoubleExceptionVector.literal);
  174. RELOCATE_ENTRY(_DoubleExceptionVector_text,
  175. .DoubleExceptionVector.text);
  176. RELOCATE_ENTRY(_DebugInterruptVector_text,
  177. .DebugInterruptVector.text);
  178. #endif
  179. #if defined(CONFIG_SMP)
  180. RELOCATE_ENTRY(_SecondaryResetVector_text,
  181. .SecondaryResetVector.text);
  182. #endif
  183. __boot_reloc_table_end = ABSOLUTE(.) ;
  184. INIT_SETUP(XCHAL_ICACHE_LINESIZE)
  185. INIT_CALLS
  186. CON_INITCALL
  187. SECURITY_INITCALL
  188. INIT_RAM_FS
  189. }
  190. PERCPU_SECTION(XCHAL_ICACHE_LINESIZE)
  191. /* We need this dummy segment here */
  192. . = ALIGN(4);
  193. .dummy : { LONG(0) }
  194. #ifdef CONFIG_VECTORS_OFFSET
  195. /* The vectors are relocated to the real position at startup time */
  196. SECTION_VECTOR (_WindowVectors_text,
  197. .WindowVectors.text,
  198. WINDOW_VECTORS_VADDR, 4,
  199. .dummy)
  200. SECTION_VECTOR (_DebugInterruptVector_literal,
  201. .DebugInterruptVector.literal,
  202. DEBUG_VECTOR_VADDR - 4,
  203. SIZEOF(.WindowVectors.text),
  204. .WindowVectors.text)
  205. SECTION_VECTOR (_DebugInterruptVector_text,
  206. .DebugInterruptVector.text,
  207. DEBUG_VECTOR_VADDR,
  208. 4,
  209. .DebugInterruptVector.literal)
  210. #undef LAST
  211. #define LAST .DebugInterruptVector.text
  212. #if XCHAL_EXCM_LEVEL >= 2
  213. SECTION_VECTOR (_Level2InterruptVector_text,
  214. .Level2InterruptVector.text,
  215. INTLEVEL2_VECTOR_VADDR,
  216. SIZEOF(LAST), LAST)
  217. # undef LAST
  218. # define LAST .Level2InterruptVector.text
  219. #endif
  220. #if XCHAL_EXCM_LEVEL >= 3
  221. SECTION_VECTOR (_Level3InterruptVector_text,
  222. .Level3InterruptVector.text,
  223. INTLEVEL3_VECTOR_VADDR,
  224. SIZEOF(LAST), LAST)
  225. # undef LAST
  226. # define LAST .Level3InterruptVector.text
  227. #endif
  228. #if XCHAL_EXCM_LEVEL >= 4
  229. SECTION_VECTOR (_Level4InterruptVector_text,
  230. .Level4InterruptVector.text,
  231. INTLEVEL4_VECTOR_VADDR,
  232. SIZEOF(LAST), LAST)
  233. # undef LAST
  234. # define LAST .Level4InterruptVector.text
  235. #endif
  236. #if XCHAL_EXCM_LEVEL >= 5
  237. SECTION_VECTOR (_Level5InterruptVector_text,
  238. .Level5InterruptVector.text,
  239. INTLEVEL5_VECTOR_VADDR,
  240. SIZEOF(LAST), LAST)
  241. # undef LAST
  242. # define LAST .Level5InterruptVector.text
  243. #endif
  244. #if XCHAL_EXCM_LEVEL >= 6
  245. SECTION_VECTOR (_Level6InterruptVector_text,
  246. .Level6InterruptVector.text,
  247. INTLEVEL6_VECTOR_VADDR,
  248. SIZEOF(LAST), LAST)
  249. # undef LAST
  250. # define LAST .Level6InterruptVector.text
  251. #endif
  252. SECTION_VECTOR (_KernelExceptionVector_literal,
  253. .KernelExceptionVector.literal,
  254. KERNEL_VECTOR_VADDR - 4,
  255. SIZEOF(LAST), LAST)
  256. #undef LAST
  257. SECTION_VECTOR (_KernelExceptionVector_text,
  258. .KernelExceptionVector.text,
  259. KERNEL_VECTOR_VADDR,
  260. 4,
  261. .KernelExceptionVector.literal)
  262. SECTION_VECTOR (_UserExceptionVector_literal,
  263. .UserExceptionVector.literal,
  264. USER_VECTOR_VADDR - 4,
  265. SIZEOF(.KernelExceptionVector.text),
  266. .KernelExceptionVector.text)
  267. SECTION_VECTOR (_UserExceptionVector_text,
  268. .UserExceptionVector.text,
  269. USER_VECTOR_VADDR,
  270. 4,
  271. .UserExceptionVector.literal)
  272. SECTION_VECTOR (_DoubleExceptionVector_literal,
  273. .DoubleExceptionVector.literal,
  274. DOUBLEEXC_VECTOR_VADDR - 48,
  275. SIZEOF(.UserExceptionVector.text),
  276. .UserExceptionVector.text)
  277. SECTION_VECTOR (_DoubleExceptionVector_text,
  278. .DoubleExceptionVector.text,
  279. DOUBLEEXC_VECTOR_VADDR,
  280. 48,
  281. .DoubleExceptionVector.literal)
  282. . = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3;
  283. #endif
  284. #if defined(CONFIG_SMP)
  285. SECTION_VECTOR (_SecondaryResetVector_text,
  286. .SecondaryResetVector.text,
  287. RESET_VECTOR1_VADDR,
  288. SIZEOF(.DoubleExceptionVector.text),
  289. .DoubleExceptionVector.text)
  290. . = LOADADDR(.SecondaryResetVector.text)+SIZEOF(.SecondaryResetVector.text);
  291. #endif
  292. . = ALIGN(PAGE_SIZE);
  293. __init_end = .;
  294. BSS_SECTION(0, 8192, 0)
  295. _end = .;
  296. .xt.lit : { *(.xt.lit) }
  297. .xt.prop : { *(.xt.prop) }
  298. .debug 0 : { *(.debug) }
  299. .line 0 : { *(.line) }
  300. .debug_srcinfo 0 : { *(.debug_srcinfo) }
  301. .debug_sfnames 0 : { *(.debug_sfnames) }
  302. .debug_aranges 0 : { *(.debug_aranges) }
  303. .debug_pubnames 0 : { *(.debug_pubnames) }
  304. .debug_info 0 : { *(.debug_info) }
  305. .debug_abbrev 0 : { *(.debug_abbrev) }
  306. .debug_line 0 : { *(.debug_line) }
  307. .debug_frame 0 : { *(.debug_frame) }
  308. .debug_str 0 : { *(.debug_str) }
  309. .debug_loc 0 : { *(.debug_loc) }
  310. .debug_macinfo 0 : { *(.debug_macinfo) }
  311. .debug_weaknames 0 : { *(.debug_weaknames) }
  312. .debug_funcnames 0 : { *(.debug_funcnames) }
  313. .debug_typenames 0 : { *(.debug_typenames) }
  314. .debug_varnames 0 : { *(.debug_varnames) }
  315. .xt.insn 0 :
  316. {
  317. *(.xt.insn)
  318. *(.gnu.linkonce.x*)
  319. }
  320. .xt.lit 0 :
  321. {
  322. *(.xt.lit)
  323. *(.gnu.linkonce.p*)
  324. }
  325. /* Sections to be discarded */
  326. DISCARDS
  327. /DISCARD/ : { *(.exit.literal) }
  328. }