vmlinux-xip.lds.S 6.7 KB

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