vmlinux.lds.S 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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. LOCK_TEXT
  102. HYPERVISOR_TEXT
  103. KPROBES_TEXT
  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_ALIGN_RODATA
  112. . = ALIGN(1<<SECTION_SHIFT);
  113. #endif
  114. _etext = .; /* End of text section */
  115. RO_DATA(PAGE_SIZE)
  116. . = ALIGN(4);
  117. __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
  118. __start___ex_table = .;
  119. #ifdef CONFIG_MMU
  120. *(__ex_table)
  121. #endif
  122. __stop___ex_table = .;
  123. }
  124. #ifdef CONFIG_ARM_UNWIND
  125. /*
  126. * Stack unwinding tables
  127. */
  128. . = ALIGN(8);
  129. .ARM.unwind_idx : {
  130. __start_unwind_idx = .;
  131. *(.ARM.exidx*)
  132. __stop_unwind_idx = .;
  133. }
  134. .ARM.unwind_tab : {
  135. __start_unwind_tab = .;
  136. *(.ARM.extab*)
  137. __stop_unwind_tab = .;
  138. }
  139. #endif
  140. NOTES
  141. #ifdef CONFIG_DEBUG_RODATA
  142. . = ALIGN(1<<SECTION_SHIFT);
  143. #else
  144. . = ALIGN(PAGE_SIZE);
  145. #endif
  146. __init_begin = .;
  147. /*
  148. * The vectors and stubs are relocatable code, and the
  149. * only thing that matters is their relative offsets
  150. */
  151. __vectors_start = .;
  152. .vectors 0xffff0000 : AT(__vectors_start) {
  153. *(.vectors)
  154. }
  155. . = __vectors_start + SIZEOF(.vectors);
  156. __vectors_end = .;
  157. __stubs_start = .;
  158. .stubs ADDR(.vectors) + 0x1000 : AT(__stubs_start) {
  159. *(.stubs)
  160. }
  161. . = __stubs_start + SIZEOF(.stubs);
  162. __stubs_end = .;
  163. PROVIDE(vector_fiq_offset = vector_fiq - ADDR(.vectors));
  164. INIT_TEXT_SECTION(8)
  165. .exit.text : {
  166. ARM_EXIT_KEEP(EXIT_TEXT)
  167. }
  168. .init.proc.info : {
  169. ARM_CPU_DISCARD(PROC_INFO)
  170. }
  171. .init.arch.info : {
  172. __arch_info_begin = .;
  173. *(.arch.info.init)
  174. __arch_info_end = .;
  175. }
  176. .init.tagtable : {
  177. __tagtable_begin = .;
  178. *(.taglist.init)
  179. __tagtable_end = .;
  180. }
  181. #ifdef CONFIG_SMP_ON_UP
  182. .init.smpalt : {
  183. __smpalt_begin = .;
  184. *(.alt.smp.init)
  185. __smpalt_end = .;
  186. }
  187. #endif
  188. .init.pv_table : {
  189. __pv_table_begin = .;
  190. *(.pv_table)
  191. __pv_table_end = .;
  192. }
  193. .init.data : {
  194. INIT_DATA
  195. INIT_SETUP(16)
  196. INIT_CALLS
  197. CON_INITCALL
  198. SECURITY_INITCALL
  199. INIT_RAM_FS
  200. }
  201. .exit.data : {
  202. ARM_EXIT_KEEP(EXIT_DATA)
  203. }
  204. #ifdef CONFIG_SMP
  205. PERCPU_SECTION(L1_CACHE_BYTES)
  206. #endif
  207. #ifdef CONFIG_DEBUG_RODATA
  208. . = ALIGN(1<<SECTION_SHIFT);
  209. #else
  210. . = ALIGN(THREAD_SIZE);
  211. #endif
  212. __init_end = .;
  213. __data_loc = .;
  214. .data : AT(__data_loc) {
  215. _data = .; /* address in memory */
  216. _sdata = .;
  217. /*
  218. * first, the init task union, aligned
  219. * to an 8192 byte boundary.
  220. */
  221. INIT_TASK_DATA(THREAD_SIZE)
  222. NOSAVE_DATA
  223. CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES)
  224. READ_MOSTLY_DATA(L1_CACHE_BYTES)
  225. /*
  226. * and the usual data section
  227. */
  228. DATA_DATA
  229. CONSTRUCTORS
  230. _edata = .;
  231. }
  232. _edata_loc = __data_loc + SIZEOF(.data);
  233. #ifdef CONFIG_HAVE_TCM
  234. /*
  235. * We align everything to a page boundary so we can
  236. * free it after init has commenced and TCM contents have
  237. * been copied to its destination.
  238. */
  239. .tcm_start : {
  240. . = ALIGN(PAGE_SIZE);
  241. __tcm_start = .;
  242. __itcm_start = .;
  243. }
  244. /*
  245. * Link these to the ITCM RAM
  246. * Put VMA to the TCM address and LMA to the common RAM
  247. * and we'll upload the contents from RAM to TCM and free
  248. * the used RAM after that.
  249. */
  250. .text_itcm ITCM_OFFSET : AT(__itcm_start)
  251. {
  252. __sitcm_text = .;
  253. *(.tcm.text)
  254. *(.tcm.rodata)
  255. . = ALIGN(4);
  256. __eitcm_text = .;
  257. }
  258. /*
  259. * Reset the dot pointer, this is needed to create the
  260. * relative __dtcm_start below (to be used as extern in code).
  261. */
  262. . = ADDR(.tcm_start) + SIZEOF(.tcm_start) + SIZEOF(.text_itcm);
  263. .dtcm_start : {
  264. __dtcm_start = .;
  265. }
  266. /* TODO: add remainder of ITCM as well, that can be used for data! */
  267. .data_dtcm DTCM_OFFSET : AT(__dtcm_start)
  268. {
  269. . = ALIGN(4);
  270. __sdtcm_data = .;
  271. *(.tcm.data)
  272. . = ALIGN(4);
  273. __edtcm_data = .;
  274. }
  275. /* Reset the dot pointer or the linker gets confused */
  276. . = ADDR(.dtcm_start) + SIZEOF(.data_dtcm);
  277. /* End marker for freeing TCM copy in linked object */
  278. .tcm_end : AT(ADDR(.dtcm_start) + SIZEOF(.data_dtcm)){
  279. . = ALIGN(PAGE_SIZE);
  280. __tcm_end = .;
  281. }
  282. #endif
  283. BSS_SECTION(0, 0, 0)
  284. _end = .;
  285. STABS_DEBUG
  286. }
  287. #ifdef CONFIG_DEBUG_RODATA
  288. /*
  289. * Without CONFIG_DEBUG_ALIGN_RODATA, __start_rodata_section_aligned will
  290. * be the first section-aligned location after __start_rodata. Otherwise,
  291. * it will be equal to __start_rodata.
  292. */
  293. __start_rodata_section_aligned = ALIGN(__start_rodata, 1 << SECTION_SHIFT);
  294. #endif
  295. /*
  296. * These must never be empty
  297. * If you have to comment these two assert statements out, your
  298. * binutils is too old (for other reasons as well)
  299. */
  300. ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")
  301. ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")
  302. /*
  303. * The HYP init code can't be more than a page long,
  304. * and should not cross a page boundary.
  305. * The above comment applies as well.
  306. */
  307. ASSERT(__hyp_idmap_text_end - (__hyp_idmap_text_start & PAGE_MASK) <= PAGE_SIZE,
  308. "HYP init code too big or misaligned")
  309. #endif /* CONFIG_XIP_KERNEL */