vmlinux.lds.S 9.1 KB

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