/* * 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
/* * LD_DEAD_CODE_DATA_ELIMINATION option enables -fdata-sections, which * generates .data.identifier sections, which need to be pulled in with * .data. We don't want to pull in .data..other sections, which Linux * has defined. Same for text and bss. * * With LTO_CLANG, the linker also splits sections by default, so we need * these macros to combine the sections during the final link. * * With AUTOFDO_CLANG and PROPELLER_CLANG, by default, the linker splits * text sections and regroups functions into subsections. * * RODATA_MAIN is not used because existing code already defines .rodata.x * sections to be brought in with rodata.
*/ #ifdefined(CONFIG_LD_DEAD_CODE_DATA_ELIMINATION) || defined(CONFIG_LTO_CLANG) || \ defined(CONFIG_AUTOFDO_CLANG) || defined(CONFIG_PROPELLER_CLANG) #define TEXT_MAIN .text .text.[0-9a-zA-Z_]* #else #define TEXT_MAIN .text #endif #ifdefined(CONFIG_LD_DEAD_CODE_DATA_ELIMINATION) || defined(CONFIG_LTO_CLANG) #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_]* #else #define DATA_MAIN .data .data.rel .data.rel.local #define SDATA_MAIN .sdata #define RODATA_MAIN .rodata #define BSS_MAIN .bss #define SBSS_MAIN .sbss #endif
/* * 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_ARCH_SUPPORTS_CFI_CLANG /* * 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
/* * .text section. Map to function alignment to avoid address changes * during second ld run in second ld pass when generating System.map * * TEXT_MAIN here will match symbols with a fixed pattern (for example, * .text.hot or .text.unlikely) if dead code elimination or * function-section is enabled. Match these symbols first before * TEXT_MAIN to ensure they are grouped together. * * Also placing .text.hot section at the beginning of a page, this * would help the TLB performance.
*/ #define TEXT_TEXT \
ALIGN_FUNCTION(); \
*(.text.asan.* .text.tsan.*) \
*(.text.unknown .text.unknown.*) \
TEXT_SPLIT \
TEXT_UNLIKELY \
. = ALIGN(PAGE_SIZE); \
TEXT_HOT \
*(TEXT_MAIN .text.fixup) \
NOINSTR_TEXT \
*(.ref.text)
/* sched.text is aling to function alignment to secure we have same
* address even at second ld pass when generating System.map */ #define SCHED_TEXT \
ALIGN_FUNCTION(); \
__sched_text_start = .; \
*(.sched.text) \
__sched_text_end = .;
/* spinlock.text is aling to function alignment to secure we have same
* address even at second ld pass when generating System.map */ #define LOCK_TEXT \
ALIGN_FUNCTION(); \
__lock_text_start = .; \
*(.spinlock.text) \
__lock_text_end = .;
/* * bss (Block Started by Symbol) - uninitialized data * zeroed during startup
*/ #define SBSS(sbss_align) \
. = ALIGN(sbss_align); \
.sbss : AT(ADDR(.sbss) - LOAD_OFFSET) { \
*(.dynsbss) \
*(SBSS_MAIN) \
*(.scommon) \
}
/* * Allow archectures to redefine BSS_FIRST_SECTIONS to add extra * sections to the front of bss.
*/ #ifndef BSS_FIRST_SECTIONS #define BSS_FIRST_SECTIONS #endif
/* * Discard .note.GNU-stack, which is emitted as PROGBITS by the compiler. * Otherwise, the type of .notes section would become PROGBITS instead of NOTES. * * Also, discard .note.gnu.property, otherwise it forces the notes section to * be 8-byte aligned which causes alignment mismatches with the kernel's custom * 4-byte aligned notes.
*/ #define NOTES \
/DISCARD/ : { \
*(.note.GNU-stack) \
*(.note.gnu.property) \
} \
.notes : AT(ADDR(.notes) - LOAD_OFFSET) { \
BOUNDED_SECTION_BY(.note.*, _notes) \
} NOTES_HEADERS \
NOTES_HEADERS_RESTORE
/* * Memory encryption operates on a page basis. Since we need to clear * the memory encryption mask for this section, it needs to be aligned * on a page boundary and be a page-size multiple in length. * * Note: We use a separate section so that only this section gets * decrypted to avoid exposing more than we wish.
*/ #ifdef CONFIG_AMD_MEM_ENCRYPT #define PERCPU_DECRYPTED_SECTION \
. = ALIGN(PAGE_SIZE); \
*(.data..percpu..decrypted) \
. = ALIGN(PAGE_SIZE); #else #define PERCPU_DECRYPTED_SECTION #endif
/* * Default discarded sections. * * Some archs want to discard exit text/data at runtime rather than * link time due to cross-section references such as alt instructions, * bug table, eh_frame, etc. DISCARDS must be the last of output * section definitions so that such archs put those in earlier section * definitions.
*/ #ifdef RUNTIME_DISCARD_EXIT #define EXIT_DISCARDS #else #define EXIT_DISCARDS \
EXIT_TEXT \
EXIT_DATA #endif
/** * PERCPU_INPUT - the percpu input sections * @cacheline: cacheline size * * The core percpu section names and core symbols which do not rely * directly upon load addresses. * * @cacheline is used to align subsections to avoid false cacheline * sharing between subsections for different purposes.
*/ #define PERCPU_INPUT(cacheline) \
__per_cpu_start = .; \
. = ALIGN(PAGE_SIZE); \
*(.data..percpu..page_aligned) \
. = ALIGN(cacheline); \
__per_cpu_hot_start = .; \
*(SORT_BY_ALIGNMENT(.data..percpu..hot.*)) \
__per_cpu_hot_end = .; \
. = ALIGN(cacheline); \
*(.data..percpu..read_mostly) \
. = ALIGN(cacheline); \
*(.data..percpu) \
*(.data..percpu..shared_aligned) \
PERCPU_DECRYPTED_SECTION \
__per_cpu_end = .;
/** * PERCPU_SECTION - define output section for percpu area * @cacheline: cacheline size * * Macro which expands to output section for percpu area. * * @cacheline is used to align subsections to avoid false cacheline * sharing between subsections for different purposes.
*/ #define PERCPU_SECTION(cacheline) \
. = ALIGN(PAGE_SIZE); \
.data..percpu : AT(ADDR(.data..percpu) - LOAD_OFFSET) { \
PERCPU_INPUT(cacheline) \
}
/* * Definition of the high level *_SECTION macros * They will fit only a subset of the architectures
*/
/* * Writeable data. * All sections are combined in a single .data section. * The sections following CONSTRUCTORS are arranged so their * typical alignment matches. * A cacheline is typical/always less than a PAGE_SIZE so * the sections that has this restriction (or similar) * is located before the ones requiring PAGE_SIZE alignment. * NOSAVE_DATA starts and ends with a PAGE_SIZE alignment which * matches the requirement of PAGE_ALIGNED_DATA. *
* use 0 as page_align if page_aligned data is not used */ #define RW_DATA(cacheline, pagealigned, inittask) \
. = ALIGN(PAGE_SIZE); \
.data : AT(ADDR(.data) - LOAD_OFFSET) { \
INIT_TASK_DATA(inittask) \
NOSAVE_DATA \
PAGE_ALIGNED_DATA(pagealigned) \
CACHE_HOT_DATA(cacheline) \
CACHELINE_ALIGNED_DATA(cacheline) \
READ_MOSTLY_DATA(cacheline) \
DATA_DATA \
CONSTRUCTORS \
} \
BUG_TABLE \
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.