vmlinux.lds.S 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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. . = 0;
  37. reloc_start = .;
  38. . = KERNELBASE;
  39. /*
  40. * Text, read only data and other permanent read-only sections
  41. */
  42. /* Text and gots */
  43. .text : AT(ADDR(.text) - LOAD_OFFSET) {
  44. ALIGN_FUNCTION();
  45. HEAD_TEXT
  46. _text = .;
  47. /* careful! __ftr_alt_* sections need to be close to .text */
  48. *(.text .fixup __ftr_alt_* .ref.text)
  49. SCHED_TEXT
  50. LOCK_TEXT
  51. KPROBES_TEXT
  52. IRQENTRY_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_TABLE(0)
  66. NOTES :kernel :notes
  67. /* The dummy segment contents for the bug workaround mentioned above
  68. near PHDRS. */
  69. .dummy : AT(ADDR(.dummy) - LOAD_OFFSET) {
  70. LONG(0)
  71. LONG(0)
  72. LONG(0)
  73. } :kernel :dummy
  74. /*
  75. * Init sections discarded at runtime
  76. */
  77. . = ALIGN(PAGE_SIZE);
  78. __init_begin = .;
  79. INIT_TEXT_SECTION(PAGE_SIZE) :kernel
  80. /* .exit.text is discarded at runtime, not link time,
  81. * to deal with references from __bug_table
  82. */
  83. .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
  84. EXIT_TEXT
  85. }
  86. .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
  87. INIT_DATA
  88. __vtop_table_begin = .;
  89. *(.vtop_fixup);
  90. __vtop_table_end = .;
  91. __ptov_table_begin = .;
  92. *(.ptov_fixup);
  93. __ptov_table_end = .;
  94. }
  95. .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
  96. INIT_SETUP(16)
  97. }
  98. .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
  99. INIT_CALLS
  100. }
  101. .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
  102. CON_INITCALL
  103. }
  104. SECURITY_INIT
  105. . = ALIGN(8);
  106. __ftr_fixup : AT(ADDR(__ftr_fixup) - LOAD_OFFSET) {
  107. __start___ftr_fixup = .;
  108. *(__ftr_fixup)
  109. __stop___ftr_fixup = .;
  110. }
  111. . = ALIGN(8);
  112. __mmu_ftr_fixup : AT(ADDR(__mmu_ftr_fixup) - LOAD_OFFSET) {
  113. __start___mmu_ftr_fixup = .;
  114. *(__mmu_ftr_fixup)
  115. __stop___mmu_ftr_fixup = .;
  116. }
  117. . = ALIGN(8);
  118. __lwsync_fixup : AT(ADDR(__lwsync_fixup) - LOAD_OFFSET) {
  119. __start___lwsync_fixup = .;
  120. *(__lwsync_fixup)
  121. __stop___lwsync_fixup = .;
  122. }
  123. #ifdef CONFIG_PPC64
  124. . = ALIGN(8);
  125. __fw_ftr_fixup : AT(ADDR(__fw_ftr_fixup) - LOAD_OFFSET) {
  126. __start___fw_ftr_fixup = .;
  127. *(__fw_ftr_fixup)
  128. __stop___fw_ftr_fixup = .;
  129. }
  130. #endif
  131. .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
  132. INIT_RAM_FS
  133. }
  134. PERCPU_SECTION(L1_CACHE_BYTES)
  135. . = ALIGN(8);
  136. .machine.desc : AT(ADDR(.machine.desc) - LOAD_OFFSET) {
  137. __machine_desc_start = . ;
  138. *(.machine.desc)
  139. __machine_desc_end = . ;
  140. }
  141. #ifdef CONFIG_RELOCATABLE
  142. . = ALIGN(8);
  143. .dynsym : AT(ADDR(.dynsym) - LOAD_OFFSET)
  144. {
  145. #ifdef CONFIG_RELOCATABLE_PPC32
  146. __dynamic_symtab = .;
  147. #endif
  148. *(.dynsym)
  149. }
  150. .dynstr : AT(ADDR(.dynstr) - LOAD_OFFSET) { *(.dynstr) }
  151. .dynamic : AT(ADDR(.dynamic) - LOAD_OFFSET)
  152. {
  153. __dynamic_start = .;
  154. *(.dynamic)
  155. }
  156. .hash : AT(ADDR(.hash) - LOAD_OFFSET) { *(.hash) }
  157. .interp : AT(ADDR(.interp) - LOAD_OFFSET) { *(.interp) }
  158. .rela.dyn : AT(ADDR(.rela.dyn) - LOAD_OFFSET)
  159. {
  160. __rela_dyn_start = .;
  161. *(.rela*)
  162. }
  163. #endif
  164. /* freed after init ends here */
  165. . = ALIGN(PAGE_SIZE);
  166. __init_end = .;
  167. /*
  168. * And now the various read/write data
  169. */
  170. . = ALIGN(PAGE_SIZE);
  171. _sdata = .;
  172. #ifdef CONFIG_PPC32
  173. .data : AT(ADDR(.data) - LOAD_OFFSET) {
  174. DATA_DATA
  175. *(.sdata)
  176. *(.got.plt) *(.got)
  177. }
  178. #else
  179. .data : AT(ADDR(.data) - LOAD_OFFSET) {
  180. DATA_DATA
  181. *(.data.rel*)
  182. *(.toc1)
  183. *(.branch_lt)
  184. }
  185. .opd : AT(ADDR(.opd) - LOAD_OFFSET) {
  186. *(.opd)
  187. }
  188. .got : AT(ADDR(.got) - LOAD_OFFSET) {
  189. __toc_start = .;
  190. *(.got)
  191. *(.toc)
  192. }
  193. #endif
  194. /* The initial task and kernel stack */
  195. INIT_TASK_DATA_SECTION(THREAD_SIZE)
  196. .data..page_aligned : AT(ADDR(.data..page_aligned) - LOAD_OFFSET) {
  197. PAGE_ALIGNED_DATA(PAGE_SIZE)
  198. }
  199. .data..cacheline_aligned : AT(ADDR(.data..cacheline_aligned) - LOAD_OFFSET) {
  200. CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES)
  201. }
  202. .data..read_mostly : AT(ADDR(.data..read_mostly) - LOAD_OFFSET) {
  203. READ_MOSTLY_DATA(L1_CACHE_BYTES)
  204. }
  205. . = ALIGN(PAGE_SIZE);
  206. .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
  207. NOSAVE_DATA
  208. }
  209. . = ALIGN(PAGE_SIZE);
  210. _edata = .;
  211. PROVIDE32 (edata = .);
  212. /*
  213. * And finally the bss
  214. */
  215. BSS_SECTION(0, 0, 0)
  216. . = ALIGN(PAGE_SIZE);
  217. _end = . ;
  218. PROVIDE32 (end = .);
  219. /* Sections to be discarded. */
  220. DISCARDS
  221. }