vmlinux-xip.lds.S 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* ld script to make ARM Linux kernel
  3. * taken from the i386 version by Russell King
  4. * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
  5. */
  6. /* No __ro_after_init data in the .rodata section - which will always be ro */
  7. #define RO_AFTER_INIT_DATA
  8. #include <linux/sizes.h>
  9. #include <asm/vmlinux.lds.h>
  10. #include <asm/cache.h>
  11. #include <asm/thread_info.h>
  12. #include <asm/memory.h>
  13. #include <asm/mpu.h>
  14. #include <asm/page.h>
  15. OUTPUT_ARCH(arm)
  16. ENTRY(stext)
  17. #ifndef __ARMEB__
  18. jiffies = jiffies_64;
  19. #else
  20. jiffies = jiffies_64 + 4;
  21. #endif
  22. SECTIONS
  23. {
  24. /*
  25. * XXX: The linker does not define how output sections are
  26. * assigned to input sections when there are multiple statements
  27. * matching the same input section name. There is no documented
  28. * order of matching.
  29. *
  30. * unwind exit sections must be discarded before the rest of the
  31. * unwind sections get included.
  32. */
  33. /DISCARD/ : {
  34. ARM_DISCARD
  35. *(.alt.smp.init)
  36. *(.pv_table)
  37. #ifndef CONFIG_ARM_UNWIND
  38. *(.ARM.exidx) *(.ARM.exidx.*)
  39. *(.ARM.extab) *(.ARM.extab.*)
  40. #endif
  41. }
  42. . = XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR);
  43. _xiprom = .; /* XIP ROM area to be mapped */
  44. .head.text : {
  45. _text = .;
  46. HEAD_TEXT
  47. }
  48. .text : { /* Real text segment */
  49. _stext = .; /* Text and read-only data */
  50. ARM_TEXT
  51. }
  52. RO_DATA(PAGE_SIZE)
  53. . = ALIGN(4);
  54. __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
  55. __start___ex_table = .;
  56. ARM_MMU_KEEP(*(__ex_table))
  57. __stop___ex_table = .;
  58. }
  59. #ifdef CONFIG_ARM_UNWIND
  60. ARM_UNWIND_SECTIONS
  61. #endif
  62. _etext = .; /* End of text and rodata section */
  63. ARM_VECTORS
  64. INIT_TEXT_SECTION(8)
  65. .exit.text : {
  66. ARM_EXIT_KEEP(EXIT_TEXT)
  67. }
  68. .init.proc.info : {
  69. ARM_CPU_DISCARD(PROC_INFO)
  70. }
  71. .init.arch.info : {
  72. __arch_info_begin = .;
  73. *(.arch.info.init)
  74. __arch_info_end = .;
  75. }
  76. .init.tagtable : {
  77. __tagtable_begin = .;
  78. *(.taglist.init)
  79. __tagtable_end = .;
  80. }
  81. .init.rodata : {
  82. INIT_SETUP(16)
  83. INIT_CALLS
  84. CON_INITCALL
  85. INIT_RAM_FS
  86. }
  87. #ifdef CONFIG_ARM_MPU
  88. . = ALIGN(SZ_128K);
  89. #endif
  90. _exiprom = .; /* End of XIP ROM area */
  91. /*
  92. * From this point, stuff is considered writable and will be copied to RAM
  93. */
  94. __data_loc = ALIGN(4); /* location in file */
  95. . = PAGE_OFFSET + TEXT_OFFSET; /* location in memory */
  96. #undef LOAD_OFFSET
  97. #define LOAD_OFFSET (PAGE_OFFSET + TEXT_OFFSET - __data_loc)
  98. . = ALIGN(THREAD_SIZE);
  99. _sdata = .;
  100. RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
  101. .data.ro_after_init : AT(ADDR(.data.ro_after_init) - LOAD_OFFSET) {
  102. *(.data..ro_after_init)
  103. }
  104. _edata = .;
  105. . = ALIGN(PAGE_SIZE);
  106. __init_begin = .;
  107. .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
  108. INIT_DATA
  109. }
  110. .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
  111. ARM_EXIT_KEEP(EXIT_DATA)
  112. }
  113. #ifdef CONFIG_SMP
  114. PERCPU_SECTION(L1_CACHE_BYTES)
  115. #endif
  116. #ifdef CONFIG_HAVE_TCM
  117. ARM_TCM
  118. #endif
  119. /*
  120. * End of copied data. We need a dummy section to get its LMA.
  121. * Also located before final ALIGN() as trailing padding is not stored
  122. * in the resulting binary file and useless to copy.
  123. */
  124. .data.endmark : AT(ADDR(.data.endmark) - LOAD_OFFSET) { }
  125. _edata_loc = LOADADDR(.data.endmark);
  126. . = ALIGN(PAGE_SIZE);
  127. __init_end = .;
  128. BSS_SECTION(0, 0, 8)
  129. #ifdef CONFIG_ARM_MPU
  130. . = ALIGN(PMSAv8_MINALIGN);
  131. #endif
  132. _end = .;
  133. STABS_DEBUG
  134. DWARF_DEBUG
  135. ARM_DETAILS
  136. ARM_ASSERTS
  137. }
  138. /*
  139. * These must never be empty
  140. * If you have to comment these two assert statements out, your
  141. * binutils is too old (for other reasons as well)
  142. */
  143. ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")
  144. ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")
  145. #ifdef CONFIG_XIP_DEFLATED_DATA
  146. /*
  147. * The .bss is used as a stack area for __inflate_kernel_data() whose stack
  148. * frame is 9568 bytes. Make sure it has extra room left.
  149. */
  150. ASSERT((_end - __bss_start) >= 12288, ".bss too small for CONFIG_XIP_DEFLATED_DATA")
  151. #endif
  152. #if defined(CONFIG_ARM_MPU) && !defined(CONFIG_COMPILE_TEST)
  153. /*
  154. * Due to PMSAv7 restriction on base address and size we have to
  155. * enforce minimal alignment restrictions. It was seen that weaker
  156. * alignment restriction on _xiprom will likely force XIP address
  157. * space spawns multiple MPU regions thus it is likely we run in
  158. * situation when we are reprogramming MPU region we run on with
  159. * something which doesn't cover reprogramming code itself, so as soon
  160. * as we update MPU settings we'd immediately try to execute straight
  161. * from background region which is XN.
  162. * It seem that alignment in 1M should suit most users.
  163. * _exiprom is aligned as 1/8 of 1M so can be covered by subregion
  164. * disable
  165. */
  166. ASSERT(!(_xiprom & (SZ_1M - 1)), "XIP start address may cause MPU programming issues")
  167. ASSERT(!(_exiprom & (SZ_128K - 1)), "XIP end address may cause MPU programming issues")
  168. #endif