vmlinux.lds.S 6.4 KB

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