vmlinux.lds.S 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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. #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. *(.xiptext)
  103. #endif
  104. IRQENTRY_TEXT
  105. SOFTIRQENTRY_TEXT
  106. ENTRY_TEXT
  107. TEXT_TEXT
  108. SCHED_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. #ifdef CONFIG_XIP_KERNEL
  176. RELOCATE_ENTRY(_xip_text, .xiptext);
  177. #endif
  178. #endif
  179. #ifdef CONFIG_XIP_KERNEL
  180. RELOCATE_ENTRY(_xip_data, .data);
  181. RELOCATE_ENTRY(_xip_init_data, .init.data);
  182. #endif
  183. #if defined(CONFIG_SECONDARY_RESET_VECTOR)
  184. RELOCATE_ENTRY(_SecondaryResetVector_text,
  185. .SecondaryResetVector.text);
  186. #endif
  187. __boot_reloc_table_end = ABSOLUTE(.) ;
  188. INIT_SETUP(XCHAL_ICACHE_LINESIZE)
  189. INIT_CALLS
  190. CON_INITCALL
  191. INIT_RAM_FS
  192. }
  193. PERCPU_SECTION(XCHAL_ICACHE_LINESIZE)
  194. /* We need this dummy segment here */
  195. . = ALIGN(4);
  196. .dummy : { LONG(0) }
  197. #undef LAST
  198. #define LAST .dummy
  199. #if !MERGED_VECTORS
  200. /* The vectors are relocated to the real position at startup time */
  201. #ifdef SUPPORT_WINDOWED
  202. SECTION_VECTOR4 (_WindowVectors_text,
  203. .WindowVectors.text,
  204. WINDOW_VECTORS_VADDR,
  205. LAST)
  206. #undef LAST
  207. #define LAST .WindowVectors.text
  208. #endif
  209. SECTION_VECTOR4 (_DebugInterruptVector_text,
  210. .DebugInterruptVector.text,
  211. DEBUG_VECTOR_VADDR,
  212. LAST)
  213. #undef LAST
  214. #define LAST .DebugInterruptVector.text
  215. #if XCHAL_EXCM_LEVEL >= 2
  216. SECTION_VECTOR4 (_Level2InterruptVector_text,
  217. .Level2InterruptVector.text,
  218. INTLEVEL2_VECTOR_VADDR,
  219. LAST)
  220. # undef LAST
  221. # define LAST .Level2InterruptVector.text
  222. #endif
  223. #if XCHAL_EXCM_LEVEL >= 3
  224. SECTION_VECTOR4 (_Level3InterruptVector_text,
  225. .Level3InterruptVector.text,
  226. INTLEVEL3_VECTOR_VADDR,
  227. LAST)
  228. # undef LAST
  229. # define LAST .Level3InterruptVector.text
  230. #endif
  231. #if XCHAL_EXCM_LEVEL >= 4
  232. SECTION_VECTOR4 (_Level4InterruptVector_text,
  233. .Level4InterruptVector.text,
  234. INTLEVEL4_VECTOR_VADDR,
  235. LAST)
  236. # undef LAST
  237. # define LAST .Level4InterruptVector.text
  238. #endif
  239. #if XCHAL_EXCM_LEVEL >= 5
  240. SECTION_VECTOR4 (_Level5InterruptVector_text,
  241. .Level5InterruptVector.text,
  242. INTLEVEL5_VECTOR_VADDR,
  243. LAST)
  244. # undef LAST
  245. # define LAST .Level5InterruptVector.text
  246. #endif
  247. #if XCHAL_EXCM_LEVEL >= 6
  248. SECTION_VECTOR4 (_Level6InterruptVector_text,
  249. .Level6InterruptVector.text,
  250. INTLEVEL6_VECTOR_VADDR,
  251. LAST)
  252. # undef LAST
  253. # define LAST .Level6InterruptVector.text
  254. #endif
  255. SECTION_VECTOR4 (_KernelExceptionVector_text,
  256. .KernelExceptionVector.text,
  257. KERNEL_VECTOR_VADDR,
  258. LAST)
  259. #undef LAST
  260. SECTION_VECTOR4 (_UserExceptionVector_text,
  261. .UserExceptionVector.text,
  262. USER_VECTOR_VADDR,
  263. .KernelExceptionVector.text)
  264. SECTION_VECTOR4 (_DoubleExceptionVector_text,
  265. .DoubleExceptionVector.text,
  266. DOUBLEEXC_VECTOR_VADDR,
  267. .UserExceptionVector.text)
  268. #define LAST .DoubleExceptionVector.text
  269. #endif
  270. #if defined(CONFIG_SECONDARY_RESET_VECTOR)
  271. SECTION_VECTOR4 (_SecondaryResetVector_text,
  272. .SecondaryResetVector.text,
  273. RESET_VECTOR1_VADDR,
  274. LAST)
  275. #undef LAST
  276. #define LAST .SecondaryResetVector.text
  277. #endif
  278. #if !MERGED_VECTORS
  279. SECTION_VECTOR4 (_exception_text,
  280. .exception.text,
  281. ,
  282. LAST)
  283. #undef LAST
  284. #define LAST .exception.text
  285. SECTION_VECTOR4 (_xip_text,
  286. .xiptext,
  287. ,
  288. LAST)
  289. #undef LAST
  290. #define LAST .xiptext
  291. #endif
  292. . = (LOADADDR(LAST) + SIZEOF(LAST) + 3) & ~ 3;
  293. .dummy1 : AT(ADDR(.dummy1)) { LONG(0) }
  294. . = ALIGN(PAGE_SIZE);
  295. #ifndef CONFIG_XIP_KERNEL
  296. __init_end = .;
  297. BSS_SECTION(0, 8192, 0)
  298. #endif
  299. _end = .;
  300. #ifdef CONFIG_XIP_KERNEL
  301. . = CONFIG_XIP_DATA_ADDR;
  302. _xip_start = .;
  303. #undef LOAD_OFFSET
  304. #define LOAD_OFFSET \
  305. (CONFIG_XIP_DATA_ADDR - (LOADADDR(.dummy1) + SIZEOF(.dummy1) + 3) & ~ 3)
  306. _xip_data_start = .;
  307. _sdata = .;
  308. RW_DATA(XCHAL_ICACHE_LINESIZE, PAGE_SIZE, THREAD_SIZE)
  309. _edata = .;
  310. _xip_data_end = .;
  311. /* Initialization data: */
  312. STRUCT_ALIGN();
  313. _xip_init_data_start = .;
  314. __init_begin = .;
  315. .init.data :
  316. {
  317. INIT_DATA
  318. }
  319. _xip_init_data_end = .;
  320. __init_end = .;
  321. BSS_SECTION(0, 8192, 0)
  322. _xip_end = .;
  323. #undef LOAD_OFFSET
  324. #endif
  325. DWARF_DEBUG
  326. .xt.prop 0 : { KEEP(*(.xt.prop .xt.prop.* .gnu.linkonce.prop.*)) }
  327. .xt.insn 0 : { KEEP(*(.xt.insn .xt.insn.* .gnu.linkonce.x*)) }
  328. .xt.lit 0 : { KEEP(*(.xt.lit .xt.lit.* .gnu.linkonce.p*)) }
  329. /* Sections to be discarded */
  330. DISCARDS
  331. }