vmlinux.lds.S 6.1 KB

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