vmlinux.lds.S 3.4 KB

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