vmlinux.lds.S 6.1 KB

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