vmlinux.lds.S 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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 <asm/page.h>
  18. #include <asm/thread_info.h>
  19. #include <variant/core.h>
  20. #include <platform/hardware.h>
  21. OUTPUT_ARCH(xtensa)
  22. ENTRY(_start)
  23. #ifdef __XTENSA_EB__
  24. jiffies = jiffies_64 + 4;
  25. #else
  26. jiffies = jiffies_64;
  27. #endif
  28. #ifndef KERNELOFFSET
  29. #define KERNELOFFSET 0xd0001000
  30. #endif
  31. /* Note: In the following macros, it would be nice to specify only the
  32. vector name and section kind and construct "sym" and "section" using
  33. CPP concatenation, but that does not work reliably. Concatenating a
  34. string with "." produces an invalid token. CPP will not print a
  35. warning because it thinks this is an assembly file, but it leaves
  36. them as multiple tokens and there may or may not be whitespace
  37. between them. */
  38. /* Macro for a relocation entry */
  39. #define RELOCATE_ENTRY(sym, section) \
  40. LONG(sym ## _start); \
  41. LONG(sym ## _end); \
  42. LONG(LOADADDR(section))
  43. /* Macro to define a section for a vector.
  44. *
  45. * Use of the MIN function catches the types of errors illustrated in
  46. * the following example:
  47. *
  48. * Assume the section .DoubleExceptionVector.literal is completely
  49. * full. Then a programmer adds code to .DoubleExceptionVector.text
  50. * that produces another literal. The final literal position will
  51. * overlay onto the first word of the adjacent code section
  52. * .DoubleExceptionVector.text. (In practice, the literals will
  53. * overwrite the code, and the first few instructions will be
  54. * garbage.)
  55. */
  56. #define SECTION_VECTOR(sym, section, addr, max_prevsec_size, prevsec) \
  57. section addr : AT((MIN(LOADADDR(prevsec) + max_prevsec_size, \
  58. LOADADDR(prevsec) + SIZEOF(prevsec)) + 3) & ~ 3) \
  59. { \
  60. . = ALIGN(4); \
  61. sym ## _start = ABSOLUTE(.); \
  62. *(section) \
  63. sym ## _end = ABSOLUTE(.); \
  64. }
  65. /*
  66. * Mapping of input sections to output sections when linking.
  67. */
  68. SECTIONS
  69. {
  70. . = KERNELOFFSET;
  71. /* .text section */
  72. _text = .;
  73. _stext = .;
  74. _ftext = .;
  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. _fdata = .;
  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. RELOCATE_ENTRY(_KernelExceptionVector_text,
  114. .KernelExceptionVector.text);
  115. RELOCATE_ENTRY(_UserExceptionVector_text,
  116. .UserExceptionVector.text);
  117. RELOCATE_ENTRY(_DoubleExceptionVector_literal,
  118. .DoubleExceptionVector.literal);
  119. RELOCATE_ENTRY(_DoubleExceptionVector_text,
  120. .DoubleExceptionVector.text);
  121. RELOCATE_ENTRY(_DebugInterruptVector_text,
  122. .DebugInterruptVector.text);
  123. __boot_reloc_table_end = ABSOLUTE(.) ;
  124. INIT_SETUP(XCHAL_ICACHE_LINESIZE)
  125. INIT_CALLS
  126. CON_INITCALL
  127. SECURITY_INITCALL
  128. INIT_RAM_FS
  129. }
  130. PERCPU_SECTION(XCHAL_ICACHE_LINESIZE)
  131. /* We need this dummy segment here */
  132. . = ALIGN(4);
  133. .dummy : { LONG(0) }
  134. /* The vectors are relocated to the real position at startup time */
  135. SECTION_VECTOR (_WindowVectors_text,
  136. .WindowVectors.text,
  137. XCHAL_WINDOW_VECTORS_VADDR, 4,
  138. .dummy)
  139. SECTION_VECTOR (_DebugInterruptVector_literal,
  140. .DebugInterruptVector.literal,
  141. XCHAL_DEBUG_VECTOR_VADDR - 4,
  142. SIZEOF(.WindowVectors.text),
  143. .WindowVectors.text)
  144. SECTION_VECTOR (_DebugInterruptVector_text,
  145. .DebugInterruptVector.text,
  146. XCHAL_DEBUG_VECTOR_VADDR,
  147. 4,
  148. .DebugInterruptVector.literal)
  149. SECTION_VECTOR (_KernelExceptionVector_literal,
  150. .KernelExceptionVector.literal,
  151. XCHAL_KERNEL_VECTOR_VADDR - 4,
  152. SIZEOF(.DebugInterruptVector.text),
  153. .DebugInterruptVector.text)
  154. SECTION_VECTOR (_KernelExceptionVector_text,
  155. .KernelExceptionVector.text,
  156. XCHAL_KERNEL_VECTOR_VADDR,
  157. 4,
  158. .KernelExceptionVector.literal)
  159. SECTION_VECTOR (_UserExceptionVector_literal,
  160. .UserExceptionVector.literal,
  161. XCHAL_USER_VECTOR_VADDR - 4,
  162. SIZEOF(.KernelExceptionVector.text),
  163. .KernelExceptionVector.text)
  164. SECTION_VECTOR (_UserExceptionVector_text,
  165. .UserExceptionVector.text,
  166. XCHAL_USER_VECTOR_VADDR,
  167. 4,
  168. .UserExceptionVector.literal)
  169. SECTION_VECTOR (_DoubleExceptionVector_literal,
  170. .DoubleExceptionVector.literal,
  171. XCHAL_DOUBLEEXC_VECTOR_VADDR - 16,
  172. SIZEOF(.UserExceptionVector.text),
  173. .UserExceptionVector.text)
  174. SECTION_VECTOR (_DoubleExceptionVector_text,
  175. .DoubleExceptionVector.text,
  176. XCHAL_DOUBLEEXC_VECTOR_VADDR,
  177. 32,
  178. .DoubleExceptionVector.literal)
  179. . = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3;
  180. . = ALIGN(PAGE_SIZE);
  181. __init_end = .;
  182. BSS_SECTION(0, 8192, 0)
  183. _end = .;
  184. /* only used by the boot loader */
  185. . = ALIGN(0x10);
  186. .bootstrap : { *(.bootstrap.literal .bootstrap.text .bootstrap.data) }
  187. . = ALIGN(0x1000);
  188. __initrd_start = .;
  189. .initrd : { *(.initrd) }
  190. __initrd_end = .;
  191. .ResetVector.text XCHAL_RESET_VECTOR_VADDR :
  192. {
  193. *(.ResetVector.text)
  194. }
  195. .xt.lit : { *(.xt.lit) }
  196. .xt.prop : { *(.xt.prop) }
  197. .debug 0 : { *(.debug) }
  198. .line 0 : { *(.line) }
  199. .debug_srcinfo 0 : { *(.debug_srcinfo) }
  200. .debug_sfnames 0 : { *(.debug_sfnames) }
  201. .debug_aranges 0 : { *(.debug_aranges) }
  202. .debug_pubnames 0 : { *(.debug_pubnames) }
  203. .debug_info 0 : { *(.debug_info) }
  204. .debug_abbrev 0 : { *(.debug_abbrev) }
  205. .debug_line 0 : { *(.debug_line) }
  206. .debug_frame 0 : { *(.debug_frame) }
  207. .debug_str 0 : { *(.debug_str) }
  208. .debug_loc 0 : { *(.debug_loc) }
  209. .debug_macinfo 0 : { *(.debug_macinfo) }
  210. .debug_weaknames 0 : { *(.debug_weaknames) }
  211. .debug_funcnames 0 : { *(.debug_funcnames) }
  212. .debug_typenames 0 : { *(.debug_typenames) }
  213. .debug_varnames 0 : { *(.debug_varnames) }
  214. .xt.insn 0 :
  215. {
  216. *(.xt.insn)
  217. *(.gnu.linkonce.x*)
  218. }
  219. .xt.lit 0 :
  220. {
  221. *(.xt.lit)
  222. *(.gnu.linkonce.p*)
  223. }
  224. /* Sections to be discarded */
  225. DISCARDS
  226. /DISCARD/ : { *(.exit.literal) }
  227. }