vmlinux.lds.S 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  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 = .;
  41. _stext = .;
  42. /*
  43. * Head text.
  44. * This needs to be in its own output section to avoid ld placing
  45. * branch trampoline stubs randomly throughout the fixed sections,
  46. * which it will do (even if the branch comes from another section)
  47. * in order to optimize stub generation.
  48. */
  49. .head.text : AT(ADDR(.head.text) - LOAD_OFFSET) {
  50. #ifdef CONFIG_PPC64
  51. KEEP(*(.head.text.first_256B));
  52. #ifdef CONFIG_PPC_BOOK3E
  53. # define END_FIXED 0x100
  54. #else
  55. KEEP(*(.head.text.real_vectors));
  56. *(.head.text.real_trampolines);
  57. KEEP(*(.head.text.virt_vectors));
  58. *(.head.text.virt_trampolines);
  59. # if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV)
  60. KEEP(*(.head.data.fwnmi_page));
  61. # define END_FIXED 0x8000
  62. # else
  63. # define END_FIXED 0x7000
  64. # endif
  65. #endif
  66. ASSERT((. == END_FIXED), "vmlinux.lds.S: fixed section overflow error");
  67. #else /* !CONFIG_PPC64 */
  68. HEAD_TEXT
  69. #endif
  70. } :kernel
  71. /*
  72. * If the build dies here, it's likely code in head_64.S is referencing
  73. * labels it can't reach, and the linker inserting stubs without the
  74. * assembler's knowledge. To debug, remove the above assert and
  75. * rebuild. Look for branch stubs in the fixed section region.
  76. *
  77. * Linker stub generation could be allowed in "trampoline"
  78. * sections if absolutely necessary, but this would require
  79. * some rework of the fixed sections. Before resorting to this,
  80. * consider references that have sufficient addressing range,
  81. * (e.g., hand coded trampolines) so the linker does not have
  82. * to add stubs.
  83. *
  84. * Linker stubs at the top of the main text section are currently not
  85. * detected, and will result in a crash at boot due to offsets being
  86. * wrong.
  87. */
  88. #ifdef CONFIG_PPC64
  89. /*
  90. * BLOCK(0) overrides the default output section alignment because
  91. * this needs to start right after .head.text in order for fixed
  92. * section placement to work.
  93. */
  94. .text BLOCK(0) : AT(ADDR(.text) - LOAD_OFFSET) {
  95. #else
  96. .text : AT(ADDR(.text) - LOAD_OFFSET) {
  97. ALIGN_FUNCTION();
  98. #endif
  99. /* careful! __ftr_alt_* sections need to be close to .text */
  100. *(.text .fixup __ftr_alt_* .ref.text)
  101. SCHED_TEXT
  102. CPUIDLE_TEXT
  103. LOCK_TEXT
  104. KPROBES_TEXT
  105. IRQENTRY_TEXT
  106. SOFTIRQENTRY_TEXT
  107. MEM_KEEP(init.text)
  108. MEM_KEEP(exit.text)
  109. #ifdef CONFIG_PPC32
  110. *(.got1)
  111. __got2_start = .;
  112. *(.got2)
  113. __got2_end = .;
  114. #endif /* CONFIG_PPC32 */
  115. } :kernel
  116. . = ALIGN(PAGE_SIZE);
  117. _etext = .;
  118. PROVIDE32 (etext = .);
  119. /* Read-only data */
  120. RODATA
  121. #ifdef CONFIG_PPC64
  122. . = ALIGN(8);
  123. __stf_entry_barrier_fixup : AT(ADDR(__stf_entry_barrier_fixup) - LOAD_OFFSET) {
  124. __start___stf_entry_barrier_fixup = .;
  125. *(__stf_entry_barrier_fixup)
  126. __stop___stf_entry_barrier_fixup = .;
  127. }
  128. . = ALIGN(8);
  129. __stf_exit_barrier_fixup : AT(ADDR(__stf_exit_barrier_fixup) - LOAD_OFFSET) {
  130. __start___stf_exit_barrier_fixup = .;
  131. *(__stf_exit_barrier_fixup)
  132. __stop___stf_exit_barrier_fixup = .;
  133. }
  134. . = ALIGN(8);
  135. __rfi_flush_fixup : AT(ADDR(__rfi_flush_fixup) - LOAD_OFFSET) {
  136. __start___rfi_flush_fixup = .;
  137. *(__rfi_flush_fixup)
  138. __stop___rfi_flush_fixup = .;
  139. }
  140. #endif /* CONFIG_PPC64 */
  141. #ifdef CONFIG_PPC_BARRIER_NOSPEC
  142. . = ALIGN(8);
  143. __spec_barrier_fixup : AT(ADDR(__spec_barrier_fixup) - LOAD_OFFSET) {
  144. __start___barrier_nospec_fixup = .;
  145. *(__barrier_nospec_fixup)
  146. __stop___barrier_nospec_fixup = .;
  147. }
  148. #endif /* CONFIG_PPC_BARRIER_NOSPEC */
  149. #ifdef CONFIG_PPC_FSL_BOOK3E
  150. . = ALIGN(8);
  151. __spec_btb_flush_fixup : AT(ADDR(__spec_btb_flush_fixup) - LOAD_OFFSET) {
  152. __start__btb_flush_fixup = .;
  153. *(__btb_flush_fixup)
  154. __stop__btb_flush_fixup = .;
  155. }
  156. #endif
  157. EXCEPTION_TABLE(0)
  158. NOTES :kernel :notes
  159. /* The dummy segment contents for the bug workaround mentioned above
  160. near PHDRS. */
  161. .dummy : AT(ADDR(.dummy) - LOAD_OFFSET) {
  162. LONG(0)
  163. LONG(0)
  164. LONG(0)
  165. } :kernel :dummy
  166. /*
  167. * Init sections discarded at runtime
  168. */
  169. . = ALIGN(PAGE_SIZE);
  170. __init_begin = .;
  171. INIT_TEXT_SECTION(PAGE_SIZE) :kernel
  172. /* .exit.text is discarded at runtime, not link time,
  173. * to deal with references from __bug_table
  174. */
  175. .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
  176. EXIT_TEXT
  177. }
  178. .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
  179. INIT_DATA
  180. __vtop_table_begin = .;
  181. *(.vtop_fixup);
  182. __vtop_table_end = .;
  183. __ptov_table_begin = .;
  184. *(.ptov_fixup);
  185. __ptov_table_end = .;
  186. }
  187. .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
  188. INIT_SETUP(16)
  189. }
  190. .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
  191. INIT_CALLS
  192. }
  193. .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
  194. CON_INITCALL
  195. }
  196. SECURITY_INIT
  197. . = ALIGN(8);
  198. __ftr_fixup : AT(ADDR(__ftr_fixup) - LOAD_OFFSET) {
  199. __start___ftr_fixup = .;
  200. *(__ftr_fixup)
  201. __stop___ftr_fixup = .;
  202. }
  203. . = ALIGN(8);
  204. __mmu_ftr_fixup : AT(ADDR(__mmu_ftr_fixup) - LOAD_OFFSET) {
  205. __start___mmu_ftr_fixup = .;
  206. *(__mmu_ftr_fixup)
  207. __stop___mmu_ftr_fixup = .;
  208. }
  209. . = ALIGN(8);
  210. __lwsync_fixup : AT(ADDR(__lwsync_fixup) - LOAD_OFFSET) {
  211. __start___lwsync_fixup = .;
  212. *(__lwsync_fixup)
  213. __stop___lwsync_fixup = .;
  214. }
  215. #ifdef CONFIG_PPC64
  216. . = ALIGN(8);
  217. __fw_ftr_fixup : AT(ADDR(__fw_ftr_fixup) - LOAD_OFFSET) {
  218. __start___fw_ftr_fixup = .;
  219. *(__fw_ftr_fixup)
  220. __stop___fw_ftr_fixup = .;
  221. }
  222. #endif
  223. .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
  224. INIT_RAM_FS
  225. }
  226. PERCPU_SECTION(L1_CACHE_BYTES)
  227. . = ALIGN(8);
  228. .machine.desc : AT(ADDR(.machine.desc) - LOAD_OFFSET) {
  229. __machine_desc_start = . ;
  230. *(.machine.desc)
  231. __machine_desc_end = . ;
  232. }
  233. #ifdef CONFIG_RELOCATABLE
  234. . = ALIGN(8);
  235. .dynsym : AT(ADDR(.dynsym) - LOAD_OFFSET)
  236. {
  237. #ifdef CONFIG_PPC32
  238. __dynamic_symtab = .;
  239. #endif
  240. *(.dynsym)
  241. }
  242. .dynstr : AT(ADDR(.dynstr) - LOAD_OFFSET) { *(.dynstr) }
  243. .dynamic : AT(ADDR(.dynamic) - LOAD_OFFSET)
  244. {
  245. __dynamic_start = .;
  246. *(.dynamic)
  247. }
  248. .hash : AT(ADDR(.hash) - LOAD_OFFSET) { *(.hash) }
  249. .interp : AT(ADDR(.interp) - LOAD_OFFSET) { *(.interp) }
  250. .rela.dyn : AT(ADDR(.rela.dyn) - LOAD_OFFSET)
  251. {
  252. __rela_dyn_start = .;
  253. *(.rela*)
  254. }
  255. #endif
  256. /* .exit.data is discarded at runtime, not link time,
  257. * to deal with references from .exit.text
  258. */
  259. .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
  260. EXIT_DATA
  261. }
  262. /* freed after init ends here */
  263. . = ALIGN(PAGE_SIZE);
  264. __init_end = .;
  265. /*
  266. * And now the various read/write data
  267. */
  268. . = ALIGN(PAGE_SIZE);
  269. _sdata = .;
  270. #ifdef CONFIG_PPC32
  271. .data : AT(ADDR(.data) - LOAD_OFFSET) {
  272. DATA_DATA
  273. *(.sdata)
  274. *(.got.plt) *(.got)
  275. }
  276. #else
  277. .data : AT(ADDR(.data) - LOAD_OFFSET) {
  278. DATA_DATA
  279. *(.data.rel*)
  280. *(.toc1)
  281. *(.branch_lt)
  282. }
  283. .opd : AT(ADDR(.opd) - LOAD_OFFSET) {
  284. *(.opd)
  285. }
  286. . = ALIGN(256);
  287. .got : AT(ADDR(.got) - LOAD_OFFSET) {
  288. __toc_start = .;
  289. #ifndef CONFIG_RELOCATABLE
  290. __prom_init_toc_start = .;
  291. arch/powerpc/kernel/prom_init.o*(.toc .got)
  292. __prom_init_toc_end = .;
  293. #endif
  294. *(.got)
  295. *(.toc)
  296. }
  297. #endif
  298. /* The initial task and kernel stack */
  299. INIT_TASK_DATA_SECTION(THREAD_SIZE)
  300. .data..page_aligned : AT(ADDR(.data..page_aligned) - LOAD_OFFSET) {
  301. PAGE_ALIGNED_DATA(PAGE_SIZE)
  302. }
  303. .data..cacheline_aligned : AT(ADDR(.data..cacheline_aligned) - LOAD_OFFSET) {
  304. CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES)
  305. }
  306. .data..read_mostly : AT(ADDR(.data..read_mostly) - LOAD_OFFSET) {
  307. READ_MOSTLY_DATA(L1_CACHE_BYTES)
  308. }
  309. . = ALIGN(PAGE_SIZE);
  310. .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
  311. NOSAVE_DATA
  312. }
  313. . = ALIGN(PAGE_SIZE);
  314. _edata = .;
  315. PROVIDE32 (edata = .);
  316. /*
  317. * And finally the bss
  318. */
  319. BSS_SECTION(0, 0, 0)
  320. . = ALIGN(PAGE_SIZE);
  321. _end = . ;
  322. PROVIDE32 (end = .);
  323. /* Sections to be discarded. */
  324. DISCARDS
  325. }