vmlinux.lds.S 7.1 KB

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