vmlinux.lds.S 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. /* ld script to make ARM Linux kernel
  2. * taken from the i386 version by Russell King
  3. * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
  4. */
  5. #include <asm-generic/vmlinux.lds.h>
  6. #include <asm/thread_info.h>
  7. #include <asm/memory.h>
  8. #include <asm/page.h>
  9. #define PROC_INFO \
  10. VMLINUX_SYMBOL(__proc_info_begin) = .; \
  11. *(.proc.info.init) \
  12. VMLINUX_SYMBOL(__proc_info_end) = .;
  13. #define IDMAP_TEXT \
  14. ALIGN_FUNCTION(); \
  15. VMLINUX_SYMBOL(__idmap_text_start) = .; \
  16. *(.idmap.text) \
  17. VMLINUX_SYMBOL(__idmap_text_end) = .;
  18. #ifdef CONFIG_HOTPLUG_CPU
  19. #define ARM_CPU_DISCARD(x)
  20. #define ARM_CPU_KEEP(x) x
  21. #else
  22. #define ARM_CPU_DISCARD(x) x
  23. #define ARM_CPU_KEEP(x)
  24. #endif
  25. #if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || \
  26. defined(CONFIG_GENERIC_BUG)
  27. #define ARM_EXIT_KEEP(x) x
  28. #define ARM_EXIT_DISCARD(x)
  29. #else
  30. #define ARM_EXIT_KEEP(x)
  31. #define ARM_EXIT_DISCARD(x) x
  32. #endif
  33. OUTPUT_ARCH(arm)
  34. ENTRY(stext)
  35. #ifndef __ARMEB__
  36. jiffies = jiffies_64;
  37. #else
  38. jiffies = jiffies_64 + 4;
  39. #endif
  40. SECTIONS
  41. {
  42. /*
  43. * XXX: The linker does not define how output sections are
  44. * assigned to input sections when there are multiple statements
  45. * matching the same input section name. There is no documented
  46. * order of matching.
  47. *
  48. * unwind exit sections must be discarded before the rest of the
  49. * unwind sections get included.
  50. */
  51. /DISCARD/ : {
  52. *(.ARM.exidx.exit.text)
  53. *(.ARM.extab.exit.text)
  54. ARM_CPU_DISCARD(*(.ARM.exidx.cpuexit.text))
  55. ARM_CPU_DISCARD(*(.ARM.extab.cpuexit.text))
  56. ARM_EXIT_DISCARD(EXIT_TEXT)
  57. ARM_EXIT_DISCARD(EXIT_DATA)
  58. EXIT_CALL
  59. #ifndef CONFIG_HOTPLUG
  60. *(.ARM.exidx.devexit.text)
  61. *(.ARM.extab.devexit.text)
  62. #endif
  63. #ifndef CONFIG_MMU
  64. *(.fixup)
  65. *(__ex_table)
  66. #endif
  67. #ifndef CONFIG_SMP_ON_UP
  68. *(.alt.smp.init)
  69. #endif
  70. *(.discard)
  71. *(.discard.*)
  72. }
  73. #ifdef CONFIG_XIP_KERNEL
  74. . = XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR);
  75. #else
  76. . = PAGE_OFFSET + TEXT_OFFSET;
  77. #endif
  78. .head.text : {
  79. _text = .;
  80. HEAD_TEXT
  81. }
  82. .text : { /* Real text segment */
  83. _stext = .; /* Text and read-only data */
  84. __exception_text_start = .;
  85. *(.exception.text)
  86. __exception_text_end = .;
  87. IRQENTRY_TEXT
  88. TEXT_TEXT
  89. SCHED_TEXT
  90. LOCK_TEXT
  91. KPROBES_TEXT
  92. IDMAP_TEXT
  93. #ifdef CONFIG_MMU
  94. *(.fixup)
  95. #endif
  96. *(.gnu.warning)
  97. *(.glue_7)
  98. *(.glue_7t)
  99. . = ALIGN(4);
  100. *(.got) /* Global offset table */
  101. ARM_CPU_KEEP(PROC_INFO)
  102. }
  103. RO_DATA(PAGE_SIZE)
  104. #ifdef CONFIG_ARM_UNWIND
  105. /*
  106. * Stack unwinding tables
  107. */
  108. . = ALIGN(8);
  109. .ARM.unwind_idx : {
  110. __start_unwind_idx = .;
  111. *(.ARM.exidx*)
  112. __stop_unwind_idx = .;
  113. }
  114. .ARM.unwind_tab : {
  115. __start_unwind_tab = .;
  116. *(.ARM.extab*)
  117. __stop_unwind_tab = .;
  118. }
  119. #endif
  120. _etext = .; /* End of text and rodata section */
  121. #ifndef CONFIG_XIP_KERNEL
  122. . = ALIGN(PAGE_SIZE);
  123. __init_begin = .;
  124. #endif
  125. INIT_TEXT_SECTION(8)
  126. .exit.text : {
  127. ARM_EXIT_KEEP(EXIT_TEXT)
  128. }
  129. .init.proc.info : {
  130. ARM_CPU_DISCARD(PROC_INFO)
  131. }
  132. .init.arch.info : {
  133. __arch_info_begin = .;
  134. *(.arch.info.init)
  135. __arch_info_end = .;
  136. }
  137. .init.tagtable : {
  138. __tagtable_begin = .;
  139. *(.taglist.init)
  140. __tagtable_end = .;
  141. }
  142. #ifdef CONFIG_SMP_ON_UP
  143. .init.smpalt : {
  144. __smpalt_begin = .;
  145. *(.alt.smp.init)
  146. __smpalt_end = .;
  147. }
  148. #endif
  149. .init.pv_table : {
  150. __pv_table_begin = .;
  151. *(.pv_table)
  152. __pv_table_end = .;
  153. }
  154. .init.data : {
  155. #ifndef CONFIG_XIP_KERNEL
  156. INIT_DATA
  157. #endif
  158. INIT_SETUP(16)
  159. INIT_CALLS
  160. CON_INITCALL
  161. SECURITY_INITCALL
  162. INIT_RAM_FS
  163. }
  164. #ifndef CONFIG_XIP_KERNEL
  165. .exit.data : {
  166. ARM_EXIT_KEEP(EXIT_DATA)
  167. }
  168. #endif
  169. PERCPU_SECTION(32)
  170. #ifdef CONFIG_XIP_KERNEL
  171. __data_loc = ALIGN(4); /* location in binary */
  172. . = PAGE_OFFSET + TEXT_OFFSET;
  173. #else
  174. __init_end = .;
  175. . = ALIGN(THREAD_SIZE);
  176. __data_loc = .;
  177. #endif
  178. .data : AT(__data_loc) {
  179. _data = .; /* address in memory */
  180. _sdata = .;
  181. /*
  182. * first, the init task union, aligned
  183. * to an 8192 byte boundary.
  184. */
  185. INIT_TASK_DATA(THREAD_SIZE)
  186. #ifdef CONFIG_XIP_KERNEL
  187. . = ALIGN(PAGE_SIZE);
  188. __init_begin = .;
  189. INIT_DATA
  190. ARM_EXIT_KEEP(EXIT_DATA)
  191. . = ALIGN(PAGE_SIZE);
  192. __init_end = .;
  193. #endif
  194. NOSAVE_DATA
  195. CACHELINE_ALIGNED_DATA(32)
  196. READ_MOSTLY_DATA(32)
  197. /*
  198. * The exception fixup table (might need resorting at runtime)
  199. */
  200. . = ALIGN(32);
  201. __start___ex_table = .;
  202. #ifdef CONFIG_MMU
  203. *(__ex_table)
  204. #endif
  205. __stop___ex_table = .;
  206. /*
  207. * and the usual data section
  208. */
  209. DATA_DATA
  210. CONSTRUCTORS
  211. _edata = .;
  212. }
  213. _edata_loc = __data_loc + SIZEOF(.data);
  214. #ifdef CONFIG_HAVE_TCM
  215. /*
  216. * We align everything to a page boundary so we can
  217. * free it after init has commenced and TCM contents have
  218. * been copied to its destination.
  219. */
  220. .tcm_start : {
  221. . = ALIGN(PAGE_SIZE);
  222. __tcm_start = .;
  223. __itcm_start = .;
  224. }
  225. /*
  226. * Link these to the ITCM RAM
  227. * Put VMA to the TCM address and LMA to the common RAM
  228. * and we'll upload the contents from RAM to TCM and free
  229. * the used RAM after that.
  230. */
  231. .text_itcm ITCM_OFFSET : AT(__itcm_start)
  232. {
  233. __sitcm_text = .;
  234. *(.tcm.text)
  235. *(.tcm.rodata)
  236. . = ALIGN(4);
  237. __eitcm_text = .;
  238. }
  239. /*
  240. * Reset the dot pointer, this is needed to create the
  241. * relative __dtcm_start below (to be used as extern in code).
  242. */
  243. . = ADDR(.tcm_start) + SIZEOF(.tcm_start) + SIZEOF(.text_itcm);
  244. .dtcm_start : {
  245. __dtcm_start = .;
  246. }
  247. /* TODO: add remainder of ITCM as well, that can be used for data! */
  248. .data_dtcm DTCM_OFFSET : AT(__dtcm_start)
  249. {
  250. . = ALIGN(4);
  251. __sdtcm_data = .;
  252. *(.tcm.data)
  253. . = ALIGN(4);
  254. __edtcm_data = .;
  255. }
  256. /* Reset the dot pointer or the linker gets confused */
  257. . = ADDR(.dtcm_start) + SIZEOF(.data_dtcm);
  258. /* End marker for freeing TCM copy in linked object */
  259. .tcm_end : AT(ADDR(.dtcm_start) + SIZEOF(.data_dtcm)){
  260. . = ALIGN(PAGE_SIZE);
  261. __tcm_end = .;
  262. }
  263. #endif
  264. NOTES
  265. BSS_SECTION(0, 0, 0)
  266. _end = .;
  267. STABS_DEBUG
  268. .comment 0 : { *(.comment) }
  269. }
  270. /*
  271. * These must never be empty
  272. * If you have to comment these two assert statements out, your
  273. * binutils is too old (for other reasons as well)
  274. */
  275. ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")
  276. ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")