vmlinux.lds.S 5.8 KB

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