vmlinux.lds.S 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. #ifdef CONFIG_PPC64
  2. #define PROVIDE32(x) PROVIDE(__unused__##x)
  3. #else
  4. #define PROVIDE32(x) PROVIDE(x)
  5. #endif
  6. #include <asm/page.h>
  7. #include <asm-generic/vmlinux.lds.h>
  8. #include <asm/cache.h>
  9. ENTRY(_stext)
  10. PHDRS {
  11. kernel PT_LOAD FLAGS(7); /* RWX */
  12. notes PT_NOTE FLAGS(0);
  13. dummy PT_NOTE FLAGS(0);
  14. /* binutils < 2.18 has a bug that makes it misbehave when taking an
  15. ELF file with all segments at load address 0 as input. This
  16. happens when running "strip" on vmlinux, because of the AT() magic
  17. in this linker script. People using GCC >= 4.2 won't run into
  18. this problem, because the "build-id" support will put some data
  19. into the "notes" segment (at a non-zero load address).
  20. To work around this, we force some data into both the "dummy"
  21. segment and the kernel segment, so the dummy segment will get a
  22. non-zero load address. It's not enough to always create the
  23. "notes" segment, since if nothing gets assigned to it, its load
  24. address will be zero. */
  25. }
  26. #ifdef CONFIG_PPC64
  27. OUTPUT_ARCH(powerpc:common64)
  28. jiffies = jiffies_64;
  29. #else
  30. OUTPUT_ARCH(powerpc:common)
  31. jiffies = jiffies_64 + 4;
  32. #endif
  33. SECTIONS
  34. {
  35. /* Sections to be discarded. */
  36. /DISCARD/ : {
  37. *(.exitcall.exit)
  38. EXIT_DATA
  39. }
  40. . = KERNELBASE;
  41. /*
  42. * Text, read only data and other permanent read-only sections
  43. */
  44. /* Text and gots */
  45. .text : AT(ADDR(.text) - LOAD_OFFSET) {
  46. ALIGN_FUNCTION();
  47. *(.text.head)
  48. _text = .;
  49. *(.text .fixup .text.init.refok .exit.text.refok __ftr_alt_*)
  50. SCHED_TEXT
  51. LOCK_TEXT
  52. KPROBES_TEXT
  53. #ifdef CONFIG_PPC32
  54. *(.got1)
  55. __got2_start = .;
  56. *(.got2)
  57. __got2_end = .;
  58. #endif /* CONFIG_PPC32 */
  59. } :kernel
  60. . = ALIGN(PAGE_SIZE);
  61. _etext = .;
  62. PROVIDE32 (etext = .);
  63. /* Read-only data */
  64. RODATA
  65. /* Exception & bug tables */
  66. __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
  67. __start___ex_table = .;
  68. *(__ex_table)
  69. __stop___ex_table = .;
  70. }
  71. NOTES :kernel :notes
  72. /* The dummy segment contents for the bug workaround mentioned above
  73. near PHDRS. */
  74. .dummy : AT(ADDR(.dummy) - LOAD_OFFSET) {
  75. LONG(0xf177)
  76. } :kernel :dummy
  77. /*
  78. * Init sections discarded at runtime
  79. */
  80. . = ALIGN(PAGE_SIZE);
  81. __init_begin = .;
  82. .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
  83. _sinittext = .;
  84. INIT_TEXT
  85. _einittext = .;
  86. } :kernel
  87. /* .exit.text is discarded at runtime, not link time,
  88. * to deal with references from __bug_table
  89. */
  90. .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
  91. EXIT_TEXT
  92. }
  93. .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
  94. INIT_DATA
  95. __vtop_table_begin = .;
  96. *(.vtop_fixup);
  97. __vtop_table_end = .;
  98. __ptov_table_begin = .;
  99. *(.ptov_fixup);
  100. __ptov_table_end = .;
  101. #ifdef CONFIG_PPC_ISERIES
  102. __dt_strings_start = .;
  103. *(.dt_strings);
  104. __dt_strings_end = .;
  105. #endif
  106. }
  107. . = ALIGN(16);
  108. .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
  109. __setup_start = .;
  110. *(.init.setup)
  111. __setup_end = .;
  112. }
  113. .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
  114. __initcall_start = .;
  115. INITCALLS
  116. __initcall_end = .;
  117. }
  118. .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
  119. __con_initcall_start = .;
  120. *(.con_initcall.init)
  121. __con_initcall_end = .;
  122. }
  123. SECURITY_INIT
  124. . = ALIGN(8);
  125. __ftr_fixup : AT(ADDR(__ftr_fixup) - LOAD_OFFSET) {
  126. __start___ftr_fixup = .;
  127. *(__ftr_fixup)
  128. __stop___ftr_fixup = .;
  129. }
  130. . = ALIGN(8);
  131. __lwsync_fixup : AT(ADDR(__lwsync_fixup) - LOAD_OFFSET) {
  132. __start___lwsync_fixup = .;
  133. *(__lwsync_fixup)
  134. __stop___lwsync_fixup = .;
  135. }
  136. #ifdef CONFIG_PPC64
  137. . = ALIGN(8);
  138. __fw_ftr_fixup : AT(ADDR(__fw_ftr_fixup) - LOAD_OFFSET) {
  139. __start___fw_ftr_fixup = .;
  140. *(__fw_ftr_fixup)
  141. __stop___fw_ftr_fixup = .;
  142. }
  143. #endif
  144. #ifdef CONFIG_BLK_DEV_INITRD
  145. . = ALIGN(PAGE_SIZE);
  146. .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
  147. __initramfs_start = .;
  148. *(.init.ramfs)
  149. __initramfs_end = .;
  150. }
  151. #endif
  152. . = ALIGN(PAGE_SIZE);
  153. .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) {
  154. __per_cpu_start = .;
  155. *(.data.percpu)
  156. *(.data.percpu.shared_aligned)
  157. __per_cpu_end = .;
  158. }
  159. . = ALIGN(8);
  160. .machine.desc : AT(ADDR(.machine.desc) - LOAD_OFFSET) {
  161. __machine_desc_start = . ;
  162. *(.machine.desc)
  163. __machine_desc_end = . ;
  164. }
  165. /* freed after init ends here */
  166. . = ALIGN(PAGE_SIZE);
  167. __init_end = .;
  168. /*
  169. * And now the various read/write data
  170. */
  171. . = ALIGN(PAGE_SIZE);
  172. _sdata = .;
  173. #ifdef CONFIG_PPC32
  174. .data : AT(ADDR(.data) - LOAD_OFFSET) {
  175. DATA_DATA
  176. *(.sdata)
  177. *(.got.plt) *(.got)
  178. }
  179. #else
  180. .data : AT(ADDR(.data) - LOAD_OFFSET) {
  181. DATA_DATA
  182. *(.data.rel*)
  183. *(.toc1)
  184. *(.branch_lt)
  185. }
  186. .opd : AT(ADDR(.opd) - LOAD_OFFSET) {
  187. *(.opd)
  188. }
  189. .got : AT(ADDR(.got) - LOAD_OFFSET) {
  190. __toc_start = .;
  191. *(.got)
  192. *(.toc)
  193. }
  194. #endif
  195. . = ALIGN(PAGE_SIZE);
  196. _edata = .;
  197. PROVIDE32 (edata = .);
  198. /* The initial task and kernel stack */
  199. #ifdef CONFIG_PPC32
  200. . = ALIGN(8192);
  201. #else
  202. . = ALIGN(16384);
  203. #endif
  204. .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
  205. *(.data.init_task)
  206. }
  207. . = ALIGN(PAGE_SIZE);
  208. .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
  209. *(.data.page_aligned)
  210. }
  211. .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
  212. *(.data.cacheline_aligned)
  213. }
  214. . = ALIGN(L1_CACHE_BYTES);
  215. .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
  216. *(.data.read_mostly)
  217. }
  218. . = ALIGN(PAGE_SIZE);
  219. .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
  220. __nosave_begin = .;
  221. *(.data.nosave)
  222. . = ALIGN(PAGE_SIZE);
  223. __nosave_end = .;
  224. }
  225. /*
  226. * And finally the bss
  227. */
  228. .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
  229. __bss_start = .;
  230. *(.sbss) *(.scommon)
  231. *(.dynbss)
  232. *(.bss)
  233. *(COMMON)
  234. __bss_stop = .;
  235. }
  236. . = ALIGN(PAGE_SIZE);
  237. _end = . ;
  238. PROVIDE32 (end = .);
  239. }