vmlinux.lds.S 7.3 KB

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