vmlinux.lds.S 5.3 KB

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