vmlinux.lds.S 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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. #define _NOCLANGUAGE
  18. #include <xtensa/config/core.h>
  19. #include <xtensa/config/system.h>
  20. OUTPUT_ARCH(xtensa)
  21. ENTRY(_start)
  22. #if XCHAL_MEMORY_ORDER == XTHAL_BIGENDIAN
  23. jiffies = jiffies_64 + 4;
  24. #else
  25. jiffies = jiffies_64;
  26. #endif
  27. #define KERNELOFFSET 0x1000
  28. /* Note: In the following macros, it would be nice to specify only the
  29. vector name and section kind and construct "sym" and "section" using
  30. CPP concatenation, but that does not work reliably. Concatenating a
  31. string with "." produces an invalid token. CPP will not print a
  32. warning because it thinks this is an assembly file, but it leaves
  33. them as multiple tokens and there may or may not be whitespace
  34. between them. */
  35. /* Macro for a relocation entry */
  36. #define RELOCATE_ENTRY(sym, section) \
  37. LONG(sym ## _start); \
  38. LONG(sym ## _end); \
  39. LONG(LOADADDR(section))
  40. /* Macro to define a section for a vector.
  41. *
  42. * Use of the MIN function catches the types of errors illustrated in
  43. * the following example:
  44. *
  45. * Assume the section .DoubleExceptionVector.literal is completely
  46. * full. Then a programmer adds code to .DoubleExceptionVector.text
  47. * that produces another literal. The final literal position will
  48. * overlay onto the first word of the adjacent code section
  49. * .DoubleExceptionVector.text. (In practice, the literals will
  50. * overwrite the code, and the first few instructions will be
  51. * garbage.)
  52. */
  53. #define SECTION_VECTOR(sym, section, addr, max_prevsec_size, prevsec) \
  54. section addr : AT((MIN(LOADADDR(prevsec) + max_prevsec_size, \
  55. LOADADDR(prevsec) + SIZEOF(prevsec)) + 3) & ~ 3) \
  56. { \
  57. . = ALIGN(4); \
  58. sym ## _start = ABSOLUTE(.); \
  59. *(section) \
  60. sym ## _end = ABSOLUTE(.); \
  61. }
  62. /*
  63. * Mapping of input sections to output sections when linking.
  64. */
  65. SECTIONS
  66. {
  67. . = XCHAL_KSEG_CACHED_VADDR + KERNELOFFSET;
  68. /* .text section */
  69. _text = .;
  70. _stext = .;
  71. _ftext = .;
  72. .text :
  73. {
  74. /* The .head.text section must be the first section! */
  75. *(.head.text)
  76. *(.literal .text)
  77. *(.srom.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. . = ALIGN(16);
  87. RODATA
  88. /* Relocation table */
  89. . = ALIGN(16);
  90. __boot_reloc_table_start = ABSOLUTE(.);
  91. __relocate : {
  92. RELOCATE_ENTRY(_WindowVectors_text,
  93. .WindowVectors.text);
  94. #if 0
  95. RELOCATE_ENTRY(_KernelExceptionVector_literal,
  96. .KernelExceptionVector.literal);
  97. #endif
  98. RELOCATE_ENTRY(_KernelExceptionVector_text,
  99. .KernelExceptionVector.text);
  100. #if 0
  101. RELOCATE_ENTRY(_UserExceptionVector_literal,
  102. .UserExceptionVector.literal);
  103. #endif
  104. RELOCATE_ENTRY(_UserExceptionVector_text,
  105. .UserExceptionVector.text);
  106. RELOCATE_ENTRY(_DoubleExceptionVector_literal,
  107. .DoubleExceptionVector.literal);
  108. RELOCATE_ENTRY(_DoubleExceptionVector_text,
  109. .DoubleExceptionVector.text);
  110. }
  111. __boot_reloc_table_end = ABSOLUTE(.) ;
  112. .fixup : { *(.fixup) }
  113. . = ALIGN(16);
  114. __ex_table : {
  115. __start___ex_table = .;
  116. *(__ex_table)
  117. __stop___ex_table = .;
  118. }
  119. /* Data section */
  120. . = ALIGN(XCHAL_ICACHE_LINESIZE);
  121. _fdata = .;
  122. .data :
  123. {
  124. *(.data) CONSTRUCTORS
  125. . = ALIGN(XCHAL_ICACHE_LINESIZE);
  126. *(.data.cacheline_aligned)
  127. }
  128. _edata = .;
  129. /* The initial task */
  130. . = ALIGN(8192);
  131. .data.init_task : { *(.data.init_task) }
  132. /* Initialization code and data: */
  133. . = ALIGN(1<<XCHAL_MMU_MIN_PTE_PAGE_SIZE);
  134. __init_begin = .;
  135. .init.text : {
  136. _sinittext = .;
  137. *(.init.literal) *(.init.text)
  138. _einittext = .;
  139. }
  140. .init.data :
  141. {
  142. *(.init.data)
  143. . = ALIGN(0x4);
  144. __tagtable_begin = .;
  145. *(.taglist)
  146. __tagtable_end = .;
  147. }
  148. . = ALIGN(XCHAL_ICACHE_LINESIZE);
  149. __setup_start = .;
  150. .init.setup : { *(.init.setup) }
  151. __setup_end = .;
  152. __initcall_start = .;
  153. .initcall.init : {
  154. *(.initcall1.init)
  155. *(.initcall2.init)
  156. *(.initcall3.init)
  157. *(.initcall4.init)
  158. *(.initcall5.init)
  159. *(.initcall6.init)
  160. *(.initcall7.init)
  161. }
  162. __initcall_end = .;
  163. __con_initcall_start = .;
  164. .con_initcall.init : { *(.con_initcall.init) }
  165. __con_initcall_end = .;
  166. SECURITY_INIT
  167. . = ALIGN(4);
  168. __start___ftr_fixup = .;
  169. __ftr_fixup : { *(__ftr_fixup) }
  170. __stop___ftr_fixup = .;
  171. . = ALIGN(32);
  172. __per_cpu_start = .;
  173. .data.percpu : { *(.data.percpu) }
  174. __per_cpu_end = .;
  175. . = ALIGN(4096);
  176. __initramfs_start =.;
  177. .init.ramfs : { *(.init.ramfs) }
  178. __initramfs_end = .;
  179. /* We need this dummy segment here */
  180. . = ALIGN(4);
  181. .dummy : { LONG(0) }
  182. /* The vectors are relocated to the real position at startup time */
  183. SECTION_VECTOR (_WindowVectors_text,
  184. .WindowVectors.text,
  185. XCHAL_WINDOW_VECTORS_VADDR, 4,
  186. .dummy)
  187. SECTION_VECTOR (_DebugInterruptVector_literal,
  188. .DebugInterruptVector.literal,
  189. XCHAL_INTLEVEL_VECTOR_VADDR(XCHAL_DEBUGLEVEL) - 4,
  190. SIZEOF(.WindowVectors.text),
  191. .WindowVectors.text)
  192. SECTION_VECTOR (_DebugInterruptVector_text,
  193. .DebugInterruptVector.text,
  194. XCHAL_INTLEVEL_VECTOR_VADDR(XCHAL_DEBUGLEVEL),
  195. 4,
  196. .DebugInterruptVector.literal)
  197. SECTION_VECTOR (_KernelExceptionVector_literal,
  198. .KernelExceptionVector.literal,
  199. XCHAL_KERNELEXC_VECTOR_VADDR - 4,
  200. SIZEOF(.DebugInterruptVector.text),
  201. .DebugInterruptVector.text)
  202. SECTION_VECTOR (_KernelExceptionVector_text,
  203. .KernelExceptionVector.text,
  204. XCHAL_KERNELEXC_VECTOR_VADDR,
  205. 4,
  206. .KernelExceptionVector.literal)
  207. SECTION_VECTOR (_UserExceptionVector_literal,
  208. .UserExceptionVector.literal,
  209. XCHAL_USEREXC_VECTOR_VADDR - 4,
  210. SIZEOF(.KernelExceptionVector.text),
  211. .KernelExceptionVector.text)
  212. SECTION_VECTOR (_UserExceptionVector_text,
  213. .UserExceptionVector.text,
  214. XCHAL_USEREXC_VECTOR_VADDR,
  215. 4,
  216. .UserExceptionVector.literal)
  217. SECTION_VECTOR (_DoubleExceptionVector_literal,
  218. .DoubleExceptionVector.literal,
  219. XCHAL_DOUBLEEXC_VECTOR_VADDR - 16,
  220. SIZEOF(.UserExceptionVector.text),
  221. .UserExceptionVector.text)
  222. SECTION_VECTOR (_DoubleExceptionVector_text,
  223. .DoubleExceptionVector.text,
  224. XCHAL_DOUBLEEXC_VECTOR_VADDR,
  225. 32,
  226. .DoubleExceptionVector.literal)
  227. . = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3;
  228. . = ALIGN(1<<XCHAL_MMU_MIN_PTE_PAGE_SIZE);
  229. __init_end = .;
  230. . = ALIGN(8192);
  231. /* BSS section */
  232. _bss_start = .;
  233. .sbss : { *(.sbss) *(.scommon) }
  234. .bss : { *(COMMON) *(.bss) }
  235. _bss_end = .;
  236. _end = .;
  237. /* only used by the boot loader */
  238. . = ALIGN(0x10);
  239. .bootstrap : { *(.bootstrap.literal .bootstrap.text .bootstrap.data) }
  240. . = ALIGN(0x1000);
  241. __initrd_start = .;
  242. .initrd : { *(.initrd) }
  243. __initrd_end = .;
  244. .ResetVector.text XCHAL_RESET_VECTOR_VADDR :
  245. {
  246. *(.ResetVector.text)
  247. }
  248. /* Sections to be discarded */
  249. /DISCARD/ :
  250. {
  251. *(.text.exit)
  252. *(.text.exit.literal)
  253. *(.data.exit)
  254. *(.exitcall.exit)
  255. }
  256. .debug 0 : { *(.debug) }
  257. .line 0 : { *(.line) }
  258. .debug_srcinfo 0 : { *(.debug_srcinfo) }
  259. .debug_sfnames 0 : { *(.debug_sfnames) }
  260. .debug_aranges 0 : { *(.debug_aranges) }
  261. .debug_pubnames 0 : { *(.debug_pubnames) }
  262. .debug_info 0 : { *(.debug_info) }
  263. .debug_abbrev 0 : { *(.debug_abbrev) }
  264. .debug_line 0 : { *(.debug_line) }
  265. .debug_frame 0 : { *(.debug_frame) }
  266. .debug_str 0 : { *(.debug_str) }
  267. .debug_loc 0 : { *(.debug_loc) }
  268. .debug_macinfo 0 : { *(.debug_macinfo) }
  269. .debug_weaknames 0 : { *(.debug_weaknames) }
  270. .debug_funcnames 0 : { *(.debug_funcnames) }
  271. .debug_typenames 0 : { *(.debug_typenames) }
  272. .debug_varnames 0 : { *(.debug_varnames) }
  273. .xt.insn 0 :
  274. {
  275. *(.xt.insn)
  276. *(.gnu.linkonce.x*)
  277. }
  278. .xt.lit 0 :
  279. {
  280. *(.xt.lit)
  281. *(.gnu.linkonce.p*)
  282. }
  283. }