vmlinux.lds.S 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  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. #ifndef KERNELOFFSET
  30. #define KERNELOFFSET 0xd0003000
  31. #endif
  32. /* Note: In the following macros, it would be nice to specify only the
  33. vector name and section kind and construct "sym" and "section" using
  34. CPP concatenation, but that does not work reliably. Concatenating a
  35. string with "." produces an invalid token. CPP will not print a
  36. warning because it thinks this is an assembly file, but it leaves
  37. them as multiple tokens and there may or may not be whitespace
  38. between them. */
  39. /* Macro for a relocation entry */
  40. #define RELOCATE_ENTRY(sym, section) \
  41. LONG(sym ## _start); \
  42. LONG(sym ## _end); \
  43. LONG(LOADADDR(section))
  44. /* Macro to define a section for a vector.
  45. *
  46. * Use of the MIN function catches the types of errors illustrated in
  47. * the following example:
  48. *
  49. * Assume the section .DoubleExceptionVector.literal is completely
  50. * full. Then a programmer adds code to .DoubleExceptionVector.text
  51. * that produces another literal. The final literal position will
  52. * overlay onto the first word of the adjacent code section
  53. * .DoubleExceptionVector.text. (In practice, the literals will
  54. * overwrite the code, and the first few instructions will be
  55. * garbage.)
  56. */
  57. #define SECTION_VECTOR(sym, section, addr, max_prevsec_size, prevsec) \
  58. section addr : AT((MIN(LOADADDR(prevsec) + max_prevsec_size, \
  59. LOADADDR(prevsec) + SIZEOF(prevsec)) + 3) & ~ 3) \
  60. { \
  61. . = ALIGN(4); \
  62. sym ## _start = ABSOLUTE(.); \
  63. *(section) \
  64. sym ## _end = ABSOLUTE(.); \
  65. }
  66. /*
  67. * Mapping of input sections to output sections when linking.
  68. */
  69. SECTIONS
  70. {
  71. . = KERNELOFFSET;
  72. /* .text section */
  73. _text = .;
  74. _stext = .;
  75. .text :
  76. {
  77. /* The HEAD_TEXT section must be the first section! */
  78. HEAD_TEXT
  79. TEXT_TEXT
  80. VMLINUX_SYMBOL(__sched_text_start) = .;
  81. *(.sched.literal .sched.text)
  82. VMLINUX_SYMBOL(__sched_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_literal,
  145. .SecondaryResetVector.literal);
  146. RELOCATE_ENTRY(_SecondaryResetVector_text,
  147. .SecondaryResetVector.text);
  148. #endif
  149. __boot_reloc_table_end = ABSOLUTE(.) ;
  150. INIT_SETUP(XCHAL_ICACHE_LINESIZE)
  151. INIT_CALLS
  152. CON_INITCALL
  153. SECURITY_INITCALL
  154. INIT_RAM_FS
  155. }
  156. PERCPU_SECTION(XCHAL_ICACHE_LINESIZE)
  157. /* We need this dummy segment here */
  158. . = ALIGN(4);
  159. .dummy : { LONG(0) }
  160. /* The vectors are relocated to the real position at startup time */
  161. SECTION_VECTOR (_WindowVectors_text,
  162. .WindowVectors.text,
  163. WINDOW_VECTORS_VADDR, 4,
  164. .dummy)
  165. SECTION_VECTOR (_DebugInterruptVector_literal,
  166. .DebugInterruptVector.literal,
  167. DEBUG_VECTOR_VADDR - 4,
  168. SIZEOF(.WindowVectors.text),
  169. .WindowVectors.text)
  170. SECTION_VECTOR (_DebugInterruptVector_text,
  171. .DebugInterruptVector.text,
  172. DEBUG_VECTOR_VADDR,
  173. 4,
  174. .DebugInterruptVector.literal)
  175. #undef LAST
  176. #define LAST .DebugInterruptVector.text
  177. #if XCHAL_EXCM_LEVEL >= 2
  178. SECTION_VECTOR (_Level2InterruptVector_text,
  179. .Level2InterruptVector.text,
  180. INTLEVEL2_VECTOR_VADDR,
  181. SIZEOF(LAST), LAST)
  182. # undef LAST
  183. # define LAST .Level2InterruptVector.text
  184. #endif
  185. #if XCHAL_EXCM_LEVEL >= 3
  186. SECTION_VECTOR (_Level3InterruptVector_text,
  187. .Level3InterruptVector.text,
  188. INTLEVEL3_VECTOR_VADDR,
  189. SIZEOF(LAST), LAST)
  190. # undef LAST
  191. # define LAST .Level3InterruptVector.text
  192. #endif
  193. #if XCHAL_EXCM_LEVEL >= 4
  194. SECTION_VECTOR (_Level4InterruptVector_text,
  195. .Level4InterruptVector.text,
  196. INTLEVEL4_VECTOR_VADDR,
  197. SIZEOF(LAST), LAST)
  198. # undef LAST
  199. # define LAST .Level4InterruptVector.text
  200. #endif
  201. #if XCHAL_EXCM_LEVEL >= 5
  202. SECTION_VECTOR (_Level5InterruptVector_text,
  203. .Level5InterruptVector.text,
  204. INTLEVEL5_VECTOR_VADDR,
  205. SIZEOF(LAST), LAST)
  206. # undef LAST
  207. # define LAST .Level5InterruptVector.text
  208. #endif
  209. #if XCHAL_EXCM_LEVEL >= 6
  210. SECTION_VECTOR (_Level6InterruptVector_text,
  211. .Level6InterruptVector.text,
  212. INTLEVEL6_VECTOR_VADDR,
  213. SIZEOF(LAST), LAST)
  214. # undef LAST
  215. # define LAST .Level6InterruptVector.text
  216. #endif
  217. SECTION_VECTOR (_KernelExceptionVector_literal,
  218. .KernelExceptionVector.literal,
  219. KERNEL_VECTOR_VADDR - 4,
  220. SIZEOF(LAST), LAST)
  221. #undef LAST
  222. SECTION_VECTOR (_KernelExceptionVector_text,
  223. .KernelExceptionVector.text,
  224. KERNEL_VECTOR_VADDR,
  225. 4,
  226. .KernelExceptionVector.literal)
  227. SECTION_VECTOR (_UserExceptionVector_literal,
  228. .UserExceptionVector.literal,
  229. USER_VECTOR_VADDR - 4,
  230. SIZEOF(.KernelExceptionVector.text),
  231. .KernelExceptionVector.text)
  232. SECTION_VECTOR (_UserExceptionVector_text,
  233. .UserExceptionVector.text,
  234. USER_VECTOR_VADDR,
  235. 4,
  236. .UserExceptionVector.literal)
  237. SECTION_VECTOR (_DoubleExceptionVector_literal,
  238. .DoubleExceptionVector.literal,
  239. DOUBLEEXC_VECTOR_VADDR - 48,
  240. SIZEOF(.UserExceptionVector.text),
  241. .UserExceptionVector.text)
  242. SECTION_VECTOR (_DoubleExceptionVector_text,
  243. .DoubleExceptionVector.text,
  244. DOUBLEEXC_VECTOR_VADDR,
  245. 48,
  246. .DoubleExceptionVector.literal)
  247. . = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3;
  248. #if defined(CONFIG_SMP)
  249. SECTION_VECTOR (_SecondaryResetVector_literal,
  250. .SecondaryResetVector.literal,
  251. RESET_VECTOR1_VADDR - 4,
  252. SIZEOF(.DoubleExceptionVector.text),
  253. .DoubleExceptionVector.text)
  254. SECTION_VECTOR (_SecondaryResetVector_text,
  255. .SecondaryResetVector.text,
  256. RESET_VECTOR1_VADDR,
  257. 4,
  258. .SecondaryResetVector.literal)
  259. . = LOADADDR(.SecondaryResetVector.text)+SIZEOF(.SecondaryResetVector.text);
  260. #endif
  261. . = ALIGN(PAGE_SIZE);
  262. __init_end = .;
  263. BSS_SECTION(0, 8192, 0)
  264. _end = .;
  265. /* only used by the boot loader */
  266. . = ALIGN(0x10);
  267. .bootstrap : { *(.bootstrap.literal .bootstrap.text .bootstrap.data) }
  268. .ResetVector.text RESET_VECTOR_VADDR :
  269. {
  270. *(.ResetVector.text)
  271. }
  272. /*
  273. * This is a remapped copy of the Secondary Reset Vector Code.
  274. * It keeps gdb in sync with the PC after switching
  275. * to the temporary mapping used while setting up
  276. * the V2 MMU mappings for Linux.
  277. *
  278. * Only debug information about this section is put in the kernel image.
  279. */
  280. .SecondaryResetVector.remapped_text 0x46000000 (INFO):
  281. {
  282. *(.SecondaryResetVector.remapped_text)
  283. }
  284. .xt.lit : { *(.xt.lit) }
  285. .xt.prop : { *(.xt.prop) }
  286. .debug 0 : { *(.debug) }
  287. .line 0 : { *(.line) }
  288. .debug_srcinfo 0 : { *(.debug_srcinfo) }
  289. .debug_sfnames 0 : { *(.debug_sfnames) }
  290. .debug_aranges 0 : { *(.debug_aranges) }
  291. .debug_pubnames 0 : { *(.debug_pubnames) }
  292. .debug_info 0 : { *(.debug_info) }
  293. .debug_abbrev 0 : { *(.debug_abbrev) }
  294. .debug_line 0 : { *(.debug_line) }
  295. .debug_frame 0 : { *(.debug_frame) }
  296. .debug_str 0 : { *(.debug_str) }
  297. .debug_loc 0 : { *(.debug_loc) }
  298. .debug_macinfo 0 : { *(.debug_macinfo) }
  299. .debug_weaknames 0 : { *(.debug_weaknames) }
  300. .debug_funcnames 0 : { *(.debug_funcnames) }
  301. .debug_typenames 0 : { *(.debug_typenames) }
  302. .debug_varnames 0 : { *(.debug_varnames) }
  303. .xt.insn 0 :
  304. {
  305. *(.xt.insn)
  306. *(.gnu.linkonce.x*)
  307. }
  308. .xt.lit 0 :
  309. {
  310. *(.xt.lit)
  311. *(.gnu.linkonce.p*)
  312. }
  313. /* Sections to be discarded */
  314. DISCARDS
  315. /DISCARD/ : { *(.exit.literal) }
  316. }