vmlinux.lds.S 5.9 KB

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