vmlinux_32.lds.S 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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. . = ALIGN(16); /* Exception table */
  46. __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
  47. __start___ex_table = .;
  48. *(__ex_table)
  49. __stop___ex_table = .;
  50. }
  51. NOTES :text :note
  52. BUG_TABLE :text
  53. . = ALIGN(4);
  54. .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) {
  55. __tracedata_start = .;
  56. *(.tracedata)
  57. __tracedata_end = .;
  58. }
  59. RODATA
  60. /* writeable */
  61. . = ALIGN(PAGE_SIZE);
  62. .data : AT(ADDR(.data) - LOAD_OFFSET) { /* Data */
  63. DATA_DATA
  64. CONSTRUCTORS
  65. } :data
  66. . = ALIGN(PAGE_SIZE);
  67. .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
  68. __nosave_begin = .;
  69. *(.data.nosave)
  70. . = ALIGN(PAGE_SIZE);
  71. __nosave_end = .;
  72. }
  73. . = ALIGN(PAGE_SIZE);
  74. .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
  75. *(.data.page_aligned)
  76. *(.data.idt)
  77. }
  78. . = ALIGN(32);
  79. .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
  80. *(.data.cacheline_aligned)
  81. }
  82. /* rarely changed data like cpu maps */
  83. . = ALIGN(32);
  84. .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
  85. *(.data.read_mostly)
  86. _edata = .; /* End of data section */
  87. }
  88. . = ALIGN(THREAD_SIZE); /* init_task */
  89. .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
  90. *(.data.init_task)
  91. }
  92. /* might get freed after init */
  93. . = ALIGN(PAGE_SIZE);
  94. .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
  95. __smp_locks = .;
  96. *(.smp_locks)
  97. __smp_locks_end = .;
  98. }
  99. /* will be freed after init
  100. * Following ALIGN() is required to make sure no other data falls on the
  101. * same page where __smp_alt_end is pointing as that page might be freed
  102. * after boot. Always make sure that ALIGN() directive is present after
  103. * the section which contains __smp_alt_end.
  104. */
  105. . = ALIGN(PAGE_SIZE);
  106. /* will be freed after init */
  107. . = ALIGN(PAGE_SIZE); /* Init code and data */
  108. .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
  109. __init_begin = .;
  110. _sinittext = .;
  111. INIT_TEXT
  112. _einittext = .;
  113. }
  114. .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
  115. INIT_DATA
  116. }
  117. . = ALIGN(16);
  118. .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
  119. __setup_start = .;
  120. *(.init.setup)
  121. __setup_end = .;
  122. }
  123. .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
  124. __initcall_start = .;
  125. INITCALLS
  126. __initcall_end = .;
  127. }
  128. .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
  129. __con_initcall_start = .;
  130. *(.con_initcall.init)
  131. __con_initcall_end = .;
  132. }
  133. .x86cpuvendor.init : AT(ADDR(.x86cpuvendor.init) - LOAD_OFFSET) {
  134. __x86cpuvendor_start = .;
  135. *(.x86cpuvendor.init)
  136. __x86cpuvendor_end = .;
  137. }
  138. SECURITY_INIT
  139. . = ALIGN(4);
  140. .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
  141. __alt_instructions = .;
  142. *(.altinstructions)
  143. __alt_instructions_end = .;
  144. }
  145. .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) {
  146. *(.altinstr_replacement)
  147. }
  148. . = ALIGN(4);
  149. .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) {
  150. __parainstructions = .;
  151. *(.parainstructions)
  152. __parainstructions_end = .;
  153. }
  154. /* .exit.text is discard at runtime, not link time, to deal with references
  155. from .altinstructions and .eh_frame */
  156. .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
  157. EXIT_TEXT
  158. }
  159. .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
  160. EXIT_DATA
  161. }
  162. #if defined(CONFIG_BLK_DEV_INITRD)
  163. . = ALIGN(PAGE_SIZE);
  164. .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
  165. __initramfs_start = .;
  166. *(.init.ramfs)
  167. __initramfs_end = .;
  168. }
  169. #endif
  170. . = ALIGN(PAGE_SIZE);
  171. .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) {
  172. __per_cpu_start = .;
  173. *(.data.percpu)
  174. *(.data.percpu.shared_aligned)
  175. __per_cpu_end = .;
  176. }
  177. . = ALIGN(PAGE_SIZE);
  178. /* freed after init ends here */
  179. .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
  180. __init_end = .;
  181. __bss_start = .; /* BSS */
  182. *(.bss.page_aligned)
  183. *(.bss)
  184. . = ALIGN(4);
  185. __bss_stop = .;
  186. _end = . ;
  187. /* This is where the kernel creates the early boot page tables */
  188. . = ALIGN(PAGE_SIZE);
  189. pg0 = . ;
  190. }
  191. /* Sections to be discarded */
  192. /DISCARD/ : {
  193. *(.exitcall.exit)
  194. }
  195. STABS_DEBUG
  196. DWARF_DEBUG
  197. }