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