vmlinux.lds.S 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  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. KEEP(*(.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_MAIN .text.fixup .text.unlikely .fixup __ftr_alt_* .ref.text);
  90. NOINSTR_TEXT
  91. SCHED_TEXT
  92. CPUIDLE_TEXT
  93. LOCK_TEXT
  94. KPROBES_TEXT
  95. IRQENTRY_TEXT
  96. SOFTIRQENTRY_TEXT
  97. /*
  98. * -Os builds call FP save/restore functions. The powerpc64
  99. * linker generates those on demand in the .sfpr section.
  100. * .sfpr gets placed at the beginning of a group of input
  101. * sections, which can break start-of-text offset if it is
  102. * included with the main text sections, so put it by itself.
  103. */
  104. *(.sfpr);
  105. MEM_KEEP(init.text)
  106. MEM_KEEP(exit.text)
  107. #ifdef CONFIG_PPC32
  108. *(.got1)
  109. __got2_start = .;
  110. *(.got2)
  111. __got2_end = .;
  112. #endif /* CONFIG_PPC32 */
  113. } :kernel
  114. . = ALIGN(PAGE_SIZE);
  115. _etext = .;
  116. PROVIDE32 (etext = .);
  117. /* Read-only data */
  118. RO_DATA(PAGE_SIZE)
  119. #ifdef CONFIG_PPC64
  120. . = ALIGN(8);
  121. __stf_entry_barrier_fixup : AT(ADDR(__stf_entry_barrier_fixup) - LOAD_OFFSET) {
  122. __start___stf_entry_barrier_fixup = .;
  123. *(__stf_entry_barrier_fixup)
  124. __stop___stf_entry_barrier_fixup = .;
  125. }
  126. . = ALIGN(8);
  127. __uaccess_flush_fixup : AT(ADDR(__uaccess_flush_fixup) - LOAD_OFFSET) {
  128. __start___uaccess_flush_fixup = .;
  129. *(__uaccess_flush_fixup)
  130. __stop___uaccess_flush_fixup = .;
  131. }
  132. . = ALIGN(8);
  133. __entry_flush_fixup : AT(ADDR(__entry_flush_fixup) - LOAD_OFFSET) {
  134. __start___entry_flush_fixup = .;
  135. *(__entry_flush_fixup)
  136. __stop___entry_flush_fixup = .;
  137. }
  138. . = ALIGN(8);
  139. __stf_exit_barrier_fixup : AT(ADDR(__stf_exit_barrier_fixup) - LOAD_OFFSET) {
  140. __start___stf_exit_barrier_fixup = .;
  141. *(__stf_exit_barrier_fixup)
  142. __stop___stf_exit_barrier_fixup = .;
  143. }
  144. . = ALIGN(8);
  145. __rfi_flush_fixup : AT(ADDR(__rfi_flush_fixup) - LOAD_OFFSET) {
  146. __start___rfi_flush_fixup = .;
  147. *(__rfi_flush_fixup)
  148. __stop___rfi_flush_fixup = .;
  149. }
  150. #endif /* CONFIG_PPC64 */
  151. #ifdef CONFIG_PPC_BARRIER_NOSPEC
  152. . = ALIGN(8);
  153. __spec_barrier_fixup : AT(ADDR(__spec_barrier_fixup) - LOAD_OFFSET) {
  154. __start___barrier_nospec_fixup = .;
  155. *(__barrier_nospec_fixup)
  156. __stop___barrier_nospec_fixup = .;
  157. }
  158. #endif /* CONFIG_PPC_BARRIER_NOSPEC */
  159. #ifdef CONFIG_PPC_FSL_BOOK3E
  160. . = ALIGN(8);
  161. __spec_btb_flush_fixup : AT(ADDR(__spec_btb_flush_fixup) - LOAD_OFFSET) {
  162. __start__btb_flush_fixup = .;
  163. *(__btb_flush_fixup)
  164. __stop__btb_flush_fixup = .;
  165. }
  166. #endif
  167. EXCEPTION_TABLE(0)
  168. NOTES :kernel :notes
  169. /* The dummy segment contents for the bug workaround mentioned above
  170. near PHDRS. */
  171. .dummy : AT(ADDR(.dummy) - LOAD_OFFSET) {
  172. LONG(0)
  173. LONG(0)
  174. LONG(0)
  175. } :kernel :dummy
  176. /*
  177. * Init sections discarded at runtime
  178. */
  179. . = ALIGN(STRICT_ALIGN_SIZE);
  180. __init_begin = .;
  181. INIT_TEXT_SECTION(PAGE_SIZE) :kernel
  182. /* .exit.text is discarded at runtime, not link time,
  183. * to deal with references from __bug_table
  184. */
  185. .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
  186. EXIT_TEXT
  187. }
  188. .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
  189. INIT_DATA
  190. __vtop_table_begin = .;
  191. KEEP(*(.vtop_fixup));
  192. __vtop_table_end = .;
  193. __ptov_table_begin = .;
  194. KEEP(*(.ptov_fixup));
  195. __ptov_table_end = .;
  196. }
  197. .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
  198. INIT_SETUP(16)
  199. }
  200. .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
  201. INIT_CALLS
  202. }
  203. .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
  204. CON_INITCALL
  205. }
  206. SECURITY_INIT
  207. . = ALIGN(8);
  208. __ftr_fixup : AT(ADDR(__ftr_fixup) - LOAD_OFFSET) {
  209. __start___ftr_fixup = .;
  210. KEEP(*(__ftr_fixup))
  211. __stop___ftr_fixup = .;
  212. }
  213. . = ALIGN(8);
  214. __mmu_ftr_fixup : AT(ADDR(__mmu_ftr_fixup) - LOAD_OFFSET) {
  215. __start___mmu_ftr_fixup = .;
  216. KEEP(*(__mmu_ftr_fixup))
  217. __stop___mmu_ftr_fixup = .;
  218. }
  219. . = ALIGN(8);
  220. __lwsync_fixup : AT(ADDR(__lwsync_fixup) - LOAD_OFFSET) {
  221. __start___lwsync_fixup = .;
  222. KEEP(*(__lwsync_fixup))
  223. __stop___lwsync_fixup = .;
  224. }
  225. #ifdef CONFIG_PPC64
  226. . = ALIGN(8);
  227. __fw_ftr_fixup : AT(ADDR(__fw_ftr_fixup) - LOAD_OFFSET) {
  228. __start___fw_ftr_fixup = .;
  229. KEEP(*(__fw_ftr_fixup))
  230. __stop___fw_ftr_fixup = .;
  231. }
  232. #endif
  233. .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
  234. INIT_RAM_FS
  235. }
  236. PERCPU_SECTION(L1_CACHE_BYTES)
  237. . = ALIGN(8);
  238. .machine.desc : AT(ADDR(.machine.desc) - LOAD_OFFSET) {
  239. __machine_desc_start = . ;
  240. KEEP(*(.machine.desc))
  241. __machine_desc_end = . ;
  242. }
  243. #ifdef CONFIG_RELOCATABLE
  244. . = ALIGN(8);
  245. .dynsym : AT(ADDR(.dynsym) - LOAD_OFFSET)
  246. {
  247. #ifdef CONFIG_PPC32
  248. __dynamic_symtab = .;
  249. #endif
  250. *(.dynsym)
  251. }
  252. .dynstr : AT(ADDR(.dynstr) - LOAD_OFFSET) { *(.dynstr) }
  253. .dynamic : AT(ADDR(.dynamic) - LOAD_OFFSET)
  254. {
  255. __dynamic_start = .;
  256. *(.dynamic)
  257. }
  258. .hash : AT(ADDR(.hash) - LOAD_OFFSET) { *(.hash) }
  259. .interp : AT(ADDR(.interp) - LOAD_OFFSET) { *(.interp) }
  260. .rela.dyn : AT(ADDR(.rela.dyn) - LOAD_OFFSET)
  261. {
  262. __rela_dyn_start = .;
  263. *(.rela*)
  264. }
  265. #endif
  266. /* .exit.data is discarded at runtime, not link time,
  267. * to deal with references from .exit.text
  268. */
  269. .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
  270. EXIT_DATA
  271. }
  272. /* freed after init ends here */
  273. . = ALIGN(PAGE_SIZE);
  274. __init_end = .;
  275. /*
  276. * And now the various read/write data
  277. */
  278. . = ALIGN(PAGE_SIZE);
  279. _sdata = .;
  280. #ifdef CONFIG_PPC32
  281. .data : AT(ADDR(.data) - LOAD_OFFSET) {
  282. DATA_DATA
  283. #ifdef CONFIG_UBSAN
  284. *(.data..Lubsan_data*)
  285. *(.data..Lubsan_type*)
  286. #endif
  287. *(.data.rel*)
  288. *(SDATA_MAIN)
  289. *(.sdata2)
  290. *(.got.plt) *(.got)
  291. *(.plt)
  292. }
  293. #else
  294. .data : AT(ADDR(.data) - LOAD_OFFSET) {
  295. DATA_DATA
  296. *(.data.rel*)
  297. *(.toc1)
  298. *(.branch_lt)
  299. }
  300. #ifdef CONFIG_DEBUG_INFO_BTF
  301. .BTF : AT(ADDR(.BTF) - LOAD_OFFSET) {
  302. *(.BTF)
  303. }
  304. #endif
  305. .opd : AT(ADDR(.opd) - LOAD_OFFSET) {
  306. __start_opd = .;
  307. KEEP(*(.opd))
  308. __end_opd = .;
  309. }
  310. . = ALIGN(256);
  311. .got : AT(ADDR(.got) - LOAD_OFFSET) {
  312. __toc_start = .;
  313. #ifndef CONFIG_RELOCATABLE
  314. __prom_init_toc_start = .;
  315. arch/powerpc/kernel/prom_init.o*(.toc .got)
  316. __prom_init_toc_end = .;
  317. #endif
  318. *(.got)
  319. *(.toc)
  320. }
  321. #endif
  322. /* The initial task and kernel stack */
  323. INIT_TASK_DATA_SECTION(THREAD_SIZE)
  324. .data..page_aligned : AT(ADDR(.data..page_aligned) - LOAD_OFFSET) {
  325. PAGE_ALIGNED_DATA(PAGE_SIZE)
  326. }
  327. .data..cacheline_aligned : AT(ADDR(.data..cacheline_aligned) - LOAD_OFFSET) {
  328. CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES)
  329. }
  330. .data..read_mostly : AT(ADDR(.data..read_mostly) - LOAD_OFFSET) {
  331. READ_MOSTLY_DATA(L1_CACHE_BYTES)
  332. }
  333. . = ALIGN(PAGE_SIZE);
  334. .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
  335. NOSAVE_DATA
  336. }
  337. BUG_TABLE
  338. . = ALIGN(PAGE_SIZE);
  339. _edata = .;
  340. PROVIDE32 (edata = .);
  341. /*
  342. * And finally the bss
  343. */
  344. BSS_SECTION(0, 0, 0)
  345. . = ALIGN(PAGE_SIZE);
  346. _end = . ;
  347. PROVIDE32 (end = .);
  348. STABS_DEBUG
  349. DWARF_DEBUG
  350. DISCARDS
  351. /DISCARD/ : {
  352. *(*.EMB.apuinfo)
  353. *(.glink .iplt .plt .rela* .comment)
  354. *(.gnu.version*)
  355. *(.gnu.attributes)
  356. *(.eh_frame)
  357. }
  358. }