vmlinux.lds.S 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  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. #define BSS_FIRST_SECTIONS *(.bss.prominit)
  8. #define EMITS_PT_NOTE
  9. #define RO_EXCEPTION_TABLE_ALIGN 0
  10. #define RUNTIME_DISCARD_EXIT
  11. #define SOFT_MASK_TABLE(align) \
  12. . = ALIGN(align); \
  13. __soft_mask_table : AT(ADDR(__soft_mask_table) - LOAD_OFFSET) { \
  14. __start___soft_mask_table = .; \
  15. KEEP(*(__soft_mask_table)) \
  16. __stop___soft_mask_table = .; \
  17. }
  18. #define RESTART_TABLE(align) \
  19. . = ALIGN(align); \
  20. __restart_table : AT(ADDR(__restart_table) - LOAD_OFFSET) { \
  21. __start___restart_table = .; \
  22. KEEP(*(__restart_table)) \
  23. __stop___restart_table = .; \
  24. }
  25. #include <asm/page.h>
  26. #include <asm-generic/vmlinux.lds.h>
  27. #include <asm/cache.h>
  28. #include <asm/thread_info.h>
  29. #define STRICT_ALIGN_SIZE (1 << CONFIG_DATA_SHIFT)
  30. #if STRICT_ALIGN_SIZE < PAGE_SIZE
  31. #error "CONFIG_DATA_SHIFT must be >= PAGE_SHIFT"
  32. #endif
  33. ENTRY(_stext)
  34. PHDRS {
  35. text PT_LOAD FLAGS(7); /* RWX */
  36. note PT_NOTE FLAGS(0);
  37. }
  38. #ifdef CONFIG_PPC64
  39. OUTPUT_ARCH(powerpc:common64)
  40. jiffies = jiffies_64;
  41. #else
  42. OUTPUT_ARCH(powerpc:common)
  43. jiffies = jiffies_64 + 4;
  44. #endif
  45. SECTIONS
  46. {
  47. . = KERNELBASE;
  48. /*
  49. * Text, read only data and other permanent read-only sections
  50. */
  51. _text = .;
  52. _stext = .;
  53. /*
  54. * Head text.
  55. * This needs to be in its own output section to avoid ld placing
  56. * branch trampoline stubs randomly throughout the fixed sections,
  57. * which it will do (even if the branch comes from another section)
  58. * in order to optimize stub generation.
  59. */
  60. .head.text : AT(ADDR(.head.text) - LOAD_OFFSET) {
  61. #ifdef CONFIG_PPC64
  62. KEEP(*(.head.text.first_256B));
  63. #ifdef CONFIG_PPC_BOOK3E_64
  64. #else
  65. KEEP(*(.head.text.real_vectors));
  66. *(.head.text.real_trampolines);
  67. KEEP(*(.head.text.virt_vectors));
  68. *(.head.text.virt_trampolines);
  69. # if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV)
  70. KEEP(*(.head.data.fwnmi_page));
  71. # endif
  72. #endif
  73. #else /* !CONFIG_PPC64 */
  74. HEAD_TEXT
  75. #endif
  76. } :text
  77. __head_end = .;
  78. #ifdef CONFIG_PPC64
  79. /*
  80. * ALIGN(0) overrides the default output section alignment because
  81. * this needs to start right after .head.text in order for fixed
  82. * section placement to work.
  83. */
  84. .text ALIGN(0) : AT(ADDR(.text) - LOAD_OFFSET) {
  85. #ifdef CONFIG_LD_HEAD_STUB_CATCH
  86. KEEP(*(.linker_stub_catch));
  87. . = . ;
  88. #endif
  89. #else
  90. .text : AT(ADDR(.text) - LOAD_OFFSET) {
  91. ALIGN_FUNCTION();
  92. #endif
  93. /* careful! __ftr_alt_* sections need to be close to .text */
  94. *(.text.hot .text.hot.* TEXT_MAIN .text.fixup .text.unlikely .text.unlikely.* .fixup __ftr_alt_* .ref.text);
  95. *(.tramp.ftrace.text);
  96. NOINSTR_TEXT
  97. SCHED_TEXT
  98. LOCK_TEXT
  99. KPROBES_TEXT
  100. IRQENTRY_TEXT
  101. SOFTIRQENTRY_TEXT
  102. /*
  103. * -Os builds call FP save/restore functions. The powerpc64
  104. * linker generates those on demand in the .sfpr section.
  105. * .sfpr gets placed at the beginning of a group of input
  106. * sections, which can break start-of-text offset if it is
  107. * included with the main text sections, so put it by itself.
  108. */
  109. *(.sfpr);
  110. *(.text.asan.* .text.tsan.*)
  111. } :text
  112. . = ALIGN(PAGE_SIZE);
  113. _etext = .;
  114. PROVIDE32 (etext = .);
  115. /* Read-only data */
  116. RO_DATA(PAGE_SIZE)
  117. #ifdef CONFIG_PPC32
  118. .sdata2 : AT(ADDR(.sdata2) - LOAD_OFFSET) {
  119. *(.sdata2)
  120. }
  121. #endif
  122. .data.rel.ro : AT(ADDR(.data.rel.ro) - LOAD_OFFSET) {
  123. *(.data.rel.ro .data.rel.ro.*)
  124. }
  125. .branch_lt : AT(ADDR(.branch_lt) - LOAD_OFFSET) {
  126. *(.branch_lt)
  127. }
  128. #ifdef CONFIG_PPC32
  129. .got1 : AT(ADDR(.got1) - LOAD_OFFSET) {
  130. *(.got1)
  131. }
  132. .got2 : AT(ADDR(.got2) - LOAD_OFFSET) {
  133. __got2_start = .;
  134. *(.got2)
  135. __got2_end = .;
  136. }
  137. .got : AT(ADDR(.got) - LOAD_OFFSET) {
  138. *(.got)
  139. *(.got.plt)
  140. }
  141. .plt : AT(ADDR(.plt) - LOAD_OFFSET) {
  142. /* XXX: is .plt (and .got.plt) required? */
  143. *(.plt)
  144. }
  145. #else /* CONFIG_PPC32 */
  146. #ifndef CONFIG_PPC_KERNEL_PCREL
  147. .toc1 : AT(ADDR(.toc1) - LOAD_OFFSET) {
  148. *(.toc1)
  149. }
  150. #endif
  151. .got : AT(ADDR(.got) - LOAD_OFFSET) ALIGN(256) {
  152. #ifdef CONFIG_PPC_KERNEL_PCREL
  153. *(.got)
  154. #else
  155. *(.got .toc)
  156. #endif
  157. }
  158. SOFT_MASK_TABLE(8)
  159. RESTART_TABLE(8)
  160. #ifdef CONFIG_PPC64_ELF_ABI_V1
  161. .opd : AT(ADDR(.opd) - LOAD_OFFSET) {
  162. __start_opd = .;
  163. KEEP(*(.opd))
  164. __end_opd = .;
  165. }
  166. #endif
  167. . = ALIGN(8);
  168. __stf_entry_barrier_fixup : AT(ADDR(__stf_entry_barrier_fixup) - LOAD_OFFSET) {
  169. __start___stf_entry_barrier_fixup = .;
  170. *(__stf_entry_barrier_fixup)
  171. __stop___stf_entry_barrier_fixup = .;
  172. }
  173. . = ALIGN(8);
  174. __uaccess_flush_fixup : AT(ADDR(__uaccess_flush_fixup) - LOAD_OFFSET) {
  175. __start___uaccess_flush_fixup = .;
  176. *(__uaccess_flush_fixup)
  177. __stop___uaccess_flush_fixup = .;
  178. }
  179. . = ALIGN(8);
  180. __entry_flush_fixup : AT(ADDR(__entry_flush_fixup) - LOAD_OFFSET) {
  181. __start___entry_flush_fixup = .;
  182. *(__entry_flush_fixup)
  183. __stop___entry_flush_fixup = .;
  184. }
  185. . = ALIGN(8);
  186. __scv_entry_flush_fixup : AT(ADDR(__scv_entry_flush_fixup) - LOAD_OFFSET) {
  187. __start___scv_entry_flush_fixup = .;
  188. *(__scv_entry_flush_fixup)
  189. __stop___scv_entry_flush_fixup = .;
  190. }
  191. . = ALIGN(8);
  192. __stf_exit_barrier_fixup : AT(ADDR(__stf_exit_barrier_fixup) - LOAD_OFFSET) {
  193. __start___stf_exit_barrier_fixup = .;
  194. *(__stf_exit_barrier_fixup)
  195. __stop___stf_exit_barrier_fixup = .;
  196. }
  197. . = ALIGN(8);
  198. __rfi_flush_fixup : AT(ADDR(__rfi_flush_fixup) - LOAD_OFFSET) {
  199. __start___rfi_flush_fixup = .;
  200. *(__rfi_flush_fixup)
  201. __stop___rfi_flush_fixup = .;
  202. }
  203. #endif /* CONFIG_PPC32 */
  204. #ifdef CONFIG_PPC_BARRIER_NOSPEC
  205. . = ALIGN(8);
  206. __spec_barrier_fixup : AT(ADDR(__spec_barrier_fixup) - LOAD_OFFSET) {
  207. __start___barrier_nospec_fixup = .;
  208. *(__barrier_nospec_fixup)
  209. __stop___barrier_nospec_fixup = .;
  210. }
  211. #endif /* CONFIG_PPC_BARRIER_NOSPEC */
  212. #ifdef CONFIG_PPC_E500
  213. . = ALIGN(8);
  214. __spec_btb_flush_fixup : AT(ADDR(__spec_btb_flush_fixup) - LOAD_OFFSET) {
  215. __start__btb_flush_fixup = .;
  216. *(__btb_flush_fixup)
  217. __stop__btb_flush_fixup = .;
  218. }
  219. #endif
  220. /*
  221. * Various code relies on __init_begin being at the strict RWX boundary.
  222. */
  223. . = ALIGN(STRICT_ALIGN_SIZE);
  224. __srwx_boundary = .;
  225. __end_rodata = .;
  226. __init_begin = .;
  227. /*
  228. * Init sections discarded at runtime
  229. */
  230. .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
  231. _sinittext = .;
  232. INIT_TEXT
  233. /*
  234. *.init.text might be RO so we must ensure this section ends on
  235. * a page boundary.
  236. */
  237. . = ALIGN(PAGE_SIZE);
  238. _einittext = .;
  239. *(.tramp.ftrace.init);
  240. } :text
  241. /* .exit.text is discarded at runtime, not link time,
  242. * to deal with references from __bug_table
  243. */
  244. .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
  245. __exittext_begin = .;
  246. EXIT_TEXT
  247. __exittext_end = .;
  248. }
  249. . = ALIGN(PAGE_SIZE);
  250. INIT_DATA_SECTION(16)
  251. . = ALIGN(8);
  252. __ftr_fixup : AT(ADDR(__ftr_fixup) - LOAD_OFFSET) {
  253. __start___ftr_fixup = .;
  254. KEEP(*(__ftr_fixup))
  255. __stop___ftr_fixup = .;
  256. }
  257. . = ALIGN(8);
  258. __mmu_ftr_fixup : AT(ADDR(__mmu_ftr_fixup) - LOAD_OFFSET) {
  259. __start___mmu_ftr_fixup = .;
  260. KEEP(*(__mmu_ftr_fixup))
  261. __stop___mmu_ftr_fixup = .;
  262. }
  263. . = ALIGN(8);
  264. __lwsync_fixup : AT(ADDR(__lwsync_fixup) - LOAD_OFFSET) {
  265. __start___lwsync_fixup = .;
  266. KEEP(*(__lwsync_fixup))
  267. __stop___lwsync_fixup = .;
  268. }
  269. #ifdef CONFIG_PPC64
  270. . = ALIGN(8);
  271. __fw_ftr_fixup : AT(ADDR(__fw_ftr_fixup) - LOAD_OFFSET) {
  272. __start___fw_ftr_fixup = .;
  273. KEEP(*(__fw_ftr_fixup))
  274. __stop___fw_ftr_fixup = .;
  275. }
  276. #endif
  277. PERCPU_SECTION(L1_CACHE_BYTES)
  278. . = ALIGN(8);
  279. .machine.desc : AT(ADDR(.machine.desc) - LOAD_OFFSET) {
  280. __machine_desc_start = . ;
  281. KEEP(*(.machine.desc))
  282. __machine_desc_end = . ;
  283. }
  284. #ifdef CONFIG_RELOCATABLE
  285. . = ALIGN(8);
  286. .dynsym : AT(ADDR(.dynsym) - LOAD_OFFSET)
  287. {
  288. __dynamic_symtab = .;
  289. *(.dynsym)
  290. }
  291. .dynstr : AT(ADDR(.dynstr) - LOAD_OFFSET) { *(.dynstr) }
  292. .dynamic : AT(ADDR(.dynamic) - LOAD_OFFSET)
  293. {
  294. __dynamic_start = .;
  295. *(.dynamic)
  296. }
  297. .hash : AT(ADDR(.hash) - LOAD_OFFSET) { *(.hash) }
  298. .gnu.hash : AT(ADDR(.gnu.hash) - LOAD_OFFSET) { *(.gnu.hash) }
  299. .interp : AT(ADDR(.interp) - LOAD_OFFSET) { *(.interp) }
  300. .rela.dyn : AT(ADDR(.rela.dyn) - LOAD_OFFSET)
  301. {
  302. __rela_dyn_start = .;
  303. *(.rela*)
  304. }
  305. #endif
  306. /* .exit.data is discarded at runtime, not link time,
  307. * to deal with references from .exit.text
  308. */
  309. .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
  310. EXIT_DATA
  311. }
  312. /* freed after init ends here */
  313. . = ALIGN(PAGE_SIZE);
  314. __init_end = .;
  315. /*
  316. * And now the various read/write data
  317. */
  318. . = ALIGN(PAGE_SIZE);
  319. _sdata = .;
  320. .data : AT(ADDR(.data) - LOAD_OFFSET) {
  321. DATA_DATA
  322. *(.data.rel*)
  323. #ifdef CONFIG_PPC32
  324. *(SDATA_MAIN)
  325. #endif
  326. }
  327. /* The initial task and kernel stack */
  328. INIT_TASK_DATA_SECTION(THREAD_ALIGN)
  329. .data..page_aligned : AT(ADDR(.data..page_aligned) - LOAD_OFFSET) {
  330. PAGE_ALIGNED_DATA(PAGE_SIZE)
  331. }
  332. .data..cacheline_aligned : AT(ADDR(.data..cacheline_aligned) - LOAD_OFFSET) {
  333. CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES)
  334. }
  335. .data..read_mostly : AT(ADDR(.data..read_mostly) - LOAD_OFFSET) {
  336. READ_MOSTLY_DATA(L1_CACHE_BYTES)
  337. }
  338. . = ALIGN(PAGE_SIZE);
  339. .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
  340. NOSAVE_DATA
  341. }
  342. BUG_TABLE
  343. . = ALIGN(PAGE_SIZE);
  344. _edata = .;
  345. PROVIDE32 (edata = .);
  346. /*
  347. * And finally the bss
  348. */
  349. BSS_SECTION(0, 0, 0)
  350. . = ALIGN(PAGE_SIZE);
  351. _end = . ;
  352. PROVIDE32 (end = .);
  353. DWARF_DEBUG
  354. ELF_DETAILS
  355. DISCARDS
  356. /DISCARD/ : {
  357. *(*.EMB.apuinfo)
  358. *(.glink .iplt .plt)
  359. *(.gnu.version*)
  360. *(.gnu.attributes)
  361. *(.eh_frame)
  362. #ifndef CONFIG_RELOCATABLE
  363. *(.rela*)
  364. #endif
  365. }
  366. }