162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * Helper macros to support writing architecture specific
362306a36Sopenharmony_ci * linker scripts.
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * A minimal linker scripts has following content:
662306a36Sopenharmony_ci * [This is a sample, architectures may have special requiriements]
762306a36Sopenharmony_ci *
862306a36Sopenharmony_ci * OUTPUT_FORMAT(...)
962306a36Sopenharmony_ci * OUTPUT_ARCH(...)
1062306a36Sopenharmony_ci * ENTRY(...)
1162306a36Sopenharmony_ci * SECTIONS
1262306a36Sopenharmony_ci * {
1362306a36Sopenharmony_ci *	. = START;
1462306a36Sopenharmony_ci *	__init_begin = .;
1562306a36Sopenharmony_ci *	HEAD_TEXT_SECTION
1662306a36Sopenharmony_ci *	INIT_TEXT_SECTION(PAGE_SIZE)
1762306a36Sopenharmony_ci *	INIT_DATA_SECTION(...)
1862306a36Sopenharmony_ci *	PERCPU_SECTION(CACHELINE_SIZE)
1962306a36Sopenharmony_ci *	__init_end = .;
2062306a36Sopenharmony_ci *
2162306a36Sopenharmony_ci *	_stext = .;
2262306a36Sopenharmony_ci *	TEXT_SECTION = 0
2362306a36Sopenharmony_ci *	_etext = .;
2462306a36Sopenharmony_ci *
2562306a36Sopenharmony_ci *      _sdata = .;
2662306a36Sopenharmony_ci *	RO_DATA(PAGE_SIZE)
2762306a36Sopenharmony_ci *	RW_DATA(...)
2862306a36Sopenharmony_ci *	_edata = .;
2962306a36Sopenharmony_ci *
3062306a36Sopenharmony_ci *	EXCEPTION_TABLE(...)
3162306a36Sopenharmony_ci *
3262306a36Sopenharmony_ci *	BSS_SECTION(0, 0, 0)
3362306a36Sopenharmony_ci *	_end = .;
3462306a36Sopenharmony_ci *
3562306a36Sopenharmony_ci *	STABS_DEBUG
3662306a36Sopenharmony_ci *	DWARF_DEBUG
3762306a36Sopenharmony_ci *	ELF_DETAILS
3862306a36Sopenharmony_ci *
3962306a36Sopenharmony_ci *	DISCARDS		// must be the last
4062306a36Sopenharmony_ci * }
4162306a36Sopenharmony_ci *
4262306a36Sopenharmony_ci * [__init_begin, __init_end] is the init section that may be freed after init
4362306a36Sopenharmony_ci * 	// __init_begin and __init_end should be page aligned, so that we can
4462306a36Sopenharmony_ci *	// free the whole .init memory
4562306a36Sopenharmony_ci * [_stext, _etext] is the text section
4662306a36Sopenharmony_ci * [_sdata, _edata] is the data section
4762306a36Sopenharmony_ci *
4862306a36Sopenharmony_ci * Some of the included output section have their own set of constants.
4962306a36Sopenharmony_ci * Examples are: [__initramfs_start, __initramfs_end] for initramfs and
5062306a36Sopenharmony_ci *               [__nosave_begin, __nosave_end] for the nosave data
5162306a36Sopenharmony_ci */
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_ci#ifndef LOAD_OFFSET
5462306a36Sopenharmony_ci#define LOAD_OFFSET 0
5562306a36Sopenharmony_ci#endif
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci/*
5862306a36Sopenharmony_ci * Only some architectures want to have the .notes segment visible in
5962306a36Sopenharmony_ci * a separate PT_NOTE ELF Program Header. When this happens, it needs
6062306a36Sopenharmony_ci * to be visible in both the kernel text's PT_LOAD and the PT_NOTE
6162306a36Sopenharmony_ci * Program Headers. In this case, though, the PT_LOAD needs to be made
6262306a36Sopenharmony_ci * the default again so that all the following sections don't also end
6362306a36Sopenharmony_ci * up in the PT_NOTE Program Header.
6462306a36Sopenharmony_ci */
6562306a36Sopenharmony_ci#ifdef EMITS_PT_NOTE
6662306a36Sopenharmony_ci#define NOTES_HEADERS		:text :note
6762306a36Sopenharmony_ci#define NOTES_HEADERS_RESTORE	__restore_ph : { *(.__restore_ph) } :text
6862306a36Sopenharmony_ci#else
6962306a36Sopenharmony_ci#define NOTES_HEADERS
7062306a36Sopenharmony_ci#define NOTES_HEADERS_RESTORE
7162306a36Sopenharmony_ci#endif
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_ci/*
7462306a36Sopenharmony_ci * Some architectures have non-executable read-only exception tables.
7562306a36Sopenharmony_ci * They can be added to the RO_DATA segment by specifying their desired
7662306a36Sopenharmony_ci * alignment.
7762306a36Sopenharmony_ci */
7862306a36Sopenharmony_ci#ifdef RO_EXCEPTION_TABLE_ALIGN
7962306a36Sopenharmony_ci#define RO_EXCEPTION_TABLE	EXCEPTION_TABLE(RO_EXCEPTION_TABLE_ALIGN)
8062306a36Sopenharmony_ci#else
8162306a36Sopenharmony_ci#define RO_EXCEPTION_TABLE
8262306a36Sopenharmony_ci#endif
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ci/* Align . function alignment. */
8562306a36Sopenharmony_ci#define ALIGN_FUNCTION()  . = ALIGN(CONFIG_FUNCTION_ALIGNMENT)
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci/*
8862306a36Sopenharmony_ci * LD_DEAD_CODE_DATA_ELIMINATION option enables -fdata-sections, which
8962306a36Sopenharmony_ci * generates .data.identifier sections, which need to be pulled in with
9062306a36Sopenharmony_ci * .data. We don't want to pull in .data..other sections, which Linux
9162306a36Sopenharmony_ci * has defined. Same for text and bss.
9262306a36Sopenharmony_ci *
9362306a36Sopenharmony_ci * With LTO_CLANG, the linker also splits sections by default, so we need
9462306a36Sopenharmony_ci * these macros to combine the sections during the final link.
9562306a36Sopenharmony_ci *
9662306a36Sopenharmony_ci * RODATA_MAIN is not used because existing code already defines .rodata.x
9762306a36Sopenharmony_ci * sections to be brought in with rodata.
9862306a36Sopenharmony_ci */
9962306a36Sopenharmony_ci#if defined(CONFIG_LD_DEAD_CODE_DATA_ELIMINATION) || defined(CONFIG_LTO_CLANG)
10062306a36Sopenharmony_ci#define TEXT_MAIN .text .text.[0-9a-zA-Z_]*
10162306a36Sopenharmony_ci#define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..L* .data..compoundliteral* .data.$__unnamed_* .data.$L*
10262306a36Sopenharmony_ci#define SDATA_MAIN .sdata .sdata.[0-9a-zA-Z_]*
10362306a36Sopenharmony_ci#define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]* .rodata..L*
10462306a36Sopenharmony_ci#define BSS_MAIN .bss .bss.[0-9a-zA-Z_]* .bss..compoundliteral*
10562306a36Sopenharmony_ci#define SBSS_MAIN .sbss .sbss.[0-9a-zA-Z_]*
10662306a36Sopenharmony_ci#else
10762306a36Sopenharmony_ci#define TEXT_MAIN .text
10862306a36Sopenharmony_ci#define DATA_MAIN .data
10962306a36Sopenharmony_ci#define SDATA_MAIN .sdata
11062306a36Sopenharmony_ci#define RODATA_MAIN .rodata
11162306a36Sopenharmony_ci#define BSS_MAIN .bss
11262306a36Sopenharmony_ci#define SBSS_MAIN .sbss
11362306a36Sopenharmony_ci#endif
11462306a36Sopenharmony_ci
11562306a36Sopenharmony_ci/*
11662306a36Sopenharmony_ci * GCC 4.5 and later have a 32 bytes section alignment for structures.
11762306a36Sopenharmony_ci * Except GCC 4.9, that feels the need to align on 64 bytes.
11862306a36Sopenharmony_ci */
11962306a36Sopenharmony_ci#define STRUCT_ALIGNMENT 32
12062306a36Sopenharmony_ci#define STRUCT_ALIGN() . = ALIGN(STRUCT_ALIGNMENT)
12162306a36Sopenharmony_ci
12262306a36Sopenharmony_ci/*
12362306a36Sopenharmony_ci * The order of the sched class addresses are important, as they are
12462306a36Sopenharmony_ci * used to determine the order of the priority of each sched class in
12562306a36Sopenharmony_ci * relation to each other.
12662306a36Sopenharmony_ci */
12762306a36Sopenharmony_ci#define SCHED_DATA				\
12862306a36Sopenharmony_ci	STRUCT_ALIGN();				\
12962306a36Sopenharmony_ci	__sched_class_highest = .;		\
13062306a36Sopenharmony_ci	*(__stop_sched_class)			\
13162306a36Sopenharmony_ci	*(__dl_sched_class)			\
13262306a36Sopenharmony_ci	*(__rt_sched_class)			\
13362306a36Sopenharmony_ci	*(__fair_sched_class)			\
13462306a36Sopenharmony_ci	*(__idle_sched_class)			\
13562306a36Sopenharmony_ci	__sched_class_lowest = .;
13662306a36Sopenharmony_ci
13762306a36Sopenharmony_ci/* The actual configuration determine if the init/exit sections
13862306a36Sopenharmony_ci * are handled as text/data or they can be discarded (which
13962306a36Sopenharmony_ci * often happens at runtime)
14062306a36Sopenharmony_ci */
14162306a36Sopenharmony_ci
14262306a36Sopenharmony_ci#if defined(CONFIG_MEMORY_HOTPLUG)
14362306a36Sopenharmony_ci#define MEM_KEEP(sec)    *(.mem##sec)
14462306a36Sopenharmony_ci#define MEM_DISCARD(sec)
14562306a36Sopenharmony_ci#else
14662306a36Sopenharmony_ci#define MEM_KEEP(sec)
14762306a36Sopenharmony_ci#define MEM_DISCARD(sec) *(.mem##sec)
14862306a36Sopenharmony_ci#endif
14962306a36Sopenharmony_ci
15062306a36Sopenharmony_ci#ifndef CONFIG_HAVE_DYNAMIC_FTRACE_NO_PATCHABLE
15162306a36Sopenharmony_ci#define KEEP_PATCHABLE		KEEP(*(__patchable_function_entries))
15262306a36Sopenharmony_ci#define PATCHABLE_DISCARDS
15362306a36Sopenharmony_ci#else
15462306a36Sopenharmony_ci#define KEEP_PATCHABLE
15562306a36Sopenharmony_ci#define PATCHABLE_DISCARDS	*(__patchable_function_entries)
15662306a36Sopenharmony_ci#endif
15762306a36Sopenharmony_ci
15862306a36Sopenharmony_ci#ifndef CONFIG_ARCH_SUPPORTS_CFI_CLANG
15962306a36Sopenharmony_ci/*
16062306a36Sopenharmony_ci * Simply points to ftrace_stub, but with the proper protocol.
16162306a36Sopenharmony_ci * Defined by the linker script in linux/vmlinux.lds.h
16262306a36Sopenharmony_ci */
16362306a36Sopenharmony_ci#define	FTRACE_STUB_HACK	ftrace_stub_graph = ftrace_stub;
16462306a36Sopenharmony_ci#else
16562306a36Sopenharmony_ci#define FTRACE_STUB_HACK
16662306a36Sopenharmony_ci#endif
16762306a36Sopenharmony_ci
16862306a36Sopenharmony_ci#ifdef CONFIG_FTRACE_MCOUNT_RECORD
16962306a36Sopenharmony_ci/*
17062306a36Sopenharmony_ci * The ftrace call sites are logged to a section whose name depends on the
17162306a36Sopenharmony_ci * compiler option used. A given kernel image will only use one, AKA
17262306a36Sopenharmony_ci * FTRACE_CALLSITE_SECTION. We capture all of them here to avoid header
17362306a36Sopenharmony_ci * dependencies for FTRACE_CALLSITE_SECTION's definition.
17462306a36Sopenharmony_ci *
17562306a36Sopenharmony_ci * ftrace_ops_list_func will be defined as arch_ftrace_ops_list_func
17662306a36Sopenharmony_ci * as some archs will have a different prototype for that function
17762306a36Sopenharmony_ci * but ftrace_ops_list_func() will have a single prototype.
17862306a36Sopenharmony_ci */
17962306a36Sopenharmony_ci#define MCOUNT_REC()	. = ALIGN(8);				\
18062306a36Sopenharmony_ci			__start_mcount_loc = .;			\
18162306a36Sopenharmony_ci			KEEP(*(__mcount_loc))			\
18262306a36Sopenharmony_ci			KEEP_PATCHABLE				\
18362306a36Sopenharmony_ci			__stop_mcount_loc = .;			\
18462306a36Sopenharmony_ci			FTRACE_STUB_HACK			\
18562306a36Sopenharmony_ci			ftrace_ops_list_func = arch_ftrace_ops_list_func;
18662306a36Sopenharmony_ci#else
18762306a36Sopenharmony_ci# ifdef CONFIG_FUNCTION_TRACER
18862306a36Sopenharmony_ci#  define MCOUNT_REC()	FTRACE_STUB_HACK			\
18962306a36Sopenharmony_ci			ftrace_ops_list_func = arch_ftrace_ops_list_func;
19062306a36Sopenharmony_ci# else
19162306a36Sopenharmony_ci#  define MCOUNT_REC()
19262306a36Sopenharmony_ci# endif
19362306a36Sopenharmony_ci#endif
19462306a36Sopenharmony_ci
19562306a36Sopenharmony_ci#define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_)	\
19662306a36Sopenharmony_ci	_BEGIN_##_label_ = .;						\
19762306a36Sopenharmony_ci	KEEP(*(_sec_))							\
19862306a36Sopenharmony_ci	_END_##_label_ = .;
19962306a36Sopenharmony_ci
20062306a36Sopenharmony_ci#define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_)	\
20162306a36Sopenharmony_ci	_label_##_BEGIN_ = .;						\
20262306a36Sopenharmony_ci	KEEP(*(_sec_))							\
20362306a36Sopenharmony_ci	_label_##_END_ = .;
20462306a36Sopenharmony_ci
20562306a36Sopenharmony_ci#define BOUNDED_SECTION_BY(_sec_, _label_)				\
20662306a36Sopenharmony_ci	BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop)
20762306a36Sopenharmony_ci
20862306a36Sopenharmony_ci#define BOUNDED_SECTION(_sec)	 BOUNDED_SECTION_BY(_sec, _sec)
20962306a36Sopenharmony_ci
21062306a36Sopenharmony_ci#define HEADERED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \
21162306a36Sopenharmony_ci	_HDR_##_label_	= .;						\
21262306a36Sopenharmony_ci	KEEP(*(.gnu.linkonce.##_sec_))					\
21362306a36Sopenharmony_ci	BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_)
21462306a36Sopenharmony_ci
21562306a36Sopenharmony_ci#define HEADERED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \
21662306a36Sopenharmony_ci	_label_##_HDR_ = .;						\
21762306a36Sopenharmony_ci	KEEP(*(.gnu.linkonce.##_sec_))					\
21862306a36Sopenharmony_ci	BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_)
21962306a36Sopenharmony_ci
22062306a36Sopenharmony_ci#define HEADERED_SECTION_BY(_sec_, _label_)				\
22162306a36Sopenharmony_ci	HEADERED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop)
22262306a36Sopenharmony_ci
22362306a36Sopenharmony_ci#define HEADERED_SECTION(_sec)	 HEADERED_SECTION_BY(_sec, _sec)
22462306a36Sopenharmony_ci
22562306a36Sopenharmony_ci#ifdef CONFIG_TRACE_BRANCH_PROFILING
22662306a36Sopenharmony_ci#define LIKELY_PROFILE()						\
22762306a36Sopenharmony_ci	BOUNDED_SECTION_BY(_ftrace_annotated_branch, _annotated_branch_profile)
22862306a36Sopenharmony_ci#else
22962306a36Sopenharmony_ci#define LIKELY_PROFILE()
23062306a36Sopenharmony_ci#endif
23162306a36Sopenharmony_ci
23262306a36Sopenharmony_ci#ifdef CONFIG_PROFILE_ALL_BRANCHES
23362306a36Sopenharmony_ci#define BRANCH_PROFILE()					\
23462306a36Sopenharmony_ci	BOUNDED_SECTION_BY(_ftrace_branch, _branch_profile)
23562306a36Sopenharmony_ci#else
23662306a36Sopenharmony_ci#define BRANCH_PROFILE()
23762306a36Sopenharmony_ci#endif
23862306a36Sopenharmony_ci
23962306a36Sopenharmony_ci#ifdef CONFIG_KPROBES
24062306a36Sopenharmony_ci#define KPROBE_BLACKLIST()				\
24162306a36Sopenharmony_ci	. = ALIGN(8);					\
24262306a36Sopenharmony_ci	BOUNDED_SECTION(_kprobe_blacklist)
24362306a36Sopenharmony_ci#else
24462306a36Sopenharmony_ci#define KPROBE_BLACKLIST()
24562306a36Sopenharmony_ci#endif
24662306a36Sopenharmony_ci
24762306a36Sopenharmony_ci#ifdef CONFIG_FUNCTION_ERROR_INJECTION
24862306a36Sopenharmony_ci#define ERROR_INJECT_WHITELIST()			\
24962306a36Sopenharmony_ci	STRUCT_ALIGN();					\
25062306a36Sopenharmony_ci	BOUNDED_SECTION(_error_injection_whitelist)
25162306a36Sopenharmony_ci#else
25262306a36Sopenharmony_ci#define ERROR_INJECT_WHITELIST()
25362306a36Sopenharmony_ci#endif
25462306a36Sopenharmony_ci
25562306a36Sopenharmony_ci#ifdef CONFIG_EVENT_TRACING
25662306a36Sopenharmony_ci#define FTRACE_EVENTS()							\
25762306a36Sopenharmony_ci	. = ALIGN(8);							\
25862306a36Sopenharmony_ci	BOUNDED_SECTION(_ftrace_events)					\
25962306a36Sopenharmony_ci	BOUNDED_SECTION_BY(_ftrace_eval_map, _ftrace_eval_maps)
26062306a36Sopenharmony_ci#else
26162306a36Sopenharmony_ci#define FTRACE_EVENTS()
26262306a36Sopenharmony_ci#endif
26362306a36Sopenharmony_ci
26462306a36Sopenharmony_ci#ifdef CONFIG_TRACING
26562306a36Sopenharmony_ci#define TRACE_PRINTKS()		BOUNDED_SECTION_BY(__trace_printk_fmt, ___trace_bprintk_fmt)
26662306a36Sopenharmony_ci#define TRACEPOINT_STR()	BOUNDED_SECTION_BY(__tracepoint_str, ___tracepoint_str)
26762306a36Sopenharmony_ci#else
26862306a36Sopenharmony_ci#define TRACE_PRINTKS()
26962306a36Sopenharmony_ci#define TRACEPOINT_STR()
27062306a36Sopenharmony_ci#endif
27162306a36Sopenharmony_ci
27262306a36Sopenharmony_ci#ifdef CONFIG_FTRACE_SYSCALLS
27362306a36Sopenharmony_ci#define TRACE_SYSCALLS()			\
27462306a36Sopenharmony_ci	. = ALIGN(8);				\
27562306a36Sopenharmony_ci	BOUNDED_SECTION_BY(__syscalls_metadata, _syscalls_metadata)
27662306a36Sopenharmony_ci#else
27762306a36Sopenharmony_ci#define TRACE_SYSCALLS()
27862306a36Sopenharmony_ci#endif
27962306a36Sopenharmony_ci
28062306a36Sopenharmony_ci#ifdef CONFIG_BPF_EVENTS
28162306a36Sopenharmony_ci#define BPF_RAW_TP() STRUCT_ALIGN();				\
28262306a36Sopenharmony_ci	BOUNDED_SECTION_BY(__bpf_raw_tp_map, __bpf_raw_tp)
28362306a36Sopenharmony_ci#else
28462306a36Sopenharmony_ci#define BPF_RAW_TP()
28562306a36Sopenharmony_ci#endif
28662306a36Sopenharmony_ci
28762306a36Sopenharmony_ci#ifdef CONFIG_SERIAL_EARLYCON
28862306a36Sopenharmony_ci#define EARLYCON_TABLE()						\
28962306a36Sopenharmony_ci	. = ALIGN(8);							\
29062306a36Sopenharmony_ci	BOUNDED_SECTION_POST_LABEL(__earlycon_table, __earlycon_table, , _end)
29162306a36Sopenharmony_ci#else
29262306a36Sopenharmony_ci#define EARLYCON_TABLE()
29362306a36Sopenharmony_ci#endif
29462306a36Sopenharmony_ci
29562306a36Sopenharmony_ci#ifdef CONFIG_SECURITY
29662306a36Sopenharmony_ci#define LSM_TABLE()					\
29762306a36Sopenharmony_ci	. = ALIGN(8);					\
29862306a36Sopenharmony_ci	BOUNDED_SECTION_PRE_LABEL(.lsm_info.init, _lsm_info, __start, __end)
29962306a36Sopenharmony_ci
30062306a36Sopenharmony_ci#define EARLY_LSM_TABLE()						\
30162306a36Sopenharmony_ci	. = ALIGN(8);							\
30262306a36Sopenharmony_ci	BOUNDED_SECTION_PRE_LABEL(.early_lsm_info.init, _early_lsm_info, __start, __end)
30362306a36Sopenharmony_ci#else
30462306a36Sopenharmony_ci#define LSM_TABLE()
30562306a36Sopenharmony_ci#define EARLY_LSM_TABLE()
30662306a36Sopenharmony_ci#endif
30762306a36Sopenharmony_ci
30862306a36Sopenharmony_ci#define ___OF_TABLE(cfg, name)	_OF_TABLE_##cfg(name)
30962306a36Sopenharmony_ci#define __OF_TABLE(cfg, name)	___OF_TABLE(cfg, name)
31062306a36Sopenharmony_ci#define OF_TABLE(cfg, name)	__OF_TABLE(IS_ENABLED(cfg), name)
31162306a36Sopenharmony_ci#define _OF_TABLE_0(name)
31262306a36Sopenharmony_ci#define _OF_TABLE_1(name)						\
31362306a36Sopenharmony_ci	. = ALIGN(8);							\
31462306a36Sopenharmony_ci	__##name##_of_table = .;					\
31562306a36Sopenharmony_ci	KEEP(*(__##name##_of_table))					\
31662306a36Sopenharmony_ci	KEEP(*(__##name##_of_table_end))
31762306a36Sopenharmony_ci
31862306a36Sopenharmony_ci#define TIMER_OF_TABLES()	OF_TABLE(CONFIG_TIMER_OF, timer)
31962306a36Sopenharmony_ci#define IRQCHIP_OF_MATCH_TABLE() OF_TABLE(CONFIG_IRQCHIP, irqchip)
32062306a36Sopenharmony_ci#define CLK_OF_TABLES()		OF_TABLE(CONFIG_COMMON_CLK, clk)
32162306a36Sopenharmony_ci#define RESERVEDMEM_OF_TABLES()	OF_TABLE(CONFIG_OF_RESERVED_MEM, reservedmem)
32262306a36Sopenharmony_ci#define CPU_METHOD_OF_TABLES()	OF_TABLE(CONFIG_SMP, cpu_method)
32362306a36Sopenharmony_ci#define CPUIDLE_METHOD_OF_TABLES() OF_TABLE(CONFIG_CPU_IDLE, cpuidle_method)
32462306a36Sopenharmony_ci
32562306a36Sopenharmony_ci#ifdef CONFIG_ACPI
32662306a36Sopenharmony_ci#define ACPI_PROBE_TABLE(name)						\
32762306a36Sopenharmony_ci	. = ALIGN(8);							\
32862306a36Sopenharmony_ci	BOUNDED_SECTION_POST_LABEL(__##name##_acpi_probe_table,		\
32962306a36Sopenharmony_ci				   __##name##_acpi_probe_table,, _end)
33062306a36Sopenharmony_ci#else
33162306a36Sopenharmony_ci#define ACPI_PROBE_TABLE(name)
33262306a36Sopenharmony_ci#endif
33362306a36Sopenharmony_ci
33462306a36Sopenharmony_ci#ifdef CONFIG_THERMAL
33562306a36Sopenharmony_ci#define THERMAL_TABLE(name)						\
33662306a36Sopenharmony_ci	. = ALIGN(8);							\
33762306a36Sopenharmony_ci	BOUNDED_SECTION_POST_LABEL(__##name##_thermal_table,		\
33862306a36Sopenharmony_ci				   __##name##_thermal_table,, _end)
33962306a36Sopenharmony_ci#else
34062306a36Sopenharmony_ci#define THERMAL_TABLE(name)
34162306a36Sopenharmony_ci#endif
34262306a36Sopenharmony_ci
34362306a36Sopenharmony_ci#define KERNEL_DTB()							\
34462306a36Sopenharmony_ci	STRUCT_ALIGN();							\
34562306a36Sopenharmony_ci	__dtb_start = .;						\
34662306a36Sopenharmony_ci	KEEP(*(.dtb.init.rodata))					\
34762306a36Sopenharmony_ci	__dtb_end = .;
34862306a36Sopenharmony_ci
34962306a36Sopenharmony_ci/*
35062306a36Sopenharmony_ci * .data section
35162306a36Sopenharmony_ci */
35262306a36Sopenharmony_ci#define DATA_DATA							\
35362306a36Sopenharmony_ci	*(.xiptext)							\
35462306a36Sopenharmony_ci	*(DATA_MAIN)							\
35562306a36Sopenharmony_ci	*(.data..decrypted)						\
35662306a36Sopenharmony_ci	*(.ref.data)							\
35762306a36Sopenharmony_ci	*(.data..shared_aligned) /* percpu related */			\
35862306a36Sopenharmony_ci	MEM_KEEP(init.data*)						\
35962306a36Sopenharmony_ci	*(.data.unlikely)						\
36062306a36Sopenharmony_ci	__start_once = .;						\
36162306a36Sopenharmony_ci	*(.data.once)							\
36262306a36Sopenharmony_ci	__end_once = .;							\
36362306a36Sopenharmony_ci	STRUCT_ALIGN();							\
36462306a36Sopenharmony_ci	*(__tracepoints)						\
36562306a36Sopenharmony_ci	/* implement dynamic printk debug */				\
36662306a36Sopenharmony_ci	. = ALIGN(8);							\
36762306a36Sopenharmony_ci	BOUNDED_SECTION_BY(__dyndbg_classes, ___dyndbg_classes)		\
36862306a36Sopenharmony_ci	BOUNDED_SECTION_BY(__dyndbg, ___dyndbg)				\
36962306a36Sopenharmony_ci	LIKELY_PROFILE()		       				\
37062306a36Sopenharmony_ci	BRANCH_PROFILE()						\
37162306a36Sopenharmony_ci	TRACE_PRINTKS()							\
37262306a36Sopenharmony_ci	BPF_RAW_TP()							\
37362306a36Sopenharmony_ci	TRACEPOINT_STR()
37462306a36Sopenharmony_ci
37562306a36Sopenharmony_ci/*
37662306a36Sopenharmony_ci * Data section helpers
37762306a36Sopenharmony_ci */
37862306a36Sopenharmony_ci#define NOSAVE_DATA							\
37962306a36Sopenharmony_ci	. = ALIGN(PAGE_SIZE);						\
38062306a36Sopenharmony_ci	__nosave_begin = .;						\
38162306a36Sopenharmony_ci	*(.data..nosave)						\
38262306a36Sopenharmony_ci	. = ALIGN(PAGE_SIZE);						\
38362306a36Sopenharmony_ci	__nosave_end = .;
38462306a36Sopenharmony_ci
38562306a36Sopenharmony_ci#define PAGE_ALIGNED_DATA(page_align)					\
38662306a36Sopenharmony_ci	. = ALIGN(page_align);						\
38762306a36Sopenharmony_ci	*(.data..page_aligned)						\
38862306a36Sopenharmony_ci	. = ALIGN(page_align);
38962306a36Sopenharmony_ci
39062306a36Sopenharmony_ci#define READ_MOSTLY_DATA(align)						\
39162306a36Sopenharmony_ci	. = ALIGN(align);						\
39262306a36Sopenharmony_ci	*(.data..read_mostly)						\
39362306a36Sopenharmony_ci	. = ALIGN(align);
39462306a36Sopenharmony_ci
39562306a36Sopenharmony_ci#define CACHELINE_ALIGNED_DATA(align)					\
39662306a36Sopenharmony_ci	. = ALIGN(align);						\
39762306a36Sopenharmony_ci	*(.data..cacheline_aligned)
39862306a36Sopenharmony_ci
39962306a36Sopenharmony_ci#define INIT_TASK_DATA(align)						\
40062306a36Sopenharmony_ci	. = ALIGN(align);						\
40162306a36Sopenharmony_ci	__start_init_task = .;						\
40262306a36Sopenharmony_ci	init_thread_union = .;						\
40362306a36Sopenharmony_ci	init_stack = .;							\
40462306a36Sopenharmony_ci	KEEP(*(.data..init_task))					\
40562306a36Sopenharmony_ci	KEEP(*(.data..init_thread_info))				\
40662306a36Sopenharmony_ci	. = __start_init_task + THREAD_SIZE;				\
40762306a36Sopenharmony_ci	__end_init_task = .;
40862306a36Sopenharmony_ci
40962306a36Sopenharmony_ci#define JUMP_TABLE_DATA							\
41062306a36Sopenharmony_ci	. = ALIGN(8);							\
41162306a36Sopenharmony_ci	BOUNDED_SECTION_BY(__jump_table, ___jump_table)
41262306a36Sopenharmony_ci
41362306a36Sopenharmony_ci#ifdef CONFIG_HAVE_STATIC_CALL_INLINE
41462306a36Sopenharmony_ci#define STATIC_CALL_DATA						\
41562306a36Sopenharmony_ci	. = ALIGN(8);							\
41662306a36Sopenharmony_ci	BOUNDED_SECTION_BY(.static_call_sites, _static_call_sites)	\
41762306a36Sopenharmony_ci	BOUNDED_SECTION_BY(.static_call_tramp_key, _static_call_tramp_key)
41862306a36Sopenharmony_ci#else
41962306a36Sopenharmony_ci#define STATIC_CALL_DATA
42062306a36Sopenharmony_ci#endif
42162306a36Sopenharmony_ci
42262306a36Sopenharmony_ci/*
42362306a36Sopenharmony_ci * Allow architectures to handle ro_after_init data on their
42462306a36Sopenharmony_ci * own by defining an empty RO_AFTER_INIT_DATA.
42562306a36Sopenharmony_ci */
42662306a36Sopenharmony_ci#ifndef RO_AFTER_INIT_DATA
42762306a36Sopenharmony_ci#define RO_AFTER_INIT_DATA						\
42862306a36Sopenharmony_ci	. = ALIGN(8);							\
42962306a36Sopenharmony_ci	__start_ro_after_init = .;					\
43062306a36Sopenharmony_ci	*(.data..ro_after_init)						\
43162306a36Sopenharmony_ci	JUMP_TABLE_DATA							\
43262306a36Sopenharmony_ci	STATIC_CALL_DATA						\
43362306a36Sopenharmony_ci	__end_ro_after_init = .;
43462306a36Sopenharmony_ci#endif
43562306a36Sopenharmony_ci
43662306a36Sopenharmony_ci/*
43762306a36Sopenharmony_ci * .kcfi_traps contains a list KCFI trap locations.
43862306a36Sopenharmony_ci */
43962306a36Sopenharmony_ci#ifndef KCFI_TRAPS
44062306a36Sopenharmony_ci#ifdef CONFIG_ARCH_USES_CFI_TRAPS
44162306a36Sopenharmony_ci#define KCFI_TRAPS							\
44262306a36Sopenharmony_ci	__kcfi_traps : AT(ADDR(__kcfi_traps) - LOAD_OFFSET) {		\
44362306a36Sopenharmony_ci		BOUNDED_SECTION_BY(.kcfi_traps, ___kcfi_traps)		\
44462306a36Sopenharmony_ci	}
44562306a36Sopenharmony_ci#else
44662306a36Sopenharmony_ci#define KCFI_TRAPS
44762306a36Sopenharmony_ci#endif
44862306a36Sopenharmony_ci#endif
44962306a36Sopenharmony_ci
45062306a36Sopenharmony_ci/*
45162306a36Sopenharmony_ci * Read only Data
45262306a36Sopenharmony_ci */
45362306a36Sopenharmony_ci#define RO_DATA(align)							\
45462306a36Sopenharmony_ci	. = ALIGN((align));						\
45562306a36Sopenharmony_ci	.rodata           : AT(ADDR(.rodata) - LOAD_OFFSET) {		\
45662306a36Sopenharmony_ci		__start_rodata = .;					\
45762306a36Sopenharmony_ci		*(.rodata) *(.rodata.*)					\
45862306a36Sopenharmony_ci		SCHED_DATA						\
45962306a36Sopenharmony_ci		RO_AFTER_INIT_DATA	/* Read only after init */	\
46062306a36Sopenharmony_ci		. = ALIGN(8);						\
46162306a36Sopenharmony_ci		BOUNDED_SECTION_BY(__tracepoints_ptrs, ___tracepoints_ptrs) \
46262306a36Sopenharmony_ci		*(__tracepoints_strings)/* Tracepoints: strings */	\
46362306a36Sopenharmony_ci	}								\
46462306a36Sopenharmony_ci									\
46562306a36Sopenharmony_ci	.rodata1          : AT(ADDR(.rodata1) - LOAD_OFFSET) {		\
46662306a36Sopenharmony_ci		*(.rodata1)						\
46762306a36Sopenharmony_ci	}								\
46862306a36Sopenharmony_ci									\
46962306a36Sopenharmony_ci	/* PCI quirks */						\
47062306a36Sopenharmony_ci	.pci_fixup        : AT(ADDR(.pci_fixup) - LOAD_OFFSET) {	\
47162306a36Sopenharmony_ci		BOUNDED_SECTION_PRE_LABEL(.pci_fixup_early,  _pci_fixups_early,  __start, __end) \
47262306a36Sopenharmony_ci		BOUNDED_SECTION_PRE_LABEL(.pci_fixup_header, _pci_fixups_header, __start, __end) \
47362306a36Sopenharmony_ci		BOUNDED_SECTION_PRE_LABEL(.pci_fixup_final,  _pci_fixups_final,  __start, __end) \
47462306a36Sopenharmony_ci		BOUNDED_SECTION_PRE_LABEL(.pci_fixup_enable, _pci_fixups_enable, __start, __end) \
47562306a36Sopenharmony_ci		BOUNDED_SECTION_PRE_LABEL(.pci_fixup_resume, _pci_fixups_resume, __start, __end) \
47662306a36Sopenharmony_ci		BOUNDED_SECTION_PRE_LABEL(.pci_fixup_suspend, _pci_fixups_suspend, __start, __end) \
47762306a36Sopenharmony_ci		BOUNDED_SECTION_PRE_LABEL(.pci_fixup_resume_early, _pci_fixups_resume_early, __start, __end) \
47862306a36Sopenharmony_ci		BOUNDED_SECTION_PRE_LABEL(.pci_fixup_suspend_late, _pci_fixups_suspend_late, __start, __end) \
47962306a36Sopenharmony_ci	}								\
48062306a36Sopenharmony_ci									\
48162306a36Sopenharmony_ci	FW_LOADER_BUILT_IN_DATA						\
48262306a36Sopenharmony_ci	TRACEDATA							\
48362306a36Sopenharmony_ci									\
48462306a36Sopenharmony_ci	PRINTK_INDEX							\
48562306a36Sopenharmony_ci									\
48662306a36Sopenharmony_ci	/* Kernel symbol table: Normal symbols */			\
48762306a36Sopenharmony_ci	__ksymtab         : AT(ADDR(__ksymtab) - LOAD_OFFSET) {		\
48862306a36Sopenharmony_ci		__start___ksymtab = .;					\
48962306a36Sopenharmony_ci		KEEP(*(SORT(___ksymtab+*)))				\
49062306a36Sopenharmony_ci		__stop___ksymtab = .;					\
49162306a36Sopenharmony_ci	}								\
49262306a36Sopenharmony_ci									\
49362306a36Sopenharmony_ci	/* Kernel symbol table: GPL-only symbols */			\
49462306a36Sopenharmony_ci	__ksymtab_gpl     : AT(ADDR(__ksymtab_gpl) - LOAD_OFFSET) {	\
49562306a36Sopenharmony_ci		__start___ksymtab_gpl = .;				\
49662306a36Sopenharmony_ci		KEEP(*(SORT(___ksymtab_gpl+*)))				\
49762306a36Sopenharmony_ci		__stop___ksymtab_gpl = .;				\
49862306a36Sopenharmony_ci	}								\
49962306a36Sopenharmony_ci									\
50062306a36Sopenharmony_ci	/* Kernel symbol table: Normal symbols */			\
50162306a36Sopenharmony_ci	__kcrctab         : AT(ADDR(__kcrctab) - LOAD_OFFSET) {		\
50262306a36Sopenharmony_ci		__start___kcrctab = .;					\
50362306a36Sopenharmony_ci		KEEP(*(SORT(___kcrctab+*)))				\
50462306a36Sopenharmony_ci		__stop___kcrctab = .;					\
50562306a36Sopenharmony_ci	}								\
50662306a36Sopenharmony_ci									\
50762306a36Sopenharmony_ci	/* Kernel symbol table: GPL-only symbols */			\
50862306a36Sopenharmony_ci	__kcrctab_gpl     : AT(ADDR(__kcrctab_gpl) - LOAD_OFFSET) {	\
50962306a36Sopenharmony_ci		__start___kcrctab_gpl = .;				\
51062306a36Sopenharmony_ci		KEEP(*(SORT(___kcrctab_gpl+*)))				\
51162306a36Sopenharmony_ci		__stop___kcrctab_gpl = .;				\
51262306a36Sopenharmony_ci	}								\
51362306a36Sopenharmony_ci									\
51462306a36Sopenharmony_ci	/* Kernel symbol table: strings */				\
51562306a36Sopenharmony_ci        __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) {	\
51662306a36Sopenharmony_ci		*(__ksymtab_strings)					\
51762306a36Sopenharmony_ci	}								\
51862306a36Sopenharmony_ci									\
51962306a36Sopenharmony_ci	/* __*init sections */						\
52062306a36Sopenharmony_ci	__init_rodata : AT(ADDR(__init_rodata) - LOAD_OFFSET) {		\
52162306a36Sopenharmony_ci		*(.ref.rodata)						\
52262306a36Sopenharmony_ci		MEM_KEEP(init.rodata)					\
52362306a36Sopenharmony_ci	}								\
52462306a36Sopenharmony_ci									\
52562306a36Sopenharmony_ci	/* Built-in module parameters. */				\
52662306a36Sopenharmony_ci	__param : AT(ADDR(__param) - LOAD_OFFSET) {			\
52762306a36Sopenharmony_ci		BOUNDED_SECTION_BY(__param, ___param)			\
52862306a36Sopenharmony_ci	}								\
52962306a36Sopenharmony_ci									\
53062306a36Sopenharmony_ci	/* Built-in module versions. */					\
53162306a36Sopenharmony_ci	__modver : AT(ADDR(__modver) - LOAD_OFFSET) {			\
53262306a36Sopenharmony_ci		BOUNDED_SECTION_BY(__modver, ___modver)			\
53362306a36Sopenharmony_ci	}								\
53462306a36Sopenharmony_ci									\
53562306a36Sopenharmony_ci	KCFI_TRAPS							\
53662306a36Sopenharmony_ci									\
53762306a36Sopenharmony_ci	RO_EXCEPTION_TABLE						\
53862306a36Sopenharmony_ci	NOTES								\
53962306a36Sopenharmony_ci	BTF								\
54062306a36Sopenharmony_ci									\
54162306a36Sopenharmony_ci	. = ALIGN((align));						\
54262306a36Sopenharmony_ci	__end_rodata = .;
54362306a36Sopenharmony_ci
54462306a36Sopenharmony_ci
54562306a36Sopenharmony_ci/*
54662306a36Sopenharmony_ci * Non-instrumentable text section
54762306a36Sopenharmony_ci */
54862306a36Sopenharmony_ci#define NOINSTR_TEXT							\
54962306a36Sopenharmony_ci		ALIGN_FUNCTION();					\
55062306a36Sopenharmony_ci		__noinstr_text_start = .;				\
55162306a36Sopenharmony_ci		*(.noinstr.text)					\
55262306a36Sopenharmony_ci		__cpuidle_text_start = .;				\
55362306a36Sopenharmony_ci		*(.cpuidle.text)					\
55462306a36Sopenharmony_ci		__cpuidle_text_end = .;					\
55562306a36Sopenharmony_ci		__noinstr_text_end = .;
55662306a36Sopenharmony_ci
55762306a36Sopenharmony_ci/*
55862306a36Sopenharmony_ci * .text section. Map to function alignment to avoid address changes
55962306a36Sopenharmony_ci * during second ld run in second ld pass when generating System.map
56062306a36Sopenharmony_ci *
56162306a36Sopenharmony_ci * TEXT_MAIN here will match .text.fixup and .text.unlikely if dead
56262306a36Sopenharmony_ci * code elimination is enabled, so these sections should be converted
56362306a36Sopenharmony_ci * to use ".." first.
56462306a36Sopenharmony_ci */
56562306a36Sopenharmony_ci#define TEXT_TEXT							\
56662306a36Sopenharmony_ci		ALIGN_FUNCTION();					\
56762306a36Sopenharmony_ci		*(.text.hot .text.hot.*)				\
56862306a36Sopenharmony_ci		*(TEXT_MAIN .text.fixup)				\
56962306a36Sopenharmony_ci		*(.text.unlikely .text.unlikely.*)			\
57062306a36Sopenharmony_ci		*(.text.unknown .text.unknown.*)			\
57162306a36Sopenharmony_ci		NOINSTR_TEXT						\
57262306a36Sopenharmony_ci		*(.ref.text)						\
57362306a36Sopenharmony_ci		*(.text.asan.* .text.tsan.*)				\
57462306a36Sopenharmony_ci	MEM_KEEP(init.text*)						\
57562306a36Sopenharmony_ci
57662306a36Sopenharmony_ci
57762306a36Sopenharmony_ci/* sched.text is aling to function alignment to secure we have same
57862306a36Sopenharmony_ci * address even at second ld pass when generating System.map */
57962306a36Sopenharmony_ci#define SCHED_TEXT							\
58062306a36Sopenharmony_ci		ALIGN_FUNCTION();					\
58162306a36Sopenharmony_ci		__sched_text_start = .;					\
58262306a36Sopenharmony_ci		*(.sched.text)						\
58362306a36Sopenharmony_ci		__sched_text_end = .;
58462306a36Sopenharmony_ci
58562306a36Sopenharmony_ci/* spinlock.text is aling to function alignment to secure we have same
58662306a36Sopenharmony_ci * address even at second ld pass when generating System.map */
58762306a36Sopenharmony_ci#define LOCK_TEXT							\
58862306a36Sopenharmony_ci		ALIGN_FUNCTION();					\
58962306a36Sopenharmony_ci		__lock_text_start = .;					\
59062306a36Sopenharmony_ci		*(.spinlock.text)					\
59162306a36Sopenharmony_ci		__lock_text_end = .;
59262306a36Sopenharmony_ci
59362306a36Sopenharmony_ci#define KPROBES_TEXT							\
59462306a36Sopenharmony_ci		ALIGN_FUNCTION();					\
59562306a36Sopenharmony_ci		__kprobes_text_start = .;				\
59662306a36Sopenharmony_ci		*(.kprobes.text)					\
59762306a36Sopenharmony_ci		__kprobes_text_end = .;
59862306a36Sopenharmony_ci
59962306a36Sopenharmony_ci#define ENTRY_TEXT							\
60062306a36Sopenharmony_ci		ALIGN_FUNCTION();					\
60162306a36Sopenharmony_ci		__entry_text_start = .;					\
60262306a36Sopenharmony_ci		*(.entry.text)						\
60362306a36Sopenharmony_ci		__entry_text_end = .;
60462306a36Sopenharmony_ci
60562306a36Sopenharmony_ci#define IRQENTRY_TEXT							\
60662306a36Sopenharmony_ci		ALIGN_FUNCTION();					\
60762306a36Sopenharmony_ci		__irqentry_text_start = .;				\
60862306a36Sopenharmony_ci		*(.irqentry.text)					\
60962306a36Sopenharmony_ci		__irqentry_text_end = .;
61062306a36Sopenharmony_ci
61162306a36Sopenharmony_ci#define SOFTIRQENTRY_TEXT						\
61262306a36Sopenharmony_ci		ALIGN_FUNCTION();					\
61362306a36Sopenharmony_ci		__softirqentry_text_start = .;				\
61462306a36Sopenharmony_ci		*(.softirqentry.text)					\
61562306a36Sopenharmony_ci		__softirqentry_text_end = .;
61662306a36Sopenharmony_ci
61762306a36Sopenharmony_ci#define STATIC_CALL_TEXT						\
61862306a36Sopenharmony_ci		ALIGN_FUNCTION();					\
61962306a36Sopenharmony_ci		__static_call_text_start = .;				\
62062306a36Sopenharmony_ci		*(.static_call.text)					\
62162306a36Sopenharmony_ci		__static_call_text_end = .;
62262306a36Sopenharmony_ci
62362306a36Sopenharmony_ci/* Section used for early init (in .S files) */
62462306a36Sopenharmony_ci#define HEAD_TEXT  KEEP(*(.head.text))
62562306a36Sopenharmony_ci
62662306a36Sopenharmony_ci#define HEAD_TEXT_SECTION							\
62762306a36Sopenharmony_ci	.head.text : AT(ADDR(.head.text) - LOAD_OFFSET) {		\
62862306a36Sopenharmony_ci		HEAD_TEXT						\
62962306a36Sopenharmony_ci	}
63062306a36Sopenharmony_ci
63162306a36Sopenharmony_ci/*
63262306a36Sopenharmony_ci * Exception table
63362306a36Sopenharmony_ci */
63462306a36Sopenharmony_ci#define EXCEPTION_TABLE(align)						\
63562306a36Sopenharmony_ci	. = ALIGN(align);						\
63662306a36Sopenharmony_ci	__ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {		\
63762306a36Sopenharmony_ci		BOUNDED_SECTION_BY(__ex_table, ___ex_table)		\
63862306a36Sopenharmony_ci	}
63962306a36Sopenharmony_ci
64062306a36Sopenharmony_ci/*
64162306a36Sopenharmony_ci * .BTF
64262306a36Sopenharmony_ci */
64362306a36Sopenharmony_ci#ifdef CONFIG_DEBUG_INFO_BTF
64462306a36Sopenharmony_ci#define BTF								\
64562306a36Sopenharmony_ci	.BTF : AT(ADDR(.BTF) - LOAD_OFFSET) {				\
64662306a36Sopenharmony_ci		BOUNDED_SECTION_BY(.BTF, _BTF)				\
64762306a36Sopenharmony_ci	}								\
64862306a36Sopenharmony_ci	. = ALIGN(4);							\
64962306a36Sopenharmony_ci	.BTF_ids : AT(ADDR(.BTF_ids) - LOAD_OFFSET) {			\
65062306a36Sopenharmony_ci		*(.BTF_ids)						\
65162306a36Sopenharmony_ci	}
65262306a36Sopenharmony_ci#else
65362306a36Sopenharmony_ci#define BTF
65462306a36Sopenharmony_ci#endif
65562306a36Sopenharmony_ci
65662306a36Sopenharmony_ci/*
65762306a36Sopenharmony_ci * Init task
65862306a36Sopenharmony_ci */
65962306a36Sopenharmony_ci#define INIT_TASK_DATA_SECTION(align)					\
66062306a36Sopenharmony_ci	. = ALIGN(align);						\
66162306a36Sopenharmony_ci	.data..init_task :  AT(ADDR(.data..init_task) - LOAD_OFFSET) {	\
66262306a36Sopenharmony_ci		INIT_TASK_DATA(align)					\
66362306a36Sopenharmony_ci	}
66462306a36Sopenharmony_ci
66562306a36Sopenharmony_ci#ifdef CONFIG_CONSTRUCTORS
66662306a36Sopenharmony_ci#define KERNEL_CTORS()	. = ALIGN(8);			   \
66762306a36Sopenharmony_ci			__ctors_start = .;		   \
66862306a36Sopenharmony_ci			KEEP(*(SORT(.ctors.*)))		   \
66962306a36Sopenharmony_ci			KEEP(*(.ctors))			   \
67062306a36Sopenharmony_ci			KEEP(*(SORT(.init_array.*)))	   \
67162306a36Sopenharmony_ci			KEEP(*(.init_array))		   \
67262306a36Sopenharmony_ci			__ctors_end = .;
67362306a36Sopenharmony_ci#else
67462306a36Sopenharmony_ci#define KERNEL_CTORS()
67562306a36Sopenharmony_ci#endif
67662306a36Sopenharmony_ci
67762306a36Sopenharmony_ci/* init and exit section handling */
67862306a36Sopenharmony_ci#define INIT_DATA							\
67962306a36Sopenharmony_ci	KEEP(*(SORT(___kentry+*)))					\
68062306a36Sopenharmony_ci	*(.init.data .init.data.*)					\
68162306a36Sopenharmony_ci	MEM_DISCARD(init.data*)						\
68262306a36Sopenharmony_ci	KERNEL_CTORS()							\
68362306a36Sopenharmony_ci	MCOUNT_REC()							\
68462306a36Sopenharmony_ci	*(.init.rodata .init.rodata.*)					\
68562306a36Sopenharmony_ci	FTRACE_EVENTS()							\
68662306a36Sopenharmony_ci	TRACE_SYSCALLS()						\
68762306a36Sopenharmony_ci	KPROBE_BLACKLIST()						\
68862306a36Sopenharmony_ci	ERROR_INJECT_WHITELIST()					\
68962306a36Sopenharmony_ci	MEM_DISCARD(init.rodata)					\
69062306a36Sopenharmony_ci	CLK_OF_TABLES()							\
69162306a36Sopenharmony_ci	RESERVEDMEM_OF_TABLES()						\
69262306a36Sopenharmony_ci	TIMER_OF_TABLES()						\
69362306a36Sopenharmony_ci	CPU_METHOD_OF_TABLES()						\
69462306a36Sopenharmony_ci	CPUIDLE_METHOD_OF_TABLES()					\
69562306a36Sopenharmony_ci	KERNEL_DTB()							\
69662306a36Sopenharmony_ci	IRQCHIP_OF_MATCH_TABLE()					\
69762306a36Sopenharmony_ci	ACPI_PROBE_TABLE(irqchip)					\
69862306a36Sopenharmony_ci	ACPI_PROBE_TABLE(timer)						\
69962306a36Sopenharmony_ci	THERMAL_TABLE(governor)						\
70062306a36Sopenharmony_ci	EARLYCON_TABLE()						\
70162306a36Sopenharmony_ci	LSM_TABLE()							\
70262306a36Sopenharmony_ci	EARLY_LSM_TABLE()						\
70362306a36Sopenharmony_ci	KUNIT_TABLE()
70462306a36Sopenharmony_ci
70562306a36Sopenharmony_ci#define INIT_TEXT							\
70662306a36Sopenharmony_ci	*(.init.text .init.text.*)					\
70762306a36Sopenharmony_ci	*(.text.startup)						\
70862306a36Sopenharmony_ci	MEM_DISCARD(init.text*)
70962306a36Sopenharmony_ci
71062306a36Sopenharmony_ci#define EXIT_DATA							\
71162306a36Sopenharmony_ci	*(.exit.data .exit.data.*)					\
71262306a36Sopenharmony_ci	*(.fini_array .fini_array.*)					\
71362306a36Sopenharmony_ci	*(.dtors .dtors.*)						\
71462306a36Sopenharmony_ci
71562306a36Sopenharmony_ci#define EXIT_TEXT							\
71662306a36Sopenharmony_ci	*(.exit.text)							\
71762306a36Sopenharmony_ci	*(.text.exit)							\
71862306a36Sopenharmony_ci
71962306a36Sopenharmony_ci#define EXIT_CALL							\
72062306a36Sopenharmony_ci	*(.exitcall.exit)
72162306a36Sopenharmony_ci
72262306a36Sopenharmony_ci/*
72362306a36Sopenharmony_ci * bss (Block Started by Symbol) - uninitialized data
72462306a36Sopenharmony_ci * zeroed during startup
72562306a36Sopenharmony_ci */
72662306a36Sopenharmony_ci#define SBSS(sbss_align)						\
72762306a36Sopenharmony_ci	. = ALIGN(sbss_align);						\
72862306a36Sopenharmony_ci	.sbss : AT(ADDR(.sbss) - LOAD_OFFSET) {				\
72962306a36Sopenharmony_ci		*(.dynsbss)						\
73062306a36Sopenharmony_ci		*(SBSS_MAIN)						\
73162306a36Sopenharmony_ci		*(.scommon)						\
73262306a36Sopenharmony_ci	}
73362306a36Sopenharmony_ci
73462306a36Sopenharmony_ci/*
73562306a36Sopenharmony_ci * Allow archectures to redefine BSS_FIRST_SECTIONS to add extra
73662306a36Sopenharmony_ci * sections to the front of bss.
73762306a36Sopenharmony_ci */
73862306a36Sopenharmony_ci#ifndef BSS_FIRST_SECTIONS
73962306a36Sopenharmony_ci#define BSS_FIRST_SECTIONS
74062306a36Sopenharmony_ci#endif
74162306a36Sopenharmony_ci
74262306a36Sopenharmony_ci#define BSS(bss_align)							\
74362306a36Sopenharmony_ci	. = ALIGN(bss_align);						\
74462306a36Sopenharmony_ci	.bss : AT(ADDR(.bss) - LOAD_OFFSET) {				\
74562306a36Sopenharmony_ci		BSS_FIRST_SECTIONS					\
74662306a36Sopenharmony_ci		. = ALIGN(PAGE_SIZE);					\
74762306a36Sopenharmony_ci		*(.bss..page_aligned)					\
74862306a36Sopenharmony_ci		. = ALIGN(PAGE_SIZE);					\
74962306a36Sopenharmony_ci		*(.dynbss)						\
75062306a36Sopenharmony_ci		*(BSS_MAIN)						\
75162306a36Sopenharmony_ci		*(COMMON)						\
75262306a36Sopenharmony_ci	}
75362306a36Sopenharmony_ci
75462306a36Sopenharmony_ci/*
75562306a36Sopenharmony_ci * DWARF debug sections.
75662306a36Sopenharmony_ci * Symbols in the DWARF debugging sections are relative to
75762306a36Sopenharmony_ci * the beginning of the section so we begin them at 0.
75862306a36Sopenharmony_ci */
75962306a36Sopenharmony_ci#define DWARF_DEBUG							\
76062306a36Sopenharmony_ci		/* DWARF 1 */						\
76162306a36Sopenharmony_ci		.debug          0 : { *(.debug) }			\
76262306a36Sopenharmony_ci		.line           0 : { *(.line) }			\
76362306a36Sopenharmony_ci		/* GNU DWARF 1 extensions */				\
76462306a36Sopenharmony_ci		.debug_srcinfo  0 : { *(.debug_srcinfo) }		\
76562306a36Sopenharmony_ci		.debug_sfnames  0 : { *(.debug_sfnames) }		\
76662306a36Sopenharmony_ci		/* DWARF 1.1 and DWARF 2 */				\
76762306a36Sopenharmony_ci		.debug_aranges  0 : { *(.debug_aranges) }		\
76862306a36Sopenharmony_ci		.debug_pubnames 0 : { *(.debug_pubnames) }		\
76962306a36Sopenharmony_ci		/* DWARF 2 */						\
77062306a36Sopenharmony_ci		.debug_info     0 : { *(.debug_info			\
77162306a36Sopenharmony_ci				.gnu.linkonce.wi.*) }			\
77262306a36Sopenharmony_ci		.debug_abbrev   0 : { *(.debug_abbrev) }		\
77362306a36Sopenharmony_ci		.debug_line     0 : { *(.debug_line) }			\
77462306a36Sopenharmony_ci		.debug_frame    0 : { *(.debug_frame) }			\
77562306a36Sopenharmony_ci		.debug_str      0 : { *(.debug_str) }			\
77662306a36Sopenharmony_ci		.debug_loc      0 : { *(.debug_loc) }			\
77762306a36Sopenharmony_ci		.debug_macinfo  0 : { *(.debug_macinfo) }		\
77862306a36Sopenharmony_ci		.debug_pubtypes 0 : { *(.debug_pubtypes) }		\
77962306a36Sopenharmony_ci		/* DWARF 3 */						\
78062306a36Sopenharmony_ci		.debug_ranges	0 : { *(.debug_ranges) }		\
78162306a36Sopenharmony_ci		/* SGI/MIPS DWARF 2 extensions */			\
78262306a36Sopenharmony_ci		.debug_weaknames 0 : { *(.debug_weaknames) }		\
78362306a36Sopenharmony_ci		.debug_funcnames 0 : { *(.debug_funcnames) }		\
78462306a36Sopenharmony_ci		.debug_typenames 0 : { *(.debug_typenames) }		\
78562306a36Sopenharmony_ci		.debug_varnames  0 : { *(.debug_varnames) }		\
78662306a36Sopenharmony_ci		/* GNU DWARF 2 extensions */				\
78762306a36Sopenharmony_ci		.debug_gnu_pubnames 0 : { *(.debug_gnu_pubnames) }	\
78862306a36Sopenharmony_ci		.debug_gnu_pubtypes 0 : { *(.debug_gnu_pubtypes) }	\
78962306a36Sopenharmony_ci		/* DWARF 4 */						\
79062306a36Sopenharmony_ci		.debug_types	0 : { *(.debug_types) }			\
79162306a36Sopenharmony_ci		/* DWARF 5 */						\
79262306a36Sopenharmony_ci		.debug_addr	0 : { *(.debug_addr) }			\
79362306a36Sopenharmony_ci		.debug_line_str	0 : { *(.debug_line_str) }		\
79462306a36Sopenharmony_ci		.debug_loclists	0 : { *(.debug_loclists) }		\
79562306a36Sopenharmony_ci		.debug_macro	0 : { *(.debug_macro) }			\
79662306a36Sopenharmony_ci		.debug_names	0 : { *(.debug_names) }			\
79762306a36Sopenharmony_ci		.debug_rnglists	0 : { *(.debug_rnglists) }		\
79862306a36Sopenharmony_ci		.debug_str_offsets	0 : { *(.debug_str_offsets) }
79962306a36Sopenharmony_ci
80062306a36Sopenharmony_ci/* Stabs debugging sections. */
80162306a36Sopenharmony_ci#define STABS_DEBUG							\
80262306a36Sopenharmony_ci		.stab 0 : { *(.stab) }					\
80362306a36Sopenharmony_ci		.stabstr 0 : { *(.stabstr) }				\
80462306a36Sopenharmony_ci		.stab.excl 0 : { *(.stab.excl) }			\
80562306a36Sopenharmony_ci		.stab.exclstr 0 : { *(.stab.exclstr) }			\
80662306a36Sopenharmony_ci		.stab.index 0 : { *(.stab.index) }			\
80762306a36Sopenharmony_ci		.stab.indexstr 0 : { *(.stab.indexstr) }
80862306a36Sopenharmony_ci
80962306a36Sopenharmony_ci/* Required sections not related to debugging. */
81062306a36Sopenharmony_ci#define ELF_DETAILS							\
81162306a36Sopenharmony_ci		.comment 0 : { *(.comment) }				\
81262306a36Sopenharmony_ci		.symtab 0 : { *(.symtab) }				\
81362306a36Sopenharmony_ci		.strtab 0 : { *(.strtab) }				\
81462306a36Sopenharmony_ci		.shstrtab 0 : { *(.shstrtab) }
81562306a36Sopenharmony_ci
81662306a36Sopenharmony_ci#ifdef CONFIG_GENERIC_BUG
81762306a36Sopenharmony_ci#define BUG_TABLE							\
81862306a36Sopenharmony_ci	. = ALIGN(8);							\
81962306a36Sopenharmony_ci	__bug_table : AT(ADDR(__bug_table) - LOAD_OFFSET) {		\
82062306a36Sopenharmony_ci		BOUNDED_SECTION_BY(__bug_table, ___bug_table)		\
82162306a36Sopenharmony_ci	}
82262306a36Sopenharmony_ci#else
82362306a36Sopenharmony_ci#define BUG_TABLE
82462306a36Sopenharmony_ci#endif
82562306a36Sopenharmony_ci
82662306a36Sopenharmony_ci#ifdef CONFIG_UNWINDER_ORC
82762306a36Sopenharmony_ci#define ORC_UNWIND_TABLE						\
82862306a36Sopenharmony_ci	.orc_header : AT(ADDR(.orc_header) - LOAD_OFFSET) {		\
82962306a36Sopenharmony_ci		BOUNDED_SECTION_BY(.orc_header, _orc_header)		\
83062306a36Sopenharmony_ci	}								\
83162306a36Sopenharmony_ci	. = ALIGN(4);							\
83262306a36Sopenharmony_ci	.orc_unwind_ip : AT(ADDR(.orc_unwind_ip) - LOAD_OFFSET) {	\
83362306a36Sopenharmony_ci		BOUNDED_SECTION_BY(.orc_unwind_ip, _orc_unwind_ip)	\
83462306a36Sopenharmony_ci	}								\
83562306a36Sopenharmony_ci	. = ALIGN(2);							\
83662306a36Sopenharmony_ci	.orc_unwind : AT(ADDR(.orc_unwind) - LOAD_OFFSET) {		\
83762306a36Sopenharmony_ci		BOUNDED_SECTION_BY(.orc_unwind, _orc_unwind)		\
83862306a36Sopenharmony_ci	}								\
83962306a36Sopenharmony_ci	text_size = _etext - _stext;					\
84062306a36Sopenharmony_ci	. = ALIGN(4);							\
84162306a36Sopenharmony_ci	.orc_lookup : AT(ADDR(.orc_lookup) - LOAD_OFFSET) {		\
84262306a36Sopenharmony_ci		orc_lookup = .;						\
84362306a36Sopenharmony_ci		. += (((text_size + LOOKUP_BLOCK_SIZE - 1) /		\
84462306a36Sopenharmony_ci			LOOKUP_BLOCK_SIZE) + 1) * 4;			\
84562306a36Sopenharmony_ci		orc_lookup_end = .;					\
84662306a36Sopenharmony_ci	}
84762306a36Sopenharmony_ci#else
84862306a36Sopenharmony_ci#define ORC_UNWIND_TABLE
84962306a36Sopenharmony_ci#endif
85062306a36Sopenharmony_ci
85162306a36Sopenharmony_ci/* Built-in firmware blobs */
85262306a36Sopenharmony_ci#ifdef CONFIG_FW_LOADER
85362306a36Sopenharmony_ci#define FW_LOADER_BUILT_IN_DATA						\
85462306a36Sopenharmony_ci	.builtin_fw : AT(ADDR(.builtin_fw) - LOAD_OFFSET) ALIGN(8) {	\
85562306a36Sopenharmony_ci		BOUNDED_SECTION_PRE_LABEL(.builtin_fw, _builtin_fw, __start, __end) \
85662306a36Sopenharmony_ci	}
85762306a36Sopenharmony_ci#else
85862306a36Sopenharmony_ci#define FW_LOADER_BUILT_IN_DATA
85962306a36Sopenharmony_ci#endif
86062306a36Sopenharmony_ci
86162306a36Sopenharmony_ci#ifdef CONFIG_PM_TRACE
86262306a36Sopenharmony_ci#define TRACEDATA							\
86362306a36Sopenharmony_ci	. = ALIGN(4);							\
86462306a36Sopenharmony_ci	.tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) {		\
86562306a36Sopenharmony_ci		BOUNDED_SECTION_POST_LABEL(.tracedata, __tracedata, _start, _end) \
86662306a36Sopenharmony_ci	}
86762306a36Sopenharmony_ci#else
86862306a36Sopenharmony_ci#define TRACEDATA
86962306a36Sopenharmony_ci#endif
87062306a36Sopenharmony_ci
87162306a36Sopenharmony_ci#ifdef CONFIG_PRINTK_INDEX
87262306a36Sopenharmony_ci#define PRINTK_INDEX							\
87362306a36Sopenharmony_ci	.printk_index : AT(ADDR(.printk_index) - LOAD_OFFSET) {		\
87462306a36Sopenharmony_ci		BOUNDED_SECTION_BY(.printk_index, _printk_index)	\
87562306a36Sopenharmony_ci	}
87662306a36Sopenharmony_ci#else
87762306a36Sopenharmony_ci#define PRINTK_INDEX
87862306a36Sopenharmony_ci#endif
87962306a36Sopenharmony_ci
88062306a36Sopenharmony_ci/*
88162306a36Sopenharmony_ci * Discard .note.GNU-stack, which is emitted as PROGBITS by the compiler.
88262306a36Sopenharmony_ci * Otherwise, the type of .notes section would become PROGBITS instead of NOTES.
88362306a36Sopenharmony_ci *
88462306a36Sopenharmony_ci * Also, discard .note.gnu.property, otherwise it forces the notes section to
88562306a36Sopenharmony_ci * be 8-byte aligned which causes alignment mismatches with the kernel's custom
88662306a36Sopenharmony_ci * 4-byte aligned notes.
88762306a36Sopenharmony_ci */
88862306a36Sopenharmony_ci#define NOTES								\
88962306a36Sopenharmony_ci	/DISCARD/ : {							\
89062306a36Sopenharmony_ci		*(.note.GNU-stack)					\
89162306a36Sopenharmony_ci		*(.note.gnu.property)					\
89262306a36Sopenharmony_ci	}								\
89362306a36Sopenharmony_ci	.notes : AT(ADDR(.notes) - LOAD_OFFSET) {			\
89462306a36Sopenharmony_ci		BOUNDED_SECTION_BY(.note.*, _notes)			\
89562306a36Sopenharmony_ci	} NOTES_HEADERS							\
89662306a36Sopenharmony_ci	NOTES_HEADERS_RESTORE
89762306a36Sopenharmony_ci
89862306a36Sopenharmony_ci#define INIT_SETUP(initsetup_align)					\
89962306a36Sopenharmony_ci		. = ALIGN(initsetup_align);				\
90062306a36Sopenharmony_ci		BOUNDED_SECTION_POST_LABEL(.init.setup, __setup, _start, _end)
90162306a36Sopenharmony_ci
90262306a36Sopenharmony_ci#define INIT_CALLS_LEVEL(level)						\
90362306a36Sopenharmony_ci		__initcall##level##_start = .;				\
90462306a36Sopenharmony_ci		KEEP(*(.initcall##level##.init))			\
90562306a36Sopenharmony_ci		KEEP(*(.initcall##level##s.init))			\
90662306a36Sopenharmony_ci
90762306a36Sopenharmony_ci#define INIT_CALLS							\
90862306a36Sopenharmony_ci		__initcall_start = .;					\
90962306a36Sopenharmony_ci		KEEP(*(.initcallearly.init))				\
91062306a36Sopenharmony_ci		INIT_CALLS_LEVEL(0)					\
91162306a36Sopenharmony_ci		INIT_CALLS_LEVEL(1)					\
91262306a36Sopenharmony_ci		INIT_CALLS_LEVEL(2)					\
91362306a36Sopenharmony_ci		INIT_CALLS_LEVEL(3)					\
91462306a36Sopenharmony_ci		INIT_CALLS_LEVEL(4)					\
91562306a36Sopenharmony_ci		INIT_CALLS_LEVEL(5)					\
91662306a36Sopenharmony_ci		INIT_CALLS_LEVEL(rootfs)				\
91762306a36Sopenharmony_ci		INIT_CALLS_LEVEL(6)					\
91862306a36Sopenharmony_ci		INIT_CALLS_LEVEL(7)					\
91962306a36Sopenharmony_ci		__initcall_end = .;
92062306a36Sopenharmony_ci
92162306a36Sopenharmony_ci#define CON_INITCALL							\
92262306a36Sopenharmony_ci	BOUNDED_SECTION_POST_LABEL(.con_initcall.init, __con_initcall, _start, _end)
92362306a36Sopenharmony_ci
92462306a36Sopenharmony_ci/* Alignment must be consistent with (kunit_suite *) in include/kunit/test.h */
92562306a36Sopenharmony_ci#define KUNIT_TABLE()							\
92662306a36Sopenharmony_ci		. = ALIGN(8);						\
92762306a36Sopenharmony_ci		BOUNDED_SECTION_POST_LABEL(.kunit_test_suites, __kunit_suites, _start, _end)
92862306a36Sopenharmony_ci
92962306a36Sopenharmony_ci#ifdef CONFIG_BLK_DEV_INITRD
93062306a36Sopenharmony_ci#define INIT_RAM_FS							\
93162306a36Sopenharmony_ci	. = ALIGN(4);							\
93262306a36Sopenharmony_ci	__initramfs_start = .;						\
93362306a36Sopenharmony_ci	KEEP(*(.init.ramfs))						\
93462306a36Sopenharmony_ci	. = ALIGN(8);							\
93562306a36Sopenharmony_ci	KEEP(*(.init.ramfs.info))
93662306a36Sopenharmony_ci#else
93762306a36Sopenharmony_ci#define INIT_RAM_FS
93862306a36Sopenharmony_ci#endif
93962306a36Sopenharmony_ci
94062306a36Sopenharmony_ci/*
94162306a36Sopenharmony_ci * Memory encryption operates on a page basis. Since we need to clear
94262306a36Sopenharmony_ci * the memory encryption mask for this section, it needs to be aligned
94362306a36Sopenharmony_ci * on a page boundary and be a page-size multiple in length.
94462306a36Sopenharmony_ci *
94562306a36Sopenharmony_ci * Note: We use a separate section so that only this section gets
94662306a36Sopenharmony_ci * decrypted to avoid exposing more than we wish.
94762306a36Sopenharmony_ci */
94862306a36Sopenharmony_ci#ifdef CONFIG_AMD_MEM_ENCRYPT
94962306a36Sopenharmony_ci#define PERCPU_DECRYPTED_SECTION					\
95062306a36Sopenharmony_ci	. = ALIGN(PAGE_SIZE);						\
95162306a36Sopenharmony_ci	*(.data..percpu..decrypted)					\
95262306a36Sopenharmony_ci	. = ALIGN(PAGE_SIZE);
95362306a36Sopenharmony_ci#else
95462306a36Sopenharmony_ci#define PERCPU_DECRYPTED_SECTION
95562306a36Sopenharmony_ci#endif
95662306a36Sopenharmony_ci
95762306a36Sopenharmony_ci
95862306a36Sopenharmony_ci/*
95962306a36Sopenharmony_ci * Default discarded sections.
96062306a36Sopenharmony_ci *
96162306a36Sopenharmony_ci * Some archs want to discard exit text/data at runtime rather than
96262306a36Sopenharmony_ci * link time due to cross-section references such as alt instructions,
96362306a36Sopenharmony_ci * bug table, eh_frame, etc.  DISCARDS must be the last of output
96462306a36Sopenharmony_ci * section definitions so that such archs put those in earlier section
96562306a36Sopenharmony_ci * definitions.
96662306a36Sopenharmony_ci */
96762306a36Sopenharmony_ci#ifdef RUNTIME_DISCARD_EXIT
96862306a36Sopenharmony_ci#define EXIT_DISCARDS
96962306a36Sopenharmony_ci#else
97062306a36Sopenharmony_ci#define EXIT_DISCARDS							\
97162306a36Sopenharmony_ci	EXIT_TEXT							\
97262306a36Sopenharmony_ci	EXIT_DATA
97362306a36Sopenharmony_ci#endif
97462306a36Sopenharmony_ci
97562306a36Sopenharmony_ci/*
97662306a36Sopenharmony_ci * Clang's -fprofile-arcs, -fsanitize=kernel-address, and
97762306a36Sopenharmony_ci * -fsanitize=thread produce unwanted sections (.eh_frame
97862306a36Sopenharmony_ci * and .init_array.*), but CONFIG_CONSTRUCTORS wants to
97962306a36Sopenharmony_ci * keep any .init_array.* sections.
98062306a36Sopenharmony_ci * https://bugs.llvm.org/show_bug.cgi?id=46478
98162306a36Sopenharmony_ci */
98262306a36Sopenharmony_ci#ifdef CONFIG_UNWIND_TABLES
98362306a36Sopenharmony_ci#define DISCARD_EH_FRAME
98462306a36Sopenharmony_ci#else
98562306a36Sopenharmony_ci#define DISCARD_EH_FRAME	*(.eh_frame)
98662306a36Sopenharmony_ci#endif
98762306a36Sopenharmony_ci#if defined(CONFIG_GCOV_KERNEL) || defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KCSAN)
98862306a36Sopenharmony_ci# ifdef CONFIG_CONSTRUCTORS
98962306a36Sopenharmony_ci#  define SANITIZER_DISCARDS						\
99062306a36Sopenharmony_ci	DISCARD_EH_FRAME
99162306a36Sopenharmony_ci# else
99262306a36Sopenharmony_ci#  define SANITIZER_DISCARDS						\
99362306a36Sopenharmony_ci	*(.init_array) *(.init_array.*)					\
99462306a36Sopenharmony_ci	DISCARD_EH_FRAME
99562306a36Sopenharmony_ci# endif
99662306a36Sopenharmony_ci#else
99762306a36Sopenharmony_ci# define SANITIZER_DISCARDS
99862306a36Sopenharmony_ci#endif
99962306a36Sopenharmony_ci
100062306a36Sopenharmony_ci#define COMMON_DISCARDS							\
100162306a36Sopenharmony_ci	SANITIZER_DISCARDS						\
100262306a36Sopenharmony_ci	PATCHABLE_DISCARDS						\
100362306a36Sopenharmony_ci	*(.discard)							\
100462306a36Sopenharmony_ci	*(.discard.*)							\
100562306a36Sopenharmony_ci	*(.export_symbol)						\
100662306a36Sopenharmony_ci	*(.modinfo)							\
100762306a36Sopenharmony_ci	/* ld.bfd warns about .gnu.version* even when not emitted */	\
100862306a36Sopenharmony_ci	*(.gnu.version*)						\
100962306a36Sopenharmony_ci
101062306a36Sopenharmony_ci#define DISCARDS							\
101162306a36Sopenharmony_ci	/DISCARD/ : {							\
101262306a36Sopenharmony_ci	EXIT_DISCARDS							\
101362306a36Sopenharmony_ci	EXIT_CALL							\
101462306a36Sopenharmony_ci	COMMON_DISCARDS							\
101562306a36Sopenharmony_ci	}
101662306a36Sopenharmony_ci
101762306a36Sopenharmony_ci/**
101862306a36Sopenharmony_ci * PERCPU_INPUT - the percpu input sections
101962306a36Sopenharmony_ci * @cacheline: cacheline size
102062306a36Sopenharmony_ci *
102162306a36Sopenharmony_ci * The core percpu section names and core symbols which do not rely
102262306a36Sopenharmony_ci * directly upon load addresses.
102362306a36Sopenharmony_ci *
102462306a36Sopenharmony_ci * @cacheline is used to align subsections to avoid false cacheline
102562306a36Sopenharmony_ci * sharing between subsections for different purposes.
102662306a36Sopenharmony_ci */
102762306a36Sopenharmony_ci#define PERCPU_INPUT(cacheline)						\
102862306a36Sopenharmony_ci	__per_cpu_start = .;						\
102962306a36Sopenharmony_ci	*(.data..percpu..first)						\
103062306a36Sopenharmony_ci	. = ALIGN(PAGE_SIZE);						\
103162306a36Sopenharmony_ci	*(.data..percpu..page_aligned)					\
103262306a36Sopenharmony_ci	. = ALIGN(cacheline);						\
103362306a36Sopenharmony_ci	*(.data..percpu..read_mostly)					\
103462306a36Sopenharmony_ci	. = ALIGN(cacheline);						\
103562306a36Sopenharmony_ci	*(.data..percpu)						\
103662306a36Sopenharmony_ci	*(.data..percpu..shared_aligned)				\
103762306a36Sopenharmony_ci	PERCPU_DECRYPTED_SECTION					\
103862306a36Sopenharmony_ci	__per_cpu_end = .;
103962306a36Sopenharmony_ci
104062306a36Sopenharmony_ci/**
104162306a36Sopenharmony_ci * PERCPU_VADDR - define output section for percpu area
104262306a36Sopenharmony_ci * @cacheline: cacheline size
104362306a36Sopenharmony_ci * @vaddr: explicit base address (optional)
104462306a36Sopenharmony_ci * @phdr: destination PHDR (optional)
104562306a36Sopenharmony_ci *
104662306a36Sopenharmony_ci * Macro which expands to output section for percpu area.
104762306a36Sopenharmony_ci *
104862306a36Sopenharmony_ci * @cacheline is used to align subsections to avoid false cacheline
104962306a36Sopenharmony_ci * sharing between subsections for different purposes.
105062306a36Sopenharmony_ci *
105162306a36Sopenharmony_ci * If @vaddr is not blank, it specifies explicit base address and all
105262306a36Sopenharmony_ci * percpu symbols will be offset from the given address.  If blank,
105362306a36Sopenharmony_ci * @vaddr always equals @laddr + LOAD_OFFSET.
105462306a36Sopenharmony_ci *
105562306a36Sopenharmony_ci * @phdr defines the output PHDR to use if not blank.  Be warned that
105662306a36Sopenharmony_ci * output PHDR is sticky.  If @phdr is specified, the next output
105762306a36Sopenharmony_ci * section in the linker script will go there too.  @phdr should have
105862306a36Sopenharmony_ci * a leading colon.
105962306a36Sopenharmony_ci *
106062306a36Sopenharmony_ci * Note that this macros defines __per_cpu_load as an absolute symbol.
106162306a36Sopenharmony_ci * If there is no need to put the percpu section at a predetermined
106262306a36Sopenharmony_ci * address, use PERCPU_SECTION.
106362306a36Sopenharmony_ci */
106462306a36Sopenharmony_ci#define PERCPU_VADDR(cacheline, vaddr, phdr)				\
106562306a36Sopenharmony_ci	__per_cpu_load = .;						\
106662306a36Sopenharmony_ci	.data..percpu vaddr : AT(__per_cpu_load - LOAD_OFFSET) {	\
106762306a36Sopenharmony_ci		PERCPU_INPUT(cacheline)					\
106862306a36Sopenharmony_ci	} phdr								\
106962306a36Sopenharmony_ci	. = __per_cpu_load + SIZEOF(.data..percpu);
107062306a36Sopenharmony_ci
107162306a36Sopenharmony_ci/**
107262306a36Sopenharmony_ci * PERCPU_SECTION - define output section for percpu area, simple version
107362306a36Sopenharmony_ci * @cacheline: cacheline size
107462306a36Sopenharmony_ci *
107562306a36Sopenharmony_ci * Align to PAGE_SIZE and outputs output section for percpu area.  This
107662306a36Sopenharmony_ci * macro doesn't manipulate @vaddr or @phdr and __per_cpu_load and
107762306a36Sopenharmony_ci * __per_cpu_start will be identical.
107862306a36Sopenharmony_ci *
107962306a36Sopenharmony_ci * This macro is equivalent to ALIGN(PAGE_SIZE); PERCPU_VADDR(@cacheline,,)
108062306a36Sopenharmony_ci * except that __per_cpu_load is defined as a relative symbol against
108162306a36Sopenharmony_ci * .data..percpu which is required for relocatable x86_32 configuration.
108262306a36Sopenharmony_ci */
108362306a36Sopenharmony_ci#define PERCPU_SECTION(cacheline)					\
108462306a36Sopenharmony_ci	. = ALIGN(PAGE_SIZE);						\
108562306a36Sopenharmony_ci	.data..percpu	: AT(ADDR(.data..percpu) - LOAD_OFFSET) {	\
108662306a36Sopenharmony_ci		__per_cpu_load = .;					\
108762306a36Sopenharmony_ci		PERCPU_INPUT(cacheline)					\
108862306a36Sopenharmony_ci	}
108962306a36Sopenharmony_ci
109062306a36Sopenharmony_ci
109162306a36Sopenharmony_ci/*
109262306a36Sopenharmony_ci * Definition of the high level *_SECTION macros
109362306a36Sopenharmony_ci * They will fit only a subset of the architectures
109462306a36Sopenharmony_ci */
109562306a36Sopenharmony_ci
109662306a36Sopenharmony_ci
109762306a36Sopenharmony_ci/*
109862306a36Sopenharmony_ci * Writeable data.
109962306a36Sopenharmony_ci * All sections are combined in a single .data section.
110062306a36Sopenharmony_ci * The sections following CONSTRUCTORS are arranged so their
110162306a36Sopenharmony_ci * typical alignment matches.
110262306a36Sopenharmony_ci * A cacheline is typical/always less than a PAGE_SIZE so
110362306a36Sopenharmony_ci * the sections that has this restriction (or similar)
110462306a36Sopenharmony_ci * is located before the ones requiring PAGE_SIZE alignment.
110562306a36Sopenharmony_ci * NOSAVE_DATA starts and ends with a PAGE_SIZE alignment which
110662306a36Sopenharmony_ci * matches the requirement of PAGE_ALIGNED_DATA.
110762306a36Sopenharmony_ci *
110862306a36Sopenharmony_ci * use 0 as page_align if page_aligned data is not used */
110962306a36Sopenharmony_ci#define RW_DATA(cacheline, pagealigned, inittask)			\
111062306a36Sopenharmony_ci	. = ALIGN(PAGE_SIZE);						\
111162306a36Sopenharmony_ci	.data : AT(ADDR(.data) - LOAD_OFFSET) {				\
111262306a36Sopenharmony_ci		INIT_TASK_DATA(inittask)				\
111362306a36Sopenharmony_ci		NOSAVE_DATA						\
111462306a36Sopenharmony_ci		PAGE_ALIGNED_DATA(pagealigned)				\
111562306a36Sopenharmony_ci		CACHELINE_ALIGNED_DATA(cacheline)			\
111662306a36Sopenharmony_ci		READ_MOSTLY_DATA(cacheline)				\
111762306a36Sopenharmony_ci		DATA_DATA						\
111862306a36Sopenharmony_ci		CONSTRUCTORS						\
111962306a36Sopenharmony_ci	}								\
112062306a36Sopenharmony_ci	BUG_TABLE							\
112162306a36Sopenharmony_ci
112262306a36Sopenharmony_ci#define INIT_TEXT_SECTION(inittext_align)				\
112362306a36Sopenharmony_ci	. = ALIGN(inittext_align);					\
112462306a36Sopenharmony_ci	.init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {		\
112562306a36Sopenharmony_ci		_sinittext = .;						\
112662306a36Sopenharmony_ci		INIT_TEXT						\
112762306a36Sopenharmony_ci		_einittext = .;						\
112862306a36Sopenharmony_ci	}
112962306a36Sopenharmony_ci
113062306a36Sopenharmony_ci#define INIT_DATA_SECTION(initsetup_align)				\
113162306a36Sopenharmony_ci	.init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {		\
113262306a36Sopenharmony_ci		INIT_DATA						\
113362306a36Sopenharmony_ci		INIT_SETUP(initsetup_align)				\
113462306a36Sopenharmony_ci		INIT_CALLS						\
113562306a36Sopenharmony_ci		CON_INITCALL						\
113662306a36Sopenharmony_ci		INIT_RAM_FS						\
113762306a36Sopenharmony_ci	}
113862306a36Sopenharmony_ci
113962306a36Sopenharmony_ci#define BSS_SECTION(sbss_align, bss_align, stop_align)			\
114062306a36Sopenharmony_ci	. = ALIGN(sbss_align);						\
114162306a36Sopenharmony_ci	__bss_start = .;						\
114262306a36Sopenharmony_ci	SBSS(sbss_align)						\
114362306a36Sopenharmony_ci	BSS(bss_align)							\
114462306a36Sopenharmony_ci	. = ALIGN(stop_align);						\
114562306a36Sopenharmony_ci	__bss_stop = .;
1146