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