vmlinux.lds.S 5.8 KB

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