vmlinux.lds.S 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifdef CONFIG_PPC64
  3. #define PROVIDE32(x) PROVIDE(__unused__##x)
  4. #else
  5. #define PROVIDE32(x) PROVIDE(x)
  6. #endif
  7. #include <asm/page.h>
  8. #include <asm-generic/vmlinux.lds.h>
  9. #include <asm/cache.h>
  10. #include <asm/thread_info.h>
  11. #if defined(CONFIG_STRICT_KERNEL_RWX) && !defined(CONFIG_PPC32)
  12. #define STRICT_ALIGN_SIZE (1 << 24)
  13. #else
  14. #define STRICT_ALIGN_SIZE PAGE_SIZE
  15. #endif
  16. ENTRY(_stext)
  17. PHDRS {
  18. kernel PT_LOAD FLAGS(7); /* RWX */
  19. notes PT_NOTE FLAGS(0);
  20. dummy PT_NOTE FLAGS(0);
  21. /* binutils < 2.18 has a bug that makes it misbehave when taking an
  22. ELF file with all segments at load address 0 as input. This
  23. happens when running "strip" on vmlinux, because of the AT() magic
  24. in this linker script. People using GCC >= 4.2 won't run into
  25. this problem, because the "build-id" support will put some data
  26. into the "notes" segment (at a non-zero load address).
  27. To work around this, we force some data into both the "dummy"
  28. segment and the kernel segment, so the dummy segment will get a
  29. non-zero load address. It's not enough to always create the
  30. "notes" segment, since if nothing gets assigned to it, its load
  31. address will be zero. */
  32. }
  33. #ifdef CONFIG_PPC64
  34. OUTPUT_ARCH(powerpc:common64)
  35. jiffies = jiffies_64;
  36. #else
  37. OUTPUT_ARCH(powerpc:common)
  38. jiffies = jiffies_64 + 4;
  39. #endif
  40. SECTIONS
  41. {
  42. . = KERNELBASE;
  43. /*
  44. * Text, read only data and other permanent read-only sections
  45. */
  46. _text = .;
  47. _stext = .;
  48. /*
  49. * Head text.
  50. * This needs to be in its own output section to avoid ld placing
  51. * branch trampoline stubs randomly throughout the fixed sections,
  52. * which it will do (even if the branch comes from another section)
  53. * in order to optimize stub generation.
  54. */
  55. .head.text : AT(ADDR(.head.text) - LOAD_OFFSET) {
  56. #ifdef CONFIG_PPC64
  57. KEEP(*(.head.text.first_256B));
  58. #ifdef CONFIG_PPC_BOOK3E
  59. #else
  60. KEEP(*(.head.text.real_vectors));
  61. *(.head.text.real_trampolines);
  62. KEEP(*(.head.text.virt_vectors));
  63. *(.head.text.virt_trampolines);
  64. # if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV)
  65. KEEP(*(.head.data.fwnmi_page));
  66. # endif
  67. #endif
  68. #else /* !CONFIG_PPC64 */
  69. HEAD_TEXT
  70. #endif
  71. } :kernel
  72. __head_end = .;
  73. #ifdef CONFIG_PPC64
  74. /*
  75. * BLOCK(0) overrides the default output section alignment because
  76. * this needs to start right after .head.text in order for fixed
  77. * section placement to work.
  78. */
  79. .text BLOCK(0) : AT(ADDR(.text) - LOAD_OFFSET) {
  80. #ifdef CONFIG_LD_HEAD_STUB_CATCH
  81. *(.linker_stub_catch);
  82. . = . ;
  83. #endif
  84. #else
  85. .text : AT(ADDR(.text) - LOAD_OFFSET) {
  86. ALIGN_FUNCTION();
  87. #endif
  88. /* careful! __ftr_alt_* sections need to be close to .text */
  89. *(.text.hot .text .text.fixup .text.unlikely .fixup __ftr_alt_* .ref.text);
  90. SCHED_TEXT
  91. CPUIDLE_TEXT
  92. LOCK_TEXT
  93. KPROBES_TEXT
  94. IRQENTRY_TEXT
  95. SOFTIRQENTRY_TEXT
  96. /*
  97. * -Os builds call FP save/restore functions. The powerpc64
  98. * linker generates those on demand in the .sfpr section.
  99. * .sfpr gets placed at the beginning of a group of input
  100. * sections, which can break start-of-text offset if it is
  101. * included with the main text sections, so put it by itself.
  102. */
  103. *(.sfpr);
  104. MEM_KEEP(init.text)
  105. MEM_KEEP(exit.text)
  106. #ifdef CONFIG_PPC32
  107. *(.got1)
  108. __got2_start = .;
  109. *(.got2)
  110. __got2_end = .;
  111. #endif /* CONFIG_PPC32 */
  112. } :kernel
  113. . = ALIGN(PAGE_SIZE);
  114. _etext = .;
  115. PROVIDE32 (etext = .);
  116. /* Read-only data */
  117. RO_DATA(PAGE_SIZE)
  118. #ifdef CONFIG_PPC64
  119. . = ALIGN(8);
  120. __stf_entry_barrier_fixup : AT(ADDR(__stf_entry_barrier_fixup) - LOAD_OFFSET) {
  121. __start___stf_entry_barrier_fixup = .;
  122. *(__stf_entry_barrier_fixup)
  123. __stop___stf_entry_barrier_fixup = .;
  124. }
  125. . = ALIGN(8);
  126. __stf_exit_barrier_fixup : AT(ADDR(__stf_exit_barrier_fixup) - LOAD_OFFSET) {
  127. __start___stf_exit_barrier_fixup = .;
  128. *(__stf_exit_barrier_fixup)
  129. __stop___stf_exit_barrier_fixup = .;
  130. }
  131. . = ALIGN(8);
  132. __rfi_flush_fixup : AT(ADDR(__rfi_flush_fixup) - LOAD_OFFSET) {
  133. __start___rfi_flush_fixup = .;
  134. *(__rfi_flush_fixup)
  135. __stop___rfi_flush_fixup = .;
  136. }
  137. #endif
  138. EXCEPTION_TABLE(0)
  139. NOTES :kernel :notes
  140. /* The dummy segment contents for the bug workaround mentioned above
  141. near PHDRS. */
  142. .dummy : AT(ADDR(.dummy) - LOAD_OFFSET) {
  143. LONG(0)
  144. LONG(0)
  145. LONG(0)
  146. } :kernel :dummy
  147. /*
  148. * Init sections discarded at runtime
  149. */
  150. . = ALIGN(STRICT_ALIGN_SIZE);
  151. __init_begin = .;
  152. INIT_TEXT_SECTION(PAGE_SIZE) :kernel
  153. /* .exit.text is discarded at runtime, not link time,
  154. * to deal with references from __bug_table
  155. */
  156. .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
  157. EXIT_TEXT
  158. }
  159. .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
  160. INIT_DATA
  161. __vtop_table_begin = .;
  162. *(.vtop_fixup);
  163. __vtop_table_end = .;
  164. __ptov_table_begin = .;
  165. *(.ptov_fixup);
  166. __ptov_table_end = .;
  167. }
  168. .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
  169. INIT_SETUP(16)
  170. }
  171. .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
  172. INIT_CALLS
  173. }
  174. .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
  175. CON_INITCALL
  176. }
  177. SECURITY_INIT
  178. . = ALIGN(8);
  179. __ftr_fixup : AT(ADDR(__ftr_fixup) - LOAD_OFFSET) {
  180. __start___ftr_fixup = .;
  181. *(__ftr_fixup)
  182. __stop___ftr_fixup = .;
  183. }
  184. . = ALIGN(8);
  185. __mmu_ftr_fixup : AT(ADDR(__mmu_ftr_fixup) - LOAD_OFFSET) {
  186. __start___mmu_ftr_fixup = .;
  187. *(__mmu_ftr_fixup)
  188. __stop___mmu_ftr_fixup = .;
  189. }
  190. . = ALIGN(8);
  191. __lwsync_fixup : AT(ADDR(__lwsync_fixup) - LOAD_OFFSET) {
  192. __start___lwsync_fixup = .;
  193. *(__lwsync_fixup)
  194. __stop___lwsync_fixup = .;
  195. }
  196. #ifdef CONFIG_PPC64
  197. . = ALIGN(8);
  198. __fw_ftr_fixup : AT(ADDR(__fw_ftr_fixup) - LOAD_OFFSET) {
  199. __start___fw_ftr_fixup = .;
  200. *(__fw_ftr_fixup)
  201. __stop___fw_ftr_fixup = .;
  202. }
  203. #endif
  204. .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
  205. INIT_RAM_FS
  206. }
  207. PERCPU_SECTION(L1_CACHE_BYTES)
  208. . = ALIGN(8);
  209. .machine.desc : AT(ADDR(.machine.desc) - LOAD_OFFSET) {
  210. __machine_desc_start = . ;
  211. *(.machine.desc)
  212. __machine_desc_end = . ;
  213. }
  214. #ifdef CONFIG_RELOCATABLE
  215. . = ALIGN(8);
  216. .dynsym : AT(ADDR(.dynsym) - LOAD_OFFSET)
  217. {
  218. #ifdef CONFIG_PPC32
  219. __dynamic_symtab = .;
  220. #endif
  221. *(.dynsym)
  222. }
  223. .dynstr : AT(ADDR(.dynstr) - LOAD_OFFSET) { *(.dynstr) }
  224. .dynamic : AT(ADDR(.dynamic) - LOAD_OFFSET)
  225. {
  226. __dynamic_start = .;
  227. *(.dynamic)
  228. }
  229. .hash : AT(ADDR(.hash) - LOAD_OFFSET) { *(.hash) }
  230. .interp : AT(ADDR(.interp) - LOAD_OFFSET) { *(.interp) }
  231. .rela.dyn : AT(ADDR(.rela.dyn) - LOAD_OFFSET)
  232. {
  233. __rela_dyn_start = .;
  234. *(.rela*)
  235. }
  236. #endif
  237. /* .exit.data is discarded at runtime, not link time,
  238. * to deal with references from .exit.text
  239. */
  240. .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
  241. EXIT_DATA
  242. }
  243. /* freed after init ends here */
  244. . = ALIGN(PAGE_SIZE);
  245. __init_end = .;
  246. /*
  247. * And now the various read/write data
  248. */
  249. . = ALIGN(PAGE_SIZE);
  250. _sdata = .;
  251. #ifdef CONFIG_PPC32
  252. .data : AT(ADDR(.data) - LOAD_OFFSET) {
  253. DATA_DATA
  254. *(.data.rel*)
  255. *(.sdata)
  256. *(.sdata2)
  257. *(.got.plt) *(.got)
  258. *(.plt)
  259. }
  260. #else
  261. .data : AT(ADDR(.data) - LOAD_OFFSET) {
  262. DATA_DATA
  263. *(.data.rel*)
  264. *(.toc1)
  265. *(.branch_lt)
  266. }
  267. .opd : AT(ADDR(.opd) - LOAD_OFFSET) {
  268. __start_opd = .;
  269. *(.opd)
  270. __end_opd = .;
  271. }
  272. . = ALIGN(256);
  273. .got : AT(ADDR(.got) - LOAD_OFFSET) {
  274. __toc_start = .;
  275. #ifndef CONFIG_RELOCATABLE
  276. __prom_init_toc_start = .;
  277. arch/powerpc/kernel/prom_init.o*(.toc .got)
  278. __prom_init_toc_end = .;
  279. #endif
  280. *(.got)
  281. *(.toc)
  282. }
  283. #endif
  284. /* The initial task and kernel stack */
  285. INIT_TASK_DATA_SECTION(THREAD_SIZE)
  286. .data..page_aligned : AT(ADDR(.data..page_aligned) - LOAD_OFFSET) {
  287. PAGE_ALIGNED_DATA(PAGE_SIZE)
  288. }
  289. .data..cacheline_aligned : AT(ADDR(.data..cacheline_aligned) - LOAD_OFFSET) {
  290. CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES)
  291. }
  292. .data..read_mostly : AT(ADDR(.data..read_mostly) - LOAD_OFFSET) {
  293. READ_MOSTLY_DATA(L1_CACHE_BYTES)
  294. }
  295. . = ALIGN(PAGE_SIZE);
  296. .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
  297. NOSAVE_DATA
  298. }
  299. BUG_TABLE
  300. . = ALIGN(PAGE_SIZE);
  301. _edata = .;
  302. PROVIDE32 (edata = .);
  303. /*
  304. * And finally the bss
  305. */
  306. BSS_SECTION(0, 0, 0)
  307. . = ALIGN(PAGE_SIZE);
  308. _end = . ;
  309. PROVIDE32 (end = .);
  310. STABS_DEBUG
  311. DWARF_DEBUG
  312. DISCARDS
  313. /DISCARD/ : {
  314. *(*.EMB.apuinfo)
  315. *(.glink .iplt .plt .rela* .comment)
  316. *(.gnu.version*)
  317. *(.gnu.attributes)
  318. *(.eh_frame)
  319. }
  320. }