vmlinux_32.lds.S 5.5 KB

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