vmlinux.lds.S 3.4 KB

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