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 = .; 48 _stext = .; 49 50 /* 51 * Head text. 52 * This needs to be in its own output section to avoid ld placing 53 * branch trampoline stubs randomly throughout the fixed sections, 54 * which it will do (even if the branch comes from another section) 55 * in order to optimize stub generation. 56 */ 57 .head.text : AT(ADDR(.head.text) - LOAD_OFFSET) { 58#ifdef CONFIG_PPC64 59 KEEP(*(.head.text.first_256B)); 60#ifdef CONFIG_PPC_BOOK3E 61#else 62 KEEP(*(.head.text.real_vectors)); 63 *(.head.text.real_trampolines); 64 KEEP(*(.head.text.virt_vectors)); 65 *(.head.text.virt_trampolines); 66# if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV) 67 KEEP(*(.head.data.fwnmi_page)); 68# endif 69#endif 70#else /* !CONFIG_PPC64 */ 71 HEAD_TEXT 72#endif 73 } :kernel 74 75 __head_end = .; 76 77#ifdef CONFIG_PPC64 78 /* 79 * BLOCK(0) overrides the default output section alignment because 80 * this needs to start right after .head.text in order for fixed 81 * section placement to work. 82 */ 83 .text BLOCK(0) : AT(ADDR(.text) - LOAD_OFFSET) { 84#ifdef CONFIG_LD_HEAD_STUB_CATCH 85 *(.linker_stub_catch); 86 . = . ; 87#endif 88 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 .text.fixup .text.unlikely .fixup __ftr_alt_* .ref.text); 95 SCHED_TEXT 96 CPUIDLE_TEXT 97 LOCK_TEXT 98 KPROBES_TEXT 99 IRQENTRY_TEXT 100 SOFTIRQENTRY_TEXT 101 /* 102 * -Os builds call FP save/restore functions. The powerpc64 103 * linker generates those on demand in the .sfpr section. 104 * .sfpr gets placed at the beginning of a group of input 105 * sections, which can break start-of-text offset if it is 106 * included with the main text sections, so put it by itself. 107 */ 108 *(.sfpr); 109 MEM_KEEP(init.text) 110 MEM_KEEP(exit.text) 111 112#ifdef CONFIG_PPC32 113 *(.got1) 114 __got2_start = .; 115 *(.got2) 116 __got2_end = .; 117#endif /* CONFIG_PPC32 */ 118 119 } :kernel 120 121 . = ALIGN(PAGE_SIZE); 122 _etext = .; 123 PROVIDE32 (etext = .); 124 125 /* Read-only data */ 126 RODATA 127 128 EXCEPTION_TABLE(0) 129 130 NOTES :kernel :notes 131 132 /* The dummy segment contents for the bug workaround mentioned above 133 near PHDRS. */ 134 .dummy : AT(ADDR(.dummy) - LOAD_OFFSET) { 135 LONG(0) 136 LONG(0) 137 LONG(0) 138 } :kernel :dummy 139 140/* 141 * Init sections discarded at runtime 142 */ 143 . = ALIGN(PAGE_SIZE); 144 __init_begin = .; 145 INIT_TEXT_SECTION(PAGE_SIZE) :kernel 146 147 /* .exit.text is discarded at runtime, not link time, 148 * to deal with references from __bug_table 149 */ 150 .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { 151 EXIT_TEXT 152 } 153 154 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { 155 INIT_DATA 156 __vtop_table_begin = .; 157 *(.vtop_fixup); 158 __vtop_table_end = .; 159 __ptov_table_begin = .; 160 *(.ptov_fixup); 161 __ptov_table_end = .; 162 } 163 164 .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) { 165 INIT_SETUP(16) 166 } 167 168 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) { 169 INIT_CALLS 170 } 171 172 .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) { 173 CON_INITCALL 174 } 175 176 SECURITY_INIT 177 178 . = ALIGN(8); 179 __ftr_fixup : AT(ADDR(__ftr_fixup) - LOAD_OFFSET) { 180 __start___ftr_fixup = .; 181 *(__ftr_fixup) 182 __stop___ftr_fixup = .; 183 } 184 . = ALIGN(8); 185 __mmu_ftr_fixup : AT(ADDR(__mmu_ftr_fixup) - LOAD_OFFSET) { 186 __start___mmu_ftr_fixup = .; 187 *(__mmu_ftr_fixup) 188 __stop___mmu_ftr_fixup = .; 189 } 190 . = ALIGN(8); 191 __lwsync_fixup : AT(ADDR(__lwsync_fixup) - LOAD_OFFSET) { 192 __start___lwsync_fixup = .; 193 *(__lwsync_fixup) 194 __stop___lwsync_fixup = .; 195 } 196#ifdef CONFIG_PPC64 197 . = ALIGN(8); 198 __fw_ftr_fixup : AT(ADDR(__fw_ftr_fixup) - LOAD_OFFSET) { 199 __start___fw_ftr_fixup = .; 200 *(__fw_ftr_fixup) 201 __stop___fw_ftr_fixup = .; 202 } 203#endif 204 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) { 205 INIT_RAM_FS 206 } 207 208 PERCPU_SECTION(L1_CACHE_BYTES) 209 210 . = ALIGN(8); 211 .machine.desc : AT(ADDR(.machine.desc) - LOAD_OFFSET) { 212 __machine_desc_start = . ; 213 *(.machine.desc) 214 __machine_desc_end = . ; 215 } 216#ifdef CONFIG_RELOCATABLE 217 . = ALIGN(8); 218 .dynsym : AT(ADDR(.dynsym) - LOAD_OFFSET) 219 { 220#ifdef CONFIG_PPC32 221 __dynamic_symtab = .; 222#endif 223 *(.dynsym) 224 } 225 .dynstr : AT(ADDR(.dynstr) - LOAD_OFFSET) { *(.dynstr) } 226 .dynamic : AT(ADDR(.dynamic) - LOAD_OFFSET) 227 { 228 __dynamic_start = .; 229 *(.dynamic) 230 } 231 .hash : AT(ADDR(.hash) - LOAD_OFFSET) { *(.hash) } 232 .interp : AT(ADDR(.interp) - LOAD_OFFSET) { *(.interp) } 233 .rela.dyn : AT(ADDR(.rela.dyn) - LOAD_OFFSET) 234 { 235 __rela_dyn_start = .; 236 *(.rela*) 237 } 238#endif 239 /* .exit.data is discarded at runtime, not link time, 240 * to deal with references from .exit.text 241 */ 242 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { 243 EXIT_DATA 244 } 245 246 /* freed after init ends here */ 247 . = ALIGN(PAGE_SIZE); 248 __init_end = .; 249 250/* 251 * And now the various read/write data 252 */ 253 254 . = ALIGN(PAGE_SIZE); 255 _sdata = .; 256 257#ifdef CONFIG_PPC32 258 .data : AT(ADDR(.data) - LOAD_OFFSET) { 259 DATA_DATA 260 *(.sdata) 261 *(.sdata2) 262 *(.got.plt) *(.got) 263 *(.plt) 264 } 265#else 266 .data : AT(ADDR(.data) - LOAD_OFFSET) { 267 DATA_DATA 268 *(.data.rel*) 269 *(.toc1) 270 *(.branch_lt) 271 } 272 273 .opd : AT(ADDR(.opd) - LOAD_OFFSET) { 274 *(.opd) 275 } 276 277 . = ALIGN(256); 278 .got : AT(ADDR(.got) - LOAD_OFFSET) { 279 __toc_start = .; 280#ifndef CONFIG_RELOCATABLE 281 __prom_init_toc_start = .; 282 arch/powerpc/kernel/prom_init.o*(.toc .got) 283 __prom_init_toc_end = .; 284#endif 285 *(.got) 286 *(.toc) 287 } 288#endif 289 290 /* The initial task and kernel stack */ 291 INIT_TASK_DATA_SECTION(THREAD_SIZE) 292 293 .data..page_aligned : AT(ADDR(.data..page_aligned) - LOAD_OFFSET) { 294 PAGE_ALIGNED_DATA(PAGE_SIZE) 295 } 296 297 .data..cacheline_aligned : AT(ADDR(.data..cacheline_aligned) - LOAD_OFFSET) { 298 CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES) 299 } 300 301 .data..read_mostly : AT(ADDR(.data..read_mostly) - LOAD_OFFSET) { 302 READ_MOSTLY_DATA(L1_CACHE_BYTES) 303 } 304 305 . = ALIGN(PAGE_SIZE); 306 .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) { 307 NOSAVE_DATA 308 } 309 310 BUG_TABLE 311 312 . = ALIGN(PAGE_SIZE); 313 _edata = .; 314 PROVIDE32 (edata = .); 315 316/* 317 * And finally the bss 318 */ 319 320 BSS_SECTION(0, 0, 0) 321 322 . = ALIGN(PAGE_SIZE); 323 _end = . ; 324 PROVIDE32 (end = .); 325 326 STABS_DEBUG 327 328 DWARF_DEBUG 329 330 DISCARDS 331 /DISCARD/ : { 332 *(*.EMB.apuinfo) 333 *(.glink .iplt .plt .rela* .comment) 334 *(.gnu.version*) 335 *(.gnu.attributes) 336 *(.eh_frame) 337 } 338} 339