vmlinux.lds.S 3.8 KB

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