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 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 17ENTRY(_stext) 18 19PHDRS { 20 kernel PT_LOAD FLAGS(7); /* RWX */ 21 notes PT_NOTE FLAGS(0); 22 dummy PT_NOTE FLAGS(0); 23 24 /* binutils < 2.18 has a bug that makes it misbehave when taking an 25 ELF file with all segments at load address 0 as input. This 26 happens when running "strip" on vmlinux, because of the AT() magic 27 in this linker script. People using GCC >= 4.2 won't run into 28 this problem, because the "build-id" support will put some data 29 into the "notes" segment (at a non-zero load address). 30 31 To work around this, we force some data into both the "dummy" 32 segment and the kernel segment, so the dummy segment will get a 33 non-zero load address. It's not enough to always create the 34 "notes" segment, since if nothing gets assigned to it, its load 35 address will be zero. */ 36} 37 38#ifdef CONFIG_PPC64 39OUTPUT_ARCH(powerpc:common64) 40jiffies = jiffies_64; 41#else 42OUTPUT_ARCH(powerpc:common) 43jiffies = jiffies_64 + 4; 44#endif 45SECTIONS 46{ 47 . = KERNELBASE; 48 49/* 50 * Text, read only data and other permanent read-only sections 51 */ 52 53 _text = .; 54 _stext = .; 55 56 /* 57 * Head text. 58 * This needs to be in its own output section to avoid ld placing 59 * branch trampoline stubs randomly throughout the fixed sections, 60 * which it will do (even if the branch comes from another section) 61 * in order to optimize stub generation. 62 */ 63 .head.text : AT(ADDR(.head.text) - LOAD_OFFSET) { 64#ifdef CONFIG_PPC64 65 KEEP(*(.head.text.first_256B)); 66#ifdef CONFIG_PPC_BOOK3E 67#else 68 KEEP(*(.head.text.real_vectors)); 69 *(.head.text.real_trampolines); 70 KEEP(*(.head.text.virt_vectors)); 71 *(.head.text.virt_trampolines); 72# if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV) 73 KEEP(*(.head.data.fwnmi_page)); 74# endif 75#endif 76#else /* !CONFIG_PPC64 */ 77 HEAD_TEXT 78#endif 79 } :kernel 80 81 __head_end = .; 82 83#ifdef CONFIG_PPC64 84 /* 85 * BLOCK(0) overrides the default output section alignment because 86 * this needs to start right after .head.text in order for fixed 87 * section placement to work. 88 */ 89 .text BLOCK(0) : AT(ADDR(.text) - LOAD_OFFSET) { 90#ifdef CONFIG_LD_HEAD_STUB_CATCH 91 *(.linker_stub_catch); 92 . = . ; 93#endif 94 95#else 96 .text : AT(ADDR(.text) - LOAD_OFFSET) { 97 ALIGN_FUNCTION(); 98#endif 99 /* careful! __ftr_alt_* sections need to be close to .text */ 100 *(.text.hot .text .text.fixup .text.unlikely .fixup __ftr_alt_* .ref.text); 101 SCHED_TEXT 102 CPUIDLE_TEXT 103 LOCK_TEXT 104 KPROBES_TEXT 105 IRQENTRY_TEXT 106 SOFTIRQENTRY_TEXT 107 /* 108 * -Os builds call FP save/restore functions. The powerpc64 109 * linker generates those on demand in the .sfpr section. 110 * .sfpr gets placed at the beginning of a group of input 111 * sections, which can break start-of-text offset if it is 112 * included with the main text sections, so put it by itself. 113 */ 114 *(.sfpr); 115 MEM_KEEP(init.text) 116 MEM_KEEP(exit.text) 117 118#ifdef CONFIG_PPC32 119 *(.got1) 120 __got2_start = .; 121 *(.got2) 122 __got2_end = .; 123#endif /* CONFIG_PPC32 */ 124 125 } :kernel 126 127 . = ALIGN(PAGE_SIZE); 128 _etext = .; 129 PROVIDE32 (etext = .); 130 131 /* Read-only data */ 132 RO_DATA(PAGE_SIZE) 133 134 EXCEPTION_TABLE(0) 135 136 NOTES :kernel :notes 137 138 /* The dummy segment contents for the bug workaround mentioned above 139 near PHDRS. */ 140 .dummy : AT(ADDR(.dummy) - LOAD_OFFSET) { 141 LONG(0) 142 LONG(0) 143 LONG(0) 144 } :kernel :dummy 145 146/* 147 * Init sections discarded at runtime 148 */ 149 . = ALIGN(STRICT_ALIGN_SIZE); 150 __init_begin = .; 151 INIT_TEXT_SECTION(PAGE_SIZE) :kernel 152 153 /* .exit.text is discarded at runtime, not link time, 154 * to deal with references from __bug_table 155 */ 156 .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { 157 EXIT_TEXT 158 } 159 160 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { 161 INIT_DATA 162 __vtop_table_begin = .; 163 *(.vtop_fixup); 164 __vtop_table_end = .; 165 __ptov_table_begin = .; 166 *(.ptov_fixup); 167 __ptov_table_end = .; 168 } 169 170 .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) { 171 INIT_SETUP(16) 172 } 173 174 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) { 175 INIT_CALLS 176 } 177 178 .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) { 179 CON_INITCALL 180 } 181 182 SECURITY_INIT 183 184 . = ALIGN(8); 185 __ftr_fixup : AT(ADDR(__ftr_fixup) - LOAD_OFFSET) { 186 __start___ftr_fixup = .; 187 *(__ftr_fixup) 188 __stop___ftr_fixup = .; 189 } 190 . = ALIGN(8); 191 __mmu_ftr_fixup : AT(ADDR(__mmu_ftr_fixup) - LOAD_OFFSET) { 192 __start___mmu_ftr_fixup = .; 193 *(__mmu_ftr_fixup) 194 __stop___mmu_ftr_fixup = .; 195 } 196 . = ALIGN(8); 197 __lwsync_fixup : AT(ADDR(__lwsync_fixup) - LOAD_OFFSET) { 198 __start___lwsync_fixup = .; 199 *(__lwsync_fixup) 200 __stop___lwsync_fixup = .; 201 } 202#ifdef CONFIG_PPC64 203 . = ALIGN(8); 204 __fw_ftr_fixup : AT(ADDR(__fw_ftr_fixup) - LOAD_OFFSET) { 205 __start___fw_ftr_fixup = .; 206 *(__fw_ftr_fixup) 207 __stop___fw_ftr_fixup = .; 208 } 209#endif 210 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) { 211 INIT_RAM_FS 212 } 213 214 PERCPU_SECTION(L1_CACHE_BYTES) 215 216 . = ALIGN(8); 217 .machine.desc : AT(ADDR(.machine.desc) - LOAD_OFFSET) { 218 __machine_desc_start = . ; 219 *(.machine.desc) 220 __machine_desc_end = . ; 221 } 222#ifdef CONFIG_RELOCATABLE 223 . = ALIGN(8); 224 .dynsym : AT(ADDR(.dynsym) - LOAD_OFFSET) 225 { 226#ifdef CONFIG_PPC32 227 __dynamic_symtab = .; 228#endif 229 *(.dynsym) 230 } 231 .dynstr : AT(ADDR(.dynstr) - LOAD_OFFSET) { *(.dynstr) } 232 .dynamic : AT(ADDR(.dynamic) - LOAD_OFFSET) 233 { 234 __dynamic_start = .; 235 *(.dynamic) 236 } 237 .hash : AT(ADDR(.hash) - LOAD_OFFSET) { *(.hash) } 238 .interp : AT(ADDR(.interp) - LOAD_OFFSET) { *(.interp) } 239 .rela.dyn : AT(ADDR(.rela.dyn) - LOAD_OFFSET) 240 { 241 __rela_dyn_start = .; 242 *(.rela*) 243 } 244#endif 245 /* .exit.data is discarded at runtime, not link time, 246 * to deal with references from .exit.text 247 */ 248 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { 249 EXIT_DATA 250 } 251 252 /* freed after init ends here */ 253 . = ALIGN(PAGE_SIZE); 254 __init_end = .; 255 256/* 257 * And now the various read/write data 258 */ 259 260 . = ALIGN(PAGE_SIZE); 261 _sdata = .; 262 263#ifdef CONFIG_PPC32 264 .data : AT(ADDR(.data) - LOAD_OFFSET) { 265 DATA_DATA 266 *(.sdata) 267 *(.sdata2) 268 *(.got.plt) *(.got) 269 *(.plt) 270 } 271#else 272 .data : AT(ADDR(.data) - LOAD_OFFSET) { 273 DATA_DATA 274 *(.data.rel*) 275 *(.toc1) 276 *(.branch_lt) 277 } 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 BUG_TABLE 317 318 . = ALIGN(PAGE_SIZE); 319 _edata = .; 320 PROVIDE32 (edata = .); 321 322/* 323 * And finally the bss 324 */ 325 326 BSS_SECTION(0, 0, 0) 327 328 . = ALIGN(PAGE_SIZE); 329 _end = . ; 330 PROVIDE32 (end = .); 331 332 STABS_DEBUG 333 334 DWARF_DEBUG 335 336 DISCARDS 337 /DISCARD/ : { 338 *(*.EMB.apuinfo) 339 *(.glink .iplt .plt .rela* .comment) 340 *(.gnu.version*) 341 *(.gnu.attributes) 342 *(.eh_frame) 343 } 344} 345