vmlinux.lds.S 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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 - 2005 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 <variant/core.h>
  18. #include <platform/hardware.h>
  19. OUTPUT_ARCH(xtensa)
  20. ENTRY(_start)
  21. #ifdef __XTENSA_EB__
  22. jiffies = jiffies_64 + 4;
  23. #else
  24. jiffies = jiffies_64;
  25. #endif
  26. #ifndef KERNELOFFSET
  27. #define KERNELOFFSET 0xd0001000
  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. #define SECTION_VECTOR(sym, section, addr, max_prevsec_size, prevsec) \
  55. section addr : AT((MIN(LOADADDR(prevsec) + max_prevsec_size, \
  56. LOADADDR(prevsec) + SIZEOF(prevsec)) + 3) & ~ 3) \
  57. { \
  58. . = ALIGN(4); \
  59. sym ## _start = ABSOLUTE(.); \
  60. *(section) \
  61. sym ## _end = ABSOLUTE(.); \
  62. }
  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. _ftext = .;
  73. .text :
  74. {
  75. /* The HEAD_TEXT section must be the first section! */
  76. HEAD_TEXT
  77. TEXT_TEXT
  78. VMLINUX_SYMBOL(__sched_text_start) = .;
  79. *(.sched.literal .sched.text)
  80. VMLINUX_SYMBOL(__sched_text_end) = .;
  81. VMLINUX_SYMBOL(__lock_text_start) = .;
  82. *(.spinlock.literal .spinlock.text)
  83. VMLINUX_SYMBOL(__lock_text_end) = .;
  84. }
  85. _etext = .;
  86. PROVIDE (etext = .);
  87. . = ALIGN(16);
  88. RODATA
  89. /* Relocation table */
  90. .fixup : { *(.fixup) }
  91. . = ALIGN(16);
  92. __ex_table : {
  93. __start___ex_table = .;
  94. *(__ex_table)
  95. __stop___ex_table = .;
  96. }
  97. /* Data section */
  98. . = ALIGN(XCHAL_ICACHE_LINESIZE);
  99. _fdata = .;
  100. .data :
  101. {
  102. DATA_DATA
  103. CONSTRUCTORS
  104. . = ALIGN(XCHAL_ICACHE_LINESIZE);
  105. *(.data.cacheline_aligned)
  106. }
  107. _edata = .;
  108. /* The initial task */
  109. . = ALIGN(8192);
  110. .data.init_task : { *(.data.init_task) }
  111. /* Initialization code and data: */
  112. . = ALIGN(1 << 12);
  113. __init_begin = .;
  114. .init.text : {
  115. _sinittext = .;
  116. INIT_TEXT
  117. _einittext = .;
  118. }
  119. .init.data :
  120. {
  121. INIT_DATA
  122. . = ALIGN(0x4);
  123. __tagtable_begin = .;
  124. *(.taglist)
  125. __tagtable_end = .;
  126. . = ALIGN(16);
  127. __boot_reloc_table_start = ABSOLUTE(.);
  128. RELOCATE_ENTRY(_WindowVectors_text,
  129. .WindowVectors.text);
  130. RELOCATE_ENTRY(_KernelExceptionVector_text,
  131. .KernelExceptionVector.text);
  132. RELOCATE_ENTRY(_UserExceptionVector_text,
  133. .UserExceptionVector.text);
  134. RELOCATE_ENTRY(_DoubleExceptionVector_literal,
  135. .DoubleExceptionVector.literal);
  136. RELOCATE_ENTRY(_DoubleExceptionVector_text,
  137. .DoubleExceptionVector.text);
  138. RELOCATE_ENTRY(_DebugInterruptVector_text,
  139. .DebugInterruptVector.text);
  140. __boot_reloc_table_end = ABSOLUTE(.) ;
  141. }
  142. . = ALIGN(XCHAL_ICACHE_LINESIZE);
  143. __setup_start = .;
  144. .init.setup : { *(.init.setup) }
  145. __setup_end = .;
  146. __initcall_start = .;
  147. .initcall.init : {
  148. INITCALLS
  149. }
  150. __initcall_end = .;
  151. __con_initcall_start = .;
  152. .con_initcall.init : { *(.con_initcall.init) }
  153. __con_initcall_end = .;
  154. SECURITY_INIT
  155. #ifdef CONFIG_BLK_DEV_INITRD
  156. . = ALIGN(4096);
  157. __initramfs_start =.;
  158. .init.ramfs : { *(.init.ramfs) }
  159. __initramfs_end = .;
  160. #endif
  161. PERCPU(4096)
  162. /* We need this dummy segment here */
  163. . = ALIGN(4);
  164. .dummy : { LONG(0) }
  165. /* The vectors are relocated to the real position at startup time */
  166. SECTION_VECTOR (_WindowVectors_text,
  167. .WindowVectors.text,
  168. XCHAL_WINDOW_VECTORS_VADDR, 4,
  169. .dummy)
  170. SECTION_VECTOR (_DebugInterruptVector_literal,
  171. .DebugInterruptVector.literal,
  172. XCHAL_DEBUG_VECTOR_VADDR - 4,
  173. SIZEOF(.WindowVectors.text),
  174. .WindowVectors.text)
  175. SECTION_VECTOR (_DebugInterruptVector_text,
  176. .DebugInterruptVector.text,
  177. XCHAL_DEBUG_VECTOR_VADDR,
  178. 4,
  179. .DebugInterruptVector.literal)
  180. SECTION_VECTOR (_KernelExceptionVector_literal,
  181. .KernelExceptionVector.literal,
  182. XCHAL_KERNEL_VECTOR_VADDR - 4,
  183. SIZEOF(.DebugInterruptVector.text),
  184. .DebugInterruptVector.text)
  185. SECTION_VECTOR (_KernelExceptionVector_text,
  186. .KernelExceptionVector.text,
  187. XCHAL_KERNEL_VECTOR_VADDR,
  188. 4,
  189. .KernelExceptionVector.literal)
  190. SECTION_VECTOR (_UserExceptionVector_literal,
  191. .UserExceptionVector.literal,
  192. XCHAL_USER_VECTOR_VADDR - 4,
  193. SIZEOF(.KernelExceptionVector.text),
  194. .KernelExceptionVector.text)
  195. SECTION_VECTOR (_UserExceptionVector_text,
  196. .UserExceptionVector.text,
  197. XCHAL_USER_VECTOR_VADDR,
  198. 4,
  199. .UserExceptionVector.literal)
  200. SECTION_VECTOR (_DoubleExceptionVector_literal,
  201. .DoubleExceptionVector.literal,
  202. XCHAL_DOUBLEEXC_VECTOR_VADDR - 16,
  203. SIZEOF(.UserExceptionVector.text),
  204. .UserExceptionVector.text)
  205. SECTION_VECTOR (_DoubleExceptionVector_text,
  206. .DoubleExceptionVector.text,
  207. XCHAL_DOUBLEEXC_VECTOR_VADDR,
  208. 32,
  209. .DoubleExceptionVector.literal)
  210. . = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3;
  211. . = ALIGN(1 << 12);
  212. __init_end = .;
  213. . = ALIGN(8192);
  214. /* BSS section */
  215. _bss_start = .;
  216. .bss : { *(.bss.page_aligned) *(.bss) }
  217. _bss_end = .;
  218. _end = .;
  219. /* only used by the boot loader */
  220. . = ALIGN(0x10);
  221. .bootstrap : { *(.bootstrap.literal .bootstrap.text .bootstrap.data) }
  222. . = ALIGN(0x1000);
  223. __initrd_start = .;
  224. .initrd : { *(.initrd) }
  225. __initrd_end = .;
  226. .ResetVector.text XCHAL_RESET_VECTOR_VADDR :
  227. {
  228. *(.ResetVector.text)
  229. }
  230. /* Sections to be discarded */
  231. /DISCARD/ :
  232. {
  233. *(.exit.literal)
  234. EXIT_TEXT
  235. EXIT_DATA
  236. *(.exitcall.exit)
  237. }
  238. .xt.lit : { *(.xt.lit) }
  239. .xt.prop : { *(.xt.prop) }
  240. .debug 0 : { *(.debug) }
  241. .line 0 : { *(.line) }
  242. .debug_srcinfo 0 : { *(.debug_srcinfo) }
  243. .debug_sfnames 0 : { *(.debug_sfnames) }
  244. .debug_aranges 0 : { *(.debug_aranges) }
  245. .debug_pubnames 0 : { *(.debug_pubnames) }
  246. .debug_info 0 : { *(.debug_info) }
  247. .debug_abbrev 0 : { *(.debug_abbrev) }
  248. .debug_line 0 : { *(.debug_line) }
  249. .debug_frame 0 : { *(.debug_frame) }
  250. .debug_str 0 : { *(.debug_str) }
  251. .debug_loc 0 : { *(.debug_loc) }
  252. .debug_macinfo 0 : { *(.debug_macinfo) }
  253. .debug_weaknames 0 : { *(.debug_weaknames) }
  254. .debug_funcnames 0 : { *(.debug_funcnames) }
  255. .debug_typenames 0 : { *(.debug_typenames) }
  256. .debug_varnames 0 : { *(.debug_varnames) }
  257. .xt.insn 0 :
  258. {
  259. *(.xt.insn)
  260. *(.gnu.linkonce.x*)
  261. }
  262. .xt.lit 0 :
  263. {
  264. *(.xt.lit)
  265. *(.gnu.linkonce.p*)
  266. }
  267. }