2 * Helper macros to support writing architecture specific
5 * A minimal linker scripts has following content:
6 * [This is a sample, architectures may have special requiriements]
16 * INIT_TEXT_SECTION(PAGE_SIZE)
17 * INIT_DATA_SECTION(...)
18 * PERCPU_SECTION(CACHELINE_SIZE)
30 * EXCEPTION_TABLE(...)
32 * BSS_SECTION(0, 0, 0)
39 * DISCARDS // must be the last
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
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
58 * Only some architectures want to have the .notes segment visible in
59 * a separate PT_NOTE ELF Program Header. When this happens, it needs
60 * to be visible in both the kernel text's PT_LOAD and the PT_NOTE
61 * Program Headers. In this case, though, the PT_LOAD needs to be made
62 * the default again so that all the following sections don't also end
63 * up in the PT_NOTE Program Header.
66 #define NOTES_HEADERS :text :note
67 #define NOTES_HEADERS_RESTORE __restore_ph : { *(.__restore_ph) } :text
70 #define NOTES_HEADERS_RESTORE
74 * Some architectures have non-executable read-only exception tables.
75 * They can be added to the RO_DATA segment by specifying their desired
78 #ifdef RO_EXCEPTION_TABLE_ALIGN
79 #define RO_EXCEPTION_TABLE EXCEPTION_TABLE(RO_EXCEPTION_TABLE_ALIGN)
81 #define RO_EXCEPTION_TABLE
84 /* Align . to a 8 byte boundary equals to maximum function alignment. */
85 #define ALIGN_FUNCTION() . = ALIGN(8)
88 * LD_DEAD_CODE_DATA_ELIMINATION option enables -fdata-sections, which
89 * generates .data.identifier sections, which need to be pulled in with
90 * .data. We don't want to pull in .data..other sections, which Linux
91 * has defined. Same for text and bss.
93 * RODATA_MAIN is not used because existing code already defines .rodata.x
94 * sections to be brought in with rodata.
96 #ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
97 #define TEXT_MAIN .text .text.[0-9a-zA-Z_]*
98 #define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..LPBX*
99 #define SDATA_MAIN .sdata .sdata.[0-9a-zA-Z_]*
100 #define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]*
101 #define BSS_MAIN .bss .bss.[0-9a-zA-Z_]*
102 #define SBSS_MAIN .sbss .sbss.[0-9a-zA-Z_]*
104 #define TEXT_MAIN .text
105 #define DATA_MAIN .data
106 #define SDATA_MAIN .sdata
107 #define RODATA_MAIN .rodata
108 #define BSS_MAIN .bss
109 #define SBSS_MAIN .sbss
113 * GCC 4.5 and later have a 32 bytes section alignment for structures.
114 * Except GCC 4.9, that feels the need to align on 64 bytes.
116 #if __GNUC__ == 4 && __GNUC_MINOR__ == 9
117 #define STRUCT_ALIGNMENT 64
119 #define STRUCT_ALIGNMENT 32
121 #define STRUCT_ALIGN() . = ALIGN(STRUCT_ALIGNMENT)
124 * The order of the sched class addresses are important, as they are
125 * used to determine the order of the priority of each sched class in
126 * relation to each other.
130 __begin_sched_classes = .; \
131 *(__idle_sched_class) \
132 *(__fair_sched_class) \
133 *(__rt_sched_class) \
134 *(__dl_sched_class) \
135 *(__stop_sched_class) \
136 __end_sched_classes = .;
138 /* The actual configuration determine if the init/exit sections
139 * are handled as text/data or they can be discarded (which
140 * often happens at runtime)
142 #ifdef CONFIG_HOTPLUG_CPU
143 #define CPU_KEEP(sec) *(.cpu##sec)
144 #define CPU_DISCARD(sec)
146 #define CPU_KEEP(sec)
147 #define CPU_DISCARD(sec) *(.cpu##sec)
150 #if defined(CONFIG_MEMORY_HOTPLUG)
151 #define MEM_KEEP(sec) *(.mem##sec)
152 #define MEM_DISCARD(sec)
154 #define MEM_KEEP(sec)
155 #define MEM_DISCARD(sec) *(.mem##sec)
158 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
160 * The ftrace call sites are logged to a section whose name depends on the
161 * compiler option used. A given kernel image will only use one, AKA
162 * FTRACE_CALLSITE_SECTION. We capture all of them here to avoid header
163 * dependencies for FTRACE_CALLSITE_SECTION's definition.
165 * Need to also make ftrace_stub_graph point to ftrace_stub
166 * so that the same stub location may have different protocols
167 * and not mess up with C verifiers.
169 #define MCOUNT_REC() . = ALIGN(8); \
170 __start_mcount_loc = .; \
171 KEEP(*(__mcount_loc)) \
172 KEEP(*(__patchable_function_entries)) \
173 __stop_mcount_loc = .; \
174 ftrace_stub_graph = ftrace_stub;
176 # ifdef CONFIG_FUNCTION_TRACER
177 # define MCOUNT_REC() ftrace_stub_graph = ftrace_stub;
179 # define MCOUNT_REC()
183 #ifdef CONFIG_TRACE_BRANCH_PROFILING
184 #define LIKELY_PROFILE() __start_annotated_branch_profile = .; \
185 KEEP(*(_ftrace_annotated_branch)) \
186 __stop_annotated_branch_profile = .;
188 #define LIKELY_PROFILE()
191 #ifdef CONFIG_PROFILE_ALL_BRANCHES
192 #define BRANCH_PROFILE() __start_branch_profile = .; \
193 KEEP(*(_ftrace_branch)) \
194 __stop_branch_profile = .;
196 #define BRANCH_PROFILE()
199 #ifdef CONFIG_KPROBES
200 #define KPROBE_BLACKLIST() . = ALIGN(8); \
201 __start_kprobe_blacklist = .; \
202 KEEP(*(_kprobe_blacklist)) \
203 __stop_kprobe_blacklist = .;
205 #define KPROBE_BLACKLIST()
208 #ifdef CONFIG_FUNCTION_ERROR_INJECTION
209 #define ERROR_INJECT_WHITELIST() STRUCT_ALIGN(); \
210 __start_error_injection_whitelist = .; \
211 KEEP(*(_error_injection_whitelist)) \
212 __stop_error_injection_whitelist = .;
214 #define ERROR_INJECT_WHITELIST()
217 #ifdef CONFIG_EVENT_TRACING
218 #define FTRACE_EVENTS() . = ALIGN(8); \
219 __start_ftrace_events = .; \
220 KEEP(*(_ftrace_events)) \
221 __stop_ftrace_events = .; \
222 __start_ftrace_eval_maps = .; \
223 KEEP(*(_ftrace_eval_map)) \
224 __stop_ftrace_eval_maps = .;
226 #define FTRACE_EVENTS()
229 #ifdef CONFIG_TRACING
230 #define TRACE_PRINTKS() __start___trace_bprintk_fmt = .; \
231 KEEP(*(__trace_printk_fmt)) /* Trace_printk fmt' pointer */ \
232 __stop___trace_bprintk_fmt = .;
233 #define TRACEPOINT_STR() __start___tracepoint_str = .; \
234 KEEP(*(__tracepoint_str)) /* Trace_printk fmt' pointer */ \
235 __stop___tracepoint_str = .;
237 #define TRACE_PRINTKS()
238 #define TRACEPOINT_STR()
241 #ifdef CONFIG_FTRACE_SYSCALLS
242 #define TRACE_SYSCALLS() . = ALIGN(8); \
243 __start_syscalls_metadata = .; \
244 KEEP(*(__syscalls_metadata)) \
245 __stop_syscalls_metadata = .;
247 #define TRACE_SYSCALLS()
250 #ifdef CONFIG_BPF_EVENTS
251 #define BPF_RAW_TP() STRUCT_ALIGN(); \
252 __start__bpf_raw_tp = .; \
253 KEEP(*(__bpf_raw_tp_map)) \
254 __stop__bpf_raw_tp = .;
259 #ifdef CONFIG_SERIAL_EARLYCON
260 #define EARLYCON_TABLE() . = ALIGN(8); \
261 __earlycon_table = .; \
262 KEEP(*(__earlycon_table)) \
263 __earlycon_table_end = .;
265 #define EARLYCON_TABLE()
268 #ifdef CONFIG_SECURITY
269 #define LSM_TABLE() . = ALIGN(8); \
270 __start_lsm_info = .; \
271 KEEP(*(.lsm_info.init)) \
273 #define EARLY_LSM_TABLE() . = ALIGN(8); \
274 __start_early_lsm_info = .; \
275 KEEP(*(.early_lsm_info.init)) \
276 __end_early_lsm_info = .;
279 #define EARLY_LSM_TABLE()
282 #define ___OF_TABLE(cfg, name) _OF_TABLE_##cfg(name)
283 #define __OF_TABLE(cfg, name) ___OF_TABLE(cfg, name)
284 #define OF_TABLE(cfg, name) __OF_TABLE(IS_ENABLED(cfg), name)
285 #define _OF_TABLE_0(name)
286 #define _OF_TABLE_1(name) \
288 __##name##_of_table = .; \
289 KEEP(*(__##name##_of_table)) \
290 KEEP(*(__##name##_of_table_end))
292 #define TIMER_OF_TABLES() OF_TABLE(CONFIG_TIMER_OF, timer)
293 #define IRQCHIP_OF_MATCH_TABLE() OF_TABLE(CONFIG_IRQCHIP, irqchip)
294 #define CLK_OF_TABLES() OF_TABLE(CONFIG_COMMON_CLK, clk)
295 #define RESERVEDMEM_OF_TABLES() OF_TABLE(CONFIG_OF_RESERVED_MEM, reservedmem)
296 #define CPU_METHOD_OF_TABLES() OF_TABLE(CONFIG_SMP, cpu_method)
297 #define CPUIDLE_METHOD_OF_TABLES() OF_TABLE(CONFIG_CPU_IDLE, cpuidle_method)
300 #define ACPI_PROBE_TABLE(name) \
302 __##name##_acpi_probe_table = .; \
303 KEEP(*(__##name##_acpi_probe_table)) \
304 __##name##_acpi_probe_table_end = .;
306 #define ACPI_PROBE_TABLE(name)
309 #ifdef CONFIG_THERMAL
310 #define THERMAL_TABLE(name) \
312 __##name##_thermal_table = .; \
313 KEEP(*(__##name##_thermal_table)) \
314 __##name##_thermal_table_end = .;
316 #define THERMAL_TABLE(name)
320 #define DTPM_TABLE() \
323 KEEP(*(__dtpm_table)) \
324 __dtpm_table_end = .;
329 #define KERNEL_DTB() \
332 KEEP(*(.dtb.init.rodata)) \
342 *(.data..shared_aligned) /* percpu related */ \
343 MEM_KEEP(init.data*) \
344 MEM_KEEP(exit.data*) \
351 /* implement dynamic printk debug */ \
353 __start___dyndbg = .; \
355 __stop___dyndbg = .; \
363 * Data section helpers
365 #define NOSAVE_DATA \
366 . = ALIGN(PAGE_SIZE); \
367 __nosave_begin = .; \
369 . = ALIGN(PAGE_SIZE); \
372 #define PAGE_ALIGNED_DATA(page_align) \
373 . = ALIGN(page_align); \
374 *(.data..page_aligned) \
375 . = ALIGN(page_align);
377 #define READ_MOSTLY_DATA(align) \
379 *(.data..read_mostly) \
382 #define CACHELINE_ALIGNED_DATA(align) \
384 *(.data..cacheline_aligned)
386 #define INIT_TASK_DATA(align) \
388 __start_init_task = .; \
389 init_thread_union = .; \
391 KEEP(*(.data..init_task)) \
392 KEEP(*(.data..init_thread_info)) \
393 . = __start_init_task + THREAD_SIZE; \
396 #define JUMP_TABLE_DATA \
398 __start___jump_table = .; \
399 KEEP(*(__jump_table)) \
400 __stop___jump_table = .;
402 #define STATIC_CALL_DATA \
404 __start_static_call_sites = .; \
405 KEEP(*(.static_call_sites)) \
406 __stop_static_call_sites = .;
409 * Allow architectures to handle ro_after_init data on their
410 * own by defining an empty RO_AFTER_INIT_DATA.
412 #ifndef RO_AFTER_INIT_DATA
413 #define RO_AFTER_INIT_DATA \
415 __start_ro_after_init = .; \
416 *(.data..ro_after_init) \
419 __end_ro_after_init = .;
425 #define RO_DATA(align) \
426 . = ALIGN((align)); \
427 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
428 __start_rodata = .; \
429 *(.rodata) *(.rodata.*) \
431 RO_AFTER_INIT_DATA /* Read only after init */ \
433 __start___tracepoints_ptrs = .; \
434 KEEP(*(__tracepoints_ptrs)) /* Tracepoints: pointer array */ \
435 __stop___tracepoints_ptrs = .; \
436 *(__tracepoints_strings)/* Tracepoints: strings */ \
439 .rodata1 : AT(ADDR(.rodata1) - LOAD_OFFSET) { \
444 .pci_fixup : AT(ADDR(.pci_fixup) - LOAD_OFFSET) { \
445 __start_pci_fixups_early = .; \
446 KEEP(*(.pci_fixup_early)) \
447 __end_pci_fixups_early = .; \
448 __start_pci_fixups_header = .; \
449 KEEP(*(.pci_fixup_header)) \
450 __end_pci_fixups_header = .; \
451 __start_pci_fixups_final = .; \
452 KEEP(*(.pci_fixup_final)) \
453 __end_pci_fixups_final = .; \
454 __start_pci_fixups_enable = .; \
455 KEEP(*(.pci_fixup_enable)) \
456 __end_pci_fixups_enable = .; \
457 __start_pci_fixups_resume = .; \
458 KEEP(*(.pci_fixup_resume)) \
459 __end_pci_fixups_resume = .; \
460 __start_pci_fixups_resume_early = .; \
461 KEEP(*(.pci_fixup_resume_early)) \
462 __end_pci_fixups_resume_early = .; \
463 __start_pci_fixups_suspend = .; \
464 KEEP(*(.pci_fixup_suspend)) \
465 __end_pci_fixups_suspend = .; \
466 __start_pci_fixups_suspend_late = .; \
467 KEEP(*(.pci_fixup_suspend_late)) \
468 __end_pci_fixups_suspend_late = .; \
471 /* Built-in firmware blobs */ \
472 .builtin_fw : AT(ADDR(.builtin_fw) - LOAD_OFFSET) ALIGN(8) { \
473 __start_builtin_fw = .; \
474 KEEP(*(.builtin_fw)) \
475 __end_builtin_fw = .; \
480 /* Kernel symbol table: Normal symbols */ \
481 __ksymtab : AT(ADDR(__ksymtab) - LOAD_OFFSET) { \
482 __start___ksymtab = .; \
483 KEEP(*(SORT(___ksymtab+*))) \
484 __stop___ksymtab = .; \
487 /* Kernel symbol table: GPL-only symbols */ \
488 __ksymtab_gpl : AT(ADDR(__ksymtab_gpl) - LOAD_OFFSET) { \
489 __start___ksymtab_gpl = .; \
490 KEEP(*(SORT(___ksymtab_gpl+*))) \
491 __stop___ksymtab_gpl = .; \
494 /* Kernel symbol table: Normal unused symbols */ \
495 __ksymtab_unused : AT(ADDR(__ksymtab_unused) - LOAD_OFFSET) { \
496 __start___ksymtab_unused = .; \
497 KEEP(*(SORT(___ksymtab_unused+*))) \
498 __stop___ksymtab_unused = .; \
501 /* Kernel symbol table: GPL-only unused symbols */ \
502 __ksymtab_unused_gpl : AT(ADDR(__ksymtab_unused_gpl) - LOAD_OFFSET) { \
503 __start___ksymtab_unused_gpl = .; \
504 KEEP(*(SORT(___ksymtab_unused_gpl+*))) \
505 __stop___ksymtab_unused_gpl = .; \
508 /* Kernel symbol table: GPL-future-only symbols */ \
509 __ksymtab_gpl_future : AT(ADDR(__ksymtab_gpl_future) - LOAD_OFFSET) { \
510 __start___ksymtab_gpl_future = .; \
511 KEEP(*(SORT(___ksymtab_gpl_future+*))) \
512 __stop___ksymtab_gpl_future = .; \
515 /* Kernel symbol table: Normal symbols */ \
516 __kcrctab : AT(ADDR(__kcrctab) - LOAD_OFFSET) { \
517 __start___kcrctab = .; \
518 KEEP(*(SORT(___kcrctab+*))) \
519 __stop___kcrctab = .; \
522 /* Kernel symbol table: GPL-only symbols */ \
523 __kcrctab_gpl : AT(ADDR(__kcrctab_gpl) - LOAD_OFFSET) { \
524 __start___kcrctab_gpl = .; \
525 KEEP(*(SORT(___kcrctab_gpl+*))) \
526 __stop___kcrctab_gpl = .; \
529 /* Kernel symbol table: Normal unused symbols */ \
530 __kcrctab_unused : AT(ADDR(__kcrctab_unused) - LOAD_OFFSET) { \
531 __start___kcrctab_unused = .; \
532 KEEP(*(SORT(___kcrctab_unused+*))) \
533 __stop___kcrctab_unused = .; \
536 /* Kernel symbol table: GPL-only unused symbols */ \
537 __kcrctab_unused_gpl : AT(ADDR(__kcrctab_unused_gpl) - LOAD_OFFSET) { \
538 __start___kcrctab_unused_gpl = .; \
539 KEEP(*(SORT(___kcrctab_unused_gpl+*))) \
540 __stop___kcrctab_unused_gpl = .; \
543 /* Kernel symbol table: GPL-future-only symbols */ \
544 __kcrctab_gpl_future : AT(ADDR(__kcrctab_gpl_future) - LOAD_OFFSET) { \
545 __start___kcrctab_gpl_future = .; \
546 KEEP(*(SORT(___kcrctab_gpl_future+*))) \
547 __stop___kcrctab_gpl_future = .; \
550 /* Kernel symbol table: strings */ \
551 __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \
552 *(__ksymtab_strings) \
555 /* __*init sections */ \
556 __init_rodata : AT(ADDR(__init_rodata) - LOAD_OFFSET) { \
558 MEM_KEEP(init.rodata) \
559 MEM_KEEP(exit.rodata) \
562 /* Built-in module parameters. */ \
563 __param : AT(ADDR(__param) - LOAD_OFFSET) { \
564 __start___param = .; \
566 __stop___param = .; \
569 /* Built-in module versions. */ \
570 __modver : AT(ADDR(__modver) - LOAD_OFFSET) { \
571 __start___modver = .; \
573 __stop___modver = .; \
580 . = ALIGN((align)); \
584 * Non-instrumentable text section
586 #define NOINSTR_TEXT \
588 __noinstr_text_start = .; \
590 __noinstr_text_end = .;
593 * .text section. Map to function alignment to avoid address changes
594 * during second ld run in second ld pass when generating System.map
596 * TEXT_MAIN here will match .text.fixup and .text.unlikely if dead
597 * code elimination is enabled, so these sections should be converted
602 *(.text.hot .text.hot.*) \
603 *(TEXT_MAIN .text.fixup) \
604 *(.text.unlikely .text.unlikely.*) \
605 *(.text.unknown .text.unknown.*) \
609 MEM_KEEP(init.text*) \
610 MEM_KEEP(exit.text*) \
613 /* sched.text is aling to function alignment to secure we have same
614 * address even at second ld pass when generating System.map */
617 __sched_text_start = .; \
619 __sched_text_end = .;
621 /* spinlock.text is aling to function alignment to secure we have same
622 * address even at second ld pass when generating System.map */
625 __lock_text_start = .; \
629 #define CPUIDLE_TEXT \
631 __cpuidle_text_start = .; \
633 __cpuidle_text_end = .;
635 #define KPROBES_TEXT \
637 __kprobes_text_start = .; \
639 __kprobes_text_end = .;
643 __entry_text_start = .; \
645 __entry_text_end = .;
647 #define IRQENTRY_TEXT \
649 __irqentry_text_start = .; \
651 __irqentry_text_end = .;
653 #define SOFTIRQENTRY_TEXT \
655 __softirqentry_text_start = .; \
656 *(.softirqentry.text) \
657 __softirqentry_text_end = .;
659 #define STATIC_CALL_TEXT \
661 __static_call_text_start = .; \
662 *(.static_call.text) \
663 __static_call_text_end = .;
665 /* Section used for early init (in .S files) */
666 #define HEAD_TEXT KEEP(*(.head.text))
668 #define HEAD_TEXT_SECTION \
669 .head.text : AT(ADDR(.head.text) - LOAD_OFFSET) { \
676 #define EXCEPTION_TABLE(align) \
678 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { \
679 __start___ex_table = .; \
680 KEEP(*(__ex_table)) \
681 __stop___ex_table = .; \
687 #ifdef CONFIG_DEBUG_INFO_BTF
689 .BTF : AT(ADDR(.BTF) - LOAD_OFFSET) { \
695 .BTF_ids : AT(ADDR(.BTF_ids) - LOAD_OFFSET) { \
705 #define INIT_TASK_DATA_SECTION(align) \
707 .data..init_task : AT(ADDR(.data..init_task) - LOAD_OFFSET) { \
708 INIT_TASK_DATA(align) \
711 #ifdef CONFIG_CONSTRUCTORS
712 #define KERNEL_CTORS() . = ALIGN(8); \
714 KEEP(*(SORT(.ctors.*))) \
716 KEEP(*(SORT(.init_array.*))) \
717 KEEP(*(.init_array)) \
720 #define KERNEL_CTORS()
723 /* init and exit section handling */
725 KEEP(*(SORT(___kentry+*))) \
726 *(.init.data init.data.*) \
727 MEM_DISCARD(init.data*) \
730 *(.init.rodata .init.rodata.*) \
734 ERROR_INJECT_WHITELIST() \
735 MEM_DISCARD(init.rodata) \
737 RESERVEDMEM_OF_TABLES() \
739 CPU_METHOD_OF_TABLES() \
740 CPUIDLE_METHOD_OF_TABLES() \
742 IRQCHIP_OF_MATCH_TABLE() \
743 ACPI_PROBE_TABLE(irqchip) \
744 ACPI_PROBE_TABLE(timer) \
745 THERMAL_TABLE(governor) \
753 *(.init.text .init.text.*) \
755 MEM_DISCARD(init.text*)
758 *(.exit.data .exit.data.*) \
759 *(.fini_array .fini_array.*) \
761 MEM_DISCARD(exit.data*) \
762 MEM_DISCARD(exit.rodata*)
767 MEM_DISCARD(exit.text)
773 * bss (Block Started by Symbol) - uninitialized data
774 * zeroed during startup
776 #define SBSS(sbss_align) \
777 . = ALIGN(sbss_align); \
778 .sbss : AT(ADDR(.sbss) - LOAD_OFFSET) { \
785 * Allow archectures to redefine BSS_FIRST_SECTIONS to add extra
786 * sections to the front of bss.
788 #ifndef BSS_FIRST_SECTIONS
789 #define BSS_FIRST_SECTIONS
792 #define BSS(bss_align) \
793 . = ALIGN(bss_align); \
794 .bss : AT(ADDR(.bss) - LOAD_OFFSET) { \
796 . = ALIGN(PAGE_SIZE); \
797 *(.bss..page_aligned) \
798 . = ALIGN(PAGE_SIZE); \
805 * DWARF debug sections.
806 * Symbols in the DWARF debugging sections are relative to
807 * the beginning of the section so we begin them at 0.
809 #define DWARF_DEBUG \
811 .debug 0 : { *(.debug) } \
812 .line 0 : { *(.line) } \
813 /* GNU DWARF 1 extensions */ \
814 .debug_srcinfo 0 : { *(.debug_srcinfo) } \
815 .debug_sfnames 0 : { *(.debug_sfnames) } \
816 /* DWARF 1.1 and DWARF 2 */ \
817 .debug_aranges 0 : { *(.debug_aranges) } \
818 .debug_pubnames 0 : { *(.debug_pubnames) } \
820 .debug_info 0 : { *(.debug_info \
821 .gnu.linkonce.wi.*) } \
822 .debug_abbrev 0 : { *(.debug_abbrev) } \
823 .debug_line 0 : { *(.debug_line) } \
824 .debug_frame 0 : { *(.debug_frame) } \
825 .debug_str 0 : { *(.debug_str) } \
826 .debug_loc 0 : { *(.debug_loc) } \
827 .debug_macinfo 0 : { *(.debug_macinfo) } \
828 .debug_pubtypes 0 : { *(.debug_pubtypes) } \
830 .debug_ranges 0 : { *(.debug_ranges) } \
831 /* SGI/MIPS DWARF 2 extensions */ \
832 .debug_weaknames 0 : { *(.debug_weaknames) } \
833 .debug_funcnames 0 : { *(.debug_funcnames) } \
834 .debug_typenames 0 : { *(.debug_typenames) } \
835 .debug_varnames 0 : { *(.debug_varnames) } \
836 /* GNU DWARF 2 extensions */ \
837 .debug_gnu_pubnames 0 : { *(.debug_gnu_pubnames) } \
838 .debug_gnu_pubtypes 0 : { *(.debug_gnu_pubtypes) } \
840 .debug_types 0 : { *(.debug_types) } \
842 .debug_macro 0 : { *(.debug_macro) } \
843 .debug_addr 0 : { *(.debug_addr) }
845 /* Stabs debugging sections. */
846 #define STABS_DEBUG \
847 .stab 0 : { *(.stab) } \
848 .stabstr 0 : { *(.stabstr) } \
849 .stab.excl 0 : { *(.stab.excl) } \
850 .stab.exclstr 0 : { *(.stab.exclstr) } \
851 .stab.index 0 : { *(.stab.index) } \
852 .stab.indexstr 0 : { *(.stab.indexstr) }
854 /* Required sections not related to debugging. */
855 #define ELF_DETAILS \
856 .comment 0 : { *(.comment) } \
857 .symtab 0 : { *(.symtab) } \
858 .strtab 0 : { *(.strtab) } \
859 .shstrtab 0 : { *(.shstrtab) }
861 #ifdef CONFIG_GENERIC_BUG
864 __bug_table : AT(ADDR(__bug_table) - LOAD_OFFSET) { \
865 __start___bug_table = .; \
866 KEEP(*(__bug_table)) \
867 __stop___bug_table = .; \
873 #ifdef CONFIG_UNWINDER_ORC
874 #define ORC_UNWIND_TABLE \
876 .orc_unwind_ip : AT(ADDR(.orc_unwind_ip) - LOAD_OFFSET) { \
877 __start_orc_unwind_ip = .; \
878 KEEP(*(.orc_unwind_ip)) \
879 __stop_orc_unwind_ip = .; \
882 .orc_unwind : AT(ADDR(.orc_unwind) - LOAD_OFFSET) { \
883 __start_orc_unwind = .; \
884 KEEP(*(.orc_unwind)) \
885 __stop_orc_unwind = .; \
888 .orc_lookup : AT(ADDR(.orc_lookup) - LOAD_OFFSET) { \
890 . += (((SIZEOF(.text) + LOOKUP_BLOCK_SIZE - 1) / \
891 LOOKUP_BLOCK_SIZE) + 1) * 4; \
892 orc_lookup_end = .; \
895 #define ORC_UNWIND_TABLE
898 #ifdef CONFIG_PM_TRACE
901 .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) { \
902 __tracedata_start = .; \
903 KEEP(*(.tracedata)) \
904 __tracedata_end = .; \
911 .notes : AT(ADDR(.notes) - LOAD_OFFSET) { \
916 NOTES_HEADERS_RESTORE
918 #define INIT_SETUP(initsetup_align) \
919 . = ALIGN(initsetup_align); \
921 KEEP(*(.init.setup)) \
924 #define INIT_CALLS_LEVEL(level) \
925 __initcall##level##_start = .; \
926 KEEP(*(.initcall##level##.init)) \
927 KEEP(*(.initcall##level##s.init)) \
930 __initcall_start = .; \
931 KEEP(*(.initcallearly.init)) \
932 INIT_CALLS_LEVEL(0) \
933 INIT_CALLS_LEVEL(1) \
934 INIT_CALLS_LEVEL(2) \
935 INIT_CALLS_LEVEL(3) \
936 INIT_CALLS_LEVEL(4) \
937 INIT_CALLS_LEVEL(5) \
938 INIT_CALLS_LEVEL(rootfs) \
939 INIT_CALLS_LEVEL(6) \
940 INIT_CALLS_LEVEL(7) \
943 #define CON_INITCALL \
944 __con_initcall_start = .; \
945 KEEP(*(.con_initcall.init)) \
946 __con_initcall_end = .;
948 /* Alignment must be consistent with (kunit_suite *) in include/kunit/test.h */
949 #define KUNIT_TABLE() \
951 __kunit_suites_start = .; \
952 KEEP(*(.kunit_test_suites)) \
953 __kunit_suites_end = .;
955 #ifdef CONFIG_BLK_DEV_INITRD
956 #define INIT_RAM_FS \
958 __initramfs_start = .; \
959 KEEP(*(.init.ramfs)) \
961 KEEP(*(.init.ramfs.info))
967 * Memory encryption operates on a page basis. Since we need to clear
968 * the memory encryption mask for this section, it needs to be aligned
969 * on a page boundary and be a page-size multiple in length.
971 * Note: We use a separate section so that only this section gets
972 * decrypted to avoid exposing more than we wish.
974 #ifdef CONFIG_AMD_MEM_ENCRYPT
975 #define PERCPU_DECRYPTED_SECTION \
976 . = ALIGN(PAGE_SIZE); \
977 *(.data..percpu..decrypted) \
978 . = ALIGN(PAGE_SIZE);
980 #define PERCPU_DECRYPTED_SECTION
985 * Default discarded sections.
987 * Some archs want to discard exit text/data at runtime rather than
988 * link time due to cross-section references such as alt instructions,
989 * bug table, eh_frame, etc. DISCARDS must be the last of output
990 * section definitions so that such archs put those in earlier section
993 #ifdef RUNTIME_DISCARD_EXIT
994 #define EXIT_DISCARDS
996 #define EXIT_DISCARDS \
1002 * Clang's -fsanitize=kernel-address and -fsanitize=thread produce
1003 * unwanted sections (.eh_frame and .init_array.*), but
1004 * CONFIG_CONSTRUCTORS wants to keep any .init_array.* sections.
1005 * https://bugs.llvm.org/show_bug.cgi?id=46478
1007 #if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KCSAN)
1008 # ifdef CONFIG_CONSTRUCTORS
1009 # define SANITIZER_DISCARDS \
1012 # define SANITIZER_DISCARDS \
1013 *(.init_array) *(.init_array.*) \
1017 # define SANITIZER_DISCARDS
1020 #define COMMON_DISCARDS \
1021 SANITIZER_DISCARDS \
1025 /* ld.bfd warns about .gnu.version* even when not emitted */ \
1036 * PERCPU_INPUT - the percpu input sections
1037 * @cacheline: cacheline size
1039 * The core percpu section names and core symbols which do not rely
1040 * directly upon load addresses.
1042 * @cacheline is used to align subsections to avoid false cacheline
1043 * sharing between subsections for different purposes.
1045 #define PERCPU_INPUT(cacheline) \
1046 __per_cpu_start = .; \
1047 *(.data..percpu..first) \
1048 . = ALIGN(PAGE_SIZE); \
1049 *(.data..percpu..page_aligned) \
1050 . = ALIGN(cacheline); \
1051 *(.data..percpu..read_mostly) \
1052 . = ALIGN(cacheline); \
1054 *(.data..percpu..shared_aligned) \
1055 PERCPU_DECRYPTED_SECTION \
1059 * PERCPU_VADDR - define output section for percpu area
1060 * @cacheline: cacheline size
1061 * @vaddr: explicit base address (optional)
1062 * @phdr: destination PHDR (optional)
1064 * Macro which expands to output section for percpu area.
1066 * @cacheline is used to align subsections to avoid false cacheline
1067 * sharing between subsections for different purposes.
1069 * If @vaddr is not blank, it specifies explicit base address and all
1070 * percpu symbols will be offset from the given address. If blank,
1071 * @vaddr always equals @laddr + LOAD_OFFSET.
1073 * @phdr defines the output PHDR to use if not blank. Be warned that
1074 * output PHDR is sticky. If @phdr is specified, the next output
1075 * section in the linker script will go there too. @phdr should have
1078 * Note that this macros defines __per_cpu_load as an absolute symbol.
1079 * If there is no need to put the percpu section at a predetermined
1080 * address, use PERCPU_SECTION.
1082 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
1083 __per_cpu_load = .; \
1084 .data..percpu vaddr : AT(__per_cpu_load - LOAD_OFFSET) { \
1085 PERCPU_INPUT(cacheline) \
1087 . = __per_cpu_load + SIZEOF(.data..percpu);
1090 * PERCPU_SECTION - define output section for percpu area, simple version
1091 * @cacheline: cacheline size
1093 * Align to PAGE_SIZE and outputs output section for percpu area. This
1094 * macro doesn't manipulate @vaddr or @phdr and __per_cpu_load and
1095 * __per_cpu_start will be identical.
1097 * This macro is equivalent to ALIGN(PAGE_SIZE); PERCPU_VADDR(@cacheline,,)
1098 * except that __per_cpu_load is defined as a relative symbol against
1099 * .data..percpu which is required for relocatable x86_32 configuration.
1101 #define PERCPU_SECTION(cacheline) \
1102 . = ALIGN(PAGE_SIZE); \
1103 .data..percpu : AT(ADDR(.data..percpu) - LOAD_OFFSET) { \
1104 __per_cpu_load = .; \
1105 PERCPU_INPUT(cacheline) \
1110 * Definition of the high level *_SECTION macros
1111 * They will fit only a subset of the architectures
1117 * All sections are combined in a single .data section.
1118 * The sections following CONSTRUCTORS are arranged so their
1119 * typical alignment matches.
1120 * A cacheline is typical/always less than a PAGE_SIZE so
1121 * the sections that has this restriction (or similar)
1122 * is located before the ones requiring PAGE_SIZE alignment.
1123 * NOSAVE_DATA starts and ends with a PAGE_SIZE alignment which
1124 * matches the requirement of PAGE_ALIGNED_DATA.
1126 * use 0 as page_align if page_aligned data is not used */
1127 #define RW_DATA(cacheline, pagealigned, inittask) \
1128 . = ALIGN(PAGE_SIZE); \
1129 .data : AT(ADDR(.data) - LOAD_OFFSET) { \
1130 INIT_TASK_DATA(inittask) \
1132 PAGE_ALIGNED_DATA(pagealigned) \
1133 CACHELINE_ALIGNED_DATA(cacheline) \
1134 READ_MOSTLY_DATA(cacheline) \
1140 #define INIT_TEXT_SECTION(inittext_align) \
1141 . = ALIGN(inittext_align); \
1142 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) { \
1148 #define INIT_DATA_SECTION(initsetup_align) \
1149 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { \
1151 INIT_SETUP(initsetup_align) \
1157 #define BSS_SECTION(sbss_align, bss_align, stop_align) \
1158 . = ALIGN(sbss_align); \
1162 . = ALIGN(stop_align); \