vmlinux.lds.S 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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 = 0;
  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. *(.bootstrap.text)
  28. /* Then all the functions that are "hot" in profiles, to group them
  29. onto the same hugetlb entry */
  30. #include "functionlist"
  31. /* Then the rest */
  32. *(.text)
  33. SCHED_TEXT
  34. LOCK_TEXT
  35. KPROBES_TEXT
  36. *(.fixup)
  37. *(.gnu.warning)
  38. } :text = 0x9090
  39. /* out-of-line lock text */
  40. .text.lock : AT(ADDR(.text.lock) - LOAD_OFFSET) { *(.text.lock) }
  41. _etext = .; /* End of text section */
  42. . = ALIGN(16); /* Exception table */
  43. __start___ex_table = .;
  44. __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { *(__ex_table) }
  45. __stop___ex_table = .;
  46. RODATA
  47. BUG_TABLE
  48. . = ALIGN(PAGE_SIZE); /* Align data segment to page size boundary */
  49. /* Data */
  50. .data : AT(ADDR(.data) - LOAD_OFFSET) {
  51. *(.data)
  52. CONSTRUCTORS
  53. } :data
  54. _edata = .; /* End of data section */
  55. . = ALIGN(PAGE_SIZE);
  56. . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
  57. .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
  58. *(.data.cacheline_aligned)
  59. }
  60. . = ALIGN(CONFIG_X86_INTERNODE_CACHE_BYTES);
  61. .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
  62. *(.data.read_mostly)
  63. }
  64. #define VSYSCALL_ADDR (-10*1024*1024)
  65. #define VSYSCALL_PHYS_ADDR ((LOADADDR(.data.read_mostly) + SIZEOF(.data.read_mostly) + 4095) & ~(4095))
  66. #define VSYSCALL_VIRT_ADDR ((ADDR(.data.read_mostly) + SIZEOF(.data.read_mostly) + 4095) & ~(4095))
  67. #define VLOAD_OFFSET (VSYSCALL_ADDR - VSYSCALL_PHYS_ADDR)
  68. #define VLOAD(x) (ADDR(x) - VLOAD_OFFSET)
  69. #define VVIRT_OFFSET (VSYSCALL_ADDR - VSYSCALL_VIRT_ADDR)
  70. #define VVIRT(x) (ADDR(x) - VVIRT_OFFSET)
  71. . = VSYSCALL_ADDR;
  72. .vsyscall_0 : AT(VSYSCALL_PHYS_ADDR) { *(.vsyscall_0) } :user
  73. __vsyscall_0 = VSYSCALL_VIRT_ADDR;
  74. . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
  75. .xtime_lock : AT(VLOAD(.xtime_lock)) { *(.xtime_lock) }
  76. xtime_lock = VVIRT(.xtime_lock);
  77. .vxtime : AT(VLOAD(.vxtime)) { *(.vxtime) }
  78. vxtime = VVIRT(.vxtime);
  79. .vgetcpu_mode : AT(VLOAD(.vgetcpu_mode)) { *(.vgetcpu_mode) }
  80. vgetcpu_mode = VVIRT(.vgetcpu_mode);
  81. .sys_tz : AT(VLOAD(.sys_tz)) { *(.sys_tz) }
  82. sys_tz = VVIRT(.sys_tz);
  83. .sysctl_vsyscall : AT(VLOAD(.sysctl_vsyscall)) { *(.sysctl_vsyscall) }
  84. sysctl_vsyscall = VVIRT(.sysctl_vsyscall);
  85. .xtime : AT(VLOAD(.xtime)) { *(.xtime) }
  86. xtime = VVIRT(.xtime);
  87. . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
  88. .jiffies : AT(VLOAD(.jiffies)) { *(.jiffies) }
  89. jiffies = VVIRT(.jiffies);
  90. .vsyscall_1 ADDR(.vsyscall_0) + 1024: AT(VLOAD(.vsyscall_1)) { *(.vsyscall_1) }
  91. .vsyscall_2 ADDR(.vsyscall_0) + 2048: AT(VLOAD(.vsyscall_2)) { *(.vsyscall_2) }
  92. .vsyscall_3 ADDR(.vsyscall_0) + 3072: AT(VLOAD(.vsyscall_3)) { *(.vsyscall_3) }
  93. . = VSYSCALL_VIRT_ADDR + 4096;
  94. #undef VSYSCALL_ADDR
  95. #undef VSYSCALL_PHYS_ADDR
  96. #undef VSYSCALL_VIRT_ADDR
  97. #undef VLOAD_OFFSET
  98. #undef VLOAD
  99. #undef VVIRT_OFFSET
  100. #undef VVIRT
  101. . = ALIGN(8192); /* init_task */
  102. .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
  103. *(.data.init_task)
  104. }:data.init
  105. . = ALIGN(4096);
  106. .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
  107. *(.data.page_aligned)
  108. }
  109. /* might get freed after init */
  110. . = ALIGN(4096);
  111. __smp_alt_begin = .;
  112. __smp_alt_instructions = .;
  113. .smp_altinstructions : AT(ADDR(.smp_altinstructions) - LOAD_OFFSET) {
  114. *(.smp_altinstructions)
  115. }
  116. __smp_alt_instructions_end = .;
  117. . = ALIGN(8);
  118. __smp_locks = .;
  119. .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
  120. *(.smp_locks)
  121. }
  122. __smp_locks_end = .;
  123. .smp_altinstr_replacement : AT(ADDR(.smp_altinstr_replacement) - LOAD_OFFSET) {
  124. *(.smp_altinstr_replacement)
  125. }
  126. . = ALIGN(4096);
  127. __smp_alt_end = .;
  128. . = ALIGN(4096); /* Init code and data */
  129. __init_begin = .;
  130. .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
  131. _sinittext = .;
  132. *(.init.text)
  133. _einittext = .;
  134. }
  135. __initdata_begin = .;
  136. .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { *(.init.data) }
  137. __initdata_end = .;
  138. . = ALIGN(16);
  139. __setup_start = .;
  140. .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) { *(.init.setup) }
  141. __setup_end = .;
  142. __initcall_start = .;
  143. .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
  144. INITCALLS
  145. }
  146. __initcall_end = .;
  147. __con_initcall_start = .;
  148. .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
  149. *(.con_initcall.init)
  150. }
  151. __con_initcall_end = .;
  152. SECURITY_INIT
  153. . = ALIGN(8);
  154. __alt_instructions = .;
  155. .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
  156. *(.altinstructions)
  157. }
  158. __alt_instructions_end = .;
  159. .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) {
  160. *(.altinstr_replacement)
  161. }
  162. /* .exit.text is discard at runtime, not link time, to deal with references
  163. from .altinstructions and .eh_frame */
  164. .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { *(.exit.text) }
  165. .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { *(.exit.data) }
  166. . = ALIGN(4096);
  167. __initramfs_start = .;
  168. .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) { *(.init.ramfs) }
  169. __initramfs_end = .;
  170. . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
  171. __per_cpu_start = .;
  172. .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) { *(.data.percpu) }
  173. __per_cpu_end = .;
  174. . = ALIGN(4096);
  175. __init_end = .;
  176. . = ALIGN(4096);
  177. __nosave_begin = .;
  178. .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) { *(.data.nosave) }
  179. . = ALIGN(4096);
  180. __nosave_end = .;
  181. __bss_start = .; /* BSS */
  182. .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
  183. *(.bss.page_aligned)
  184. *(.bss)
  185. }
  186. __bss_stop = .;
  187. _end = . ;
  188. /* Sections to be discarded */
  189. /DISCARD/ : {
  190. *(.exitcall.exit)
  191. *(.eh_frame)
  192. }
  193. STABS_DEBUG
  194. DWARF_DEBUG
  195. }