/* * Helper macros to support writing architecture specific * linker scripts. * * A minimal linker scripts has following content: * [This is a sample, architectures may have special requirements] * * OUTPUT_FORMAT(...) * OUTPUT_ARCH(...) * ENTRY(...) * SECTIONS * { * . = START; * __init_begin = .; * HEAD_TEXT_SECTION * INIT_TEXT_SECTION(PAGE_SIZE) * INIT_DATA_SECTION(...) * PERCPU_SECTION(CACHELINE_SIZE) * __init_end = .; * * _stext = .; * TEXT_SECTION = 0 * _etext = .; * * _sdata = .; * RO_DATA(PAGE_SIZE) * RW_DATA(...) * _edata = .; * * EXCEPTION_TABLE(...) * * BSS_SECTION(0, 0, 0) * _end = .; * * STABS_DEBUG * DWARF_DEBUG * ELF_DETAILS * * DISCARDS // must be the last * } * * [__init_begin, __init_end] is the init section that may be freed after init * // __init_begin and __init_end should be page aligned, so that we can * // free the whole .init memory * [_stext, _etext] is the text section * [_sdata, _edata] is the data section * * Some of the included output section have their own set of constants. * Examples are: [__initramfs_start, __initramfs_end] for initramfs and * [__nosave_begin, __nosave_end] for the nosave data */ #include <asm-generic/codetag.lds.h> #ifndef LOAD_OFFSET#define LOAD_OFFSET 0#endif /* * Only some architectures want to have the .notes segment visible in * a separate PT_NOTE ELF Program Header. When this happens, it needs * to be visible in both the kernel text's PT_LOAD and the PT_NOTE * Program Headers. In this case, though, the PT_LOAD needs to be made * the default again so that all the following sections don't also end * up in the PT_NOTE Program Header. */#ifdef EMITS_PT_NOTE#define NOTES_HEADERS :text :note#define NOTES_HEADERS_RESTORE __restore_ph : { *(.__restore_ph) } :text#else#define NOTES_HEADERS#define NOTES_HEADERS_RESTORE#endif /* * Some architectures have non-executable read-only exception tables. * They can be added to the RO_DATA segment by specifying their desired * alignment. */#ifdef RO_EXCEPTION_TABLE_ALIGN#define RO_EXCEPTION_TABLE EXCEPTION_TABLE(RO_EXCEPTION_TABLE_ALIGN)#else#define RO_EXCEPTION_TABLE#endif /* Align . function alignment. */#define ALIGN_FUNCTION() . = ALIGN(CONFIG_FUNCTION_ALIGNMENT) /* * Support -ffunction-sections by matching .text and .text.*, * but exclude '.text..*', .text.startup[.*], and .text.exit[.*]. * * .text.startup and .text.startup.* are matched later by INIT_TEXT, and * .text.exit and .text.exit.* are matched later by EXIT_TEXT, so they must be * explicitly excluded here. * * Other .text.* sections that are typically grouped separately, such as * .text.unlikely or .text.hot, must be matched explicitly before using * TEXT_MAIN. * * NOTE: builds *with* and *without* -ffunction-sections are both supported by * this single macro. Even with -ffunction-sections, there may be some objects * NOT compiled with the flag due to the use of a specific Makefile override * like cflags-y or AUTOFDO_PROFILE_foo.o. So this single catchall rule is * needed to support mixed object builds. * * One implication is that functions named startup(), exit(), split(), * unlikely(), hot(), and unknown() are not allowed in the kernel due to the * ambiguity of their section names with -ffunction-sections. For example, * .text.startup could be __attribute__((constructor)) code in a *non* * ffunction-sections object, which should be placed in .init.text; or it could * be an actual function named startup() in an ffunction-sections object, which * should be placed in .text. The build will detect and complain about any such * ambiguously named functions. */#define TEXT_MAIN \ .text \ .text.[_0-9A-Za-df-rt-z]* \ .text.s[_0-9A-Za-su-z]* .text.s .text.s.* \ .text.st[_0-9A-Zb-z]* .text.st .text.st.* \ .text.sta[_0-9A-Za-qs-z]* .text.sta .text.sta.* \ .text.star[_0-9A-Za-su-z]* .text.star .text.star.* \ .text.start[_0-9A-Za-tv-z]* .text.start .text.start.* \ .text.startu[_0-9A-Za-oq-z]* .text.startu .text.startu.* \ .text.startup[_0-9A-Za-z]* \ .text.e[_0-9A-Za-wy-z]* .text.e .text.e.* \ .text.ex[_0-9A-Za-hj-z]* .text.ex .text.ex.* \ .text.exi[_0-9A-Za-su-z]* .text.exi .text.exi.* \ .text.exit[_0-9A-Za-z]* /* * Support -fdata-sections by matching .data, .data.*, and others, * but exclude '.data..*'. */#define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data.rel.* .data..L* .data..compoundliteral* .data.$__unnamed_* .data.$L*#define SDATA_MAIN .sdata .sdata.[0-9a-zA-Z_]*#define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]* .rodata..L*#define BSS_MAIN .bss .bss.[0-9a-zA-Z_]* .bss..L* .bss..compoundliteral*#define SBSS_MAIN .sbss .sbss.[0-9a-zA-Z_]* /* * GCC 4.5 and later have a 32 bytes section alignment for structures. * Except GCC 4.9, that feels the need to align on 64 bytes. */#define STRUCT_ALIGNMENT 32#define STRUCT_ALIGN() . = ALIGN(STRUCT_ALIGNMENT) /* * The order of the sched class addresses are important, as they are * used to determine the order of the priority of each sched class in * relation to each other. */#define SCHED_DATA \ STRUCT_ALIGN(); \ __sched_class_highest = .; \ *(__stop_sched_class) \ *(__dl_sched_class) \ *(__rt_sched_class) \ *(__fair_sched_class) \ *(__ext_sched_class) \ *(__idle_sched_class) \ __sched_class_lowest = .; /* The actual configuration determine if the init/exit sections * are handled as text/data or they can be discarded (which * often happens at runtime) */ #ifndef CONFIG_HAVE_DYNAMIC_FTRACE_NO_PATCHABLE#define KEEP_PATCHABLE KEEP(*(__patchable_function_entries))#define PATCHABLE_DISCARDS#else#define KEEP_PATCHABLE#define PATCHABLE_DISCARDS *(__patchable_function_entries)#endif #ifndef CONFIG_ARCH_SUPPORTS_CFI/* * Simply points to ftrace_stub, but with the proper protocol. * Defined by the linker script in linux/vmlinux.lds.h */#define FTRACE_STUB_HACK ftrace_stub_graph = ftrace_stub;#else#define FTRACE_STUB_HACK#endif #ifdef CONFIG_DYNAMIC_FTRACE/* * The ftrace call sites are logged to a section whose name depends on the * compiler option used. A given kernel image will only use one, AKA * FTRACE_CALLSITE_SECTION. We capture all of them here to avoid header * dependencies for FTRACE_CALLSITE_SECTION's definition. * * ftrace_ops_list_func will be defined as arch_ftrace_ops_list_func * as some archs will have a different prototype for that function * but ftrace_ops_list_func() will have a single prototype. */#define MCOUNT_REC() . = ALIGN(8); \ __start_mcount_loc = .; \ KEEP(*(__mcount_loc)) \ KEEP_PATCHABLE \ __stop_mcount_loc = .; \ FTRACE_STUB_HACK \ ftrace_ops_list_func = arch_ftrace_ops_list_func;#else# ifdef CONFIG_FUNCTION_TRACER# define MCOUNT_REC() FTRACE_STUB_HACK \ ftrace_ops_list_func = arch_ftrace_ops_list_func;# else# define MCOUNT_REC()# endif#endif #define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_) \ _BEGIN_##_label_ = .; \ KEEP(*(_sec_)) \ _END_##_label_ = .; #define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_) \ _label_##_BEGIN_ = .; \ KEEP(*(_sec_)) \ _label_##_END_ = .; #define BOUNDED_SECTION_BY(_sec_, _label_) \ BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop) #define BOUNDED_SECTION(_sec) BOUNDED_SECTION_BY(_sec, _sec) #define HEADERED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \ _HDR_##_label_ = .; \ KEEP(*(.gnu.linkonce.##_sec_)) \ BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_) #define HEADERED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \ _label_##_HDR_ = .; \ KEEP(*(.gnu.linkonce.##_sec_)) \ BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_) #define HEADERED_SECTION_BY(_sec_, _label_) \ HEADERED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop) #define HEADERED_SECTION(_sec) HEADERED_SECTION_BY(_sec, _sec) #ifdef CONFIG_TRACE_BRANCH_PROFILING#define LIKELY_PROFILE() \ BOUNDED_SECTION_BY(_ftrace_annotated_branch, _annotated_branch_profile)#else#define LIKELY_PROFILE()#endif #ifdef CONFIG_PROFILE_ALL_BRANCHES#define BRANCH_PROFILE() \ BOUNDED_SECTION_BY(_ftrace_branch, _branch_profile)#else#define BRANCH_PROFILE()#endif #ifdef CONFIG_KPROBES#define KPROBE_BLACKLIST() \ . = ALIGN(8); \ BOUNDED_SECTION(_kprobe_blacklist)#else#define KPROBE_BLACKLIST()#endif #ifdef CONFIG_FUNCTION_ERROR_INJECTION#define ERROR_INJECT_WHITELIST() \ STRUCT_ALIGN(); \ BOUNDED_SECTION(_error_injection_whitelist)#else#define ERROR_INJECT_WHITELIST()#endif #ifdef CONFIG_EVENT_TRACING#define FTRACE_EVENTS() \ . = ALIGN(8); \ BOUNDED_SECTION(_ftrace_events) \ BOUNDED_SECTION_BY(_ftrace_eval_map, _ftrace_eval_maps)#else#define FTRACE_EVENTS()#endif #ifdef CONFIG_TRACING#define TRACE_PRINTKS() BOUNDED_SECTION_BY(__trace_printk_fmt, ___trace_bprintk_fmt)#define TRACEPOINT_STR() BOUNDED_SECTION_BY(__tracepoint_str, ___tracepoint_str)#else#define TRACE_PRINTKS()#define TRACEPOINT_STR()#endif #ifdef CONFIG_FTRACE_SYSCALLS#define TRACE_SYSCALLS() \ . = ALIGN(8); \ BOUNDED_SECTION_BY(__syscalls_metadata, _syscalls_metadata)#else#define TRACE_SYSCALLS()#endif #ifdef CONFIG_BPF_EVENTS#define BPF_RAW_TP() STRUCT_ALIGN(); \ BOUNDED_SECTION_BY(__bpf_raw_tp_map, __bpf_raw_tp)#else#define BPF_RAW_TP()#endif #ifdef CONFIG_SERIAL_EARLYCON#define EARLYCON_TABLE() \ . = ALIGN(8); \ BOUNDED_SECTION_POST_LABEL(__earlycon_table, __earlycon_table, , _end)#else#define EARLYCON_TABLE()#endif #ifdef CONFIG_SECURITY#define LSM_TABLE() \ . = ALIGN(8); \ BOUNDED_SECTION_PRE_LABEL(.lsm_info.init, _lsm_info, __start, __end) #define EARLY_LSM_TABLE() \ . = ALIGN(8); \ BOUNDED_SECTION_PRE_LABEL(.early_lsm_info.init, _early_lsm_info, __start, __end)#else#define LSM_TABLE()#define EARLY_LSM_TABLE()#endif #define ___OF_TABLE(cfg, name) _OF_TABLE_##cfg(name)#define __OF_TABLE(cfg, name) ___OF_TABLE(cfg, name)#define OF_TABLE(cfg, name) __OF_TABLE(IS_ENABLED(cfg), name)#define _OF_TABLE_0(name)#define _OF_TABLE_1(name) \ . = ALIGN(8); \ __##name##_of_table = .; \ KEEP(*(__##name##_of_table)) \ KEEP(*(__##name##_of_table_end)) #define TIMER_OF_TABLES() OF_TABLE(CONFIG_TIMER_OF, timer)#define IRQCHIP_OF_MATCH_TABLE() OF_TABLE(CONFIG_IRQCHIP, irqchip)#define CLK_OF_TABLES() OF_TABLE(CONFIG_COMMON_CLK, clk)#define RESERVEDMEM_OF_TABLES() OF_TABLE(CONFIG_OF_RESERVED_MEM, reservedmem)#define CPU_METHOD_OF_TABLES() OF_TABLE(CONFIG_SMP, cpu_method)#define CPUIDLE_METHOD_OF_TABLES() OF_TABLE(CONFIG_CPU_IDLE, cpuidle_method) #ifdef CONFIG_ACPI#define ACPI_PROBE_TABLE(name) \ . = ALIGN(8); \ BOUNDED_SECTION_POST_LABEL(__##name##_acpi_probe_table, \ __##name##_acpi_probe_table,, _end)#else#define ACPI_PROBE_TABLE(name)#endif #ifdef CONFIG_THERMAL#define THERMAL_TABLE(name) \ . = ALIGN(8); \ BOUNDED_SECTION_POST_LABEL(__##name##_thermal_table, \ __##name##_thermal_table,, _end)#else#define THERMAL_TABLE(name)#endif #define KERNEL_DTB() \ STRUCT_ALIGN(); \ __dtb_start = .; \ KEEP(*(.dtb.init.rodata)) \ __dtb_end = .; /* * .data section */#define DATA_DATA \ *(.xiptext) \ *(DATA_MAIN) \ *(.data..decrypted) \ *(.ref.data) \ *(.data..shared_aligned) /* percpu related */ \ *(.data..unlikely) \ __start_once = .; \ *(.data..once) \ __end_once = .; \ *(.data..do_once) \ STRUCT_ALIGN(); \ *(__tracepoints) \ /* implement dynamic printk debug */ \ . = ALIGN(8); \ BOUNDED_SECTION_BY(__dyndbg_classes, ___dyndbg_classes) \ BOUNDED_SECTION_BY(__dyndbg, ___dyndbg) \ CODETAG_SECTIONS() \ LIKELY_PROFILE() \ BRANCH_PROFILE() \ TRACE_PRINTKS() \ BPF_RAW_TP() \ TRACEPOINT_STR() \ KUNIT_TABLE() /* * Data section helpers */#define NOSAVE_DATA \ . = ALIGN(PAGE_SIZE); \ __nosave_begin = .; \ *(.data..nosave) \ . = ALIGN(PAGE_SIZE); \ __nosave_end = .; #define CACHE_HOT_DATA(align) \ . = ALIGN(align); \ *(SORT_BY_ALIGNMENT(.data..hot.*)) \ . = ALIGN(align); #define PAGE_ALIGNED_DATA(page_align) \ . = ALIGN(page_align); \ *(.data..page_aligned) \ . = ALIGN(page_align); #define READ_MOSTLY_DATA(align) \ . = ALIGN(align); \ *(.data..read_mostly) \ . = ALIGN(align); #define CACHELINE_ALIGNED_DATA(align) \ . = ALIGN(align); \ *(.data..cacheline_aligned) #define INIT_TASK_DATA(align) \ . = ALIGN(align); \ __start_init_stack = .; \ init_thread_union = .; \ init_stack = .; \ KEEP(*(.data..init_thread_info)) \ . = __start_init_stack + THREAD_SIZE; \ __end_init_stack = .; #define JUMP_TABLE_DATA \ . = ALIGN(8); \ BOUNDED_SECTION_BY(__jump_table, ___jump_table) #ifdef CONFIG_HAVE_STATIC_CALL_INLINE#define STATIC_CALL_DATA \ . = ALIGN(8); \ BOUNDED_SECTION_BY(.static_call_sites, _static_call_sites) \ BOUNDED_SECTION_BY(.static_call_tramp_key, _static_call_tramp_key)#else#define STATIC_CALL_DATA#endif /* * Allow architectures to handle ro_after_init data on their * own by defining an empty RO_AFTER_INIT_DATA. */#ifndef RO_AFTER_INIT_DATA#define RO_AFTER_INIT_DATA \ . = ALIGN(8); \ __start_ro_after_init = .; \ *(.data..ro_after_init) \ JUMP_TABLE_DATA \ STATIC_CALL_DATA \ __end_ro_after_init = .;#endif /* * .kcfi_traps contains a list KCFI trap locations. */#ifndef KCFI_TRAPS#ifdef CONFIG_ARCH_USES_CFI_TRAPS#define KCFI_TRAPS \ __kcfi_traps : AT(ADDR(__kcfi_traps) - LOAD_OFFSET) { \ BOUNDED_SECTION_BY(.kcfi_traps, ___kcfi_traps) \ }#else#define KCFI_TRAPS#endif#endif /* * Read only Data */#define RO_DATA(align) \ . = ALIGN((align)); \ .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \ __start_rodata = .; \ *(.rodata) *(.rodata.*) *(.data.rel.ro*) \ SCHED_DATA \ RO_AFTER_INIT_DATA /* Read only after init */ \ . = ALIGN(8); \ BOUNDED_SECTION_BY(__tracepoints_ptrs, ___tracepoints_ptrs) \ *(__tracepoints_strings)/* Tracepoints: strings */ \ } \ \ .rodata1 : AT(ADDR(.rodata1) - LOAD_OFFSET) { \ *(.rodata1) \ } \ \ /* PCI quirks */ \ .pci_fixup : AT(ADDR(.pci_fixup) - LOAD_OFFSET) { \ BOUNDED_SECTION_PRE_LABEL(.pci_fixup_early, _pci_fixups_early, __start, __end) \ BOUNDED_SECTION_PRE_LABEL(.pci_fixup_header, _pci_fixups_header, __start, __end) \ BOUNDED_SECTION_PRE_LABEL(.pci_fixup_final, _pci_fixups_final, __start, __end) \ BOUNDED_SECTION_PRE_LABEL(.pci_fixup_enable, _pci_fixups_enable, __start, __end) \ BOUNDED_SECTION_PRE_LABEL(.pci_fixup_resume, _pci_fixups_resume, __start, __end) \Lines 1–500 of 1189. Load more
/* * Helper macros to support writing architecture specific * linker scripts. * * A minimal linker scripts has following content: * [This is a sample, architectures may have special requirements] * * OUTPUT_FORMAT(...) * OUTPUT_ARCH(...) * ENTRY(...) * SECTIONS * { * . = START; * __init_begin = .; * HEAD_TEXT_SECTION * INIT_TEXT_SECTION(PAGE_SIZE) * INIT_DATA_SECTION(...) * PERCPU_SECTION(CACHELINE_SIZE) * __init_end = .; * * _stext = .; * TEXT_SECTION = 0 * _etext = .; * * _sdata = .; * RO_DATA(PAGE_SIZE) * RW_DATA(...) * _edata = .; * * EXCEPTION_TABLE(...) * * BSS_SECTION(0, 0, 0) * _end = .; * * STABS_DEBUG * DWARF_DEBUG * ELF_DETAILS * * DISCARDS // must be the last * } * * [__init_begin, __init_end] is the init section that may be freed after init * // __init_begin and __init_end should be page aligned, so that we can * // free the whole .init memory * [_stext, _etext] is the text section * [_sdata, _edata] is the data section * * Some of the included output section have their own set of constants. * Examples are: [__initramfs_start, __initramfs_end] for initramfs and * [__nosave_begin, __nosave_end] for the nosave data */ #include <asm-generic/codetag.lds.h> #ifndef LOAD_OFFSET #define LOAD_OFFSET 0 #endif /* * Only some architectures want to have the .notes segment visible in * a separate PT_NOTE ELF Program Header. When this happens, it needs * to be visible in both the kernel text's PT_LOAD and the PT_NOTE * Program Headers. In this case, though, the PT_LOAD needs to be made * the default again so that all the following sections don't also end * up in the PT_NOTE Program Header. */ #ifdef EMITS_PT_NOTE #define NOTES_HEADERS :text :note #define NOTES_HEADERS_RESTORE __restore_ph : { *(.__restore_ph) } :text #else #define NOTES_HEADERS #define NOTES_HEADERS_RESTORE #endif /* * Some architectures have non-executable read-only exception tables. * They can be added to the RO_DATA segment by specifying their desired * alignment. */ #ifdef RO_EXCEPTION_TABLE_ALIGN #define RO_EXCEPTION_TABLE EXCEPTION_TABLE(RO_EXCEPTION_TABLE_ALIGN) #else #define RO_EXCEPTION_TABLE #endif /* Align . function alignment. */ #define ALIGN_FUNCTION() . = ALIGN(CONFIG_FUNCTION_ALIGNMENT) /* * Support -ffunction-sections by matching .text and .text.*, * but exclude '.text..*', .text.startup[.*], and .text.exit[.*]. * * .text.startup and .text.startup.* are matched later by INIT_TEXT, and * .text.exit and .text.exit.* are matched later by EXIT_TEXT, so they must be * explicitly excluded here. * * Other .text.* sections that are typically grouped separately, such as * .text.unlikely or .text.hot, must be matched explicitly before using * TEXT_MAIN. * * NOTE: builds *with* and *without* -ffunction-sections are both supported by * this single macro. Even with -ffunction-sections, there may be some objects * NOT compiled with the flag due to the use of a specific Makefile override * like cflags-y or AUTOFDO_PROFILE_foo.o. So this single catchall rule is * needed to support mixed object builds. * * One implication is that functions named startup(), exit(), split(), * unlikely(), hot(), and unknown() are not allowed in the kernel due to the * ambiguity of their section names with -ffunction-sections. For example, * .text.startup could be __attribute__((constructor)) code in a *non* * ffunction-sections object, which should be placed in .init.text; or it could * be an actual function named startup() in an ffunction-sections object, which * should be placed in .text. The build will detect and complain about any such * ambiguously named functions. */ #define TEXT_MAIN \ .text \ .text.[_0-9A-Za-df-rt-z]* \ .text.s[_0-9A-Za-su-z]* .text.s .text.s.* \ .text.st[_0-9A-Zb-z]* .text.st .text.st.* \ .text.sta[_0-9A-Za-qs-z]* .text.sta .text.sta.* \ .text.star[_0-9A-Za-su-z]* .text.star .text.star.* \ .text.start[_0-9A-Za-tv-z]* .text.start .text.start.* \ .text.startu[_0-9A-Za-oq-z]* .text.startu .text.startu.* \ .text.startup[_0-9A-Za-z]* \ .text.e[_0-9A-Za-wy-z]* .text.e .text.e.* \ .text.ex[_0-9A-Za-hj-z]* .text.ex .text.ex.* \ .text.exi[_0-9A-Za-su-z]* .text.exi .text.exi.* \ .text.exit[_0-9A-Za-z]* /* * Support -fdata-sections by matching .data, .data.*, and others, * but exclude '.data..*'. */ #define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data.rel.* .data..L* .data..compoundliteral* .data.$__unnamed_* .data.$L* #define SDATA_MAIN .sdata .sdata.[0-9a-zA-Z_]* #define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]* .rodata..L* #define BSS_MAIN .bss .bss.[0-9a-zA-Z_]* .bss..L* .bss..compoundliteral* #define SBSS_MAIN .sbss .sbss.[0-9a-zA-Z_]* /* * GCC 4.5 and later have a 32 bytes section alignment for structures. * Except GCC 4.9, that feels the need to align on 64 bytes. */ #define STRUCT_ALIGNMENT 32 #define STRUCT_ALIGN() . = ALIGN(STRUCT_ALIGNMENT) /* * The order of the sched class addresses are important, as they are * used to determine the order of the priority of each sched class in * relation to each other. */ #define SCHED_DATA \ STRUCT_ALIGN(); \ __sched_class_highest = .; \ *(__stop_sched_class) \ *(__dl_sched_class) \ *(__rt_sched_class) \ *(__fair_sched_class) \ *(__ext_sched_class) \ *(__idle_sched_class) \ __sched_class_lowest = .; /* The actual configuration determine if the init/exit sections * are handled as text/data or they can be discarded (which * often happens at runtime) */ #ifndef CONFIG_HAVE_DYNAMIC_FTRACE_NO_PATCHABLE #define KEEP_PATCHABLE KEEP(*(__patchable_function_entries)) #define PATCHABLE_DISCARDS #else #define KEEP_PATCHABLE #define PATCHABLE_DISCARDS *(__patchable_function_entries) #endif #ifndef CONFIG_ARCH_SUPPORTS_CFI /* * Simply points to ftrace_stub, but with the proper protocol. * Defined by the linker script in linux/vmlinux.lds.h */ #define FTRACE_STUB_HACK ftrace_stub_graph = ftrace_stub; #else #define FTRACE_STUB_HACK #endif #ifdef CONFIG_DYNAMIC_FTRACE /* * The ftrace call sites are logged to a section whose name depends on the * compiler option used. A given kernel image will only use one, AKA * FTRACE_CALLSITE_SECTION. We capture all of them here to avoid header * dependencies for FTRACE_CALLSITE_SECTION's definition. * * ftrace_ops_list_func will be defined as arch_ftrace_ops_list_func * as some archs will have a different prototype for that function * but ftrace_ops_list_func() will have a single prototype. */ #define MCOUNT_REC() . = ALIGN(8); \ __start_mcount_loc = .; \ KEEP(*(__mcount_loc)) \ KEEP_PATCHABLE \ __stop_mcount_loc = .; \ FTRACE_STUB_HACK \ ftrace_ops_list_func = arch_ftrace_ops_list_func; #else # ifdef CONFIG_FUNCTION_TRACER # define MCOUNT_REC() FTRACE_STUB_HACK \ ftrace_ops_list_func = arch_ftrace_ops_list_func; # else # define MCOUNT_REC() # endif #endif #define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_) \ _BEGIN_##_label_ = .; \ KEEP(*(_sec_)) \ _END_##_label_ = .; #define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_) \ _label_##_BEGIN_ = .; \ KEEP(*(_sec_)) \ _label_##_END_ = .; #define BOUNDED_SECTION_BY(_sec_, _label_) \ BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop) #define BOUNDED_SECTION(_sec) BOUNDED_SECTION_BY(_sec, _sec) #define HEADERED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \ _HDR_##_label_ = .; \ KEEP(*(.gnu.linkonce.##_sec_)) \ BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_) #define HEADERED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \ _label_##_HDR_ = .; \ KEEP(*(.gnu.linkonce.##_sec_)) \ BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_) #define HEADERED_SECTION_BY(_sec_, _label_) \ HEADERED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop) #define HEADERED_SECTION(_sec) HEADERED_SECTION_BY(_sec, _sec) #ifdef CONFIG_TRACE_BRANCH_PROFILING #define LIKELY_PROFILE() \ BOUNDED_SECTION_BY(_ftrace_annotated_branch, _annotated_branch_profile) #else #define LIKELY_PROFILE() #endif #ifdef CONFIG_PROFILE_ALL_BRANCHES #define BRANCH_PROFILE() \ BOUNDED_SECTION_BY(_ftrace_branch, _branch_profile) #else #define BRANCH_PROFILE() #endif #ifdef CONFIG_KPROBES #define KPROBE_BLACKLIST() \ . = ALIGN(8); \ BOUNDED_SECTION(_kprobe_blacklist) #else #define KPROBE_BLACKLIST() #endif #ifdef CONFIG_FUNCTION_ERROR_INJECTION #define ERROR_INJECT_WHITELIST() \ STRUCT_ALIGN(); \ BOUNDED_SECTION(_error_injection_whitelist) #else #define ERROR_INJECT_WHITELIST() #endif #ifdef CONFIG_EVENT_TRACING #define FTRACE_EVENTS() \ . = ALIGN(8); \ BOUNDED_SECTION(_ftrace_events) \ BOUNDED_SECTION_BY(_ftrace_eval_map, _ftrace_eval_maps) #else #define FTRACE_EVENTS() #endif #ifdef CONFIG_TRACING #define TRACE_PRINTKS() BOUNDED_SECTION_BY(__trace_printk_fmt, ___trace_bprintk_fmt) #define TRACEPOINT_STR() BOUNDED_SECTION_BY(__tracepoint_str, ___tracepoint_str) #else #define TRACE_PRINTKS() #define TRACEPOINT_STR() #endif #ifdef CONFIG_FTRACE_SYSCALLS #define TRACE_SYSCALLS() \ . = ALIGN(8); \ BOUNDED_SECTION_BY(__syscalls_metadata, _syscalls_metadata) #else #define TRACE_SYSCALLS() #endif #ifdef CONFIG_BPF_EVENTS #define BPF_RAW_TP() STRUCT_ALIGN(); \ BOUNDED_SECTION_BY(__bpf_raw_tp_map, __bpf_raw_tp) #else #define BPF_RAW_TP() #endif #ifdef CONFIG_SERIAL_EARLYCON #define EARLYCON_TABLE() \ . = ALIGN(8); \ BOUNDED_SECTION_POST_LABEL(__earlycon_table, __earlycon_table, , _end) #else #define EARLYCON_TABLE() #endif #ifdef CONFIG_SECURITY #define LSM_TABLE() \ . = ALIGN(8); \ BOUNDED_SECTION_PRE_LABEL(.lsm_info.init, _lsm_info, __start, __end) #define EARLY_LSM_TABLE() \ . = ALIGN(8); \ BOUNDED_SECTION_PRE_LABEL(.early_lsm_info.init, _early_lsm_info, __start, __end) #else #define LSM_TABLE() #define EARLY_LSM_TABLE() #endif #define ___OF_TABLE(cfg, name) _OF_TABLE_##cfg(name) #define __OF_TABLE(cfg, name) ___OF_TABLE(cfg, name) #define OF_TABLE(cfg, name) __OF_TABLE(IS_ENABLED(cfg), name) #define _OF_TABLE_0(name) #define _OF_TABLE_1(name) \ . = ALIGN(8); \ __##name##_of_table = .; \ KEEP(*(__##name##_of_table)) \ KEEP(*(__##name##_of_table_end)) #define TIMER_OF_TABLES() OF_TABLE(CONFIG_TIMER_OF, timer) #define IRQCHIP_OF_MATCH_TABLE() OF_TABLE(CONFIG_IRQCHIP, irqchip) #define CLK_OF_TABLES() OF_TABLE(CONFIG_COMMON_CLK, clk) #define RESERVEDMEM_OF_TABLES() OF_TABLE(CONFIG_OF_RESERVED_MEM, reservedmem) #define CPU_METHOD_OF_TABLES() OF_TABLE(CONFIG_SMP, cpu_method) #define CPUIDLE_METHOD_OF_TABLES() OF_TABLE(CONFIG_CPU_IDLE, cpuidle_method) #ifdef CONFIG_ACPI #define ACPI_PROBE_TABLE(name) \ . = ALIGN(8); \ BOUNDED_SECTION_POST_LABEL(__##name##_acpi_probe_table, \ __##name##_acpi_probe_table,, _end) #else #define ACPI_PROBE_TABLE(name) #endif #ifdef CONFIG_THERMAL #define THERMAL_TABLE(name) \ . = ALIGN(8); \ BOUNDED_SECTION_POST_LABEL(__##name##_thermal_table, \ __##name##_thermal_table,, _end) #else #define THERMAL_TABLE(name) #endif #define KERNEL_DTB() \ STRUCT_ALIGN(); \ __dtb_start = .; \ KEEP(*(.dtb.init.rodata)) \ __dtb_end = .; /* * .data section */ #define DATA_DATA \ *(.xiptext) \ *(DATA_MAIN) \ *(.data..decrypted) \ *(.ref.data) \ *(.data..shared_aligned) /* percpu related */ \ *(.data..unlikely) \ __start_once = .; \ *(.data..once) \ __end_once = .; \ *(.data..do_once) \ STRUCT_ALIGN(); \ *(__tracepoints) \ /* implement dynamic printk debug */ \ . = ALIGN(8); \ BOUNDED_SECTION_BY(__dyndbg_classes, ___dyndbg_classes) \ BOUNDED_SECTION_BY(__dyndbg, ___dyndbg) \ CODETAG_SECTIONS() \ LIKELY_PROFILE() \ BRANCH_PROFILE() \ TRACE_PRINTKS() \ BPF_RAW_TP() \ TRACEPOINT_STR() \ KUNIT_TABLE() /* * Data section helpers */ #define NOSAVE_DATA \ . = ALIGN(PAGE_SIZE); \ __nosave_begin = .; \ *(.data..nosave) \ . = ALIGN(PAGE_SIZE); \ __nosave_end = .; #define CACHE_HOT_DATA(align) \ . = ALIGN(align); \ *(SORT_BY_ALIGNMENT(.data..hot.*)) \ . = ALIGN(align); #define PAGE_ALIGNED_DATA(page_align) \ . = ALIGN(page_align); \ *(.data..page_aligned) \ . = ALIGN(page_align); #define READ_MOSTLY_DATA(align) \ . = ALIGN(align); \ *(.data..read_mostly) \ . = ALIGN(align); #define CACHELINE_ALIGNED_DATA(align) \ . = ALIGN(align); \ *(.data..cacheline_aligned) #define INIT_TASK_DATA(align) \ . = ALIGN(align); \ __start_init_stack = .; \ init_thread_union = .; \ init_stack = .; \ KEEP(*(.data..init_thread_info)) \ . = __start_init_stack + THREAD_SIZE; \ __end_init_stack = .; #define JUMP_TABLE_DATA \ . = ALIGN(8); \ BOUNDED_SECTION_BY(__jump_table, ___jump_table) #ifdef CONFIG_HAVE_STATIC_CALL_INLINE #define STATIC_CALL_DATA \ . = ALIGN(8); \ BOUNDED_SECTION_BY(.static_call_sites, _static_call_sites) \ BOUNDED_SECTION_BY(.static_call_tramp_key, _static_call_tramp_key) #else #define STATIC_CALL_DATA #endif /* * Allow architectures to handle ro_after_init data on their * own by defining an empty RO_AFTER_INIT_DATA. */ #ifndef RO_AFTER_INIT_DATA #define RO_AFTER_INIT_DATA \ . = ALIGN(8); \ __start_ro_after_init = .; \ *(.data..ro_after_init) \ JUMP_TABLE_DATA \ STATIC_CALL_DATA \ __end_ro_after_init = .; #endif /* * .kcfi_traps contains a list KCFI trap locations. */ #ifndef KCFI_TRAPS #ifdef CONFIG_ARCH_USES_CFI_TRAPS #define KCFI_TRAPS \ __kcfi_traps : AT(ADDR(__kcfi_traps) - LOAD_OFFSET) { \ BOUNDED_SECTION_BY(.kcfi_traps, ___kcfi_traps) \ } #else #define KCFI_TRAPS #endif #endif /* * Read only Data */ #define RO_DATA(align) \ . = ALIGN((align)); \ .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \ __start_rodata = .; \ *(.rodata) *(.rodata.*) *(.data.rel.ro*) \ SCHED_DATA \ RO_AFTER_INIT_DATA /* Read only after init */ \ . = ALIGN(8); \ BOUNDED_SECTION_BY(__tracepoints_ptrs, ___tracepoints_ptrs) \ *(__tracepoints_strings)/* Tracepoints: strings */ \ } \ \ .rodata1 : AT(ADDR(.rodata1) - LOAD_OFFSET) { \ *(.rodata1) \ } \ \ /* PCI quirks */ \ .pci_fixup : AT(ADDR(.pci_fixup) - LOAD_OFFSET) { \ BOUNDED_SECTION_PRE_LABEL(.pci_fixup_early, _pci_fixups_early, __start, __end) \ BOUNDED_SECTION_PRE_LABEL(.pci_fixup_header, _pci_fixups_header, __start, __end) \ BOUNDED_SECTION_PRE_LABEL(.pci_fixup_final, _pci_fixups_final, __start, __end) \ BOUNDED_SECTION_PRE_LABEL(.pci_fixup_enable, _pci_fixups_enable, __start, __end) \ BOUNDED_SECTION_PRE_LABEL(.pci_fixup_resume, _pci_fixups_resume, __start, __end) \