vmlinux-xip.lds.S 6.6 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(PAGE_SIZE); \
  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_MMU
  66. *(.text.fixup)
  67. *(__ex_table)
  68. #endif
  69. #ifndef CONFIG_SMP_ON_UP
  70. *(.alt.smp.init)
  71. #endif
  72. *(.discard)
  73. *(.discard.*)
  74. }
  75. . = XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR);
  76. _xiprom = .; /* XIP ROM area to be mapped */
  77. .head.text : {
  78. _text = .;
  79. HEAD_TEXT
  80. }
  81. .text : { /* Real text segment */
  82. _stext = .; /* Text and read-only data */
  83. IDMAP_TEXT
  84. __exception_text_start = .;
  85. *(.exception.text)
  86. __exception_text_end = .;
  87. IRQENTRY_TEXT
  88. TEXT_TEXT
  89. SCHED_TEXT
  90. CPUIDLE_TEXT
  91. LOCK_TEXT
  92. KPROBES_TEXT
  93. *(.gnu.warning)
  94. *(.glue_7)
  95. *(.glue_7t)
  96. . = ALIGN(4);
  97. *(.got) /* Global offset table */
  98. ARM_CPU_KEEP(PROC_INFO)
  99. }
  100. RO_DATA(PAGE_SIZE)
  101. . = ALIGN(4);
  102. __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
  103. __start___ex_table = .;
  104. #ifdef CONFIG_MMU
  105. *(__ex_table)
  106. #endif
  107. __stop___ex_table = .;
  108. }
  109. #ifdef CONFIG_ARM_UNWIND
  110. /*
  111. * Stack unwinding tables
  112. */
  113. . = ALIGN(8);
  114. .ARM.unwind_idx : {
  115. __start_unwind_idx = .;
  116. *(.ARM.exidx*)
  117. __stop_unwind_idx = .;
  118. }
  119. .ARM.unwind_tab : {
  120. __start_unwind_tab = .;
  121. *(.ARM.extab*)
  122. __stop_unwind_tab = .;
  123. }
  124. #endif
  125. NOTES
  126. _etext = .; /* End of text and rodata section */
  127. /*
  128. * The vectors and stubs are relocatable code, and the
  129. * only thing that matters is their relative offsets
  130. */
  131. __vectors_start = .;
  132. .vectors 0xffff0000 : AT(__vectors_start) {
  133. *(.vectors)
  134. }
  135. . = __vectors_start + SIZEOF(.vectors);
  136. __vectors_end = .;
  137. __stubs_start = .;
  138. .stubs ADDR(.vectors) + 0x1000 : AT(__stubs_start) {
  139. *(.stubs)
  140. }
  141. . = __stubs_start + SIZEOF(.stubs);
  142. __stubs_end = .;
  143. PROVIDE(vector_fiq_offset = vector_fiq - ADDR(.vectors));
  144. INIT_TEXT_SECTION(8)
  145. .exit.text : {
  146. ARM_EXIT_KEEP(EXIT_TEXT)
  147. }
  148. .init.proc.info : {
  149. ARM_CPU_DISCARD(PROC_INFO)
  150. }
  151. .init.arch.info : {
  152. __arch_info_begin = .;
  153. *(.arch.info.init)
  154. __arch_info_end = .;
  155. }
  156. .init.tagtable : {
  157. __tagtable_begin = .;
  158. *(.taglist.init)
  159. __tagtable_end = .;
  160. }
  161. #ifdef CONFIG_SMP_ON_UP
  162. .init.smpalt : {
  163. __smpalt_begin = .;
  164. *(.alt.smp.init)
  165. __smpalt_end = .;
  166. }
  167. #endif
  168. .init.pv_table : {
  169. __pv_table_begin = .;
  170. *(.pv_table)
  171. __pv_table_end = .;
  172. }
  173. .init.data : {
  174. INIT_SETUP(16)
  175. INIT_CALLS
  176. CON_INITCALL
  177. SECURITY_INITCALL
  178. INIT_RAM_FS
  179. }
  180. #ifdef CONFIG_SMP
  181. PERCPU_SECTION(L1_CACHE_BYTES)
  182. #endif
  183. _exiprom = .; /* End of XIP ROM area */
  184. __data_loc = ALIGN(4); /* location in binary */
  185. . = PAGE_OFFSET + TEXT_OFFSET;
  186. .data : AT(__data_loc) {
  187. _data = .; /* address in memory */
  188. _sdata = .;
  189. /*
  190. * first, the init task union, aligned
  191. * to an 8192 byte boundary.
  192. */
  193. INIT_TASK_DATA(THREAD_SIZE)
  194. . = ALIGN(PAGE_SIZE);
  195. __init_begin = .;
  196. INIT_DATA
  197. ARM_EXIT_KEEP(EXIT_DATA)
  198. . = ALIGN(PAGE_SIZE);
  199. __init_end = .;
  200. NOSAVE_DATA
  201. CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES)
  202. READ_MOSTLY_DATA(L1_CACHE_BYTES)
  203. /*
  204. * and the usual data section
  205. */
  206. DATA_DATA
  207. CONSTRUCTORS
  208. _edata = .;
  209. }
  210. _edata_loc = __data_loc + SIZEOF(.data);
  211. #ifdef CONFIG_HAVE_TCM
  212. /*
  213. * We align everything to a page boundary so we can
  214. * free it after init has commenced and TCM contents have
  215. * been copied to its destination.
  216. */
  217. .tcm_start : {
  218. . = ALIGN(PAGE_SIZE);
  219. __tcm_start = .;
  220. __itcm_start = .;
  221. }
  222. /*
  223. * Link these to the ITCM RAM
  224. * Put VMA to the TCM address and LMA to the common RAM
  225. * and we'll upload the contents from RAM to TCM and free
  226. * the used RAM after that.
  227. */
  228. .text_itcm ITCM_OFFSET : AT(__itcm_start)
  229. {
  230. __sitcm_text = .;
  231. *(.tcm.text)
  232. *(.tcm.rodata)
  233. . = ALIGN(4);
  234. __eitcm_text = .;
  235. }
  236. /*
  237. * Reset the dot pointer, this is needed to create the
  238. * relative __dtcm_start below (to be used as extern in code).
  239. */
  240. . = ADDR(.tcm_start) + SIZEOF(.tcm_start) + SIZEOF(.text_itcm);
  241. .dtcm_start : {
  242. __dtcm_start = .;
  243. }
  244. /* TODO: add remainder of ITCM as well, that can be used for data! */
  245. .data_dtcm DTCM_OFFSET : AT(__dtcm_start)
  246. {
  247. . = ALIGN(4);
  248. __sdtcm_data = .;
  249. *(.tcm.data)
  250. . = ALIGN(4);
  251. __edtcm_data = .;
  252. }
  253. /* Reset the dot pointer or the linker gets confused */
  254. . = ADDR(.dtcm_start) + SIZEOF(.data_dtcm);
  255. /* End marker for freeing TCM copy in linked object */
  256. .tcm_end : AT(ADDR(.dtcm_start) + SIZEOF(.data_dtcm)){
  257. . = ALIGN(PAGE_SIZE);
  258. __tcm_end = .;
  259. }
  260. #endif
  261. BSS_SECTION(0, 0, 0)
  262. _end = .;
  263. STABS_DEBUG
  264. }
  265. /*
  266. * These must never be empty
  267. * If you have to comment these two assert statements out, your
  268. * binutils is too old (for other reasons as well)
  269. */
  270. ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")
  271. ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")
  272. /*
  273. * The HYP init code can't be more than a page long,
  274. * and should not cross a page boundary.
  275. * The above comment applies as well.
  276. */
  277. ASSERT(__hyp_idmap_text_end - (__hyp_idmap_text_start & PAGE_MASK) <= PAGE_SIZE,
  278. "HYP init code too big or misaligned")