1 /* 2 * Helper macros to support writing architecture specific 3 * linker scripts. 4 * 5 * A minimal linker scripts has following content: 6 * [This is a sample, architectures may have special requiriements] 7 * 8 * OUTPUT_FORMAT(...) 9 * OUTPUT_ARCH(...) 10 * ENTRY(...) 11 * SECTIONS 12 * { 13 * . = START; 14 * __init_begin = .; 15 * HEAD_TEXT_SECTION 16 * INIT_TEXT_SECTION(PAGE_SIZE) 17 * INIT_DATA_SECTION(...) 18 * PERCPU_SECTION(CACHELINE_SIZE) 19 * __init_end = .; 20 * 21 * _stext = .; 22 * TEXT_SECTION = 0 23 * _etext = .; 24 * 25 * _sdata = .; 26 * RO_DATA_SECTION(PAGE_SIZE) 27 * RW_DATA_SECTION(...) 28 * _edata = .; 29 * 30 * EXCEPTION_TABLE(...) 31 * NOTES 32 * 33 * BSS_SECTION(0, 0, 0) 34 * _end = .; 35 * 36 * STABS_DEBUG 37 * DWARF_DEBUG 38 * 39 * DISCARDS // must be the last 40 * } 41 * 42 * [__init_begin, __init_end] is the init section that may be freed after init 43 * // __init_begin and __init_end should be page aligned, so that we can 44 * // free the whole .init memory 45 * [_stext, _etext] is the text section 46 * [_sdata, _edata] is the data section 47 * 48 * Some of the included output section have their own set of constants. 49 * Examples are: [__initramfs_start, __initramfs_end] for initramfs and 50 * [__nosave_begin, __nosave_end] for the nosave data 51 */ 52 53 #ifndef LOAD_OFFSET 54 #define LOAD_OFFSET 0 55 #endif 56 57 #include <linux/export.h> 58 59 /* Align . to a 8 byte boundary equals to maximum function alignment. */ 60 #define ALIGN_FUNCTION() . = ALIGN(8) 61 62 /* 63 * LD_DEAD_CODE_DATA_ELIMINATION option enables -fdata-sections, which 64 * generates .data.identifier sections, which need to be pulled in with 65 * .data. We don't want to pull in .data..other sections, which Linux 66 * has defined. Same for text and bss. 67 */ 68 #ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION 69 #define TEXT_MAIN .text .text.[0-9a-zA-Z_]* 70 #define DATA_MAIN .data .data.[0-9a-zA-Z_]* 71 #define BSS_MAIN .bss .bss.[0-9a-zA-Z_]* 72 #else 73 #define TEXT_MAIN .text 74 #define DATA_MAIN .data 75 #define BSS_MAIN .bss 76 #endif 77 78 /* 79 * Align to a 32 byte boundary equal to the 80 * alignment gcc 4.5 uses for a struct 81 */ 82 #define STRUCT_ALIGNMENT 32 83 #define STRUCT_ALIGN() . = ALIGN(STRUCT_ALIGNMENT) 84 85 /* The actual configuration determine if the init/exit sections 86 * are handled as text/data or they can be discarded (which 87 * often happens at runtime) 88 */ 89 #ifdef CONFIG_HOTPLUG_CPU 90 #define CPU_KEEP(sec) *(.cpu##sec) 91 #define CPU_DISCARD(sec) 92 #else 93 #define CPU_KEEP(sec) 94 #define CPU_DISCARD(sec) *(.cpu##sec) 95 #endif 96 97 #if defined(CONFIG_MEMORY_HOTPLUG) 98 #define MEM_KEEP(sec) *(.mem##sec) 99 #define MEM_DISCARD(sec) 100 #else 101 #define MEM_KEEP(sec) 102 #define MEM_DISCARD(sec) *(.mem##sec) 103 #endif 104 105 #ifdef CONFIG_FTRACE_MCOUNT_RECORD 106 #define MCOUNT_REC() . = ALIGN(8); \ 107 VMLINUX_SYMBOL(__start_mcount_loc) = .; \ 108 *(__mcount_loc) \ 109 VMLINUX_SYMBOL(__stop_mcount_loc) = .; 110 #else 111 #define MCOUNT_REC() 112 #endif 113 114 #ifdef CONFIG_TRACE_BRANCH_PROFILING 115 #define LIKELY_PROFILE() VMLINUX_SYMBOL(__start_annotated_branch_profile) = .; \ 116 *(_ftrace_annotated_branch) \ 117 VMLINUX_SYMBOL(__stop_annotated_branch_profile) = .; 118 #else 119 #define LIKELY_PROFILE() 120 #endif 121 122 #ifdef CONFIG_PROFILE_ALL_BRANCHES 123 #define BRANCH_PROFILE() VMLINUX_SYMBOL(__start_branch_profile) = .; \ 124 *(_ftrace_branch) \ 125 VMLINUX_SYMBOL(__stop_branch_profile) = .; 126 #else 127 #define BRANCH_PROFILE() 128 #endif 129 130 #ifdef CONFIG_KPROBES 131 #define KPROBE_BLACKLIST() . = ALIGN(8); \ 132 VMLINUX_SYMBOL(__start_kprobe_blacklist) = .; \ 133 KEEP(*(_kprobe_blacklist)) \ 134 VMLINUX_SYMBOL(__stop_kprobe_blacklist) = .; 135 #else 136 #define KPROBE_BLACKLIST() 137 #endif 138 139 #ifdef CONFIG_EVENT_TRACING 140 #define FTRACE_EVENTS() . = ALIGN(8); \ 141 VMLINUX_SYMBOL(__start_ftrace_events) = .; \ 142 KEEP(*(_ftrace_events)) \ 143 VMLINUX_SYMBOL(__stop_ftrace_events) = .; \ 144 VMLINUX_SYMBOL(__start_ftrace_eval_maps) = .; \ 145 KEEP(*(_ftrace_eval_map)) \ 146 VMLINUX_SYMBOL(__stop_ftrace_eval_maps) = .; 147 #else 148 #define FTRACE_EVENTS() 149 #endif 150 151 #ifdef CONFIG_TRACING 152 #define TRACE_PRINTKS() VMLINUX_SYMBOL(__start___trace_bprintk_fmt) = .; \ 153 KEEP(*(__trace_printk_fmt)) /* Trace_printk fmt' pointer */ \ 154 VMLINUX_SYMBOL(__stop___trace_bprintk_fmt) = .; 155 #define TRACEPOINT_STR() VMLINUX_SYMBOL(__start___tracepoint_str) = .; \ 156 KEEP(*(__tracepoint_str)) /* Trace_printk fmt' pointer */ \ 157 VMLINUX_SYMBOL(__stop___tracepoint_str) = .; 158 #else 159 #define TRACE_PRINTKS() 160 #define TRACEPOINT_STR() 161 #endif 162 163 #ifdef CONFIG_FTRACE_SYSCALLS 164 #define TRACE_SYSCALLS() . = ALIGN(8); \ 165 VMLINUX_SYMBOL(__start_syscalls_metadata) = .; \ 166 KEEP(*(__syscalls_metadata)) \ 167 VMLINUX_SYMBOL(__stop_syscalls_metadata) = .; 168 #else 169 #define TRACE_SYSCALLS() 170 #endif 171 172 #ifdef CONFIG_SERIAL_EARLYCON 173 #define EARLYCON_TABLE() STRUCT_ALIGN(); \ 174 VMLINUX_SYMBOL(__earlycon_table) = .; \ 175 KEEP(*(__earlycon_table)) \ 176 VMLINUX_SYMBOL(__earlycon_table_end) = .; 177 #else 178 #define EARLYCON_TABLE() 179 #endif 180 181 #define ___OF_TABLE(cfg, name) _OF_TABLE_##cfg(name) 182 #define __OF_TABLE(cfg, name) ___OF_TABLE(cfg, name) 183 #define OF_TABLE(cfg, name) __OF_TABLE(IS_ENABLED(cfg), name) 184 #define _OF_TABLE_0(name) 185 #define _OF_TABLE_1(name) \ 186 . = ALIGN(8); \ 187 VMLINUX_SYMBOL(__##name##_of_table) = .; \ 188 KEEP(*(__##name##_of_table)) \ 189 KEEP(*(__##name##_of_table_end)) 190 191 #define TIMER_OF_TABLES() OF_TABLE(CONFIG_TIMER_OF, timer) 192 #define IRQCHIP_OF_MATCH_TABLE() OF_TABLE(CONFIG_IRQCHIP, irqchip) 193 #define CLK_OF_TABLES() OF_TABLE(CONFIG_COMMON_CLK, clk) 194 #define IOMMU_OF_TABLES() OF_TABLE(CONFIG_OF_IOMMU, iommu) 195 #define RESERVEDMEM_OF_TABLES() OF_TABLE(CONFIG_OF_RESERVED_MEM, reservedmem) 196 #define CPU_METHOD_OF_TABLES() OF_TABLE(CONFIG_SMP, cpu_method) 197 #define CPUIDLE_METHOD_OF_TABLES() OF_TABLE(CONFIG_CPU_IDLE, cpuidle_method) 198 199 #ifdef CONFIG_ACPI 200 #define ACPI_PROBE_TABLE(name) \ 201 . = ALIGN(8); \ 202 VMLINUX_SYMBOL(__##name##_acpi_probe_table) = .; \ 203 KEEP(*(__##name##_acpi_probe_table)) \ 204 VMLINUX_SYMBOL(__##name##_acpi_probe_table_end) = .; 205 #else 206 #define ACPI_PROBE_TABLE(name) 207 #endif 208 209 #define KERNEL_DTB() \ 210 STRUCT_ALIGN(); \ 211 VMLINUX_SYMBOL(__dtb_start) = .; \ 212 KEEP(*(.dtb.init.rodata)) \ 213 VMLINUX_SYMBOL(__dtb_end) = .; 214 215 /* 216 * .data section 217 */ 218 #define DATA_DATA \ 219 *(DATA_MAIN) \ 220 *(.ref.data) \ 221 *(.data..shared_aligned) /* percpu related */ \ 222 MEM_KEEP(init.data) \ 223 MEM_KEEP(exit.data) \ 224 *(.data.unlikely) \ 225 STRUCT_ALIGN(); \ 226 *(__tracepoints) \ 227 /* implement dynamic printk debug */ \ 228 . = ALIGN(8); \ 229 VMLINUX_SYMBOL(__start___jump_table) = .; \ 230 KEEP(*(__jump_table)) \ 231 VMLINUX_SYMBOL(__stop___jump_table) = .; \ 232 . = ALIGN(8); \ 233 VMLINUX_SYMBOL(__start___verbose) = .; \ 234 KEEP(*(__verbose)) \ 235 VMLINUX_SYMBOL(__stop___verbose) = .; \ 236 LIKELY_PROFILE() \ 237 BRANCH_PROFILE() \ 238 TRACE_PRINTKS() \ 239 TRACEPOINT_STR() 240 241 /* 242 * Data section helpers 243 */ 244 #define NOSAVE_DATA \ 245 . = ALIGN(PAGE_SIZE); \ 246 VMLINUX_SYMBOL(__nosave_begin) = .; \ 247 *(.data..nosave) \ 248 . = ALIGN(PAGE_SIZE); \ 249 VMLINUX_SYMBOL(__nosave_end) = .; 250 251 #define PAGE_ALIGNED_DATA(page_align) \ 252 . = ALIGN(page_align); \ 253 *(.data..page_aligned) 254 255 #define READ_MOSTLY_DATA(align) \ 256 . = ALIGN(align); \ 257 *(.data..read_mostly) \ 258 . = ALIGN(align); 259 260 #define CACHELINE_ALIGNED_DATA(align) \ 261 . = ALIGN(align); \ 262 *(.data..cacheline_aligned) 263 264 #define INIT_TASK_DATA(align) \ 265 . = ALIGN(align); \ 266 VMLINUX_SYMBOL(__start_init_task) = .; \ 267 *(.data..init_task) \ 268 VMLINUX_SYMBOL(__end_init_task) = .; 269 270 /* 271 * Allow architectures to handle ro_after_init data on their 272 * own by defining an empty RO_AFTER_INIT_DATA. 273 */ 274 #ifndef RO_AFTER_INIT_DATA 275 #define RO_AFTER_INIT_DATA \ 276 VMLINUX_SYMBOL(__start_ro_after_init) = .; \ 277 *(.data..ro_after_init) \ 278 VMLINUX_SYMBOL(__end_ro_after_init) = .; 279 #endif 280 281 /* 282 * Read only Data 283 */ 284 #define RO_DATA_SECTION(align) \ 285 . = ALIGN((align)); \ 286 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \ 287 VMLINUX_SYMBOL(__start_rodata) = .; \ 288 *(.rodata) *(.rodata.*) \ 289 RO_AFTER_INIT_DATA /* Read only after init */ \ 290 KEEP(*(__vermagic)) /* Kernel version magic */ \ 291 . = ALIGN(8); \ 292 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \ 293 KEEP(*(__tracepoints_ptrs)) /* Tracepoints: pointer array */ \ 294 VMLINUX_SYMBOL(__stop___tracepoints_ptrs) = .; \ 295 *(__tracepoints_strings)/* Tracepoints: strings */ \ 296 } \ 297 \ 298 .rodata1 : AT(ADDR(.rodata1) - LOAD_OFFSET) { \ 299 *(.rodata1) \ 300 } \ 301 \ 302 /* PCI quirks */ \ 303 .pci_fixup : AT(ADDR(.pci_fixup) - LOAD_OFFSET) { \ 304 VMLINUX_SYMBOL(__start_pci_fixups_early) = .; \ 305 KEEP(*(.pci_fixup_early)) \ 306 VMLINUX_SYMBOL(__end_pci_fixups_early) = .; \ 307 VMLINUX_SYMBOL(__start_pci_fixups_header) = .; \ 308 KEEP(*(.pci_fixup_header)) \ 309 VMLINUX_SYMBOL(__end_pci_fixups_header) = .; \ 310 VMLINUX_SYMBOL(__start_pci_fixups_final) = .; \ 311 KEEP(*(.pci_fixup_final)) \ 312 VMLINUX_SYMBOL(__end_pci_fixups_final) = .; \ 313 VMLINUX_SYMBOL(__start_pci_fixups_enable) = .; \ 314 KEEP(*(.pci_fixup_enable)) \ 315 VMLINUX_SYMBOL(__end_pci_fixups_enable) = .; \ 316 VMLINUX_SYMBOL(__start_pci_fixups_resume) = .; \ 317 KEEP(*(.pci_fixup_resume)) \ 318 VMLINUX_SYMBOL(__end_pci_fixups_resume) = .; \ 319 VMLINUX_SYMBOL(__start_pci_fixups_resume_early) = .; \ 320 KEEP(*(.pci_fixup_resume_early)) \ 321 VMLINUX_SYMBOL(__end_pci_fixups_resume_early) = .; \ 322 VMLINUX_SYMBOL(__start_pci_fixups_suspend) = .; \ 323 KEEP(*(.pci_fixup_suspend)) \ 324 VMLINUX_SYMBOL(__end_pci_fixups_suspend) = .; \ 325 VMLINUX_SYMBOL(__start_pci_fixups_suspend_late) = .; \ 326 KEEP(*(.pci_fixup_suspend_late)) \ 327 VMLINUX_SYMBOL(__end_pci_fixups_suspend_late) = .; \ 328 } \ 329 \ 330 /* Built-in firmware blobs */ \ 331 .builtin_fw : AT(ADDR(.builtin_fw) - LOAD_OFFSET) { \ 332 VMLINUX_SYMBOL(__start_builtin_fw) = .; \ 333 KEEP(*(.builtin_fw)) \ 334 VMLINUX_SYMBOL(__end_builtin_fw) = .; \ 335 } \ 336 \ 337 TRACEDATA \ 338 \ 339 /* Kernel symbol table: Normal symbols */ \ 340 __ksymtab : AT(ADDR(__ksymtab) - LOAD_OFFSET) { \ 341 VMLINUX_SYMBOL(__start___ksymtab) = .; \ 342 KEEP(*(SORT(___ksymtab+*))) \ 343 VMLINUX_SYMBOL(__stop___ksymtab) = .; \ 344 } \ 345 \ 346 /* Kernel symbol table: GPL-only symbols */ \ 347 __ksymtab_gpl : AT(ADDR(__ksymtab_gpl) - LOAD_OFFSET) { \ 348 VMLINUX_SYMBOL(__start___ksymtab_gpl) = .; \ 349 KEEP(*(SORT(___ksymtab_gpl+*))) \ 350 VMLINUX_SYMBOL(__stop___ksymtab_gpl) = .; \ 351 } \ 352 \ 353 /* Kernel symbol table: Normal unused symbols */ \ 354 __ksymtab_unused : AT(ADDR(__ksymtab_unused) - LOAD_OFFSET) { \ 355 VMLINUX_SYMBOL(__start___ksymtab_unused) = .; \ 356 KEEP(*(SORT(___ksymtab_unused+*))) \ 357 VMLINUX_SYMBOL(__stop___ksymtab_unused) = .; \ 358 } \ 359 \ 360 /* Kernel symbol table: GPL-only unused symbols */ \ 361 __ksymtab_unused_gpl : AT(ADDR(__ksymtab_unused_gpl) - LOAD_OFFSET) { \ 362 VMLINUX_SYMBOL(__start___ksymtab_unused_gpl) = .; \ 363 KEEP(*(SORT(___ksymtab_unused_gpl+*))) \ 364 VMLINUX_SYMBOL(__stop___ksymtab_unused_gpl) = .; \ 365 } \ 366 \ 367 /* Kernel symbol table: GPL-future-only symbols */ \ 368 __ksymtab_gpl_future : AT(ADDR(__ksymtab_gpl_future) - LOAD_OFFSET) { \ 369 VMLINUX_SYMBOL(__start___ksymtab_gpl_future) = .; \ 370 KEEP(*(SORT(___ksymtab_gpl_future+*))) \ 371 VMLINUX_SYMBOL(__stop___ksymtab_gpl_future) = .; \ 372 } \ 373 \ 374 /* Kernel symbol table: Normal symbols */ \ 375 __kcrctab : AT(ADDR(__kcrctab) - LOAD_OFFSET) { \ 376 VMLINUX_SYMBOL(__start___kcrctab) = .; \ 377 KEEP(*(SORT(___kcrctab+*))) \ 378 VMLINUX_SYMBOL(__stop___kcrctab) = .; \ 379 } \ 380 \ 381 /* Kernel symbol table: GPL-only symbols */ \ 382 __kcrctab_gpl : AT(ADDR(__kcrctab_gpl) - LOAD_OFFSET) { \ 383 VMLINUX_SYMBOL(__start___kcrctab_gpl) = .; \ 384 KEEP(*(SORT(___kcrctab_gpl+*))) \ 385 VMLINUX_SYMBOL(__stop___kcrctab_gpl) = .; \ 386 } \ 387 \ 388 /* Kernel symbol table: Normal unused symbols */ \ 389 __kcrctab_unused : AT(ADDR(__kcrctab_unused) - LOAD_OFFSET) { \ 390 VMLINUX_SYMBOL(__start___kcrctab_unused) = .; \ 391 KEEP(*(SORT(___kcrctab_unused+*))) \ 392 VMLINUX_SYMBOL(__stop___kcrctab_unused) = .; \ 393 } \ 394 \ 395 /* Kernel symbol table: GPL-only unused symbols */ \ 396 __kcrctab_unused_gpl : AT(ADDR(__kcrctab_unused_gpl) - LOAD_OFFSET) { \ 397 VMLINUX_SYMBOL(__start___kcrctab_unused_gpl) = .; \ 398 KEEP(*(SORT(___kcrctab_unused_gpl+*))) \ 399 VMLINUX_SYMBOL(__stop___kcrctab_unused_gpl) = .; \ 400 } \ 401 \ 402 /* Kernel symbol table: GPL-future-only symbols */ \ 403 __kcrctab_gpl_future : AT(ADDR(__kcrctab_gpl_future) - LOAD_OFFSET) { \ 404 VMLINUX_SYMBOL(__start___kcrctab_gpl_future) = .; \ 405 KEEP(*(SORT(___kcrctab_gpl_future+*))) \ 406 VMLINUX_SYMBOL(__stop___kcrctab_gpl_future) = .; \ 407 } \ 408 \ 409 /* Kernel symbol table: strings */ \ 410 __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \ 411 *(__ksymtab_strings) \ 412 } \ 413 \ 414 /* __*init sections */ \ 415 __init_rodata : AT(ADDR(__init_rodata) - LOAD_OFFSET) { \ 416 *(.ref.rodata) \ 417 MEM_KEEP(init.rodata) \ 418 MEM_KEEP(exit.rodata) \ 419 } \ 420 \ 421 /* Built-in module parameters. */ \ 422 __param : AT(ADDR(__param) - LOAD_OFFSET) { \ 423 VMLINUX_SYMBOL(__start___param) = .; \ 424 KEEP(*(__param)) \ 425 VMLINUX_SYMBOL(__stop___param) = .; \ 426 } \ 427 \ 428 /* Built-in module versions. */ \ 429 __modver : AT(ADDR(__modver) - LOAD_OFFSET) { \ 430 VMLINUX_SYMBOL(__start___modver) = .; \ 431 KEEP(*(__modver)) \ 432 VMLINUX_SYMBOL(__stop___modver) = .; \ 433 . = ALIGN((align)); \ 434 VMLINUX_SYMBOL(__end_rodata) = .; \ 435 } \ 436 . = ALIGN((align)); 437 438 /* RODATA & RO_DATA provided for backward compatibility. 439 * All archs are supposed to use RO_DATA() */ 440 #define RODATA RO_DATA_SECTION(4096) 441 #define RO_DATA(align) RO_DATA_SECTION(align) 442 443 #define SECURITY_INIT \ 444 .security_initcall.init : AT(ADDR(.security_initcall.init) - LOAD_OFFSET) { \ 445 VMLINUX_SYMBOL(__security_initcall_start) = .; \ 446 KEEP(*(.security_initcall.init)) \ 447 VMLINUX_SYMBOL(__security_initcall_end) = .; \ 448 } 449 450 /* 451 * .text section. Map to function alignment to avoid address changes 452 * during second ld run in second ld pass when generating System.map 453 * 454 * TEXT_MAIN here will match .text.fixup and .text.unlikely if dead 455 * code elimination is enabled, so these sections should be converted 456 * to use ".." first. 457 */ 458 #define TEXT_TEXT \ 459 ALIGN_FUNCTION(); \ 460 *(.text.hot TEXT_MAIN .text.fixup .text.unlikely) \ 461 *(.ref.text) \ 462 MEM_KEEP(init.text) \ 463 MEM_KEEP(exit.text) \ 464 465 466 /* sched.text is aling to function alignment to secure we have same 467 * address even at second ld pass when generating System.map */ 468 #define SCHED_TEXT \ 469 ALIGN_FUNCTION(); \ 470 VMLINUX_SYMBOL(__sched_text_start) = .; \ 471 *(.sched.text) \ 472 VMLINUX_SYMBOL(__sched_text_end) = .; 473 474 /* spinlock.text is aling to function alignment to secure we have same 475 * address even at second ld pass when generating System.map */ 476 #define LOCK_TEXT \ 477 ALIGN_FUNCTION(); \ 478 VMLINUX_SYMBOL(__lock_text_start) = .; \ 479 *(.spinlock.text) \ 480 VMLINUX_SYMBOL(__lock_text_end) = .; 481 482 #define CPUIDLE_TEXT \ 483 ALIGN_FUNCTION(); \ 484 VMLINUX_SYMBOL(__cpuidle_text_start) = .; \ 485 *(.cpuidle.text) \ 486 VMLINUX_SYMBOL(__cpuidle_text_end) = .; 487 488 #define KPROBES_TEXT \ 489 ALIGN_FUNCTION(); \ 490 VMLINUX_SYMBOL(__kprobes_text_start) = .; \ 491 *(.kprobes.text) \ 492 VMLINUX_SYMBOL(__kprobes_text_end) = .; 493 494 #define ENTRY_TEXT \ 495 ALIGN_FUNCTION(); \ 496 VMLINUX_SYMBOL(__entry_text_start) = .; \ 497 *(.entry.text) \ 498 VMLINUX_SYMBOL(__entry_text_end) = .; 499 500 #define IRQENTRY_TEXT \ 501 ALIGN_FUNCTION(); \ 502 VMLINUX_SYMBOL(__irqentry_text_start) = .; \ 503 *(.irqentry.text) \ 504 VMLINUX_SYMBOL(__irqentry_text_end) = .; 505 506 #define SOFTIRQENTRY_TEXT \ 507 ALIGN_FUNCTION(); \ 508 VMLINUX_SYMBOL(__softirqentry_text_start) = .; \ 509 *(.softirqentry.text) \ 510 VMLINUX_SYMBOL(__softirqentry_text_end) = .; 511 512 /* Section used for early init (in .S files) */ 513 #define HEAD_TEXT *(.head.text) 514 515 #define HEAD_TEXT_SECTION \ 516 .head.text : AT(ADDR(.head.text) - LOAD_OFFSET) { \ 517 HEAD_TEXT \ 518 } 519 520 /* 521 * Exception table 522 */ 523 #define EXCEPTION_TABLE(align) \ 524 . = ALIGN(align); \ 525 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { \ 526 VMLINUX_SYMBOL(__start___ex_table) = .; \ 527 KEEP(*(__ex_table)) \ 528 VMLINUX_SYMBOL(__stop___ex_table) = .; \ 529 } 530 531 /* 532 * Init task 533 */ 534 #define INIT_TASK_DATA_SECTION(align) \ 535 . = ALIGN(align); \ 536 .data..init_task : AT(ADDR(.data..init_task) - LOAD_OFFSET) { \ 537 INIT_TASK_DATA(align) \ 538 } 539 540 #ifdef CONFIG_CONSTRUCTORS 541 #define KERNEL_CTORS() . = ALIGN(8); \ 542 VMLINUX_SYMBOL(__ctors_start) = .; \ 543 KEEP(*(.ctors)) \ 544 KEEP(*(SORT(.init_array.*))) \ 545 KEEP(*(.init_array)) \ 546 VMLINUX_SYMBOL(__ctors_end) = .; 547 #else 548 #define KERNEL_CTORS() 549 #endif 550 551 /* init and exit section handling */ 552 #define INIT_DATA \ 553 KEEP(*(SORT(___kentry+*))) \ 554 *(.init.data) \ 555 MEM_DISCARD(init.data) \ 556 KERNEL_CTORS() \ 557 MCOUNT_REC() \ 558 *(.init.rodata) \ 559 FTRACE_EVENTS() \ 560 TRACE_SYSCALLS() \ 561 KPROBE_BLACKLIST() \ 562 MEM_DISCARD(init.rodata) \ 563 CLK_OF_TABLES() \ 564 RESERVEDMEM_OF_TABLES() \ 565 TIMER_OF_TABLES() \ 566 IOMMU_OF_TABLES() \ 567 CPU_METHOD_OF_TABLES() \ 568 CPUIDLE_METHOD_OF_TABLES() \ 569 KERNEL_DTB() \ 570 IRQCHIP_OF_MATCH_TABLE() \ 571 ACPI_PROBE_TABLE(irqchip) \ 572 ACPI_PROBE_TABLE(timer) \ 573 ACPI_PROBE_TABLE(iort) \ 574 EARLYCON_TABLE() 575 576 #define INIT_TEXT \ 577 *(.init.text) \ 578 *(.text.startup) \ 579 MEM_DISCARD(init.text) 580 581 #define EXIT_DATA \ 582 *(.exit.data) \ 583 *(.fini_array) \ 584 *(.dtors) \ 585 MEM_DISCARD(exit.data) \ 586 MEM_DISCARD(exit.rodata) 587 588 #define EXIT_TEXT \ 589 *(.exit.text) \ 590 *(.text.exit) \ 591 MEM_DISCARD(exit.text) 592 593 #define EXIT_CALL \ 594 *(.exitcall.exit) 595 596 /* 597 * bss (Block Started by Symbol) - uninitialized data 598 * zeroed during startup 599 */ 600 #define SBSS(sbss_align) \ 601 . = ALIGN(sbss_align); \ 602 .sbss : AT(ADDR(.sbss) - LOAD_OFFSET) { \ 603 *(.dynsbss) \ 604 *(.sbss) \ 605 *(.scommon) \ 606 } 607 608 /* 609 * Allow archectures to redefine BSS_FIRST_SECTIONS to add extra 610 * sections to the front of bss. 611 */ 612 #ifndef BSS_FIRST_SECTIONS 613 #define BSS_FIRST_SECTIONS 614 #endif 615 616 #define BSS(bss_align) \ 617 . = ALIGN(bss_align); \ 618 .bss : AT(ADDR(.bss) - LOAD_OFFSET) { \ 619 BSS_FIRST_SECTIONS \ 620 *(.bss..page_aligned) \ 621 *(.dynbss) \ 622 *(BSS_MAIN) \ 623 *(COMMON) \ 624 } 625 626 /* 627 * DWARF debug sections. 628 * Symbols in the DWARF debugging sections are relative to 629 * the beginning of the section so we begin them at 0. 630 */ 631 #define DWARF_DEBUG \ 632 /* DWARF 1 */ \ 633 .debug 0 : { *(.debug) } \ 634 .line 0 : { *(.line) } \ 635 /* GNU DWARF 1 extensions */ \ 636 .debug_srcinfo 0 : { *(.debug_srcinfo) } \ 637 .debug_sfnames 0 : { *(.debug_sfnames) } \ 638 /* DWARF 1.1 and DWARF 2 */ \ 639 .debug_aranges 0 : { *(.debug_aranges) } \ 640 .debug_pubnames 0 : { *(.debug_pubnames) } \ 641 /* DWARF 2 */ \ 642 .debug_info 0 : { *(.debug_info \ 643 .gnu.linkonce.wi.*) } \ 644 .debug_abbrev 0 : { *(.debug_abbrev) } \ 645 .debug_line 0 : { *(.debug_line) } \ 646 .debug_frame 0 : { *(.debug_frame) } \ 647 .debug_str 0 : { *(.debug_str) } \ 648 .debug_loc 0 : { *(.debug_loc) } \ 649 .debug_macinfo 0 : { *(.debug_macinfo) } \ 650 .debug_pubtypes 0 : { *(.debug_pubtypes) } \ 651 /* DWARF 3 */ \ 652 .debug_ranges 0 : { *(.debug_ranges) } \ 653 /* SGI/MIPS DWARF 2 extensions */ \ 654 .debug_weaknames 0 : { *(.debug_weaknames) } \ 655 .debug_funcnames 0 : { *(.debug_funcnames) } \ 656 .debug_typenames 0 : { *(.debug_typenames) } \ 657 .debug_varnames 0 : { *(.debug_varnames) } \ 658 /* GNU DWARF 2 extensions */ \ 659 .debug_gnu_pubnames 0 : { *(.debug_gnu_pubnames) } \ 660 .debug_gnu_pubtypes 0 : { *(.debug_gnu_pubtypes) } \ 661 /* DWARF 4 */ \ 662 .debug_types 0 : { *(.debug_types) } \ 663 /* DWARF 5 */ \ 664 .debug_macro 0 : { *(.debug_macro) } \ 665 .debug_addr 0 : { *(.debug_addr) } 666 667 /* Stabs debugging sections. */ 668 #define STABS_DEBUG \ 669 .stab 0 : { *(.stab) } \ 670 .stabstr 0 : { *(.stabstr) } \ 671 .stab.excl 0 : { *(.stab.excl) } \ 672 .stab.exclstr 0 : { *(.stab.exclstr) } \ 673 .stab.index 0 : { *(.stab.index) } \ 674 .stab.indexstr 0 : { *(.stab.indexstr) } \ 675 .comment 0 : { *(.comment) } 676 677 #ifdef CONFIG_GENERIC_BUG 678 #define BUG_TABLE \ 679 . = ALIGN(8); \ 680 __bug_table : AT(ADDR(__bug_table) - LOAD_OFFSET) { \ 681 VMLINUX_SYMBOL(__start___bug_table) = .; \ 682 KEEP(*(__bug_table)) \ 683 VMLINUX_SYMBOL(__stop___bug_table) = .; \ 684 } 685 #else 686 #define BUG_TABLE 687 #endif 688 689 #ifdef CONFIG_ORC_UNWINDER 690 #define ORC_UNWIND_TABLE \ 691 . = ALIGN(4); \ 692 .orc_unwind_ip : AT(ADDR(.orc_unwind_ip) - LOAD_OFFSET) { \ 693 VMLINUX_SYMBOL(__start_orc_unwind_ip) = .; \ 694 KEEP(*(.orc_unwind_ip)) \ 695 VMLINUX_SYMBOL(__stop_orc_unwind_ip) = .; \ 696 } \ 697 . = ALIGN(6); \ 698 .orc_unwind : AT(ADDR(.orc_unwind) - LOAD_OFFSET) { \ 699 VMLINUX_SYMBOL(__start_orc_unwind) = .; \ 700 KEEP(*(.orc_unwind)) \ 701 VMLINUX_SYMBOL(__stop_orc_unwind) = .; \ 702 } \ 703 . = ALIGN(4); \ 704 .orc_lookup : AT(ADDR(.orc_lookup) - LOAD_OFFSET) { \ 705 VMLINUX_SYMBOL(orc_lookup) = .; \ 706 . += (((SIZEOF(.text) + LOOKUP_BLOCK_SIZE - 1) / \ 707 LOOKUP_BLOCK_SIZE) + 1) * 4; \ 708 VMLINUX_SYMBOL(orc_lookup_end) = .; \ 709 } 710 #else 711 #define ORC_UNWIND_TABLE 712 #endif 713 714 #ifdef CONFIG_PM_TRACE 715 #define TRACEDATA \ 716 . = ALIGN(4); \ 717 .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) { \ 718 VMLINUX_SYMBOL(__tracedata_start) = .; \ 719 KEEP(*(.tracedata)) \ 720 VMLINUX_SYMBOL(__tracedata_end) = .; \ 721 } 722 #else 723 #define TRACEDATA 724 #endif 725 726 #define NOTES \ 727 .notes : AT(ADDR(.notes) - LOAD_OFFSET) { \ 728 VMLINUX_SYMBOL(__start_notes) = .; \ 729 *(.note.*) \ 730 VMLINUX_SYMBOL(__stop_notes) = .; \ 731 } 732 733 #define INIT_SETUP(initsetup_align) \ 734 . = ALIGN(initsetup_align); \ 735 VMLINUX_SYMBOL(__setup_start) = .; \ 736 KEEP(*(.init.setup)) \ 737 VMLINUX_SYMBOL(__setup_end) = .; 738 739 #define INIT_CALLS_LEVEL(level) \ 740 VMLINUX_SYMBOL(__initcall##level##_start) = .; \ 741 KEEP(*(.initcall##level##.init)) \ 742 KEEP(*(.initcall##level##s.init)) \ 743 744 #define INIT_CALLS \ 745 VMLINUX_SYMBOL(__initcall_start) = .; \ 746 KEEP(*(.initcallearly.init)) \ 747 INIT_CALLS_LEVEL(0) \ 748 INIT_CALLS_LEVEL(1) \ 749 INIT_CALLS_LEVEL(2) \ 750 INIT_CALLS_LEVEL(3) \ 751 INIT_CALLS_LEVEL(4) \ 752 INIT_CALLS_LEVEL(5) \ 753 INIT_CALLS_LEVEL(rootfs) \ 754 INIT_CALLS_LEVEL(6) \ 755 INIT_CALLS_LEVEL(7) \ 756 VMLINUX_SYMBOL(__initcall_end) = .; 757 758 #define CON_INITCALL \ 759 VMLINUX_SYMBOL(__con_initcall_start) = .; \ 760 KEEP(*(.con_initcall.init)) \ 761 VMLINUX_SYMBOL(__con_initcall_end) = .; 762 763 #define SECURITY_INITCALL \ 764 VMLINUX_SYMBOL(__security_initcall_start) = .; \ 765 KEEP(*(.security_initcall.init)) \ 766 VMLINUX_SYMBOL(__security_initcall_end) = .; 767 768 #ifdef CONFIG_BLK_DEV_INITRD 769 #define INIT_RAM_FS \ 770 . = ALIGN(4); \ 771 VMLINUX_SYMBOL(__initramfs_start) = .; \ 772 KEEP(*(.init.ramfs)) \ 773 . = ALIGN(8); \ 774 KEEP(*(.init.ramfs.info)) 775 #else 776 #define INIT_RAM_FS 777 #endif 778 779 /* 780 * Default discarded sections. 781 * 782 * Some archs want to discard exit text/data at runtime rather than 783 * link time due to cross-section references such as alt instructions, 784 * bug table, eh_frame, etc. DISCARDS must be the last of output 785 * section definitions so that such archs put those in earlier section 786 * definitions. 787 */ 788 #define DISCARDS \ 789 /DISCARD/ : { \ 790 EXIT_TEXT \ 791 EXIT_DATA \ 792 EXIT_CALL \ 793 *(.discard) \ 794 *(.discard.*) \ 795 } 796 797 /** 798 * PERCPU_INPUT - the percpu input sections 799 * @cacheline: cacheline size 800 * 801 * The core percpu section names and core symbols which do not rely 802 * directly upon load addresses. 803 * 804 * @cacheline is used to align subsections to avoid false cacheline 805 * sharing between subsections for different purposes. 806 */ 807 #define PERCPU_INPUT(cacheline) \ 808 VMLINUX_SYMBOL(__per_cpu_start) = .; \ 809 *(.data..percpu..first) \ 810 . = ALIGN(PAGE_SIZE); \ 811 *(.data..percpu..page_aligned) \ 812 . = ALIGN(cacheline); \ 813 *(.data..percpu..read_mostly) \ 814 . = ALIGN(cacheline); \ 815 *(.data..percpu) \ 816 *(.data..percpu..shared_aligned) \ 817 VMLINUX_SYMBOL(__per_cpu_end) = .; 818 819 /** 820 * PERCPU_VADDR - define output section for percpu area 821 * @cacheline: cacheline size 822 * @vaddr: explicit base address (optional) 823 * @phdr: destination PHDR (optional) 824 * 825 * Macro which expands to output section for percpu area. 826 * 827 * @cacheline is used to align subsections to avoid false cacheline 828 * sharing between subsections for different purposes. 829 * 830 * If @vaddr is not blank, it specifies explicit base address and all 831 * percpu symbols will be offset from the given address. If blank, 832 * @vaddr always equals @laddr + LOAD_OFFSET. 833 * 834 * @phdr defines the output PHDR to use if not blank. Be warned that 835 * output PHDR is sticky. If @phdr is specified, the next output 836 * section in the linker script will go there too. @phdr should have 837 * a leading colon. 838 * 839 * Note that this macros defines __per_cpu_load as an absolute symbol. 840 * If there is no need to put the percpu section at a predetermined 841 * address, use PERCPU_SECTION. 842 */ 843 #define PERCPU_VADDR(cacheline, vaddr, phdr) \ 844 VMLINUX_SYMBOL(__per_cpu_load) = .; \ 845 .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \ 846 - LOAD_OFFSET) { \ 847 PERCPU_INPUT(cacheline) \ 848 } phdr \ 849 . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu); 850 851 /** 852 * PERCPU_SECTION - define output section for percpu area, simple version 853 * @cacheline: cacheline size 854 * 855 * Align to PAGE_SIZE and outputs output section for percpu area. This 856 * macro doesn't manipulate @vaddr or @phdr and __per_cpu_load and 857 * __per_cpu_start will be identical. 858 * 859 * This macro is equivalent to ALIGN(PAGE_SIZE); PERCPU_VADDR(@cacheline,,) 860 * except that __per_cpu_load is defined as a relative symbol against 861 * .data..percpu which is required for relocatable x86_32 configuration. 862 */ 863 #define PERCPU_SECTION(cacheline) \ 864 . = ALIGN(PAGE_SIZE); \ 865 .data..percpu : AT(ADDR(.data..percpu) - LOAD_OFFSET) { \ 866 VMLINUX_SYMBOL(__per_cpu_load) = .; \ 867 PERCPU_INPUT(cacheline) \ 868 } 869 870 871 /* 872 * Definition of the high level *_SECTION macros 873 * They will fit only a subset of the architectures 874 */ 875 876 877 /* 878 * Writeable data. 879 * All sections are combined in a single .data section. 880 * The sections following CONSTRUCTORS are arranged so their 881 * typical alignment matches. 882 * A cacheline is typical/always less than a PAGE_SIZE so 883 * the sections that has this restriction (or similar) 884 * is located before the ones requiring PAGE_SIZE alignment. 885 * NOSAVE_DATA starts and ends with a PAGE_SIZE alignment which 886 * matches the requirement of PAGE_ALIGNED_DATA. 887 * 888 * use 0 as page_align if page_aligned data is not used */ 889 #define RW_DATA_SECTION(cacheline, pagealigned, inittask) \ 890 . = ALIGN(PAGE_SIZE); \ 891 .data : AT(ADDR(.data) - LOAD_OFFSET) { \ 892 INIT_TASK_DATA(inittask) \ 893 NOSAVE_DATA \ 894 PAGE_ALIGNED_DATA(pagealigned) \ 895 CACHELINE_ALIGNED_DATA(cacheline) \ 896 READ_MOSTLY_DATA(cacheline) \ 897 DATA_DATA \ 898 CONSTRUCTORS \ 899 } \ 900 BUG_TABLE \ 901 902 #define INIT_TEXT_SECTION(inittext_align) \ 903 . = ALIGN(inittext_align); \ 904 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) { \ 905 VMLINUX_SYMBOL(_sinittext) = .; \ 906 INIT_TEXT \ 907 VMLINUX_SYMBOL(_einittext) = .; \ 908 } 909 910 #define INIT_DATA_SECTION(initsetup_align) \ 911 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { \ 912 INIT_DATA \ 913 INIT_SETUP(initsetup_align) \ 914 INIT_CALLS \ 915 CON_INITCALL \ 916 SECURITY_INITCALL \ 917 INIT_RAM_FS \ 918 } 919 920 #define BSS_SECTION(sbss_align, bss_align, stop_align) \ 921 . = ALIGN(sbss_align); \ 922 VMLINUX_SYMBOL(__bss_start) = .; \ 923 SBSS(sbss_align) \ 924 BSS(bss_align) \ 925 . = ALIGN(stop_align); \ 926 VMLINUX_SYMBOL(__bss_stop) = .; 927