vmlinux.lds.S 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  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. __boot_reloc_table_end = ABSOLUTE(.) ;
  144. INIT_SETUP(XCHAL_ICACHE_LINESIZE)
  145. INIT_CALLS
  146. CON_INITCALL
  147. SECURITY_INITCALL
  148. INIT_RAM_FS
  149. }
  150. PERCPU_SECTION(XCHAL_ICACHE_LINESIZE)
  151. /* We need this dummy segment here */
  152. . = ALIGN(4);
  153. .dummy : { LONG(0) }
  154. /* The vectors are relocated to the real position at startup time */
  155. SECTION_VECTOR (_WindowVectors_text,
  156. .WindowVectors.text,
  157. WINDOW_VECTORS_VADDR, 4,
  158. .dummy)
  159. SECTION_VECTOR (_DebugInterruptVector_literal,
  160. .DebugInterruptVector.literal,
  161. DEBUG_VECTOR_VADDR - 4,
  162. SIZEOF(.WindowVectors.text),
  163. .WindowVectors.text)
  164. SECTION_VECTOR (_DebugInterruptVector_text,
  165. .DebugInterruptVector.text,
  166. DEBUG_VECTOR_VADDR,
  167. 4,
  168. .DebugInterruptVector.literal)
  169. #undef LAST
  170. #define LAST .DebugInterruptVector.text
  171. #if XCHAL_EXCM_LEVEL >= 2
  172. SECTION_VECTOR (_Level2InterruptVector_text,
  173. .Level2InterruptVector.text,
  174. INTLEVEL2_VECTOR_VADDR,
  175. SIZEOF(LAST), LAST)
  176. # undef LAST
  177. # define LAST .Level2InterruptVector.text
  178. #endif
  179. #if XCHAL_EXCM_LEVEL >= 3
  180. SECTION_VECTOR (_Level3InterruptVector_text,
  181. .Level3InterruptVector.text,
  182. INTLEVEL3_VECTOR_VADDR,
  183. SIZEOF(LAST), LAST)
  184. # undef LAST
  185. # define LAST .Level3InterruptVector.text
  186. #endif
  187. #if XCHAL_EXCM_LEVEL >= 4
  188. SECTION_VECTOR (_Level4InterruptVector_text,
  189. .Level4InterruptVector.text,
  190. INTLEVEL4_VECTOR_VADDR,
  191. SIZEOF(LAST), LAST)
  192. # undef LAST
  193. # define LAST .Level4InterruptVector.text
  194. #endif
  195. #if XCHAL_EXCM_LEVEL >= 5
  196. SECTION_VECTOR (_Level5InterruptVector_text,
  197. .Level5InterruptVector.text,
  198. INTLEVEL5_VECTOR_VADDR,
  199. SIZEOF(LAST), LAST)
  200. # undef LAST
  201. # define LAST .Level5InterruptVector.text
  202. #endif
  203. #if XCHAL_EXCM_LEVEL >= 6
  204. SECTION_VECTOR (_Level6InterruptVector_text,
  205. .Level6InterruptVector.text,
  206. INTLEVEL6_VECTOR_VADDR,
  207. SIZEOF(LAST), LAST)
  208. # undef LAST
  209. # define LAST .Level6InterruptVector.text
  210. #endif
  211. SECTION_VECTOR (_KernelExceptionVector_literal,
  212. .KernelExceptionVector.literal,
  213. KERNEL_VECTOR_VADDR - 4,
  214. SIZEOF(LAST), LAST)
  215. #undef LAST
  216. SECTION_VECTOR (_KernelExceptionVector_text,
  217. .KernelExceptionVector.text,
  218. KERNEL_VECTOR_VADDR,
  219. 4,
  220. .KernelExceptionVector.literal)
  221. SECTION_VECTOR (_UserExceptionVector_literal,
  222. .UserExceptionVector.literal,
  223. USER_VECTOR_VADDR - 4,
  224. SIZEOF(.KernelExceptionVector.text),
  225. .KernelExceptionVector.text)
  226. SECTION_VECTOR (_UserExceptionVector_text,
  227. .UserExceptionVector.text,
  228. USER_VECTOR_VADDR,
  229. 4,
  230. .UserExceptionVector.literal)
  231. SECTION_VECTOR (_DoubleExceptionVector_literal,
  232. .DoubleExceptionVector.literal,
  233. DOUBLEEXC_VECTOR_VADDR - 16,
  234. SIZEOF(.UserExceptionVector.text),
  235. .UserExceptionVector.text)
  236. SECTION_VECTOR (_DoubleExceptionVector_text,
  237. .DoubleExceptionVector.text,
  238. DOUBLEEXC_VECTOR_VADDR,
  239. 32,
  240. .DoubleExceptionVector.literal)
  241. . = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3;
  242. . = ALIGN(PAGE_SIZE);
  243. __init_end = .;
  244. BSS_SECTION(0, 8192, 0)
  245. _end = .;
  246. /* only used by the boot loader */
  247. . = ALIGN(0x10);
  248. .bootstrap : { *(.bootstrap.literal .bootstrap.text .bootstrap.data) }
  249. .ResetVector.text RESET_VECTOR_VADDR :
  250. {
  251. *(.ResetVector.text)
  252. }
  253. /*
  254. * This is a remapped copy of the Secondary Reset Vector Code.
  255. * It keeps gdb in sync with the PC after switching
  256. * to the temporary mapping used while setting up
  257. * the V2 MMU mappings for Linux.
  258. *
  259. * Only debug information about this section is put in the kernel image.
  260. */
  261. .SecondaryResetVector.remapped_text 0x46000000 (INFO):
  262. {
  263. *(.SecondaryResetVector.remapped_text)
  264. }
  265. .xt.lit : { *(.xt.lit) }
  266. .xt.prop : { *(.xt.prop) }
  267. .debug 0 : { *(.debug) }
  268. .line 0 : { *(.line) }
  269. .debug_srcinfo 0 : { *(.debug_srcinfo) }
  270. .debug_sfnames 0 : { *(.debug_sfnames) }
  271. .debug_aranges 0 : { *(.debug_aranges) }
  272. .debug_pubnames 0 : { *(.debug_pubnames) }
  273. .debug_info 0 : { *(.debug_info) }
  274. .debug_abbrev 0 : { *(.debug_abbrev) }
  275. .debug_line 0 : { *(.debug_line) }
  276. .debug_frame 0 : { *(.debug_frame) }
  277. .debug_str 0 : { *(.debug_str) }
  278. .debug_loc 0 : { *(.debug_loc) }
  279. .debug_macinfo 0 : { *(.debug_macinfo) }
  280. .debug_weaknames 0 : { *(.debug_weaknames) }
  281. .debug_funcnames 0 : { *(.debug_funcnames) }
  282. .debug_typenames 0 : { *(.debug_typenames) }
  283. .debug_varnames 0 : { *(.debug_varnames) }
  284. .xt.insn 0 :
  285. {
  286. *(.xt.insn)
  287. *(.gnu.linkonce.x*)
  288. }
  289. .xt.lit 0 :
  290. {
  291. *(.xt.lit)
  292. *(.gnu.linkonce.p*)
  293. }
  294. /* Sections to be discarded */
  295. DISCARDS
  296. /DISCARD/ : { *(.exit.literal) }
  297. }