vmlinux.lds.S 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. #ifdef CONFIG_XIP_KERNEL
  7. #include "vmlinux-xip.lds.S"
  8. #else
  9. #include <asm-generic/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. #include <asm/pgtable.h>
  16. #include "vmlinux.lds.h"
  17. OUTPUT_ARCH(arm)
  18. ENTRY(stext)
  19. #ifndef __ARMEB__
  20. jiffies = jiffies_64;
  21. #else
  22. jiffies = jiffies_64 + 4;
  23. #endif
  24. SECTIONS
  25. {
  26. /*
  27. * XXX: The linker does not define how output sections are
  28. * assigned to input sections when there are multiple statements
  29. * matching the same input section name. There is no documented
  30. * order of matching.
  31. *
  32. * unwind exit sections must be discarded before the rest of the
  33. * unwind sections get included.
  34. */
  35. /DISCARD/ : {
  36. ARM_DISCARD
  37. #ifndef CONFIG_SMP_ON_UP
  38. *(.alt.smp.init)
  39. #endif
  40. }
  41. . = PAGE_OFFSET + TEXT_OFFSET;
  42. .head.text : {
  43. _text = .;
  44. HEAD_TEXT
  45. }
  46. #ifdef CONFIG_STRICT_KERNEL_RWX
  47. . = ALIGN(1<<SECTION_SHIFT);
  48. #endif
  49. #ifdef CONFIG_ARM_MPU
  50. . = ALIGN(PMSAv8_MINALIGN);
  51. #endif
  52. .text : { /* Real text segment */
  53. _stext = .; /* Text and read-only data */
  54. ARM_TEXT
  55. }
  56. #ifdef CONFIG_DEBUG_ALIGN_RODATA
  57. . = ALIGN(1<<SECTION_SHIFT);
  58. #endif
  59. _etext = .; /* End of text section */
  60. RO_DATA(PAGE_SIZE)
  61. . = ALIGN(4);
  62. __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
  63. __start___ex_table = .;
  64. ARM_MMU_KEEP(*(__ex_table))
  65. __stop___ex_table = .;
  66. }
  67. #ifdef CONFIG_ARM_UNWIND
  68. ARM_UNWIND_SECTIONS
  69. #endif
  70. NOTES
  71. #ifdef CONFIG_STRICT_KERNEL_RWX
  72. . = ALIGN(1<<SECTION_SHIFT);
  73. #else
  74. . = ALIGN(PAGE_SIZE);
  75. #endif
  76. __init_begin = .;
  77. ARM_VECTORS
  78. INIT_TEXT_SECTION(8)
  79. .exit.text : {
  80. ARM_EXIT_KEEP(EXIT_TEXT)
  81. }
  82. .init.proc.info : {
  83. ARM_CPU_DISCARD(PROC_INFO)
  84. }
  85. .init.arch.info : {
  86. __arch_info_begin = .;
  87. *(.arch.info.init)
  88. __arch_info_end = .;
  89. }
  90. .init.tagtable : {
  91. __tagtable_begin = .;
  92. *(.taglist.init)
  93. __tagtable_end = .;
  94. }
  95. #ifdef CONFIG_SMP_ON_UP
  96. .init.smpalt : {
  97. __smpalt_begin = .;
  98. *(.alt.smp.init)
  99. __smpalt_end = .;
  100. }
  101. #endif
  102. .init.pv_table : {
  103. __pv_table_begin = .;
  104. *(.pv_table)
  105. __pv_table_end = .;
  106. }
  107. INIT_DATA_SECTION(16)
  108. .exit.data : {
  109. ARM_EXIT_KEEP(EXIT_DATA)
  110. }
  111. #ifdef CONFIG_SMP
  112. PERCPU_SECTION(L1_CACHE_BYTES)
  113. #endif
  114. #ifdef CONFIG_HAVE_TCM
  115. ARM_TCM
  116. #endif
  117. #ifdef CONFIG_STRICT_KERNEL_RWX
  118. . = ALIGN(1<<SECTION_SHIFT);
  119. #else
  120. . = ALIGN(THREAD_SIZE);
  121. #endif
  122. __init_end = .;
  123. _sdata = .;
  124. RW_DATA_SECTION(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
  125. _edata = .;
  126. BSS_SECTION(0, 0, 0)
  127. #ifdef CONFIG_ARM_MPU
  128. . = ALIGN(PMSAv8_MINALIGN);
  129. #endif
  130. _end = .;
  131. STABS_DEBUG
  132. }
  133. #ifdef CONFIG_STRICT_KERNEL_RWX
  134. /*
  135. * Without CONFIG_DEBUG_ALIGN_RODATA, __start_rodata_section_aligned will
  136. * be the first section-aligned location after __start_rodata. Otherwise,
  137. * it will be equal to __start_rodata.
  138. */
  139. __start_rodata_section_aligned = ALIGN(__start_rodata, 1 << SECTION_SHIFT);
  140. #endif
  141. /*
  142. * These must never be empty
  143. * If you have to comment these two assert statements out, your
  144. * binutils is too old (for other reasons as well)
  145. */
  146. ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")
  147. ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")
  148. /*
  149. * The HYP init code can't be more than a page long,
  150. * and should not cross a page boundary.
  151. * The above comment applies as well.
  152. */
  153. ASSERT(__hyp_idmap_text_end - (__hyp_idmap_text_start & PAGE_MASK) <= PAGE_SIZE,
  154. "HYP init code too big or misaligned")
  155. #endif /* CONFIG_XIP_KERNEL */