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 * With LTO_CLANG, the linker also splits sections by default, so we need
94 * these macros to combine the sections during the final link.
96 * RODATA_MAIN is not used because existing code already defines .rodata.x
97 * sections to be brought in with rodata.
99 #if defined(CONFIG_LD_DEAD_CODE_DATA_ELIMINATION) || defined(CONFIG_LTO_CLANG)
100 #define TEXT_MAIN .text .text.[0-9a-zA-Z_]*
101 #define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..L* .data..compoundliteral* .data.$__unnamed_* .data.$L*
102 #define SDATA_MAIN .sdata .sdata.[0-9a-zA-Z_]*
103 #define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]* .rodata..L*
104 #define BSS_MAIN .bss .bss.[0-9a-zA-Z_]* .bss..compoundliteral*
105 #define SBSS_MAIN .sbss .sbss.[0-9a-zA-Z_]*
107 #define TEXT_MAIN .text
108 #define DATA_MAIN .data
109 #define SDATA_MAIN .sdata
110 #define RODATA_MAIN .rodata
111 #define BSS_MAIN .bss
112 #define SBSS_MAIN .sbss
116 * GCC 4.5 and later have a 32 bytes section alignment for structures.
117 * Except GCC 4.9, that feels the need to align on 64 bytes.
119 #define STRUCT_ALIGNMENT 32
120 #define STRUCT_ALIGN() . = ALIGN(STRUCT_ALIGNMENT)
123 * The order of the sched class addresses are important, as they are
124 * used to determine the order of the priority of each sched class in
125 * relation to each other.
129 __sched_class_highest = .; \
130 *(__stop_sched_class) \
131 *(__dl_sched_class) \
132 *(__rt_sched_class) \
133 *(__fair_sched_class) \
134 *(__idle_sched_class) \
135 __sched_class_lowest = .;
137 /* The actual configuration determine if the init/exit sections
138 * are handled as text/data or they can be discarded (which
139 * often happens at runtime)
141 #ifdef CONFIG_HOTPLUG_CPU
142 #define CPU_KEEP(sec) *(.cpu##sec)
143 #define CPU_DISCARD(sec)
145 #define CPU_KEEP(sec)
146 #define CPU_DISCARD(sec) *(.cpu##sec)
149 #if defined(CONFIG_MEMORY_HOTPLUG)
150 #define MEM_KEEP(sec) *(.mem##sec)
151 #define MEM_DISCARD(sec)
153 #define MEM_KEEP(sec)
154 #define MEM_DISCARD(sec) *(.mem##sec)
157 #ifndef CONFIG_HAVE_DYNAMIC_FTRACE_NO_PATCHABLE
158 #define KEEP_PATCHABLE KEEP(*(__patchable_function_entries))
159 #define PATCHABLE_DISCARDS
161 #define KEEP_PATCHABLE
162 #define PATCHABLE_DISCARDS *(__patchable_function_entries)
165 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
167 * The ftrace call sites are logged to a section whose name depends on the
168 * compiler option used. A given kernel image will only use one, AKA
169 * FTRACE_CALLSITE_SECTION. We capture all of them here to avoid header
170 * dependencies for FTRACE_CALLSITE_SECTION's definition.
172 * Need to also make ftrace_stub_graph point to ftrace_stub
173 * so that the same stub location may have different protocols
174 * and not mess up with C verifiers.
176 * ftrace_ops_list_func will be defined as arch_ftrace_ops_list_func
177 * as some archs will have a different prototype for that function
178 * but ftrace_ops_list_func() will have a single prototype.
180 #define MCOUNT_REC() . = ALIGN(8); \
181 __start_mcount_loc = .; \
182 KEEP(*(__mcount_loc)) \
184 __stop_mcount_loc = .; \
185 ftrace_stub_graph = ftrace_stub; \
186 ftrace_ops_list_func = arch_ftrace_ops_list_func;
188 # ifdef CONFIG_FUNCTION_TRACER
189 # define MCOUNT_REC() ftrace_stub_graph = ftrace_stub; \
190 ftrace_ops_list_func = arch_ftrace_ops_list_func;
192 # define MCOUNT_REC()
196 #ifdef CONFIG_TRACE_BRANCH_PROFILING
197 #define LIKELY_PROFILE() __start_annotated_branch_profile = .; \
198 KEEP(*(_ftrace_annotated_branch)) \
199 __stop_annotated_branch_profile = .;
201 #define LIKELY_PROFILE()
204 #ifdef CONFIG_PROFILE_ALL_BRANCHES
205 #define BRANCH_PROFILE() __start_branch_profile = .; \
206 KEEP(*(_ftrace_branch)) \
207 __stop_branch_profile = .;
209 #define BRANCH_PROFILE()
212 #ifdef CONFIG_KPROBES
213 #define KPROBE_BLACKLIST() . = ALIGN(8); \
214 __start_kprobe_blacklist = .; \
215 KEEP(*(_kprobe_blacklist)) \
216 __stop_kprobe_blacklist = .;
218 #define KPROBE_BLACKLIST()
221 #ifdef CONFIG_FUNCTION_ERROR_INJECTION
222 #define ERROR_INJECT_WHITELIST() STRUCT_ALIGN(); \
223 __start_error_injection_whitelist = .; \
224 KEEP(*(_error_injection_whitelist)) \
225 __stop_error_injection_whitelist = .;
227 #define ERROR_INJECT_WHITELIST()
230 #ifdef CONFIG_EVENT_TRACING
231 #define FTRACE_EVENTS() . = ALIGN(8); \
232 __start_ftrace_events = .; \
233 KEEP(*(_ftrace_events)) \
234 __stop_ftrace_events = .; \
235 __start_ftrace_eval_maps = .; \
236 KEEP(*(_ftrace_eval_map)) \
237 __stop_ftrace_eval_maps = .;
239 #define FTRACE_EVENTS()
242 #ifdef CONFIG_TRACING
243 #define TRACE_PRINTKS() __start___trace_bprintk_fmt = .; \
244 KEEP(*(__trace_printk_fmt)) /* Trace_printk fmt' pointer */ \
245 __stop___trace_bprintk_fmt = .;
246 #define TRACEPOINT_STR() __start___tracepoint_str = .; \
247 KEEP(*(__tracepoint_str)) /* Trace_printk fmt' pointer */ \
248 __stop___tracepoint_str = .;
250 #define TRACE_PRINTKS()
251 #define TRACEPOINT_STR()
254 #ifdef CONFIG_FTRACE_SYSCALLS
255 #define TRACE_SYSCALLS() . = ALIGN(8); \
256 __start_syscalls_metadata = .; \
257 KEEP(*(__syscalls_metadata)) \
258 __stop_syscalls_metadata = .;
260 #define TRACE_SYSCALLS()
263 #ifdef CONFIG_BPF_EVENTS
264 #define BPF_RAW_TP() STRUCT_ALIGN(); \
265 __start__bpf_raw_tp = .; \
266 KEEP(*(__bpf_raw_tp_map)) \
267 __stop__bpf_raw_tp = .;
272 #ifdef CONFIG_SERIAL_EARLYCON
273 #define EARLYCON_TABLE() . = ALIGN(8); \
274 __earlycon_table = .; \
275 KEEP(*(__earlycon_table)) \
276 __earlycon_table_end = .;
278 #define EARLYCON_TABLE()
281 #ifdef CONFIG_SECURITY
282 #define LSM_TABLE() . = ALIGN(8); \
283 __start_lsm_info = .; \
284 KEEP(*(.lsm_info.init)) \
286 #define EARLY_LSM_TABLE() . = ALIGN(8); \
287 __start_early_lsm_info = .; \
288 KEEP(*(.early_lsm_info.init)) \
289 __end_early_lsm_info = .;
292 #define EARLY_LSM_TABLE()
295 #define ___OF_TABLE(cfg, name) _OF_TABLE_##cfg(name)
296 #define __OF_TABLE(cfg, name) ___OF_TABLE(cfg, name)
297 #define OF_TABLE(cfg, name) __OF_TABLE(IS_ENABLED(cfg), name)
298 #define _OF_TABLE_0(name)
299 #define _OF_TABLE_1(name) \
301 __##name##_of_table = .; \
302 KEEP(*(__##name##_of_table)) \
303 KEEP(*(__##name##_of_table_end))
305 #define TIMER_OF_TABLES() OF_TABLE(CONFIG_TIMER_OF, timer)
306 #define IRQCHIP_OF_MATCH_TABLE() OF_TABLE(CONFIG_IRQCHIP, irqchip)
307 #define CLK_OF_TABLES() OF_TABLE(CONFIG_COMMON_CLK, clk)
308 #define RESERVEDMEM_OF_TABLES() OF_TABLE(CONFIG_OF_RESERVED_MEM, reservedmem)
309 #define CPU_METHOD_OF_TABLES() OF_TABLE(CONFIG_SMP, cpu_method)
310 #define CPUIDLE_METHOD_OF_TABLES() OF_TABLE(CONFIG_CPU_IDLE, cpuidle_method)
313 #define ACPI_PROBE_TABLE(name) \
315 __##name##_acpi_probe_table = .; \
316 KEEP(*(__##name##_acpi_probe_table)) \
317 __##name##_acpi_probe_table_end = .;
319 #define ACPI_PROBE_TABLE(name)
322 #ifdef CONFIG_THERMAL
323 #define THERMAL_TABLE(name) \
325 __##name##_thermal_table = .; \
326 KEEP(*(__##name##_thermal_table)) \
327 __##name##_thermal_table_end = .;
329 #define THERMAL_TABLE(name)
332 #define KERNEL_DTB() \
335 KEEP(*(.dtb.init.rodata)) \
345 *(.data..shared_aligned) /* percpu related */ \
346 MEM_KEEP(init.data*) \
347 MEM_KEEP(exit.data*) \
354 /* implement dynamic printk debug */ \
356 __start___dyndbg_classes = .; \
357 KEEP(*(__dyndbg_classes)) \
358 __stop___dyndbg_classes = .; \
359 __start___dyndbg = .; \
361 __stop___dyndbg = .; \
369 * Data section helpers
371 #define NOSAVE_DATA \
372 . = ALIGN(PAGE_SIZE); \
373 __nosave_begin = .; \
375 . = ALIGN(PAGE_SIZE); \
378 #define PAGE_ALIGNED_DATA(page_align) \
379 . = ALIGN(page_align); \
380 *(.data..page_aligned) \
381 . = ALIGN(page_align);
383 #define READ_MOSTLY_DATA(align) \
385 *(.data..read_mostly) \
388 #define CACHELINE_ALIGNED_DATA(align) \
390 *(.data..cacheline_aligned)
392 #define INIT_TASK_DATA(align) \
394 __start_init_task = .; \
395 init_thread_union = .; \
397 KEEP(*(.data..init_task)) \
398 KEEP(*(.data..init_thread_info)) \
399 . = __start_init_task + THREAD_SIZE; \
402 #define JUMP_TABLE_DATA \
404 __start___jump_table = .; \
405 KEEP(*(__jump_table)) \
406 __stop___jump_table = .;
408 #ifdef CONFIG_HAVE_STATIC_CALL_INLINE
409 #define STATIC_CALL_DATA \
411 __start_static_call_sites = .; \
412 KEEP(*(.static_call_sites)) \
413 __stop_static_call_sites = .; \
414 __start_static_call_tramp_key = .; \
415 KEEP(*(.static_call_tramp_key)) \
416 __stop_static_call_tramp_key = .;
418 #define STATIC_CALL_DATA
422 * Allow architectures to handle ro_after_init data on their
423 * own by defining an empty RO_AFTER_INIT_DATA.
425 #ifndef RO_AFTER_INIT_DATA
426 #define RO_AFTER_INIT_DATA \
428 __start_ro_after_init = .; \
429 *(.data..ro_after_init) \
432 __end_ro_after_init = .;
436 * .kcfi_traps contains a list KCFI trap locations.
439 #ifdef CONFIG_ARCH_USES_CFI_TRAPS
441 __kcfi_traps : AT(ADDR(__kcfi_traps) - LOAD_OFFSET) { \
442 __start___kcfi_traps = .; \
443 KEEP(*(.kcfi_traps)) \
444 __stop___kcfi_traps = .; \
454 #define RO_DATA(align) \
455 . = ALIGN((align)); \
456 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
457 __start_rodata = .; \
458 *(.rodata) *(.rodata.*) \
460 RO_AFTER_INIT_DATA /* Read only after init */ \
462 __start___tracepoints_ptrs = .; \
463 KEEP(*(__tracepoints_ptrs)) /* Tracepoints: pointer array */ \
464 __stop___tracepoints_ptrs = .; \
465 *(__tracepoints_strings)/* Tracepoints: strings */ \
468 .rodata1 : AT(ADDR(.rodata1) - LOAD_OFFSET) { \
473 .pci_fixup : AT(ADDR(.pci_fixup) - LOAD_OFFSET) { \
474 __start_pci_fixups_early = .; \
475 KEEP(*(.pci_fixup_early)) \
476 __end_pci_fixups_early = .; \
477 __start_pci_fixups_header = .; \
478 KEEP(*(.pci_fixup_header)) \
479 __end_pci_fixups_header = .; \
480 __start_pci_fixups_final = .; \
481 KEEP(*(.pci_fixup_final)) \
482 __end_pci_fixups_final = .; \
483 __start_pci_fixups_enable = .; \
484 KEEP(*(.pci_fixup_enable)) \
485 __end_pci_fixups_enable = .; \
486 __start_pci_fixups_resume = .; \
487 KEEP(*(.pci_fixup_resume)) \
488 __end_pci_fixups_resume = .; \
489 __start_pci_fixups_resume_early = .; \
490 KEEP(*(.pci_fixup_resume_early)) \
491 __end_pci_fixups_resume_early = .; \
492 __start_pci_fixups_suspend = .; \
493 KEEP(*(.pci_fixup_suspend)) \
494 __end_pci_fixups_suspend = .; \
495 __start_pci_fixups_suspend_late = .; \
496 KEEP(*(.pci_fixup_suspend_late)) \
497 __end_pci_fixups_suspend_late = .; \
500 FW_LOADER_BUILT_IN_DATA \
505 /* Kernel symbol table: Normal symbols */ \
506 __ksymtab : AT(ADDR(__ksymtab) - LOAD_OFFSET) { \
507 __start___ksymtab = .; \
508 KEEP(*(SORT(___ksymtab+*))) \
509 __stop___ksymtab = .; \
512 /* Kernel symbol table: GPL-only symbols */ \
513 __ksymtab_gpl : AT(ADDR(__ksymtab_gpl) - LOAD_OFFSET) { \
514 __start___ksymtab_gpl = .; \
515 KEEP(*(SORT(___ksymtab_gpl+*))) \
516 __stop___ksymtab_gpl = .; \
519 /* Kernel symbol table: Normal symbols */ \
520 __kcrctab : AT(ADDR(__kcrctab) - LOAD_OFFSET) { \
521 __start___kcrctab = .; \
522 KEEP(*(SORT(___kcrctab+*))) \
523 __stop___kcrctab = .; \
526 /* Kernel symbol table: GPL-only symbols */ \
527 __kcrctab_gpl : AT(ADDR(__kcrctab_gpl) - LOAD_OFFSET) { \
528 __start___kcrctab_gpl = .; \
529 KEEP(*(SORT(___kcrctab_gpl+*))) \
530 __stop___kcrctab_gpl = .; \
533 /* Kernel symbol table: strings */ \
534 __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \
535 *(__ksymtab_strings) \
538 /* __*init sections */ \
539 __init_rodata : AT(ADDR(__init_rodata) - LOAD_OFFSET) { \
541 MEM_KEEP(init.rodata) \
542 MEM_KEEP(exit.rodata) \
545 /* Built-in module parameters. */ \
546 __param : AT(ADDR(__param) - LOAD_OFFSET) { \
547 __start___param = .; \
549 __stop___param = .; \
552 /* Built-in module versions. */ \
553 __modver : AT(ADDR(__modver) - LOAD_OFFSET) { \
554 __start___modver = .; \
556 __stop___modver = .; \
565 . = ALIGN((align)); \
570 * Non-instrumentable text section
572 #define NOINSTR_TEXT \
574 __noinstr_text_start = .; \
576 __noinstr_text_end = .;
579 * .text section. Map to function alignment to avoid address changes
580 * during second ld run in second ld pass when generating System.map
582 * TEXT_MAIN here will match .text.fixup and .text.unlikely if dead
583 * code elimination is enabled, so these sections should be converted
588 *(.text.hot .text.hot.*) \
589 *(TEXT_MAIN .text.fixup) \
590 *(.text.unlikely .text.unlikely.*) \
591 *(.text.unknown .text.unknown.*) \
595 *(.text.asan.* .text.tsan.*) \
596 MEM_KEEP(init.text*) \
597 MEM_KEEP(exit.text*) \
600 /* sched.text is aling to function alignment to secure we have same
601 * address even at second ld pass when generating System.map */
604 __sched_text_start = .; \
606 __sched_text_end = .;
608 /* spinlock.text is aling to function alignment to secure we have same
609 * address even at second ld pass when generating System.map */
612 __lock_text_start = .; \
616 #define CPUIDLE_TEXT \
618 __cpuidle_text_start = .; \
620 __cpuidle_text_end = .;
622 #define KPROBES_TEXT \
624 __kprobes_text_start = .; \
626 __kprobes_text_end = .;
630 __entry_text_start = .; \
632 __entry_text_end = .;
634 #define IRQENTRY_TEXT \
636 __irqentry_text_start = .; \
638 __irqentry_text_end = .;
640 #define SOFTIRQENTRY_TEXT \
642 __softirqentry_text_start = .; \
643 *(.softirqentry.text) \
644 __softirqentry_text_end = .;
646 #define STATIC_CALL_TEXT \
648 __static_call_text_start = .; \
649 *(.static_call.text) \
650 __static_call_text_end = .;
652 /* Section used for early init (in .S files) */
653 #define HEAD_TEXT KEEP(*(.head.text))
655 #define HEAD_TEXT_SECTION \
656 .head.text : AT(ADDR(.head.text) - LOAD_OFFSET) { \
663 #define EXCEPTION_TABLE(align) \
665 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { \
666 __start___ex_table = .; \
667 KEEP(*(__ex_table)) \
668 __stop___ex_table = .; \
674 #ifdef CONFIG_DEBUG_INFO_BTF
676 .BTF : AT(ADDR(.BTF) - LOAD_OFFSET) { \
682 .BTF_ids : AT(ADDR(.BTF_ids) - LOAD_OFFSET) { \
692 #define INIT_TASK_DATA_SECTION(align) \
694 .data..init_task : AT(ADDR(.data..init_task) - LOAD_OFFSET) { \
695 INIT_TASK_DATA(align) \
698 #ifdef CONFIG_CONSTRUCTORS
699 #define KERNEL_CTORS() . = ALIGN(8); \
701 KEEP(*(SORT(.ctors.*))) \
703 KEEP(*(SORT(.init_array.*))) \
704 KEEP(*(.init_array)) \
707 #define KERNEL_CTORS()
710 /* init and exit section handling */
712 KEEP(*(SORT(___kentry+*))) \
713 *(.init.data init.data.*) \
714 MEM_DISCARD(init.data*) \
717 *(.init.rodata .init.rodata.*) \
721 ERROR_INJECT_WHITELIST() \
722 MEM_DISCARD(init.rodata) \
724 RESERVEDMEM_OF_TABLES() \
726 CPU_METHOD_OF_TABLES() \
727 CPUIDLE_METHOD_OF_TABLES() \
729 IRQCHIP_OF_MATCH_TABLE() \
730 ACPI_PROBE_TABLE(irqchip) \
731 ACPI_PROBE_TABLE(timer) \
732 THERMAL_TABLE(governor) \
739 *(.init.text .init.text.*) \
741 MEM_DISCARD(init.text*)
744 *(.exit.data .exit.data.*) \
745 *(.fini_array .fini_array.*) \
747 MEM_DISCARD(exit.data*) \
748 MEM_DISCARD(exit.rodata*)
753 MEM_DISCARD(exit.text)
759 * bss (Block Started by Symbol) - uninitialized data
760 * zeroed during startup
762 #define SBSS(sbss_align) \
763 . = ALIGN(sbss_align); \
764 .sbss : AT(ADDR(.sbss) - LOAD_OFFSET) { \
771 * Allow archectures to redefine BSS_FIRST_SECTIONS to add extra
772 * sections to the front of bss.
774 #ifndef BSS_FIRST_SECTIONS
775 #define BSS_FIRST_SECTIONS
778 #define BSS(bss_align) \
779 . = ALIGN(bss_align); \
780 .bss : AT(ADDR(.bss) - LOAD_OFFSET) { \
782 . = ALIGN(PAGE_SIZE); \
783 *(.bss..page_aligned) \
784 . = ALIGN(PAGE_SIZE); \
791 * DWARF debug sections.
792 * Symbols in the DWARF debugging sections are relative to
793 * the beginning of the section so we begin them at 0.
795 #define DWARF_DEBUG \
797 .debug 0 : { *(.debug) } \
798 .line 0 : { *(.line) } \
799 /* GNU DWARF 1 extensions */ \
800 .debug_srcinfo 0 : { *(.debug_srcinfo) } \
801 .debug_sfnames 0 : { *(.debug_sfnames) } \
802 /* DWARF 1.1 and DWARF 2 */ \
803 .debug_aranges 0 : { *(.debug_aranges) } \
804 .debug_pubnames 0 : { *(.debug_pubnames) } \
806 .debug_info 0 : { *(.debug_info \
807 .gnu.linkonce.wi.*) } \
808 .debug_abbrev 0 : { *(.debug_abbrev) } \
809 .debug_line 0 : { *(.debug_line) } \
810 .debug_frame 0 : { *(.debug_frame) } \
811 .debug_str 0 : { *(.debug_str) } \
812 .debug_loc 0 : { *(.debug_loc) } \
813 .debug_macinfo 0 : { *(.debug_macinfo) } \
814 .debug_pubtypes 0 : { *(.debug_pubtypes) } \
816 .debug_ranges 0 : { *(.debug_ranges) } \
817 /* SGI/MIPS DWARF 2 extensions */ \
818 .debug_weaknames 0 : { *(.debug_weaknames) } \
819 .debug_funcnames 0 : { *(.debug_funcnames) } \
820 .debug_typenames 0 : { *(.debug_typenames) } \
821 .debug_varnames 0 : { *(.debug_varnames) } \
822 /* GNU DWARF 2 extensions */ \
823 .debug_gnu_pubnames 0 : { *(.debug_gnu_pubnames) } \
824 .debug_gnu_pubtypes 0 : { *(.debug_gnu_pubtypes) } \
826 .debug_types 0 : { *(.debug_types) } \
828 .debug_addr 0 : { *(.debug_addr) } \
829 .debug_line_str 0 : { *(.debug_line_str) } \
830 .debug_loclists 0 : { *(.debug_loclists) } \
831 .debug_macro 0 : { *(.debug_macro) } \
832 .debug_names 0 : { *(.debug_names) } \
833 .debug_rnglists 0 : { *(.debug_rnglists) } \
834 .debug_str_offsets 0 : { *(.debug_str_offsets) }
836 /* Stabs debugging sections. */
837 #define STABS_DEBUG \
838 .stab 0 : { *(.stab) } \
839 .stabstr 0 : { *(.stabstr) } \
840 .stab.excl 0 : { *(.stab.excl) } \
841 .stab.exclstr 0 : { *(.stab.exclstr) } \
842 .stab.index 0 : { *(.stab.index) } \
843 .stab.indexstr 0 : { *(.stab.indexstr) }
845 /* Required sections not related to debugging. */
846 #define ELF_DETAILS \
847 .comment 0 : { *(.comment) } \
848 .symtab 0 : { *(.symtab) } \
849 .strtab 0 : { *(.strtab) } \
850 .shstrtab 0 : { *(.shstrtab) }
852 #ifdef CONFIG_GENERIC_BUG
855 __bug_table : AT(ADDR(__bug_table) - LOAD_OFFSET) { \
856 __start___bug_table = .; \
857 KEEP(*(__bug_table)) \
858 __stop___bug_table = .; \
864 #ifdef CONFIG_UNWINDER_ORC
865 #define ORC_UNWIND_TABLE \
867 .orc_unwind_ip : AT(ADDR(.orc_unwind_ip) - LOAD_OFFSET) { \
868 __start_orc_unwind_ip = .; \
869 KEEP(*(.orc_unwind_ip)) \
870 __stop_orc_unwind_ip = .; \
873 .orc_unwind : AT(ADDR(.orc_unwind) - LOAD_OFFSET) { \
874 __start_orc_unwind = .; \
875 KEEP(*(.orc_unwind)) \
876 __stop_orc_unwind = .; \
878 text_size = _etext - _stext; \
880 .orc_lookup : AT(ADDR(.orc_lookup) - LOAD_OFFSET) { \
882 . += (((text_size + LOOKUP_BLOCK_SIZE - 1) / \
883 LOOKUP_BLOCK_SIZE) + 1) * 4; \
884 orc_lookup_end = .; \
887 #define ORC_UNWIND_TABLE
890 /* Built-in firmware blobs */
891 #ifdef CONFIG_FW_LOADER
892 #define FW_LOADER_BUILT_IN_DATA \
893 .builtin_fw : AT(ADDR(.builtin_fw) - LOAD_OFFSET) ALIGN(8) { \
894 __start_builtin_fw = .; \
895 KEEP(*(.builtin_fw)) \
896 __end_builtin_fw = .; \
899 #define FW_LOADER_BUILT_IN_DATA
902 #ifdef CONFIG_PM_TRACE
905 .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) { \
906 __tracedata_start = .; \
907 KEEP(*(.tracedata)) \
908 __tracedata_end = .; \
914 #ifdef CONFIG_PRINTK_INDEX
915 #define PRINTK_INDEX \
916 .printk_index : AT(ADDR(.printk_index) - LOAD_OFFSET) { \
917 __start_printk_index = .; \
919 __stop_printk_index = .; \
926 .notes : AT(ADDR(.notes) - LOAD_OFFSET) { \
931 NOTES_HEADERS_RESTORE
933 #define INIT_SETUP(initsetup_align) \
934 . = ALIGN(initsetup_align); \
936 KEEP(*(.init.setup)) \
939 #define INIT_CALLS_LEVEL(level) \
940 __initcall##level##_start = .; \
941 KEEP(*(.initcall##level##.init)) \
942 KEEP(*(.initcall##level##s.init)) \
945 __initcall_start = .; \
946 KEEP(*(.initcallearly.init)) \
947 INIT_CALLS_LEVEL(0) \
948 INIT_CALLS_LEVEL(1) \
949 INIT_CALLS_LEVEL(2) \
950 INIT_CALLS_LEVEL(3) \
951 INIT_CALLS_LEVEL(4) \
952 INIT_CALLS_LEVEL(5) \
953 INIT_CALLS_LEVEL(rootfs) \
954 INIT_CALLS_LEVEL(6) \
955 INIT_CALLS_LEVEL(7) \
958 #define CON_INITCALL \
959 __con_initcall_start = .; \
960 KEEP(*(.con_initcall.init)) \
961 __con_initcall_end = .;
963 /* Alignment must be consistent with (kunit_suite *) in include/kunit/test.h */
964 #define KUNIT_TABLE() \
966 __kunit_suites_start = .; \
967 KEEP(*(.kunit_test_suites)) \
968 __kunit_suites_end = .;
970 #ifdef CONFIG_BLK_DEV_INITRD
971 #define INIT_RAM_FS \
973 __initramfs_start = .; \
974 KEEP(*(.init.ramfs)) \
976 KEEP(*(.init.ramfs.info))
982 * Memory encryption operates on a page basis. Since we need to clear
983 * the memory encryption mask for this section, it needs to be aligned
984 * on a page boundary and be a page-size multiple in length.
986 * Note: We use a separate section so that only this section gets
987 * decrypted to avoid exposing more than we wish.
989 #ifdef CONFIG_AMD_MEM_ENCRYPT
990 #define PERCPU_DECRYPTED_SECTION \
991 . = ALIGN(PAGE_SIZE); \
992 *(.data..decrypted) \
993 *(.data..percpu..decrypted) \
994 . = ALIGN(PAGE_SIZE);
996 #define PERCPU_DECRYPTED_SECTION
1001 * Default discarded sections.
1003 * Some archs want to discard exit text/data at runtime rather than
1004 * link time due to cross-section references such as alt instructions,
1005 * bug table, eh_frame, etc. DISCARDS must be the last of output
1006 * section definitions so that such archs put those in earlier section
1009 #ifdef RUNTIME_DISCARD_EXIT
1010 #define EXIT_DISCARDS
1012 #define EXIT_DISCARDS \
1018 * Clang's -fprofile-arcs, -fsanitize=kernel-address, and
1019 * -fsanitize=thread produce unwanted sections (.eh_frame
1020 * and .init_array.*), but CONFIG_CONSTRUCTORS wants to
1021 * keep any .init_array.* sections.
1022 * https://bugs.llvm.org/show_bug.cgi?id=46478
1024 #if defined(CONFIG_GCOV_KERNEL) || defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KCSAN)
1025 # ifdef CONFIG_CONSTRUCTORS
1026 # define SANITIZER_DISCARDS \
1029 # define SANITIZER_DISCARDS \
1030 *(.init_array) *(.init_array.*) \
1034 # define SANITIZER_DISCARDS
1037 #define COMMON_DISCARDS \
1038 SANITIZER_DISCARDS \
1039 PATCHABLE_DISCARDS \
1043 /* ld.bfd warns about .gnu.version* even when not emitted */ \
1054 * PERCPU_INPUT - the percpu input sections
1055 * @cacheline: cacheline size
1057 * The core percpu section names and core symbols which do not rely
1058 * directly upon load addresses.
1060 * @cacheline is used to align subsections to avoid false cacheline
1061 * sharing between subsections for different purposes.
1063 #define PERCPU_INPUT(cacheline) \
1064 __per_cpu_start = .; \
1065 *(.data..percpu..first) \
1066 . = ALIGN(PAGE_SIZE); \
1067 *(.data..percpu..page_aligned) \
1068 . = ALIGN(cacheline); \
1069 *(.data..percpu..read_mostly) \
1070 . = ALIGN(cacheline); \
1072 *(.data..percpu..shared_aligned) \
1073 PERCPU_DECRYPTED_SECTION \
1077 * PERCPU_VADDR - define output section for percpu area
1078 * @cacheline: cacheline size
1079 * @vaddr: explicit base address (optional)
1080 * @phdr: destination PHDR (optional)
1082 * Macro which expands to output section for percpu area.
1084 * @cacheline is used to align subsections to avoid false cacheline
1085 * sharing between subsections for different purposes.
1087 * If @vaddr is not blank, it specifies explicit base address and all
1088 * percpu symbols will be offset from the given address. If blank,
1089 * @vaddr always equals @laddr + LOAD_OFFSET.
1091 * @phdr defines the output PHDR to use if not blank. Be warned that
1092 * output PHDR is sticky. If @phdr is specified, the next output
1093 * section in the linker script will go there too. @phdr should have
1096 * Note that this macros defines __per_cpu_load as an absolute symbol.
1097 * If there is no need to put the percpu section at a predetermined
1098 * address, use PERCPU_SECTION.
1100 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
1101 __per_cpu_load = .; \
1102 .data..percpu vaddr : AT(__per_cpu_load - LOAD_OFFSET) { \
1103 PERCPU_INPUT(cacheline) \
1105 . = __per_cpu_load + SIZEOF(.data..percpu);
1108 * PERCPU_SECTION - define output section for percpu area, simple version
1109 * @cacheline: cacheline size
1111 * Align to PAGE_SIZE and outputs output section for percpu area. This
1112 * macro doesn't manipulate @vaddr or @phdr and __per_cpu_load and
1113 * __per_cpu_start will be identical.
1115 * This macro is equivalent to ALIGN(PAGE_SIZE); PERCPU_VADDR(@cacheline,,)
1116 * except that __per_cpu_load is defined as a relative symbol against
1117 * .data..percpu which is required for relocatable x86_32 configuration.
1119 #define PERCPU_SECTION(cacheline) \
1120 . = ALIGN(PAGE_SIZE); \
1121 .data..percpu : AT(ADDR(.data..percpu) - LOAD_OFFSET) { \
1122 __per_cpu_load = .; \
1123 PERCPU_INPUT(cacheline) \
1128 * Definition of the high level *_SECTION macros
1129 * They will fit only a subset of the architectures
1135 * All sections are combined in a single .data section.
1136 * The sections following CONSTRUCTORS are arranged so their
1137 * typical alignment matches.
1138 * A cacheline is typical/always less than a PAGE_SIZE so
1139 * the sections that has this restriction (or similar)
1140 * is located before the ones requiring PAGE_SIZE alignment.
1141 * NOSAVE_DATA starts and ends with a PAGE_SIZE alignment which
1142 * matches the requirement of PAGE_ALIGNED_DATA.
1144 * use 0 as page_align if page_aligned data is not used */
1145 #define RW_DATA(cacheline, pagealigned, inittask) \
1146 . = ALIGN(PAGE_SIZE); \
1147 .data : AT(ADDR(.data) - LOAD_OFFSET) { \
1148 INIT_TASK_DATA(inittask) \
1150 PAGE_ALIGNED_DATA(pagealigned) \
1151 CACHELINE_ALIGNED_DATA(cacheline) \
1152 READ_MOSTLY_DATA(cacheline) \
1158 #define INIT_TEXT_SECTION(inittext_align) \
1159 . = ALIGN(inittext_align); \
1160 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) { \
1166 #define INIT_DATA_SECTION(initsetup_align) \
1167 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { \
1169 INIT_SETUP(initsetup_align) \
1175 #define BSS_SECTION(sbss_align, bss_align, stop_align) \
1176 . = ALIGN(sbss_align); \
1180 . = ALIGN(stop_align); \