vmlinux.lds.S 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  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 <[email protected]>
  13. * Marc Gauthier <[email protected], [email protected]>
  14. * Joe Taylor <[email protected], [email protected]>
  15. */
  16. #define RO_EXCEPTION_TABLE_ALIGN 16
  17. #include <asm-generic/vmlinux.lds.h>
  18. #include <asm/page.h>
  19. #include <asm/thread_info.h>
  20. #include <asm/core.h>
  21. #include <asm/vectors.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. #if !defined(CONFIG_VECTORS_ADDR) && XCHAL_HAVE_VECBASE
  42. #define MERGED_VECTORS 1
  43. #else
  44. #define MERGED_VECTORS 0
  45. #endif
  46. /*
  47. * Macro to define a section for a vector. When MERGED_VECTORS is 0
  48. * code for every vector is located with other init data. At startup
  49. * time head.S copies code for every vector to its final position according
  50. * to description recorded in the corresponding RELOCATE_ENTRY.
  51. */
  52. #define SECTION_VECTOR4(sym, section, addr, prevsec) \
  53. section addr : AT(((LOADADDR(prevsec) + SIZEOF(prevsec)) + 3) & ~ 3) \
  54. { \
  55. . = ALIGN(4); \
  56. sym ## _start = ABSOLUTE(.); \
  57. *(section) \
  58. sym ## _end = ABSOLUTE(.); \
  59. }
  60. #define SECTION_VECTOR2(section, addr) \
  61. . = addr; \
  62. *(section)
  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. #if MERGED_VECTORS
  77. . = ALIGN(PAGE_SIZE);
  78. _vecbase = .;
  79. #ifdef SUPPORT_WINDOWED
  80. SECTION_VECTOR2 (.WindowVectors.text, WINDOW_VECTORS_VADDR)
  81. #endif
  82. #if XCHAL_EXCM_LEVEL >= 2
  83. SECTION_VECTOR2 (.Level2InterruptVector.text, INTLEVEL2_VECTOR_VADDR)
  84. #endif
  85. #if XCHAL_EXCM_LEVEL >= 3
  86. SECTION_VECTOR2 (.Level3InterruptVector.text, INTLEVEL3_VECTOR_VADDR)
  87. #endif
  88. #if XCHAL_EXCM_LEVEL >= 4
  89. SECTION_VECTOR2 (.Level4InterruptVector.text, INTLEVEL4_VECTOR_VADDR)
  90. #endif
  91. #if XCHAL_EXCM_LEVEL >= 5
  92. SECTION_VECTOR2 (.Level5InterruptVector.text, INTLEVEL5_VECTOR_VADDR)
  93. #endif
  94. #if XCHAL_EXCM_LEVEL >= 6
  95. SECTION_VECTOR2 (.Level6InterruptVector.text, INTLEVEL6_VECTOR_VADDR)
  96. #endif
  97. SECTION_VECTOR2 (.DebugInterruptVector.text, DEBUG_VECTOR_VADDR)
  98. SECTION_VECTOR2 (.KernelExceptionVector.text, KERNEL_VECTOR_VADDR)
  99. SECTION_VECTOR2 (.UserExceptionVector.text, USER_VECTOR_VADDR)
  100. SECTION_VECTOR2 (.DoubleExceptionVector.text, DOUBLEEXC_VECTOR_VADDR)
  101. *(.exception.text)
  102. #endif
  103. IRQENTRY_TEXT
  104. SOFTIRQENTRY_TEXT
  105. ENTRY_TEXT
  106. TEXT_TEXT
  107. SCHED_TEXT
  108. CPUIDLE_TEXT
  109. LOCK_TEXT
  110. *(.fixup)
  111. }
  112. _etext = .;
  113. PROVIDE (etext = .);
  114. . = ALIGN(16);
  115. RO_DATA(4096)
  116. /* Data section */
  117. #ifdef CONFIG_XIP_KERNEL
  118. INIT_TEXT_SECTION(PAGE_SIZE)
  119. #else
  120. _sdata = .;
  121. RW_DATA(XCHAL_ICACHE_LINESIZE, PAGE_SIZE, THREAD_SIZE)
  122. _edata = .;
  123. /* Initialization code and data: */
  124. . = ALIGN(PAGE_SIZE);
  125. __init_begin = .;
  126. INIT_TEXT_SECTION(PAGE_SIZE)
  127. .init.data :
  128. {
  129. INIT_DATA
  130. }
  131. #endif
  132. .init.rodata :
  133. {
  134. . = ALIGN(0x4);
  135. __tagtable_begin = .;
  136. *(.taglist)
  137. __tagtable_end = .;
  138. . = ALIGN(16);
  139. __boot_reloc_table_start = ABSOLUTE(.);
  140. #if !MERGED_VECTORS
  141. #ifdef SUPPORT_WINDOWED
  142. RELOCATE_ENTRY(_WindowVectors_text,
  143. .WindowVectors.text);
  144. #endif
  145. #if XCHAL_EXCM_LEVEL >= 2
  146. RELOCATE_ENTRY(_Level2InterruptVector_text,
  147. .Level2InterruptVector.text);
  148. #endif
  149. #if XCHAL_EXCM_LEVEL >= 3
  150. RELOCATE_ENTRY(_Level3InterruptVector_text,
  151. .Level3InterruptVector.text);
  152. #endif
  153. #if XCHAL_EXCM_LEVEL >= 4
  154. RELOCATE_ENTRY(_Level4InterruptVector_text,
  155. .Level4InterruptVector.text);
  156. #endif
  157. #if XCHAL_EXCM_LEVEL >= 5
  158. RELOCATE_ENTRY(_Level5InterruptVector_text,
  159. .Level5InterruptVector.text);
  160. #endif
  161. #if XCHAL_EXCM_LEVEL >= 6
  162. RELOCATE_ENTRY(_Level6InterruptVector_text,
  163. .Level6InterruptVector.text);
  164. #endif
  165. RELOCATE_ENTRY(_KernelExceptionVector_text,
  166. .KernelExceptionVector.text);
  167. RELOCATE_ENTRY(_UserExceptionVector_text,
  168. .UserExceptionVector.text);
  169. RELOCATE_ENTRY(_DoubleExceptionVector_text,
  170. .DoubleExceptionVector.text);
  171. RELOCATE_ENTRY(_DebugInterruptVector_text,
  172. .DebugInterruptVector.text);
  173. RELOCATE_ENTRY(_exception_text,
  174. .exception.text);
  175. #endif
  176. #ifdef CONFIG_XIP_KERNEL
  177. RELOCATE_ENTRY(_xip_data, .data);
  178. RELOCATE_ENTRY(_xip_init_data, .init.data);
  179. #endif
  180. #if defined(CONFIG_SECONDARY_RESET_VECTOR)
  181. RELOCATE_ENTRY(_SecondaryResetVector_text,
  182. .SecondaryResetVector.text);
  183. #endif
  184. __boot_reloc_table_end = ABSOLUTE(.) ;
  185. INIT_SETUP(XCHAL_ICACHE_LINESIZE)
  186. INIT_CALLS
  187. CON_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. #undef LAST
  195. #define LAST .dummy
  196. #if !MERGED_VECTORS
  197. /* The vectors are relocated to the real position at startup time */
  198. #ifdef SUPPORT_WINDOWED
  199. SECTION_VECTOR4 (_WindowVectors_text,
  200. .WindowVectors.text,
  201. WINDOW_VECTORS_VADDR,
  202. LAST)
  203. #undef LAST
  204. #define LAST .WindowVectors.text
  205. #endif
  206. SECTION_VECTOR4 (_DebugInterruptVector_text,
  207. .DebugInterruptVector.text,
  208. DEBUG_VECTOR_VADDR,
  209. LAST)
  210. #undef LAST
  211. #define LAST .DebugInterruptVector.text
  212. #if XCHAL_EXCM_LEVEL >= 2
  213. SECTION_VECTOR4 (_Level2InterruptVector_text,
  214. .Level2InterruptVector.text,
  215. INTLEVEL2_VECTOR_VADDR,
  216. LAST)
  217. # undef LAST
  218. # define LAST .Level2InterruptVector.text
  219. #endif
  220. #if XCHAL_EXCM_LEVEL >= 3
  221. SECTION_VECTOR4 (_Level3InterruptVector_text,
  222. .Level3InterruptVector.text,
  223. INTLEVEL3_VECTOR_VADDR,
  224. LAST)
  225. # undef LAST
  226. # define LAST .Level3InterruptVector.text
  227. #endif
  228. #if XCHAL_EXCM_LEVEL >= 4
  229. SECTION_VECTOR4 (_Level4InterruptVector_text,
  230. .Level4InterruptVector.text,
  231. INTLEVEL4_VECTOR_VADDR,
  232. LAST)
  233. # undef LAST
  234. # define LAST .Level4InterruptVector.text
  235. #endif
  236. #if XCHAL_EXCM_LEVEL >= 5
  237. SECTION_VECTOR4 (_Level5InterruptVector_text,
  238. .Level5InterruptVector.text,
  239. INTLEVEL5_VECTOR_VADDR,
  240. LAST)
  241. # undef LAST
  242. # define LAST .Level5InterruptVector.text
  243. #endif
  244. #if XCHAL_EXCM_LEVEL >= 6
  245. SECTION_VECTOR4 (_Level6InterruptVector_text,
  246. .Level6InterruptVector.text,
  247. INTLEVEL6_VECTOR_VADDR,
  248. LAST)
  249. # undef LAST
  250. # define LAST .Level6InterruptVector.text
  251. #endif
  252. SECTION_VECTOR4 (_KernelExceptionVector_text,
  253. .KernelExceptionVector.text,
  254. KERNEL_VECTOR_VADDR,
  255. LAST)
  256. #undef LAST
  257. SECTION_VECTOR4 (_UserExceptionVector_text,
  258. .UserExceptionVector.text,
  259. USER_VECTOR_VADDR,
  260. .KernelExceptionVector.text)
  261. SECTION_VECTOR4 (_DoubleExceptionVector_text,
  262. .DoubleExceptionVector.text,
  263. DOUBLEEXC_VECTOR_VADDR,
  264. .UserExceptionVector.text)
  265. #define LAST .DoubleExceptionVector.text
  266. #endif
  267. #if defined(CONFIG_SECONDARY_RESET_VECTOR)
  268. SECTION_VECTOR4 (_SecondaryResetVector_text,
  269. .SecondaryResetVector.text,
  270. RESET_VECTOR1_VADDR,
  271. LAST)
  272. #undef LAST
  273. #define LAST .SecondaryResetVector.text
  274. #endif
  275. #if !MERGED_VECTORS
  276. SECTION_VECTOR4 (_exception_text,
  277. .exception.text,
  278. ,
  279. LAST)
  280. #undef LAST
  281. #define LAST .exception.text
  282. #endif
  283. . = (LOADADDR(LAST) + SIZEOF(LAST) + 3) & ~ 3;
  284. .dummy1 : AT(ADDR(.dummy1)) { LONG(0) }
  285. . = ALIGN(PAGE_SIZE);
  286. #ifndef CONFIG_XIP_KERNEL
  287. __init_end = .;
  288. BSS_SECTION(0, 8192, 0)
  289. #endif
  290. _end = .;
  291. #ifdef CONFIG_XIP_KERNEL
  292. . = CONFIG_XIP_DATA_ADDR;
  293. _xip_start = .;
  294. #undef LOAD_OFFSET
  295. #define LOAD_OFFSET \
  296. (CONFIG_XIP_DATA_ADDR - (LOADADDR(.dummy1) + SIZEOF(.dummy1) + 3) & ~ 3)
  297. _xip_data_start = .;
  298. _sdata = .;
  299. RW_DATA(XCHAL_ICACHE_LINESIZE, PAGE_SIZE, THREAD_SIZE)
  300. _edata = .;
  301. _xip_data_end = .;
  302. /* Initialization data: */
  303. STRUCT_ALIGN();
  304. _xip_init_data_start = .;
  305. __init_begin = .;
  306. .init.data :
  307. {
  308. INIT_DATA
  309. }
  310. _xip_init_data_end = .;
  311. __init_end = .;
  312. BSS_SECTION(0, 8192, 0)
  313. _xip_end = .;
  314. #undef LOAD_OFFSET
  315. #endif
  316. DWARF_DEBUG
  317. .xt.prop 0 : { KEEP(*(.xt.prop .xt.prop.* .gnu.linkonce.prop.*)) }
  318. .xt.insn 0 : { KEEP(*(.xt.insn .xt.insn.* .gnu.linkonce.x*)) }
  319. .xt.lit 0 : { KEEP(*(.xt.lit .xt.lit.* .gnu.linkonce.p*)) }
  320. /* Sections to be discarded */
  321. DISCARDS
  322. }