vmlinux.lds.S 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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. #include <linux/config.h>
  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. SECTIONS
  13. {
  14. . = __START_KERNEL;
  15. phys_startup_64 = startup_64 - LOAD_OFFSET;
  16. _text = .; /* Text and read-only data */
  17. .text : AT(ADDR(.text) - LOAD_OFFSET) {
  18. *(.text)
  19. SCHED_TEXT
  20. LOCK_TEXT
  21. KPROBES_TEXT
  22. *(.fixup)
  23. *(.gnu.warning)
  24. } = 0x9090
  25. /* out-of-line lock text */
  26. .text.lock : AT(ADDR(.text.lock) - LOAD_OFFSET) { *(.text.lock) }
  27. _etext = .; /* End of text section */
  28. . = ALIGN(16); /* Exception table */
  29. __start___ex_table = .;
  30. __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { *(__ex_table) }
  31. __stop___ex_table = .;
  32. RODATA
  33. /* Data */
  34. .data : AT(ADDR(.data) - LOAD_OFFSET) {
  35. *(.data)
  36. CONSTRUCTORS
  37. }
  38. _edata = .; /* End of data section */
  39. __bss_start = .; /* BSS */
  40. .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
  41. *(.bss.page_aligned)
  42. *(.bss)
  43. }
  44. __bss_end = .;
  45. . = ALIGN(PAGE_SIZE);
  46. . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
  47. .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
  48. *(.data.cacheline_aligned)
  49. }
  50. . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
  51. .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
  52. *(.data.read_mostly)
  53. }
  54. #define VSYSCALL_ADDR (-10*1024*1024)
  55. #define VSYSCALL_PHYS_ADDR ((LOADADDR(.data.read_mostly) + SIZEOF(.data.read_mostly) + 4095) & ~(4095))
  56. #define VSYSCALL_VIRT_ADDR ((ADDR(.data.read_mostly) + SIZEOF(.data.read_mostly) + 4095) & ~(4095))
  57. #define VLOAD_OFFSET (VSYSCALL_ADDR - VSYSCALL_PHYS_ADDR)
  58. #define VLOAD(x) (ADDR(x) - VLOAD_OFFSET)
  59. #define VVIRT_OFFSET (VSYSCALL_ADDR - VSYSCALL_VIRT_ADDR)
  60. #define VVIRT(x) (ADDR(x) - VVIRT_OFFSET)
  61. . = VSYSCALL_ADDR;
  62. .vsyscall_0 : AT(VSYSCALL_PHYS_ADDR) { *(.vsyscall_0) }
  63. __vsyscall_0 = VSYSCALL_VIRT_ADDR;
  64. . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
  65. .xtime_lock : AT(VLOAD(.xtime_lock)) { *(.xtime_lock) }
  66. xtime_lock = VVIRT(.xtime_lock);
  67. .vxtime : AT(VLOAD(.vxtime)) { *(.vxtime) }
  68. vxtime = VVIRT(.vxtime);
  69. .wall_jiffies : AT(VLOAD(.wall_jiffies)) { *(.wall_jiffies) }
  70. wall_jiffies = VVIRT(.wall_jiffies);
  71. .sys_tz : AT(VLOAD(.sys_tz)) { *(.sys_tz) }
  72. sys_tz = VVIRT(.sys_tz);
  73. .sysctl_vsyscall : AT(VLOAD(.sysctl_vsyscall)) { *(.sysctl_vsyscall) }
  74. sysctl_vsyscall = VVIRT(.sysctl_vsyscall);
  75. .xtime : AT(VLOAD(.xtime)) { *(.xtime) }
  76. xtime = VVIRT(.xtime);
  77. . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
  78. .jiffies : AT(VLOAD(.jiffies)) { *(.jiffies) }
  79. jiffies = VVIRT(.jiffies);
  80. .vsyscall_1 ADDR(.vsyscall_0) + 1024: AT(VLOAD(.vsyscall_1)) { *(.vsyscall_1) }
  81. .vsyscall_2 ADDR(.vsyscall_0) + 2048: AT(VLOAD(.vsyscall_2)) { *(.vsyscall_2) }
  82. .vsyscall_3 ADDR(.vsyscall_0) + 3072: AT(VLOAD(.vsyscall_3)) { *(.vsyscall_3) }
  83. . = VSYSCALL_VIRT_ADDR + 4096;
  84. #undef VSYSCALL_ADDR
  85. #undef VSYSCALL_PHYS_ADDR
  86. #undef VSYSCALL_VIRT_ADDR
  87. #undef VLOAD_OFFSET
  88. #undef VLOAD
  89. #undef VVIRT_OFFSET
  90. #undef VVIRT
  91. . = ALIGN(8192); /* init_task */
  92. .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
  93. *(.data.init_task)
  94. }
  95. . = ALIGN(4096);
  96. .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
  97. *(.data.page_aligned)
  98. }
  99. . = ALIGN(4096); /* Init code and data */
  100. __init_begin = .;
  101. .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
  102. _sinittext = .;
  103. *(.init.text)
  104. _einittext = .;
  105. }
  106. __initdata_begin = .;
  107. .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { *(.init.data) }
  108. __initdata_end = .;
  109. . = ALIGN(16);
  110. __setup_start = .;
  111. .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) { *(.init.setup) }
  112. __setup_end = .;
  113. __initcall_start = .;
  114. .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
  115. *(.initcall1.init)
  116. *(.initcall2.init)
  117. *(.initcall3.init)
  118. *(.initcall4.init)
  119. *(.initcall5.init)
  120. *(.initcall6.init)
  121. *(.initcall7.init)
  122. }
  123. __initcall_end = .;
  124. __con_initcall_start = .;
  125. .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
  126. *(.con_initcall.init)
  127. }
  128. __con_initcall_end = .;
  129. SECURITY_INIT
  130. . = ALIGN(8);
  131. __alt_instructions = .;
  132. .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
  133. *(.altinstructions)
  134. }
  135. __alt_instructions_end = .;
  136. .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) {
  137. *(.altinstr_replacement)
  138. }
  139. /* .exit.text is discard at runtime, not link time, to deal with references
  140. from .altinstructions and .eh_frame */
  141. .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { *(.exit.text) }
  142. .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { *(.exit.data) }
  143. . = ALIGN(4096);
  144. __initramfs_start = .;
  145. .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) { *(.init.ramfs) }
  146. __initramfs_end = .;
  147. . = ALIGN(32);
  148. __per_cpu_start = .;
  149. .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) { *(.data.percpu) }
  150. __per_cpu_end = .;
  151. . = ALIGN(4096);
  152. __init_end = .;
  153. . = ALIGN(4096);
  154. __nosave_begin = .;
  155. .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) { *(.data.nosave) }
  156. . = ALIGN(4096);
  157. __nosave_end = .;
  158. _end = . ;
  159. /* Sections to be discarded */
  160. /DISCARD/ : {
  161. *(.exitcall.exit)
  162. #ifndef CONFIG_DEBUG_INFO
  163. *(.eh_frame)
  164. #endif
  165. }
  166. /* DWARF 2 */
  167. .debug_info 0 : { *(.debug_info) }
  168. .debug_abbrev 0 : { *(.debug_abbrev) }
  169. .debug_line 0 : { *(.debug_line) }
  170. .debug_frame 0 : { *(.debug_frame) }
  171. .debug_str 0 : { *(.debug_str) }
  172. .debug_loc 0 : { *(.debug_loc) }
  173. .debug_macinfo 0 : { *(.debug_macinfo) }
  174. /* SGI/MIPS DWARF 2 extensions */
  175. .debug_weaknames 0 : { *(.debug_weaknames) }
  176. .debug_funcnames 0 : { *(.debug_funcnames) }
  177. .debug_typenames 0 : { *(.debug_typenames) }
  178. .debug_varnames 0 : { *(.debug_varnames) }
  179. .comment 0 : { *(.comment) }
  180. }