vmlinux.lds.S 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /*
  2. * ld script for the x86 kernel
  3. *
  4. * Historic 32-bit version written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
  5. *
  6. * Modernisation and unification done by Sam Ravnborg <sam@ravnborg.org>
  7. *
  8. *
  9. * Don't define absolute symbols until and unless you know that symbol
  10. * value is should remain constant even if kernel image is relocated
  11. * at run time. Absolute symbols are not relocated. If symbol value should
  12. * change if kernel is relocated, make the symbol section relative and
  13. * put it inside the section definition.
  14. */
  15. #ifdef CONFIG_X86_32
  16. #define LOAD_OFFSET __PAGE_OFFSET
  17. #else
  18. #define LOAD_OFFSET __START_KERNEL_map
  19. #endif
  20. #include <asm-generic/vmlinux.lds.h>
  21. #include <asm/asm-offsets.h>
  22. #include <asm/thread_info.h>
  23. #include <asm/page_types.h>
  24. #include <asm/cache.h>
  25. #include <asm/boot.h>
  26. #undef i386 /* in case the preprocessor is a 32bit one */
  27. OUTPUT_FORMAT(CONFIG_OUTPUT_FORMAT, CONFIG_OUTPUT_FORMAT, CONFIG_OUTPUT_FORMAT)
  28. #ifdef CONFIG_X86_32
  29. OUTPUT_ARCH(i386)
  30. ENTRY(phys_startup_32)
  31. jiffies = jiffies_64;
  32. #else
  33. OUTPUT_ARCH(i386:x86-64)
  34. ENTRY(phys_startup_64)
  35. jiffies_64 = jiffies;
  36. #endif
  37. PHDRS {
  38. text PT_LOAD FLAGS(5); /* R_E */
  39. data PT_LOAD FLAGS(7); /* RWE */
  40. #ifdef CONFIG_X86_64
  41. user PT_LOAD FLAGS(7); /* RWE */
  42. data.init PT_LOAD FLAGS(7); /* RWE */
  43. #ifdef CONFIG_SMP
  44. percpu PT_LOAD FLAGS(7); /* RWE */
  45. #endif
  46. data.init2 PT_LOAD FLAGS(7); /* RWE */
  47. #endif
  48. note PT_NOTE FLAGS(0); /* ___ */
  49. }
  50. SECTIONS
  51. {
  52. #ifdef CONFIG_X86_32
  53. . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
  54. phys_startup_32 = startup_32 - LOAD_OFFSET;
  55. #else
  56. . = __START_KERNEL;
  57. phys_startup_64 = startup_64 - LOAD_OFFSET;
  58. #endif
  59. /* Text and read-only data */
  60. /* bootstrapping code */
  61. .text.head : AT(ADDR(.text.head) - LOAD_OFFSET) {
  62. _text = .;
  63. *(.text.head)
  64. } :text = 0x9090
  65. /* The rest of the text */
  66. .text : AT(ADDR(.text) - LOAD_OFFSET) {
  67. #ifdef CONFIG_X86_32
  68. /* not really needed, already page aligned */
  69. . = ALIGN(PAGE_SIZE);
  70. *(.text.page_aligned)
  71. #endif
  72. . = ALIGN(8);
  73. _stext = .;
  74. TEXT_TEXT
  75. SCHED_TEXT
  76. LOCK_TEXT
  77. KPROBES_TEXT
  78. IRQENTRY_TEXT
  79. *(.fixup)
  80. *(.gnu.warning)
  81. /* End of text section */
  82. _etext = .;
  83. } :text = 0x9090
  84. NOTES :text :note
  85. /* Exception table */
  86. . = ALIGN(16);
  87. __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
  88. __start___ex_table = .;
  89. *(__ex_table)
  90. __stop___ex_table = .;
  91. } :text = 0x9090
  92. RODATA
  93. /* Data */
  94. . = ALIGN(PAGE_SIZE);
  95. .data : AT(ADDR(.data) - LOAD_OFFSET) {
  96. DATA_DATA
  97. CONSTRUCTORS
  98. #ifdef CONFIG_X86_64
  99. /* End of data section */
  100. _edata = .;
  101. #endif
  102. } :data
  103. #ifdef CONFIG_X86_32
  104. /* 32 bit has nosave before _edata */
  105. . = ALIGN(PAGE_SIZE);
  106. .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
  107. __nosave_begin = .;
  108. *(.data.nosave)
  109. . = ALIGN(PAGE_SIZE);
  110. __nosave_end = .;
  111. }
  112. #endif
  113. . = ALIGN(PAGE_SIZE);
  114. .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
  115. *(.data.page_aligned)
  116. *(.data.idt)
  117. }
  118. #ifdef CONFIG_X86_32
  119. . = ALIGN(32);
  120. #else
  121. . = ALIGN(PAGE_SIZE);
  122. . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
  123. #endif
  124. .data.cacheline_aligned :
  125. AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
  126. *(.data.cacheline_aligned)
  127. }
  128. /* rarely changed data like cpu maps */
  129. #ifdef CONFIG_X86_32
  130. . = ALIGN(32);
  131. #else
  132. . = ALIGN(CONFIG_X86_INTERNODE_CACHE_BYTES);
  133. #endif
  134. .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
  135. *(.data.read_mostly)
  136. #ifdef CONFIG_X86_32
  137. /* End of data section */
  138. _edata = .;
  139. #endif
  140. }
  141. #ifdef CONFIG_X86_32
  142. # include "vmlinux_32.lds.S"
  143. #else
  144. # include "vmlinux_64.lds.S"
  145. #endif
  146. STABS_DEBUG
  147. DWARF_DEBUG
  148. }
  149. #ifdef CONFIG_X86_32
  150. ASSERT((_end - LOAD_OFFSET <= KERNEL_IMAGE_SIZE),
  151. "kernel image bigger than KERNEL_IMAGE_SIZE")
  152. #else
  153. /*
  154. * Per-cpu symbols which need to be offset from __per_cpu_load
  155. * for the boot processor.
  156. */
  157. #define INIT_PER_CPU(x) init_per_cpu__##x = per_cpu__##x + __per_cpu_load
  158. INIT_PER_CPU(gdt_page);
  159. INIT_PER_CPU(irq_stack_union);
  160. /*
  161. * Build-time check on the image size:
  162. */
  163. ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
  164. "kernel image bigger than KERNEL_IMAGE_SIZE")
  165. #ifdef CONFIG_SMP
  166. ASSERT((per_cpu__irq_stack_union == 0),
  167. "irq_stack_union is not at start of per-cpu area");
  168. #endif
  169. #endif /* CONFIG_X86_32 */
  170. #ifdef CONFIG_KEXEC
  171. #include <asm/kexec.h>
  172. ASSERT(kexec_control_code_size <= KEXEC_CONTROL_CODE_MAX_SIZE,
  173. "kexec control code size is too big")
  174. #endif