vmlinux.lds.S 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. /*
  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. #include <asm-generic/vmlinux.lds.h>
  7. #include <asm/cache.h>
  8. #include <asm/kernel-pgtable.h>
  9. #include <asm/thread_info.h>
  10. #include <asm/memory.h>
  11. #include <asm/page.h>
  12. #include <asm/pgtable.h>
  13. #include "image.h"
  14. /* .exit.text needed in case of alternative patching */
  15. #define ARM_EXIT_KEEP(x) x
  16. #define ARM_EXIT_DISCARD(x)
  17. OUTPUT_ARCH(aarch64)
  18. ENTRY(_text)
  19. jiffies = jiffies_64;
  20. #define HYPERVISOR_TEXT \
  21. /* \
  22. * Align to 4 KB so that \
  23. * a) the HYP vector table is at its minimum \
  24. * alignment of 2048 bytes \
  25. * b) the HYP init code will not cross a page \
  26. * boundary if its size does not exceed \
  27. * 4 KB (see related ASSERT() below) \
  28. */ \
  29. . = ALIGN(SZ_4K); \
  30. VMLINUX_SYMBOL(__hyp_idmap_text_start) = .; \
  31. *(.hyp.idmap.text) \
  32. VMLINUX_SYMBOL(__hyp_idmap_text_end) = .; \
  33. VMLINUX_SYMBOL(__hyp_text_start) = .; \
  34. *(.hyp.text) \
  35. VMLINUX_SYMBOL(__hyp_text_end) = .;
  36. #define IDMAP_TEXT \
  37. . = ALIGN(SZ_4K); \
  38. VMLINUX_SYMBOL(__idmap_text_start) = .; \
  39. *(.idmap.text) \
  40. VMLINUX_SYMBOL(__idmap_text_end) = .;
  41. #ifdef CONFIG_HIBERNATION
  42. #define HIBERNATE_TEXT \
  43. . = ALIGN(SZ_4K); \
  44. VMLINUX_SYMBOL(__hibernate_exit_text_start) = .;\
  45. *(.hibernate_exit.text) \
  46. VMLINUX_SYMBOL(__hibernate_exit_text_end) = .;
  47. #else
  48. #define HIBERNATE_TEXT
  49. #endif
  50. /*
  51. * The size of the PE/COFF section that covers the kernel image, which
  52. * runs from stext to _edata, must be a round multiple of the PE/COFF
  53. * FileAlignment, which we set to its minimum value of 0x200. 'stext'
  54. * itself is 4 KB aligned, so padding out _edata to a 0x200 aligned
  55. * boundary should be sufficient.
  56. */
  57. PECOFF_FILE_ALIGNMENT = 0x200;
  58. #ifdef CONFIG_EFI
  59. #define PECOFF_EDATA_PADDING \
  60. .pecoff_edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGNMENT); }
  61. #else
  62. #define PECOFF_EDATA_PADDING
  63. #endif
  64. #if defined(CONFIG_DEBUG_ALIGN_RODATA)
  65. /*
  66. * 4 KB granule: 1 level 2 entry
  67. * 16 KB granule: 128 level 3 entries, with contiguous bit
  68. * 64 KB granule: 32 level 3 entries, with contiguous bit
  69. */
  70. #define SEGMENT_ALIGN SZ_2M
  71. #else
  72. /*
  73. * 4 KB granule: 16 level 3 entries, with contiguous bit
  74. * 16 KB granule: 4 level 3 entries, without contiguous bit
  75. * 64 KB granule: 1 level 3 entry
  76. */
  77. #define SEGMENT_ALIGN SZ_64K
  78. #endif
  79. SECTIONS
  80. {
  81. /*
  82. * XXX: The linker does not define how output sections are
  83. * assigned to input sections when there are multiple statements
  84. * matching the same input section name. There is no documented
  85. * order of matching.
  86. */
  87. /DISCARD/ : {
  88. ARM_EXIT_DISCARD(EXIT_TEXT)
  89. ARM_EXIT_DISCARD(EXIT_DATA)
  90. EXIT_CALL
  91. *(.discard)
  92. *(.discard.*)
  93. *(.interp .dynamic)
  94. *(.dynsym .dynstr .hash)
  95. }
  96. . = KIMAGE_VADDR + TEXT_OFFSET;
  97. .head.text : {
  98. _text = .;
  99. HEAD_TEXT
  100. }
  101. .text : { /* Real text segment */
  102. _stext = .; /* Text and read-only data */
  103. __exception_text_start = .;
  104. *(.exception.text)
  105. __exception_text_end = .;
  106. IRQENTRY_TEXT
  107. SOFTIRQENTRY_TEXT
  108. ENTRY_TEXT
  109. TEXT_TEXT
  110. SCHED_TEXT
  111. LOCK_TEXT
  112. KPROBES_TEXT
  113. HYPERVISOR_TEXT
  114. IDMAP_TEXT
  115. HIBERNATE_TEXT
  116. *(.fixup)
  117. *(.gnu.warning)
  118. . = ALIGN(16);
  119. *(.got) /* Global offset table */
  120. }
  121. . = ALIGN(SEGMENT_ALIGN);
  122. _etext = .; /* End of text section */
  123. RO_DATA(PAGE_SIZE) /* everything from this point to */
  124. EXCEPTION_TABLE(8) /* __init_begin will be marked RO NX */
  125. NOTES
  126. . = ALIGN(SEGMENT_ALIGN);
  127. __init_begin = .;
  128. INIT_TEXT_SECTION(8)
  129. .exit.text : {
  130. ARM_EXIT_KEEP(EXIT_TEXT)
  131. }
  132. .init.data : {
  133. INIT_DATA
  134. INIT_SETUP(16)
  135. INIT_CALLS
  136. CON_INITCALL
  137. SECURITY_INITCALL
  138. INIT_RAM_FS
  139. *(.init.rodata.* .init.bss) /* from the EFI stub */
  140. }
  141. .exit.data : {
  142. ARM_EXIT_KEEP(EXIT_DATA)
  143. }
  144. PERCPU_SECTION(L1_CACHE_BYTES)
  145. . = ALIGN(4);
  146. .altinstructions : {
  147. __alt_instructions = .;
  148. *(.altinstructions)
  149. __alt_instructions_end = .;
  150. }
  151. .altinstr_replacement : {
  152. *(.altinstr_replacement)
  153. }
  154. .rela : ALIGN(8) {
  155. *(.rela .rela*)
  156. }
  157. __rela_offset = ABSOLUTE(ADDR(.rela) - KIMAGE_VADDR);
  158. __rela_size = SIZEOF(.rela);
  159. . = ALIGN(SEGMENT_ALIGN);
  160. __init_end = .;
  161. _data = .;
  162. _sdata = .;
  163. RW_DATA_SECTION(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
  164. PECOFF_EDATA_PADDING
  165. _edata = .;
  166. BSS_SECTION(0, 0, 0)
  167. . = ALIGN(PAGE_SIZE);
  168. idmap_pg_dir = .;
  169. . += IDMAP_DIR_SIZE;
  170. swapper_pg_dir = .;
  171. . += SWAPPER_DIR_SIZE;
  172. _end = .;
  173. STABS_DEBUG
  174. HEAD_SYMBOLS
  175. }
  176. /*
  177. * The HYP init code and ID map text can't be longer than a page each,
  178. * and should not cross a page boundary.
  179. */
  180. ASSERT(__hyp_idmap_text_end - (__hyp_idmap_text_start & ~(SZ_4K - 1)) <= SZ_4K,
  181. "HYP init code too big or misaligned")
  182. ASSERT(__idmap_text_end - (__idmap_text_start & ~(SZ_4K - 1)) <= SZ_4K,
  183. "ID map text too big or misaligned")
  184. #ifdef CONFIG_HIBERNATION
  185. ASSERT(__hibernate_exit_text_end - (__hibernate_exit_text_start & ~(SZ_4K - 1))
  186. <= SZ_4K, "Hibernate exit text too big or misaligned")
  187. #endif
  188. /*
  189. * If padding is applied before .head.text, virt<->phys conversions will fail.
  190. */
  191. ASSERT(_text == (KIMAGE_VADDR + TEXT_OFFSET), "HEAD is misaligned")