vmlinux.lds.S 6.5 KB

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