vmlinux_64.lds.S 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. PHDRS {
  2. text PT_LOAD FLAGS(5); /* R_E */
  3. data PT_LOAD FLAGS(7); /* RWE */
  4. user PT_LOAD FLAGS(7); /* RWE */
  5. data.init PT_LOAD FLAGS(7); /* RWE */
  6. #ifdef CONFIG_SMP
  7. percpu PT_LOAD FLAGS(7); /* RWE */
  8. #endif
  9. data.init2 PT_LOAD FLAGS(7); /* RWE */
  10. note PT_NOTE FLAGS(0); /* ___ */
  11. }
  12. SECTIONS
  13. {
  14. . = __START_KERNEL;
  15. phys_startup_64 = startup_64 - LOAD_OFFSET;
  16. /* Text and read-only data */
  17. .text : AT(ADDR(.text) - LOAD_OFFSET) {
  18. _text = .;
  19. /* First the code that has to be first for bootstrapping */
  20. *(.text.head)
  21. _stext = .;
  22. /* Then the rest */
  23. TEXT_TEXT
  24. SCHED_TEXT
  25. LOCK_TEXT
  26. KPROBES_TEXT
  27. IRQENTRY_TEXT
  28. *(.fixup)
  29. *(.gnu.warning)
  30. /* End of text section */
  31. _etext = .;
  32. } :text = 0x9090
  33. NOTES :text :note
  34. /* Exception table */
  35. . = ALIGN(16);
  36. __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
  37. __start___ex_table = .;
  38. *(__ex_table)
  39. __stop___ex_table = .;
  40. } :text = 0x9090
  41. RODATA
  42. /* Align data segment to page size boundary */
  43. . = ALIGN(PAGE_SIZE);
  44. /* Data */
  45. .data : AT(ADDR(.data) - LOAD_OFFSET) {
  46. DATA_DATA
  47. CONSTRUCTORS
  48. /* End of data section */
  49. _edata = .;
  50. } :data
  51. .data.cacheline_aligned :
  52. AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
  53. . = ALIGN(PAGE_SIZE);
  54. . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
  55. *(.data.cacheline_aligned)
  56. }
  57. . = ALIGN(CONFIG_X86_INTERNODE_CACHE_BYTES);
  58. .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
  59. *(.data.read_mostly)
  60. }
  61. #define VSYSCALL_ADDR (-10*1024*1024)
  62. #define VSYSCALL_PHYS_ADDR ((LOADADDR(.data.read_mostly) + \
  63. SIZEOF(.data.read_mostly) + 4095) & ~(4095))
  64. #define VSYSCALL_VIRT_ADDR ((ADDR(.data.read_mostly) + \
  65. SIZEOF(.data.read_mostly) + 4095) & ~(4095))
  66. #define VLOAD_OFFSET (VSYSCALL_ADDR - VSYSCALL_PHYS_ADDR)
  67. #define VLOAD(x) (ADDR(x) - VLOAD_OFFSET)
  68. #define VVIRT_OFFSET (VSYSCALL_ADDR - VSYSCALL_VIRT_ADDR)
  69. #define VVIRT(x) (ADDR(x) - VVIRT_OFFSET)
  70. . = VSYSCALL_ADDR;
  71. .vsyscall_0 : AT(VSYSCALL_PHYS_ADDR) {
  72. *(.vsyscall_0)
  73. } :user
  74. __vsyscall_0 = VSYSCALL_VIRT_ADDR;
  75. . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
  76. .vsyscall_fn : AT(VLOAD(.vsyscall_fn)) {
  77. *(.vsyscall_fn)
  78. }
  79. . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
  80. .vsyscall_gtod_data : AT(VLOAD(.vsyscall_gtod_data)) {
  81. *(.vsyscall_gtod_data)
  82. }
  83. vsyscall_gtod_data = VVIRT(.vsyscall_gtod_data);
  84. .vsyscall_clock : AT(VLOAD(.vsyscall_clock)) {
  85. *(.vsyscall_clock)
  86. }
  87. vsyscall_clock = VVIRT(.vsyscall_clock);
  88. .vsyscall_1 ADDR(.vsyscall_0) + 1024: AT(VLOAD(.vsyscall_1)) {
  89. *(.vsyscall_1)
  90. }
  91. .vsyscall_2 ADDR(.vsyscall_0) + 2048: AT(VLOAD(.vsyscall_2)) {
  92. *(.vsyscall_2)
  93. }
  94. .vgetcpu_mode : AT(VLOAD(.vgetcpu_mode)) {
  95. *(.vgetcpu_mode)
  96. }
  97. vgetcpu_mode = VVIRT(.vgetcpu_mode);
  98. . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
  99. .jiffies : AT(VLOAD(.jiffies)) {
  100. *(.jiffies)
  101. }
  102. jiffies = VVIRT(.jiffies);
  103. .vsyscall_3 ADDR(.vsyscall_0) + 3072: AT(VLOAD(.vsyscall_3)) {
  104. *(.vsyscall_3)
  105. }
  106. . = VSYSCALL_VIRT_ADDR + PAGE_SIZE;
  107. #undef VSYSCALL_ADDR
  108. #undef VSYSCALL_PHYS_ADDR
  109. #undef VSYSCALL_VIRT_ADDR
  110. #undef VLOAD_OFFSET
  111. #undef VLOAD
  112. #undef VVIRT_OFFSET
  113. #undef VVIRT
  114. /* init_task */
  115. .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
  116. . = ALIGN(THREAD_SIZE);
  117. *(.data.init_task)
  118. } :data.init
  119. .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
  120. . = ALIGN(PAGE_SIZE);
  121. *(.data.page_aligned)
  122. }
  123. .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
  124. /* might get freed after init */
  125. . = ALIGN(PAGE_SIZE);
  126. __smp_alt_begin = .;
  127. __smp_locks = .;
  128. *(.smp_locks)
  129. __smp_locks_end = .;
  130. . = ALIGN(PAGE_SIZE);
  131. __smp_alt_end = .;
  132. }
  133. /* Init code and data */
  134. . = ALIGN(PAGE_SIZE);
  135. __init_begin = .; /* paired with __init_end */
  136. .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
  137. _sinittext = .;
  138. INIT_TEXT
  139. _einittext = .;
  140. }
  141. .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
  142. __initdata_begin = .;
  143. INIT_DATA
  144. __initdata_end = .;
  145. }
  146. .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
  147. . = ALIGN(16);
  148. __setup_start = .;
  149. *(.init.setup)
  150. __setup_end = .;
  151. }
  152. .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
  153. __initcall_start = .;
  154. INITCALLS
  155. __initcall_end = .;
  156. }
  157. .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
  158. __con_initcall_start = .;
  159. *(.con_initcall.init)
  160. __con_initcall_end = .;
  161. }
  162. .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
  163. __x86_cpu_dev_start = .;
  164. *(.x86_cpu_dev.init)
  165. __x86_cpu_dev_end = .;
  166. }
  167. SECURITY_INIT
  168. . = ALIGN(8);
  169. .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) {
  170. __parainstructions = .;
  171. *(.parainstructions)
  172. __parainstructions_end = .;
  173. }
  174. .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
  175. . = ALIGN(8);
  176. __alt_instructions = .;
  177. *(.altinstructions)
  178. __alt_instructions_end = .;
  179. }
  180. .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) {
  181. *(.altinstr_replacement)
  182. }
  183. /*
  184. * .exit.text is discard at runtime, not link time, to deal with
  185. * references from .altinstructions and .eh_frame
  186. */
  187. .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
  188. EXIT_TEXT
  189. }
  190. .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
  191. EXIT_DATA
  192. }
  193. #ifdef CONFIG_BLK_DEV_INITRD
  194. . = ALIGN(PAGE_SIZE);
  195. .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
  196. __initramfs_start = .;
  197. *(.init.ramfs)
  198. __initramfs_end = .;
  199. }
  200. #endif
  201. #ifdef CONFIG_SMP
  202. /*
  203. * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
  204. * output PHDR, so the next output section - __data_nosave - should
  205. * start another section data.init2. Also, pda should be at the head of
  206. * percpu area. Preallocate it and define the percpu offset symbol
  207. * so that it can be accessed as a percpu variable.
  208. */
  209. . = ALIGN(PAGE_SIZE);
  210. PERCPU_VADDR(0, :percpu)
  211. #else
  212. PERCPU(PAGE_SIZE)
  213. #endif
  214. . = ALIGN(PAGE_SIZE);
  215. __init_end = .;
  216. .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
  217. . = ALIGN(PAGE_SIZE);
  218. __nosave_begin = .;
  219. *(.data.nosave)
  220. . = ALIGN(PAGE_SIZE);
  221. __nosave_end = .;
  222. } :data.init2
  223. /* use another section data.init2, see PERCPU_VADDR() above */
  224. .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
  225. . = ALIGN(PAGE_SIZE);
  226. __bss_start = .; /* BSS */
  227. *(.bss.page_aligned)
  228. *(.bss)
  229. __bss_stop = .;
  230. }
  231. .brk : AT(ADDR(.brk) - LOAD_OFFSET) {
  232. . = ALIGN(PAGE_SIZE);
  233. __brk_base = .;
  234. . += 64 * 1024; /* 64k alignment slop space */
  235. *(.brk_reservation) /* areas brk users have reserved */
  236. __brk_limit = .;
  237. }
  238. _end = . ;
  239. /* Sections to be discarded */
  240. /DISCARD/ : {
  241. *(.exitcall.exit)
  242. *(.eh_frame)
  243. *(.discard)
  244. }
  245. STABS_DEBUG
  246. DWARF_DEBUG
  247. }