vmlinux_32.lds.S 5.5 KB

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