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 . function alignment. */
85 #define ALIGN_FUNCTION() . = ALIGN(CONFIG_FUNCTION_ALIGNMENT)
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 #ifndef CONFIG_ARCH_SUPPORTS_CFI_CLANG
167 * Simply points to ftrace_stub, but with the proper protocol.
168 * Defined by the linker script in linux/vmlinux.lds.h
170 #define FTRACE_STUB_HACK ftrace_stub_graph = ftrace_stub;
172 #define FTRACE_STUB_HACK
175 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
177 * The ftrace call sites are logged to a section whose name depends on the
178 * compiler option used. A given kernel image will only use one, AKA
179 * FTRACE_CALLSITE_SECTION. We capture all of them here to avoid header
180 * dependencies for FTRACE_CALLSITE_SECTION's definition.
182 * ftrace_ops_list_func will be defined as arch_ftrace_ops_list_func
183 * as some archs will have a different prototype for that function
184 * but ftrace_ops_list_func() will have a single prototype.
186 #define MCOUNT_REC() . = ALIGN(8); \
187 __start_mcount_loc = .; \
188 KEEP(*(__mcount_loc)) \
190 __stop_mcount_loc = .; \
192 ftrace_ops_list_func = arch_ftrace_ops_list_func;
194 # ifdef CONFIG_FUNCTION_TRACER
195 # define MCOUNT_REC() FTRACE_STUB_HACK \
196 ftrace_ops_list_func = arch_ftrace_ops_list_func;
198 # define MCOUNT_REC()
202 #ifdef CONFIG_TRACE_BRANCH_PROFILING
203 #define LIKELY_PROFILE() __start_annotated_branch_profile = .; \
204 KEEP(*(_ftrace_annotated_branch)) \
205 __stop_annotated_branch_profile = .;
207 #define LIKELY_PROFILE()
210 #ifdef CONFIG_PROFILE_ALL_BRANCHES
211 #define BRANCH_PROFILE() __start_branch_profile = .; \
212 KEEP(*(_ftrace_branch)) \
213 __stop_branch_profile = .;
215 #define BRANCH_PROFILE()
218 #ifdef CONFIG_KPROBES
219 #define KPROBE_BLACKLIST() . = ALIGN(8); \
220 __start_kprobe_blacklist = .; \
221 KEEP(*(_kprobe_blacklist)) \
222 __stop_kprobe_blacklist = .;
224 #define KPROBE_BLACKLIST()
227 #ifdef CONFIG_FUNCTION_ERROR_INJECTION
228 #define ERROR_INJECT_WHITELIST() STRUCT_ALIGN(); \
229 __start_error_injection_whitelist = .; \
230 KEEP(*(_error_injection_whitelist)) \
231 __stop_error_injection_whitelist = .;
233 #define ERROR_INJECT_WHITELIST()
236 #ifdef CONFIG_EVENT_TRACING
237 #define FTRACE_EVENTS() . = ALIGN(8); \
238 __start_ftrace_events = .; \
239 KEEP(*(_ftrace_events)) \
240 __stop_ftrace_events = .; \
241 __start_ftrace_eval_maps = .; \
242 KEEP(*(_ftrace_eval_map)) \
243 __stop_ftrace_eval_maps = .;
245 #define FTRACE_EVENTS()
248 #ifdef CONFIG_TRACING
249 #define TRACE_PRINTKS() __start___trace_bprintk_fmt = .; \
250 KEEP(*(__trace_printk_fmt)) /* Trace_printk fmt' pointer */ \
251 __stop___trace_bprintk_fmt = .;
252 #define TRACEPOINT_STR() __start___tracepoint_str = .; \
253 KEEP(*(__tracepoint_str)) /* Trace_printk fmt' pointer */ \
254 __stop___tracepoint_str = .;
256 #define TRACE_PRINTKS()
257 #define TRACEPOINT_STR()
260 #ifdef CONFIG_FTRACE_SYSCALLS
261 #define TRACE_SYSCALLS() . = ALIGN(8); \
262 __start_syscalls_metadata = .; \
263 KEEP(*(__syscalls_metadata)) \
264 __stop_syscalls_metadata = .;
266 #define TRACE_SYSCALLS()
269 #ifdef CONFIG_BPF_EVENTS
270 #define BPF_RAW_TP() STRUCT_ALIGN(); \
271 __start__bpf_raw_tp = .; \
272 KEEP(*(__bpf_raw_tp_map)) \
273 __stop__bpf_raw_tp = .;
278 #ifdef CONFIG_SERIAL_EARLYCON
279 #define EARLYCON_TABLE() . = ALIGN(8); \
280 __earlycon_table = .; \
281 KEEP(*(__earlycon_table)) \
282 __earlycon_table_end = .;
284 #define EARLYCON_TABLE()
287 #ifdef CONFIG_SECURITY
288 #define LSM_TABLE() . = ALIGN(8); \
289 __start_lsm_info = .; \
290 KEEP(*(.lsm_info.init)) \
292 #define EARLY_LSM_TABLE() . = ALIGN(8); \
293 __start_early_lsm_info = .; \
294 KEEP(*(.early_lsm_info.init)) \
295 __end_early_lsm_info = .;
298 #define EARLY_LSM_TABLE()
301 #define ___OF_TABLE(cfg, name) _OF_TABLE_##cfg(name)
302 #define __OF_TABLE(cfg, name) ___OF_TABLE(cfg, name)
303 #define OF_TABLE(cfg, name) __OF_TABLE(IS_ENABLED(cfg), name)
304 #define _OF_TABLE_0(name)
305 #define _OF_TABLE_1(name) \
307 __##name##_of_table = .; \
308 KEEP(*(__##name##_of_table)) \
309 KEEP(*(__##name##_of_table_end))
311 #define TIMER_OF_TABLES() OF_TABLE(CONFIG_TIMER_OF, timer)
312 #define IRQCHIP_OF_MATCH_TABLE() OF_TABLE(CONFIG_IRQCHIP, irqchip)
313 #define CLK_OF_TABLES() OF_TABLE(CONFIG_COMMON_CLK, clk)
314 #define RESERVEDMEM_OF_TABLES() OF_TABLE(CONFIG_OF_RESERVED_MEM, reservedmem)
315 #define CPU_METHOD_OF_TABLES() OF_TABLE(CONFIG_SMP, cpu_method)
316 #define CPUIDLE_METHOD_OF_TABLES() OF_TABLE(CONFIG_CPU_IDLE, cpuidle_method)
319 #define ACPI_PROBE_TABLE(name) \
321 __##name##_acpi_probe_table = .; \
322 KEEP(*(__##name##_acpi_probe_table)) \
323 __##name##_acpi_probe_table_end = .;
325 #define ACPI_PROBE_TABLE(name)
328 #ifdef CONFIG_THERMAL
329 #define THERMAL_TABLE(name) \
331 __##name##_thermal_table = .; \
332 KEEP(*(__##name##_thermal_table)) \
333 __##name##_thermal_table_end = .;
335 #define THERMAL_TABLE(name)
338 #define KERNEL_DTB() \
341 KEEP(*(.dtb.init.rodata)) \
350 *(.data..decrypted) \
352 *(.data..shared_aligned) /* percpu related */ \
353 MEM_KEEP(init.data*) \
354 MEM_KEEP(exit.data*) \
361 /* implement dynamic printk debug */ \
363 __start___dyndbg_classes = .; \
364 KEEP(*(__dyndbg_classes)) \
365 __stop___dyndbg_classes = .; \
366 __start___dyndbg = .; \
368 __stop___dyndbg = .; \
376 * Data section helpers
378 #define NOSAVE_DATA \
379 . = ALIGN(PAGE_SIZE); \
380 __nosave_begin = .; \
382 . = ALIGN(PAGE_SIZE); \
385 #define PAGE_ALIGNED_DATA(page_align) \
386 . = ALIGN(page_align); \
387 *(.data..page_aligned) \
388 . = ALIGN(page_align);
390 #define READ_MOSTLY_DATA(align) \
392 *(.data..read_mostly) \
395 #define CACHELINE_ALIGNED_DATA(align) \
397 *(.data..cacheline_aligned)
399 #define INIT_TASK_DATA(align) \
401 __start_init_task = .; \
402 init_thread_union = .; \
404 KEEP(*(.data..init_task)) \
405 KEEP(*(.data..init_thread_info)) \
406 . = __start_init_task + THREAD_SIZE; \
409 #define JUMP_TABLE_DATA \
411 __start___jump_table = .; \
412 KEEP(*(__jump_table)) \
413 __stop___jump_table = .;
415 #ifdef CONFIG_HAVE_STATIC_CALL_INLINE
416 #define STATIC_CALL_DATA \
418 __start_static_call_sites = .; \
419 KEEP(*(.static_call_sites)) \
420 __stop_static_call_sites = .; \
421 __start_static_call_tramp_key = .; \
422 KEEP(*(.static_call_tramp_key)) \
423 __stop_static_call_tramp_key = .;
425 #define STATIC_CALL_DATA
429 * Allow architectures to handle ro_after_init data on their
430 * own by defining an empty RO_AFTER_INIT_DATA.
432 #ifndef RO_AFTER_INIT_DATA
433 #define RO_AFTER_INIT_DATA \
435 __start_ro_after_init = .; \
436 *(.data..ro_after_init) \
439 __end_ro_after_init = .;
443 * .kcfi_traps contains a list KCFI trap locations.
446 #ifdef CONFIG_ARCH_USES_CFI_TRAPS
448 __kcfi_traps : AT(ADDR(__kcfi_traps) - LOAD_OFFSET) { \
449 __start___kcfi_traps = .; \
450 KEEP(*(.kcfi_traps)) \
451 __stop___kcfi_traps = .; \
461 #define RO_DATA(align) \
462 . = ALIGN((align)); \
463 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
464 __start_rodata = .; \
465 *(.rodata) *(.rodata.*) \
467 RO_AFTER_INIT_DATA /* Read only after init */ \
469 __start___tracepoints_ptrs = .; \
470 KEEP(*(__tracepoints_ptrs)) /* Tracepoints: pointer array */ \
471 __stop___tracepoints_ptrs = .; \
472 *(__tracepoints_strings)/* Tracepoints: strings */ \
475 .rodata1 : AT(ADDR(.rodata1) - LOAD_OFFSET) { \
480 .pci_fixup : AT(ADDR(.pci_fixup) - LOAD_OFFSET) { \
481 __start_pci_fixups_early = .; \
482 KEEP(*(.pci_fixup_early)) \
483 __end_pci_fixups_early = .; \
484 __start_pci_fixups_header = .; \
485 KEEP(*(.pci_fixup_header)) \
486 __end_pci_fixups_header = .; \
487 __start_pci_fixups_final = .; \
488 KEEP(*(.pci_fixup_final)) \
489 __end_pci_fixups_final = .; \
490 __start_pci_fixups_enable = .; \
491 KEEP(*(.pci_fixup_enable)) \
492 __end_pci_fixups_enable = .; \
493 __start_pci_fixups_resume = .; \
494 KEEP(*(.pci_fixup_resume)) \
495 __end_pci_fixups_resume = .; \
496 __start_pci_fixups_resume_early = .; \
497 KEEP(*(.pci_fixup_resume_early)) \
498 __end_pci_fixups_resume_early = .; \
499 __start_pci_fixups_suspend = .; \
500 KEEP(*(.pci_fixup_suspend)) \
501 __end_pci_fixups_suspend = .; \
502 __start_pci_fixups_suspend_late = .; \
503 KEEP(*(.pci_fixup_suspend_late)) \
504 __end_pci_fixups_suspend_late = .; \
507 FW_LOADER_BUILT_IN_DATA \
512 /* Kernel symbol table: Normal symbols */ \
513 __ksymtab : AT(ADDR(__ksymtab) - LOAD_OFFSET) { \
514 __start___ksymtab = .; \
515 KEEP(*(SORT(___ksymtab+*))) \
516 __stop___ksymtab = .; \
519 /* Kernel symbol table: GPL-only symbols */ \
520 __ksymtab_gpl : AT(ADDR(__ksymtab_gpl) - LOAD_OFFSET) { \
521 __start___ksymtab_gpl = .; \
522 KEEP(*(SORT(___ksymtab_gpl+*))) \
523 __stop___ksymtab_gpl = .; \
526 /* Kernel symbol table: Normal symbols */ \
527 __kcrctab : AT(ADDR(__kcrctab) - LOAD_OFFSET) { \
528 __start___kcrctab = .; \
529 KEEP(*(SORT(___kcrctab+*))) \
530 __stop___kcrctab = .; \
533 /* Kernel symbol table: GPL-only symbols */ \
534 __kcrctab_gpl : AT(ADDR(__kcrctab_gpl) - LOAD_OFFSET) { \
535 __start___kcrctab_gpl = .; \
536 KEEP(*(SORT(___kcrctab_gpl+*))) \
537 __stop___kcrctab_gpl = .; \
540 /* Kernel symbol table: strings */ \
541 __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \
542 *(__ksymtab_strings) \
545 /* __*init sections */ \
546 __init_rodata : AT(ADDR(__init_rodata) - LOAD_OFFSET) { \
548 MEM_KEEP(init.rodata) \
549 MEM_KEEP(exit.rodata) \
552 /* Built-in module parameters. */ \
553 __param : AT(ADDR(__param) - LOAD_OFFSET) { \
554 __start___param = .; \
556 __stop___param = .; \
559 /* Built-in module versions. */ \
560 __modver : AT(ADDR(__modver) - LOAD_OFFSET) { \
561 __start___modver = .; \
563 __stop___modver = .; \
572 . = ALIGN((align)); \
577 * Non-instrumentable text section
579 #define NOINSTR_TEXT \
581 __noinstr_text_start = .; \
583 __noinstr_text_end = .;
586 * .text section. Map to function alignment to avoid address changes
587 * during second ld run in second ld pass when generating System.map
589 * TEXT_MAIN here will match .text.fixup and .text.unlikely if dead
590 * code elimination is enabled, so these sections should be converted
595 *(.text.hot .text.hot.*) \
596 *(TEXT_MAIN .text.fixup) \
597 *(.text.unlikely .text.unlikely.*) \
598 *(.text.unknown .text.unknown.*) \
602 *(.text.asan.* .text.tsan.*) \
603 MEM_KEEP(init.text*) \
604 MEM_KEEP(exit.text*) \
607 /* sched.text is aling to function alignment to secure we have same
608 * address even at second ld pass when generating System.map */
611 __sched_text_start = .; \
613 __sched_text_end = .;
615 /* spinlock.text is aling to function alignment to secure we have same
616 * address even at second ld pass when generating System.map */
619 __lock_text_start = .; \
623 #define CPUIDLE_TEXT \
625 __cpuidle_text_start = .; \
627 __cpuidle_text_end = .;
629 #define KPROBES_TEXT \
631 __kprobes_text_start = .; \
633 __kprobes_text_end = .;
637 __entry_text_start = .; \
639 __entry_text_end = .;
641 #define IRQENTRY_TEXT \
643 __irqentry_text_start = .; \
645 __irqentry_text_end = .;
647 #define SOFTIRQENTRY_TEXT \
649 __softirqentry_text_start = .; \
650 *(.softirqentry.text) \
651 __softirqentry_text_end = .;
653 #define STATIC_CALL_TEXT \
655 __static_call_text_start = .; \
656 *(.static_call.text) \
657 __static_call_text_end = .;
659 /* Section used for early init (in .S files) */
660 #define HEAD_TEXT KEEP(*(.head.text))
662 #define HEAD_TEXT_SECTION \
663 .head.text : AT(ADDR(.head.text) - LOAD_OFFSET) { \
670 #define EXCEPTION_TABLE(align) \
672 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { \
673 __start___ex_table = .; \
674 KEEP(*(__ex_table)) \
675 __stop___ex_table = .; \
681 #ifdef CONFIG_DEBUG_INFO_BTF
683 .BTF : AT(ADDR(.BTF) - LOAD_OFFSET) { \
689 .BTF_ids : AT(ADDR(.BTF_ids) - LOAD_OFFSET) { \
699 #define INIT_TASK_DATA_SECTION(align) \
701 .data..init_task : AT(ADDR(.data..init_task) - LOAD_OFFSET) { \
702 INIT_TASK_DATA(align) \
705 #ifdef CONFIG_CONSTRUCTORS
706 #define KERNEL_CTORS() . = ALIGN(8); \
708 KEEP(*(SORT(.ctors.*))) \
710 KEEP(*(SORT(.init_array.*))) \
711 KEEP(*(.init_array)) \
714 #define KERNEL_CTORS()
717 /* init and exit section handling */
719 KEEP(*(SORT(___kentry+*))) \
720 *(.init.data init.data.*) \
721 MEM_DISCARD(init.data*) \
724 *(.init.rodata .init.rodata.*) \
728 ERROR_INJECT_WHITELIST() \
729 MEM_DISCARD(init.rodata) \
731 RESERVEDMEM_OF_TABLES() \
733 CPU_METHOD_OF_TABLES() \
734 CPUIDLE_METHOD_OF_TABLES() \
736 IRQCHIP_OF_MATCH_TABLE() \
737 ACPI_PROBE_TABLE(irqchip) \
738 ACPI_PROBE_TABLE(timer) \
739 THERMAL_TABLE(governor) \
746 *(.init.text .init.text.*) \
748 MEM_DISCARD(init.text*)
751 *(.exit.data .exit.data.*) \
752 *(.fini_array .fini_array.*) \
754 MEM_DISCARD(exit.data*) \
755 MEM_DISCARD(exit.rodata*)
760 MEM_DISCARD(exit.text)
766 * bss (Block Started by Symbol) - uninitialized data
767 * zeroed during startup
769 #define SBSS(sbss_align) \
770 . = ALIGN(sbss_align); \
771 .sbss : AT(ADDR(.sbss) - LOAD_OFFSET) { \
778 * Allow archectures to redefine BSS_FIRST_SECTIONS to add extra
779 * sections to the front of bss.
781 #ifndef BSS_FIRST_SECTIONS
782 #define BSS_FIRST_SECTIONS
785 #define BSS(bss_align) \
786 . = ALIGN(bss_align); \
787 .bss : AT(ADDR(.bss) - LOAD_OFFSET) { \
789 . = ALIGN(PAGE_SIZE); \
790 *(.bss..page_aligned) \
791 . = ALIGN(PAGE_SIZE); \
798 * DWARF debug sections.
799 * Symbols in the DWARF debugging sections are relative to
800 * the beginning of the section so we begin them at 0.
802 #define DWARF_DEBUG \
804 .debug 0 : { *(.debug) } \
805 .line 0 : { *(.line) } \
806 /* GNU DWARF 1 extensions */ \
807 .debug_srcinfo 0 : { *(.debug_srcinfo) } \
808 .debug_sfnames 0 : { *(.debug_sfnames) } \
809 /* DWARF 1.1 and DWARF 2 */ \
810 .debug_aranges 0 : { *(.debug_aranges) } \
811 .debug_pubnames 0 : { *(.debug_pubnames) } \
813 .debug_info 0 : { *(.debug_info \
814 .gnu.linkonce.wi.*) } \
815 .debug_abbrev 0 : { *(.debug_abbrev) } \
816 .debug_line 0 : { *(.debug_line) } \
817 .debug_frame 0 : { *(.debug_frame) } \
818 .debug_str 0 : { *(.debug_str) } \
819 .debug_loc 0 : { *(.debug_loc) } \
820 .debug_macinfo 0 : { *(.debug_macinfo) } \
821 .debug_pubtypes 0 : { *(.debug_pubtypes) } \
823 .debug_ranges 0 : { *(.debug_ranges) } \
824 /* SGI/MIPS DWARF 2 extensions */ \
825 .debug_weaknames 0 : { *(.debug_weaknames) } \
826 .debug_funcnames 0 : { *(.debug_funcnames) } \
827 .debug_typenames 0 : { *(.debug_typenames) } \
828 .debug_varnames 0 : { *(.debug_varnames) } \
829 /* GNU DWARF 2 extensions */ \
830 .debug_gnu_pubnames 0 : { *(.debug_gnu_pubnames) } \
831 .debug_gnu_pubtypes 0 : { *(.debug_gnu_pubtypes) } \
833 .debug_types 0 : { *(.debug_types) } \
835 .debug_addr 0 : { *(.debug_addr) } \
836 .debug_line_str 0 : { *(.debug_line_str) } \
837 .debug_loclists 0 : { *(.debug_loclists) } \
838 .debug_macro 0 : { *(.debug_macro) } \
839 .debug_names 0 : { *(.debug_names) } \
840 .debug_rnglists 0 : { *(.debug_rnglists) } \
841 .debug_str_offsets 0 : { *(.debug_str_offsets) }
843 /* Stabs debugging sections. */
844 #define STABS_DEBUG \
845 .stab 0 : { *(.stab) } \
846 .stabstr 0 : { *(.stabstr) } \
847 .stab.excl 0 : { *(.stab.excl) } \
848 .stab.exclstr 0 : { *(.stab.exclstr) } \
849 .stab.index 0 : { *(.stab.index) } \
850 .stab.indexstr 0 : { *(.stab.indexstr) }
852 /* Required sections not related to debugging. */
853 #define ELF_DETAILS \
854 .comment 0 : { *(.comment) } \
855 .symtab 0 : { *(.symtab) } \
856 .strtab 0 : { *(.strtab) } \
857 .shstrtab 0 : { *(.shstrtab) }
859 #ifdef CONFIG_GENERIC_BUG
862 __bug_table : AT(ADDR(__bug_table) - LOAD_OFFSET) { \
863 __start___bug_table = .; \
864 KEEP(*(__bug_table)) \
865 __stop___bug_table = .; \
871 #ifdef CONFIG_UNWINDER_ORC
872 #define ORC_UNWIND_TABLE \
874 .orc_unwind_ip : AT(ADDR(.orc_unwind_ip) - LOAD_OFFSET) { \
875 __start_orc_unwind_ip = .; \
876 KEEP(*(.orc_unwind_ip)) \
877 __stop_orc_unwind_ip = .; \
880 .orc_unwind : AT(ADDR(.orc_unwind) - LOAD_OFFSET) { \
881 __start_orc_unwind = .; \
882 KEEP(*(.orc_unwind)) \
883 __stop_orc_unwind = .; \
885 text_size = _etext - _stext; \
887 .orc_lookup : AT(ADDR(.orc_lookup) - LOAD_OFFSET) { \
889 . += (((text_size + LOOKUP_BLOCK_SIZE - 1) / \
890 LOOKUP_BLOCK_SIZE) + 1) * 4; \
891 orc_lookup_end = .; \
894 #define ORC_UNWIND_TABLE
897 /* Built-in firmware blobs */
898 #ifdef CONFIG_FW_LOADER
899 #define FW_LOADER_BUILT_IN_DATA \
900 .builtin_fw : AT(ADDR(.builtin_fw) - LOAD_OFFSET) ALIGN(8) { \
901 __start_builtin_fw = .; \
902 KEEP(*(.builtin_fw)) \
903 __end_builtin_fw = .; \
906 #define FW_LOADER_BUILT_IN_DATA
909 #ifdef CONFIG_PM_TRACE
912 .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) { \
913 __tracedata_start = .; \
914 KEEP(*(.tracedata)) \
915 __tracedata_end = .; \
921 #ifdef CONFIG_PRINTK_INDEX
922 #define PRINTK_INDEX \
923 .printk_index : AT(ADDR(.printk_index) - LOAD_OFFSET) { \
924 __start_printk_index = .; \
926 __stop_printk_index = .; \
933 .notes : AT(ADDR(.notes) - LOAD_OFFSET) { \
938 NOTES_HEADERS_RESTORE
940 #define INIT_SETUP(initsetup_align) \
941 . = ALIGN(initsetup_align); \
943 KEEP(*(.init.setup)) \
946 #define INIT_CALLS_LEVEL(level) \
947 __initcall##level##_start = .; \
948 KEEP(*(.initcall##level##.init)) \
949 KEEP(*(.initcall##level##s.init)) \
952 __initcall_start = .; \
953 KEEP(*(.initcallearly.init)) \
954 INIT_CALLS_LEVEL(0) \
955 INIT_CALLS_LEVEL(1) \
956 INIT_CALLS_LEVEL(2) \
957 INIT_CALLS_LEVEL(3) \
958 INIT_CALLS_LEVEL(4) \
959 INIT_CALLS_LEVEL(5) \
960 INIT_CALLS_LEVEL(rootfs) \
961 INIT_CALLS_LEVEL(6) \
962 INIT_CALLS_LEVEL(7) \
965 #define CON_INITCALL \
966 __con_initcall_start = .; \
967 KEEP(*(.con_initcall.init)) \
968 __con_initcall_end = .;
970 /* Alignment must be consistent with (kunit_suite *) in include/kunit/test.h */
971 #define KUNIT_TABLE() \
973 __kunit_suites_start = .; \
974 KEEP(*(.kunit_test_suites)) \
975 __kunit_suites_end = .;
977 #ifdef CONFIG_BLK_DEV_INITRD
978 #define INIT_RAM_FS \
980 __initramfs_start = .; \
981 KEEP(*(.init.ramfs)) \
983 KEEP(*(.init.ramfs.info))
989 * Memory encryption operates on a page basis. Since we need to clear
990 * the memory encryption mask for this section, it needs to be aligned
991 * on a page boundary and be a page-size multiple in length.
993 * Note: We use a separate section so that only this section gets
994 * decrypted to avoid exposing more than we wish.
996 #ifdef CONFIG_AMD_MEM_ENCRYPT
997 #define PERCPU_DECRYPTED_SECTION \
998 . = ALIGN(PAGE_SIZE); \
999 *(.data..percpu..decrypted) \
1000 . = ALIGN(PAGE_SIZE);
1002 #define PERCPU_DECRYPTED_SECTION
1007 * Default discarded sections.
1009 * Some archs want to discard exit text/data at runtime rather than
1010 * link time due to cross-section references such as alt instructions,
1011 * bug table, eh_frame, etc. DISCARDS must be the last of output
1012 * section definitions so that such archs put those in earlier section
1015 #ifdef RUNTIME_DISCARD_EXIT
1016 #define EXIT_DISCARDS
1018 #define EXIT_DISCARDS \
1024 * Clang's -fprofile-arcs, -fsanitize=kernel-address, and
1025 * -fsanitize=thread produce unwanted sections (.eh_frame
1026 * and .init_array.*), but CONFIG_CONSTRUCTORS wants to
1027 * keep any .init_array.* sections.
1028 * https://bugs.llvm.org/show_bug.cgi?id=46478
1030 #ifdef CONFIG_UNWIND_TABLES
1031 #define DISCARD_EH_FRAME
1033 #define DISCARD_EH_FRAME *(.eh_frame)
1035 #if defined(CONFIG_GCOV_KERNEL) || defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KCSAN)
1036 # ifdef CONFIG_CONSTRUCTORS
1037 # define SANITIZER_DISCARDS \
1040 # define SANITIZER_DISCARDS \
1041 *(.init_array) *(.init_array.*) \
1045 # define SANITIZER_DISCARDS
1048 #define COMMON_DISCARDS \
1049 SANITIZER_DISCARDS \
1050 PATCHABLE_DISCARDS \
1054 /* ld.bfd warns about .gnu.version* even when not emitted */ \
1065 * PERCPU_INPUT - the percpu input sections
1066 * @cacheline: cacheline size
1068 * The core percpu section names and core symbols which do not rely
1069 * directly upon load addresses.
1071 * @cacheline is used to align subsections to avoid false cacheline
1072 * sharing between subsections for different purposes.
1074 #define PERCPU_INPUT(cacheline) \
1075 __per_cpu_start = .; \
1076 *(.data..percpu..first) \
1077 . = ALIGN(PAGE_SIZE); \
1078 *(.data..percpu..page_aligned) \
1079 . = ALIGN(cacheline); \
1080 *(.data..percpu..read_mostly) \
1081 . = ALIGN(cacheline); \
1083 *(.data..percpu..shared_aligned) \
1084 PERCPU_DECRYPTED_SECTION \
1088 * PERCPU_VADDR - define output section for percpu area
1089 * @cacheline: cacheline size
1090 * @vaddr: explicit base address (optional)
1091 * @phdr: destination PHDR (optional)
1093 * Macro which expands to output section for percpu area.
1095 * @cacheline is used to align subsections to avoid false cacheline
1096 * sharing between subsections for different purposes.
1098 * If @vaddr is not blank, it specifies explicit base address and all
1099 * percpu symbols will be offset from the given address. If blank,
1100 * @vaddr always equals @laddr + LOAD_OFFSET.
1102 * @phdr defines the output PHDR to use if not blank. Be warned that
1103 * output PHDR is sticky. If @phdr is specified, the next output
1104 * section in the linker script will go there too. @phdr should have
1107 * Note that this macros defines __per_cpu_load as an absolute symbol.
1108 * If there is no need to put the percpu section at a predetermined
1109 * address, use PERCPU_SECTION.
1111 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
1112 __per_cpu_load = .; \
1113 .data..percpu vaddr : AT(__per_cpu_load - LOAD_OFFSET) { \
1114 PERCPU_INPUT(cacheline) \
1116 . = __per_cpu_load + SIZEOF(.data..percpu);
1119 * PERCPU_SECTION - define output section for percpu area, simple version
1120 * @cacheline: cacheline size
1122 * Align to PAGE_SIZE and outputs output section for percpu area. This
1123 * macro doesn't manipulate @vaddr or @phdr and __per_cpu_load and
1124 * __per_cpu_start will be identical.
1126 * This macro is equivalent to ALIGN(PAGE_SIZE); PERCPU_VADDR(@cacheline,,)
1127 * except that __per_cpu_load is defined as a relative symbol against
1128 * .data..percpu which is required for relocatable x86_32 configuration.
1130 #define PERCPU_SECTION(cacheline) \
1131 . = ALIGN(PAGE_SIZE); \
1132 .data..percpu : AT(ADDR(.data..percpu) - LOAD_OFFSET) { \
1133 __per_cpu_load = .; \
1134 PERCPU_INPUT(cacheline) \
1139 * Definition of the high level *_SECTION macros
1140 * They will fit only a subset of the architectures
1146 * All sections are combined in a single .data section.
1147 * The sections following CONSTRUCTORS are arranged so their
1148 * typical alignment matches.
1149 * A cacheline is typical/always less than a PAGE_SIZE so
1150 * the sections that has this restriction (or similar)
1151 * is located before the ones requiring PAGE_SIZE alignment.
1152 * NOSAVE_DATA starts and ends with a PAGE_SIZE alignment which
1153 * matches the requirement of PAGE_ALIGNED_DATA.
1155 * use 0 as page_align if page_aligned data is not used */
1156 #define RW_DATA(cacheline, pagealigned, inittask) \
1157 . = ALIGN(PAGE_SIZE); \
1158 .data : AT(ADDR(.data) - LOAD_OFFSET) { \
1159 INIT_TASK_DATA(inittask) \
1161 PAGE_ALIGNED_DATA(pagealigned) \
1162 CACHELINE_ALIGNED_DATA(cacheline) \
1163 READ_MOSTLY_DATA(cacheline) \
1169 #define INIT_TEXT_SECTION(inittext_align) \
1170 . = ALIGN(inittext_align); \
1171 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) { \
1177 #define INIT_DATA_SECTION(initsetup_align) \
1178 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { \
1180 INIT_SETUP(initsetup_align) \
1186 #define BSS_SECTION(sbss_align, bss_align, stop_align) \
1187 . = ALIGN(sbss_align); \
1191 . = ALIGN(stop_align); \