vmlinux.lds.S 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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. /*
  42. * The size of the PE/COFF section that covers the kernel image, which
  43. * runs from stext to _edata, must be a round multiple of the PE/COFF
  44. * FileAlignment, which we set to its minimum value of 0x200. 'stext'
  45. * itself is 4 KB aligned, so padding out _edata to a 0x200 aligned
  46. * boundary should be sufficient.
  47. */
  48. PECOFF_FILE_ALIGNMENT = 0x200;
  49. #ifdef CONFIG_EFI
  50. #define PECOFF_EDATA_PADDING \
  51. .pecoff_edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGNMENT); }
  52. #else
  53. #define PECOFF_EDATA_PADDING
  54. #endif
  55. #if defined(CONFIG_DEBUG_ALIGN_RODATA)
  56. #define ALIGN_DEBUG_RO . = ALIGN(1<<SECTION_SHIFT);
  57. #define ALIGN_DEBUG_RO_MIN(min) ALIGN_DEBUG_RO
  58. #elif defined(CONFIG_DEBUG_RODATA)
  59. #define ALIGN_DEBUG_RO . = ALIGN(1<<PAGE_SHIFT);
  60. #define ALIGN_DEBUG_RO_MIN(min) ALIGN_DEBUG_RO
  61. #else
  62. #define ALIGN_DEBUG_RO
  63. #define ALIGN_DEBUG_RO_MIN(min) . = ALIGN(min);
  64. #endif
  65. SECTIONS
  66. {
  67. /*
  68. * XXX: The linker does not define how output sections are
  69. * assigned to input sections when there are multiple statements
  70. * matching the same input section name. There is no documented
  71. * order of matching.
  72. */
  73. /DISCARD/ : {
  74. ARM_EXIT_DISCARD(EXIT_TEXT)
  75. ARM_EXIT_DISCARD(EXIT_DATA)
  76. EXIT_CALL
  77. *(.discard)
  78. *(.discard.*)
  79. }
  80. . = PAGE_OFFSET + TEXT_OFFSET;
  81. .head.text : {
  82. _text = .;
  83. HEAD_TEXT
  84. }
  85. ALIGN_DEBUG_RO
  86. .text : { /* Real text segment */
  87. _stext = .; /* Text and read-only data */
  88. __exception_text_start = .;
  89. *(.exception.text)
  90. __exception_text_end = .;
  91. IRQENTRY_TEXT
  92. TEXT_TEXT
  93. SCHED_TEXT
  94. LOCK_TEXT
  95. HYPERVISOR_TEXT
  96. IDMAP_TEXT
  97. *(.fixup)
  98. *(.gnu.warning)
  99. . = ALIGN(16);
  100. *(.got) /* Global offset table */
  101. }
  102. ALIGN_DEBUG_RO
  103. RO_DATA(PAGE_SIZE)
  104. EXCEPTION_TABLE(8)
  105. NOTES
  106. ALIGN_DEBUG_RO
  107. _etext = .; /* End of text and rodata section */
  108. ALIGN_DEBUG_RO_MIN(PAGE_SIZE)
  109. __init_begin = .;
  110. INIT_TEXT_SECTION(8)
  111. .exit.text : {
  112. ARM_EXIT_KEEP(EXIT_TEXT)
  113. }
  114. ALIGN_DEBUG_RO_MIN(16)
  115. .init.data : {
  116. INIT_DATA
  117. INIT_SETUP(16)
  118. INIT_CALLS
  119. CON_INITCALL
  120. SECURITY_INITCALL
  121. INIT_RAM_FS
  122. }
  123. .exit.data : {
  124. ARM_EXIT_KEEP(EXIT_DATA)
  125. }
  126. PERCPU_SECTION(L1_CACHE_BYTES)
  127. . = ALIGN(PAGE_SIZE);
  128. __init_end = .;
  129. . = ALIGN(4);
  130. .altinstructions : {
  131. __alt_instructions = .;
  132. *(.altinstructions)
  133. __alt_instructions_end = .;
  134. }
  135. .altinstr_replacement : {
  136. *(.altinstr_replacement)
  137. }
  138. . = ALIGN(PAGE_SIZE);
  139. _data = .;
  140. _sdata = .;
  141. RW_DATA_SECTION(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
  142. PECOFF_EDATA_PADDING
  143. _edata = .;
  144. BSS_SECTION(0, 0, 0)
  145. . = ALIGN(PAGE_SIZE);
  146. idmap_pg_dir = .;
  147. . += IDMAP_DIR_SIZE;
  148. swapper_pg_dir = .;
  149. . += SWAPPER_DIR_SIZE;
  150. _end = .;
  151. STABS_DEBUG
  152. HEAD_SYMBOLS
  153. }
  154. /*
  155. * The HYP init code and ID map text can't be longer than a page each,
  156. * and should not cross a page boundary.
  157. */
  158. ASSERT(__hyp_idmap_text_end - (__hyp_idmap_text_start & ~(SZ_4K - 1)) <= SZ_4K,
  159. "HYP init code too big or misaligned")
  160. ASSERT(__idmap_text_end - (__idmap_text_start & ~(SZ_4K - 1)) <= SZ_4K,
  161. "ID map text too big or misaligned")
  162. /*
  163. * If padding is applied before .head.text, virt<->phys conversions will fail.
  164. */
  165. ASSERT(_text == (PAGE_OFFSET + TEXT_OFFSET), "HEAD is misaligned")