vmlinux.lds.S 6.3 KB

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