vmlinux.lds.S 4.1 KB

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