vmlinux_64.lds.S 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. /* ld script to make x86-64 Linux kernel
  2. * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>;
  3. */
  4. #define LOAD_OFFSET __START_KERNEL_map
  5. #include <asm-generic/vmlinux.lds.h>
  6. #include <asm/page.h>
  7. #undef i386 /* in case the preprocessor is a 32bit one */
  8. OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
  9. OUTPUT_ARCH(i386:x86-64)
  10. ENTRY(phys_startup_64)
  11. jiffies_64 = jiffies;
  12. _proxy_pda = 1;
  13. PHDRS {
  14. text PT_LOAD FLAGS(5); /* R_E */
  15. data PT_LOAD FLAGS(7); /* RWE */
  16. user PT_LOAD FLAGS(7); /* RWE */
  17. data.init PT_LOAD FLAGS(7); /* RWE */
  18. note PT_NOTE FLAGS(4); /* R__ */
  19. }
  20. SECTIONS
  21. {
  22. . = __START_KERNEL;
  23. phys_startup_64 = startup_64 - LOAD_OFFSET;
  24. _text = .; /* Text and read-only data */
  25. .text : AT(ADDR(.text) - LOAD_OFFSET) {
  26. /* First the code that has to be first for bootstrapping */
  27. *(.text.head)
  28. _stext = .;
  29. /* Then the rest */
  30. TEXT_TEXT
  31. SCHED_TEXT
  32. LOCK_TEXT
  33. KPROBES_TEXT
  34. *(.fixup)
  35. *(.gnu.warning)
  36. _etext = .; /* End of text section */
  37. } :text = 0x9090
  38. . = ALIGN(16); /* Exception table */
  39. __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
  40. __start___ex_table = .;
  41. *(__ex_table)
  42. __stop___ex_table = .;
  43. }
  44. NOTES :text :note
  45. BUG_TABLE :text
  46. RODATA
  47. . = ALIGN(4);
  48. .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) {
  49. __tracedata_start = .;
  50. *(.tracedata)
  51. __tracedata_end = .;
  52. }
  53. . = ALIGN(PAGE_SIZE); /* Align data segment to page size boundary */
  54. /* Data */
  55. .data : AT(ADDR(.data) - LOAD_OFFSET) {
  56. DATA_DATA
  57. CONSTRUCTORS
  58. } :data
  59. _edata = .; /* End of data section */
  60. . = ALIGN(PAGE_SIZE);
  61. . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
  62. .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
  63. *(.data.cacheline_aligned)
  64. }
  65. . = ALIGN(CONFIG_X86_INTERNODE_CACHE_BYTES);
  66. .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
  67. *(.data.read_mostly)
  68. }
  69. #define VSYSCALL_ADDR (-10*1024*1024)
  70. #define VSYSCALL_PHYS_ADDR ((LOADADDR(.data.read_mostly) + SIZEOF(.data.read_mostly) + 4095) & ~(4095))
  71. #define VSYSCALL_VIRT_ADDR ((ADDR(.data.read_mostly) + SIZEOF(.data.read_mostly) + 4095) & ~(4095))
  72. #define VLOAD_OFFSET (VSYSCALL_ADDR - VSYSCALL_PHYS_ADDR)
  73. #define VLOAD(x) (ADDR(x) - VLOAD_OFFSET)
  74. #define VVIRT_OFFSET (VSYSCALL_ADDR - VSYSCALL_VIRT_ADDR)
  75. #define VVIRT(x) (ADDR(x) - VVIRT_OFFSET)
  76. . = VSYSCALL_ADDR;
  77. .vsyscall_0 : AT(VSYSCALL_PHYS_ADDR) { *(.vsyscall_0) } :user
  78. __vsyscall_0 = VSYSCALL_VIRT_ADDR;
  79. . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
  80. .vsyscall_fn : AT(VLOAD(.vsyscall_fn)) { *(.vsyscall_fn) }
  81. . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
  82. .vsyscall_gtod_data : AT(VLOAD(.vsyscall_gtod_data))
  83. { *(.vsyscall_gtod_data) }
  84. vsyscall_gtod_data = VVIRT(.vsyscall_gtod_data);
  85. .vsyscall_clock : AT(VLOAD(.vsyscall_clock))
  86. { *(.vsyscall_clock) }
  87. vsyscall_clock = VVIRT(.vsyscall_clock);
  88. .vsyscall_1 ADDR(.vsyscall_0) + 1024: AT(VLOAD(.vsyscall_1))
  89. { *(.vsyscall_1) }
  90. .vsyscall_2 ADDR(.vsyscall_0) + 2048: AT(VLOAD(.vsyscall_2))
  91. { *(.vsyscall_2) }
  92. .vgetcpu_mode : AT(VLOAD(.vgetcpu_mode)) { *(.vgetcpu_mode) }
  93. vgetcpu_mode = VVIRT(.vgetcpu_mode);
  94. . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
  95. .jiffies : AT(VLOAD(.jiffies)) { *(.jiffies) }
  96. jiffies = VVIRT(.jiffies);
  97. .vsyscall_3 ADDR(.vsyscall_0) + 3072: AT(VLOAD(.vsyscall_3))
  98. { *(.vsyscall_3) }
  99. . = VSYSCALL_VIRT_ADDR + PAGE_SIZE;
  100. #undef VSYSCALL_ADDR
  101. #undef VSYSCALL_PHYS_ADDR
  102. #undef VSYSCALL_VIRT_ADDR
  103. #undef VLOAD_OFFSET
  104. #undef VLOAD
  105. #undef VVIRT_OFFSET
  106. #undef VVIRT
  107. . = ALIGN(THREAD_SIZE); /* init_task */
  108. .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
  109. *(.data.init_task)
  110. }:data.init
  111. . = ALIGN(PAGE_SIZE);
  112. .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
  113. *(.data.page_aligned)
  114. }
  115. /* might get freed after init */
  116. . = ALIGN(PAGE_SIZE);
  117. __smp_alt_begin = .;
  118. __smp_locks = .;
  119. .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
  120. *(.smp_locks)
  121. }
  122. __smp_locks_end = .;
  123. . = ALIGN(PAGE_SIZE);
  124. __smp_alt_end = .;
  125. . = ALIGN(PAGE_SIZE); /* Init code and data */
  126. __init_begin = .;
  127. .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
  128. _sinittext = .;
  129. INIT_TEXT
  130. _einittext = .;
  131. }
  132. .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
  133. __initdata_begin = .;
  134. INIT_DATA
  135. __initdata_end = .;
  136. }
  137. . = ALIGN(16);
  138. __setup_start = .;
  139. .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) { *(.init.setup) }
  140. __setup_end = .;
  141. __initcall_start = .;
  142. .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
  143. INITCALLS
  144. }
  145. __initcall_end = .;
  146. __con_initcall_start = .;
  147. .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
  148. *(.con_initcall.init)
  149. }
  150. __con_initcall_end = .;
  151. __x86cpuvendor_start = .;
  152. .x86cpuvendor.init : AT(ADDR(.x86cpuvendor.init) - LOAD_OFFSET) {
  153. *(.x86cpuvendor.init)
  154. }
  155. __x86cpuvendor_end = .;
  156. SECURITY_INIT
  157. . = ALIGN(8);
  158. .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) {
  159. __parainstructions = .;
  160. *(.parainstructions)
  161. __parainstructions_end = .;
  162. }
  163. . = ALIGN(8);
  164. __alt_instructions = .;
  165. .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
  166. *(.altinstructions)
  167. }
  168. __alt_instructions_end = .;
  169. .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) {
  170. *(.altinstr_replacement)
  171. }
  172. /* .exit.text is discard at runtime, not link time, to deal with references
  173. from .altinstructions and .eh_frame */
  174. .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
  175. EXIT_TEXT
  176. }
  177. .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
  178. EXIT_DATA
  179. }
  180. /* vdso blob that is mapped into user space */
  181. vdso_start = . ;
  182. .vdso : AT(ADDR(.vdso) - LOAD_OFFSET) { *(.vdso) }
  183. . = ALIGN(PAGE_SIZE);
  184. vdso_end = .;
  185. #ifdef CONFIG_BLK_DEV_INITRD
  186. . = ALIGN(PAGE_SIZE);
  187. __initramfs_start = .;
  188. .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) { *(.init.ramfs) }
  189. __initramfs_end = .;
  190. #endif
  191. PERCPU(PAGE_SIZE)
  192. . = ALIGN(PAGE_SIZE);
  193. __init_end = .;
  194. . = ALIGN(PAGE_SIZE);
  195. __nosave_begin = .;
  196. .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) { *(.data.nosave) }
  197. . = ALIGN(PAGE_SIZE);
  198. __nosave_end = .;
  199. __bss_start = .; /* BSS */
  200. .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
  201. *(.bss.page_aligned)
  202. *(.bss)
  203. }
  204. __bss_stop = .;
  205. _end = . ;
  206. /* Sections to be discarded */
  207. /DISCARD/ : {
  208. *(.exitcall.exit)
  209. *(.eh_frame)
  210. }
  211. STABS_DEBUG
  212. DWARF_DEBUG
  213. }
  214. /*
  215. * Build-time check on the image size:
  216. */
  217. ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
  218. "kernel image bigger than KERNEL_IMAGE_SIZE")