vmlinux.lds.S 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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 <linux/config.h>
  18. #define _NOCLANGUAGE
  19. #include <xtensa/config/core.h>
  20. #include <xtensa/config/system.h>
  21. OUTPUT_ARCH(xtensa)
  22. ENTRY(_start)
  23. #if XCHAL_MEMORY_ORDER == XTHAL_BIGENDIAN
  24. jiffies = jiffies_64 + 4;
  25. #else
  26. jiffies = jiffies_64;
  27. #endif
  28. #define KERNELOFFSET 0x1000
  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. . = XCHAL_KSEG_CACHED_VADDR + 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. *(.literal .text)
  78. *(.srom.text)
  79. VMLINUX_SYMBOL(__sched_text_start) = .;
  80. *(.sched.literal .sched.text)
  81. VMLINUX_SYMBOL(__sched_text_end) = .;
  82. VMLINUX_SYMBOL(__lock_text_start) = .;
  83. *(.spinlock.literal .spinlock.text)
  84. VMLINUX_SYMBOL(__lock_text_end) = .;
  85. }
  86. _etext = .;
  87. . = ALIGN(16);
  88. RODATA
  89. /* Relocation table */
  90. . = ALIGN(16);
  91. __boot_reloc_table_start = ABSOLUTE(.);
  92. __relocate : {
  93. RELOCATE_ENTRY(_WindowVectors_text,
  94. .WindowVectors.text);
  95. #if 0
  96. RELOCATE_ENTRY(_KernelExceptionVector_literal,
  97. .KernelExceptionVector.literal);
  98. #endif
  99. RELOCATE_ENTRY(_KernelExceptionVector_text,
  100. .KernelExceptionVector.text);
  101. #if 0
  102. RELOCATE_ENTRY(_UserExceptionVector_literal,
  103. .UserExceptionVector.literal);
  104. #endif
  105. RELOCATE_ENTRY(_UserExceptionVector_text,
  106. .UserExceptionVector.text);
  107. RELOCATE_ENTRY(_DoubleExceptionVector_literal,
  108. .DoubleExceptionVector.literal);
  109. RELOCATE_ENTRY(_DoubleExceptionVector_text,
  110. .DoubleExceptionVector.text);
  111. }
  112. __boot_reloc_table_end = ABSOLUTE(.) ;
  113. .fixup : { *(.fixup) }
  114. . = ALIGN(16);
  115. __ex_table : {
  116. __start___ex_table = .;
  117. *(__ex_table)
  118. __stop___ex_table = .;
  119. }
  120. /* Data section */
  121. . = ALIGN(XCHAL_ICACHE_LINESIZE);
  122. _fdata = .;
  123. .data :
  124. {
  125. *(.data) CONSTRUCTORS
  126. . = ALIGN(XCHAL_ICACHE_LINESIZE);
  127. *(.data.cacheline_aligned)
  128. }
  129. _edata = .;
  130. /* The initial task */
  131. . = ALIGN(8192);
  132. .data.init_task : { *(.data.init_task) }
  133. /* Initialization code and data: */
  134. . = ALIGN(1<<XCHAL_MMU_MIN_PTE_PAGE_SIZE);
  135. __init_begin = .;
  136. .init.text : {
  137. _sinittext = .;
  138. *(.init.literal) *(.init.text)
  139. _einittext = .;
  140. }
  141. .init.data :
  142. {
  143. *(.init.data)
  144. . = ALIGN(0x4);
  145. __tagtable_begin = .;
  146. *(.taglist)
  147. __tagtable_end = .;
  148. }
  149. . = ALIGN(XCHAL_ICACHE_LINESIZE);
  150. __setup_start = .;
  151. .init.setup : { *(.init.setup) }
  152. __setup_end = .;
  153. __initcall_start = .;
  154. .initcall.init : {
  155. *(.initcall1.init)
  156. *(.initcall2.init)
  157. *(.initcall3.init)
  158. *(.initcall4.init)
  159. *(.initcall5.init)
  160. *(.initcall6.init)
  161. *(.initcall7.init)
  162. }
  163. __initcall_end = .;
  164. __con_initcall_start = .;
  165. .con_initcall.init : { *(.con_initcall.init) }
  166. __con_initcall_end = .;
  167. SECURITY_INIT
  168. . = ALIGN(4);
  169. __start___ftr_fixup = .;
  170. __ftr_fixup : { *(__ftr_fixup) }
  171. __stop___ftr_fixup = .;
  172. . = ALIGN(32);
  173. __per_cpu_start = .;
  174. .data.percpu : { *(.data.percpu) }
  175. __per_cpu_end = .;
  176. . = ALIGN(4096);
  177. __initramfs_start =.;
  178. .init.ramfs : { *(.init.ramfs) }
  179. __initramfs_end = .;
  180. /* We need this dummy segment here */
  181. . = ALIGN(4);
  182. .dummy : { LONG(0) }
  183. /* The vectors are relocated to the real position at startup time */
  184. SECTION_VECTOR (_WindowVectors_text,
  185. .WindowVectors.text,
  186. XCHAL_WINDOW_VECTORS_VADDR, 4,
  187. .dummy)
  188. SECTION_VECTOR (_DebugInterruptVector_literal,
  189. .DebugInterruptVector.literal,
  190. XCHAL_INTLEVEL_VECTOR_VADDR(XCHAL_DEBUGLEVEL) - 4,
  191. SIZEOF(.WindowVectors.text),
  192. .WindowVectors.text)
  193. SECTION_VECTOR (_DebugInterruptVector_text,
  194. .DebugInterruptVector.text,
  195. XCHAL_INTLEVEL_VECTOR_VADDR(XCHAL_DEBUGLEVEL),
  196. 4,
  197. .DebugInterruptVector.literal)
  198. SECTION_VECTOR (_KernelExceptionVector_literal,
  199. .KernelExceptionVector.literal,
  200. XCHAL_KERNELEXC_VECTOR_VADDR - 4,
  201. SIZEOF(.DebugInterruptVector.text),
  202. .DebugInterruptVector.text)
  203. SECTION_VECTOR (_KernelExceptionVector_text,
  204. .KernelExceptionVector.text,
  205. XCHAL_KERNELEXC_VECTOR_VADDR,
  206. 4,
  207. .KernelExceptionVector.literal)
  208. SECTION_VECTOR (_UserExceptionVector_literal,
  209. .UserExceptionVector.literal,
  210. XCHAL_USEREXC_VECTOR_VADDR - 4,
  211. SIZEOF(.KernelExceptionVector.text),
  212. .KernelExceptionVector.text)
  213. SECTION_VECTOR (_UserExceptionVector_text,
  214. .UserExceptionVector.text,
  215. XCHAL_USEREXC_VECTOR_VADDR,
  216. 4,
  217. .UserExceptionVector.literal)
  218. SECTION_VECTOR (_DoubleExceptionVector_literal,
  219. .DoubleExceptionVector.literal,
  220. XCHAL_DOUBLEEXC_VECTOR_VADDR - 16,
  221. SIZEOF(.UserExceptionVector.text),
  222. .UserExceptionVector.text)
  223. SECTION_VECTOR (_DoubleExceptionVector_text,
  224. .DoubleExceptionVector.text,
  225. XCHAL_DOUBLEEXC_VECTOR_VADDR,
  226. 32,
  227. .DoubleExceptionVector.literal)
  228. . = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3;
  229. . = ALIGN(1<<XCHAL_MMU_MIN_PTE_PAGE_SIZE);
  230. __init_end = .;
  231. . = ALIGN(8192);
  232. /* BSS section */
  233. _bss_start = .;
  234. .sbss : { *(.sbss) *(.scommon) }
  235. .bss : { *(COMMON) *(.bss) }
  236. _bss_end = .;
  237. _end = .;
  238. /* only used by the boot loader */
  239. . = ALIGN(0x10);
  240. .bootstrap : { *(.bootstrap.literal .bootstrap.text .bootstrap.data) }
  241. . = ALIGN(0x1000);
  242. __initrd_start = .;
  243. .initrd : { *(.initrd) }
  244. __initrd_end = .;
  245. .ResetVector.text XCHAL_RESET_VECTOR_VADDR :
  246. {
  247. *(.ResetVector.text)
  248. }
  249. /* Sections to be discarded */
  250. /DISCARD/ :
  251. {
  252. *(.text.exit)
  253. *(.text.exit.literal)
  254. *(.data.exit)
  255. *(.exitcall.exit)
  256. }
  257. .debug 0 : { *(.debug) }
  258. .line 0 : { *(.line) }
  259. .debug_srcinfo 0 : { *(.debug_srcinfo) }
  260. .debug_sfnames 0 : { *(.debug_sfnames) }
  261. .debug_aranges 0 : { *(.debug_aranges) }
  262. .debug_pubnames 0 : { *(.debug_pubnames) }
  263. .debug_info 0 : { *(.debug_info) }
  264. .debug_abbrev 0 : { *(.debug_abbrev) }
  265. .debug_line 0 : { *(.debug_line) }
  266. .debug_frame 0 : { *(.debug_frame) }
  267. .debug_str 0 : { *(.debug_str) }
  268. .debug_loc 0 : { *(.debug_loc) }
  269. .debug_macinfo 0 : { *(.debug_macinfo) }
  270. .debug_weaknames 0 : { *(.debug_weaknames) }
  271. .debug_funcnames 0 : { *(.debug_funcnames) }
  272. .debug_typenames 0 : { *(.debug_typenames) }
  273. .debug_varnames 0 : { *(.debug_varnames) }
  274. .xt.insn 0 :
  275. {
  276. *(.xt.insn)
  277. *(.gnu.linkonce.x*)
  278. }
  279. .xt.lit 0 :
  280. {
  281. *(.xt.lit)
  282. *(.gnu.linkonce.p*)
  283. }
  284. }