vmlinux_32.lds.S 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. /* ld script to make i386 Linux kernel
  2. * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>;
  3. *
  4. * Don't define absolute symbols until and unless you know that symbol
  5. * value is should remain constant even if kernel image is relocated
  6. * at run time. Absolute symbols are not relocated. If symbol value should
  7. * change if kernel is relocated, make the symbol section relative and
  8. * put it inside the section definition.
  9. */
  10. #define LOAD_OFFSET __PAGE_OFFSET
  11. #include <asm-generic/vmlinux.lds.h>
  12. #include <asm/thread_info.h>
  13. #include <asm/page.h>
  14. #include <asm/cache.h>
  15. #include <asm/boot.h>
  16. OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
  17. OUTPUT_ARCH(i386)
  18. ENTRY(phys_startup_32)
  19. jiffies = jiffies_64;
  20. PHDRS {
  21. text PT_LOAD FLAGS(5); /* R_E */
  22. data PT_LOAD FLAGS(7); /* RWE */
  23. note PT_NOTE FLAGS(0); /* ___ */
  24. }
  25. SECTIONS
  26. {
  27. . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
  28. phys_startup_32 = startup_32 - LOAD_OFFSET;
  29. .text.head : AT(ADDR(.text.head) - LOAD_OFFSET) {
  30. _text = .; /* Text and read-only data */
  31. *(.text.head)
  32. } :text = 0x9090
  33. /* read-only */
  34. .text : AT(ADDR(.text) - LOAD_OFFSET) {
  35. . = ALIGN(PAGE_SIZE); /* not really needed, already page aligned */
  36. *(.text.page_aligned)
  37. TEXT_TEXT
  38. SCHED_TEXT
  39. LOCK_TEXT
  40. KPROBES_TEXT
  41. *(.fixup)
  42. *(.gnu.warning)
  43. _etext = .; /* End of text section */
  44. } :text = 0x9090
  45. NOTES :text :note
  46. . = ALIGN(16); /* Exception table */
  47. __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
  48. __start___ex_table = .;
  49. *(__ex_table)
  50. __stop___ex_table = .;
  51. } :text = 0x9090
  52. RODATA
  53. /* writeable */
  54. . = ALIGN(PAGE_SIZE);
  55. .data : AT(ADDR(.data) - LOAD_OFFSET) { /* Data */
  56. DATA_DATA
  57. CONSTRUCTORS
  58. } :data
  59. . = ALIGN(PAGE_SIZE);
  60. .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
  61. __nosave_begin = .;
  62. *(.data.nosave)
  63. . = ALIGN(PAGE_SIZE);
  64. __nosave_end = .;
  65. }
  66. . = ALIGN(PAGE_SIZE);
  67. .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
  68. *(.data.page_aligned)
  69. *(.data.idt)
  70. }
  71. . = ALIGN(32);
  72. .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
  73. *(.data.cacheline_aligned)
  74. }
  75. /* rarely changed data like cpu maps */
  76. . = ALIGN(32);
  77. .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
  78. *(.data.read_mostly)
  79. _edata = .; /* End of data section */
  80. }
  81. . = ALIGN(THREAD_SIZE); /* init_task */
  82. .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
  83. *(.data.init_task)
  84. }
  85. /* might get freed after init */
  86. . = ALIGN(PAGE_SIZE);
  87. .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
  88. __smp_locks = .;
  89. *(.smp_locks)
  90. __smp_locks_end = .;
  91. }
  92. /* will be freed after init
  93. * Following ALIGN() is required to make sure no other data falls on the
  94. * same page where __smp_alt_end is pointing as that page might be freed
  95. * after boot. Always make sure that ALIGN() directive is present after
  96. * the section which contains __smp_alt_end.
  97. */
  98. . = ALIGN(PAGE_SIZE);
  99. /* will be freed after init */
  100. . = ALIGN(PAGE_SIZE); /* Init code and data */
  101. .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
  102. __init_begin = .;
  103. _sinittext = .;
  104. INIT_TEXT
  105. _einittext = .;
  106. }
  107. .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
  108. INIT_DATA
  109. }
  110. . = ALIGN(16);
  111. .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
  112. __setup_start = .;
  113. *(.init.setup)
  114. __setup_end = .;
  115. }
  116. .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
  117. __initcall_start = .;
  118. INITCALLS
  119. __initcall_end = .;
  120. }
  121. .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
  122. __con_initcall_start = .;
  123. *(.con_initcall.init)
  124. __con_initcall_end = .;
  125. }
  126. .x86cpuvendor.init : AT(ADDR(.x86cpuvendor.init) - LOAD_OFFSET) {
  127. __x86cpuvendor_start = .;
  128. *(.x86cpuvendor.init)
  129. __x86cpuvendor_end = .;
  130. }
  131. SECURITY_INIT
  132. . = ALIGN(4);
  133. .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
  134. __alt_instructions = .;
  135. *(.altinstructions)
  136. __alt_instructions_end = .;
  137. }
  138. .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) {
  139. *(.altinstr_replacement)
  140. }
  141. . = ALIGN(4);
  142. .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) {
  143. __parainstructions = .;
  144. *(.parainstructions)
  145. __parainstructions_end = .;
  146. }
  147. /* .exit.text is discard at runtime, not link time, to deal with references
  148. from .altinstructions and .eh_frame */
  149. .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
  150. EXIT_TEXT
  151. }
  152. .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
  153. EXIT_DATA
  154. }
  155. #if defined(CONFIG_BLK_DEV_INITRD)
  156. . = ALIGN(PAGE_SIZE);
  157. .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
  158. __initramfs_start = .;
  159. *(.init.ramfs)
  160. __initramfs_end = .;
  161. }
  162. #endif
  163. . = ALIGN(PAGE_SIZE);
  164. .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) {
  165. __per_cpu_start = .;
  166. *(.data.percpu)
  167. *(.data.percpu.shared_aligned)
  168. __per_cpu_end = .;
  169. }
  170. . = ALIGN(PAGE_SIZE);
  171. /* freed after init ends here */
  172. .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
  173. __init_end = .;
  174. __bss_start = .; /* BSS */
  175. *(.bss.page_aligned)
  176. *(.bss)
  177. . = ALIGN(4);
  178. __bss_stop = .;
  179. _end = . ;
  180. /* This is where the kernel creates the early boot page tables */
  181. . = ALIGN(PAGE_SIZE);
  182. pg0 = . ;
  183. }
  184. /* Sections to be discarded */
  185. /DISCARD/ : {
  186. *(.exitcall.exit)
  187. }
  188. STABS_DEBUG
  189. DWARF_DEBUG
  190. }
  191. #ifdef CONFIG_KEXEC
  192. /* Link time checks */
  193. #include <asm/kexec.h>
  194. ASSERT(kexec_control_code_size <= KEXEC_CONTROL_CODE_MAX_SIZE,
  195. "kexec control code size is too big")
  196. #endif