• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Common module linker script, always used when linking a module.
3 * Archs are free to supply their own linker scripts.  ld will
4 * combine them automatically.
5 */
6#ifdef CONFIG_UNWIND_TABLES
7#define DISCARD_EH_FRAME
8#else
9#define DISCARD_EH_FRAME	*(.eh_frame)
10#endif
11
12SECTIONS {
13	/DISCARD/ : {
14		*(.discard)
15		*(.discard.*)
16		*(.export_symbol)
17	}
18
19	__ksymtab		0 : { *(SORT(___ksymtab+*)) }
20	__ksymtab_gpl		0 : { *(SORT(___ksymtab_gpl+*)) }
21	__kcrctab		0 : { *(SORT(___kcrctab+*)) }
22	__kcrctab_gpl		0 : { *(SORT(___kcrctab_gpl+*)) }
23
24	.ctors			0 : ALIGN(8) { *(SORT(.ctors.*)) *(.ctors) }
25	.init_array		0 : ALIGN(8) { *(SORT(.init_array.*)) *(.init_array) }
26
27	.altinstructions	0 : ALIGN(8) { KEEP(*(.altinstructions)) }
28	__bug_table		0 : ALIGN(8) { KEEP(*(__bug_table)) }
29	__jump_table		0 : ALIGN(8) { KEEP(*(__jump_table)) }
30
31	__patchable_function_entries : { *(__patchable_function_entries) }
32
33#ifdef CONFIG_ARCH_USES_CFI_TRAPS
34	__kcfi_traps 		: { KEEP(*(.kcfi_traps)) }
35#endif
36
37#if IS_ENABLED(CONFIG_CRYPTO_FIPS140_MOD)
38	/*
39	 * The FIPS140 module incorporates copies of builtin code, which gets
40	 * integrity checked at module load time, and registered in a way that
41	 * ensures that the integrity checked versions supersede the builtin
42	 * ones.  These objects are compiled as builtin code, and so their init
43	 * hooks will be exported from the binary in the same way as builtin
44	 * initcalls are, i.e., annotated with a level that defines the order
45	 * in which the hooks are expected to be invoked.
46	 */
47#define INIT_CALLS_LEVEL(level)						\
48		KEEP(*(.initcall##level##.init*))			\
49		KEEP(*(.initcall##level##s.init*))
50
51	.initcalls : {
52		*(.initcalls._start)
53		INIT_CALLS_LEVEL(0)
54		INIT_CALLS_LEVEL(1)
55		INIT_CALLS_LEVEL(2)
56		INIT_CALLS_LEVEL(3)
57		INIT_CALLS_LEVEL(4)
58		INIT_CALLS_LEVEL(5)
59		INIT_CALLS_LEVEL(rootfs)
60		INIT_CALLS_LEVEL(6)
61		INIT_CALLS_LEVEL(7)
62		*(.initcalls._end)
63	}
64#endif
65
66#if defined(CONFIG_LTO_CLANG) || defined(CONFIG_CRYPTO_FIPS140_MERGE_MOD_SECTIONS)
67	/*
68	 * With CONFIG_LTO_CLANG, LLD always enables -fdata-sections and
69	 * -ffunction-sections, which increases the size of the final module.
70	 * Merge the split sections in the final binary.
71	 */
72	.bss : {
73		*(.bss .bss.[0-9a-zA-Z_]*)
74		*(.bss..L*)
75	}
76
77	.data : {
78		*(.data .data.[0-9a-zA-Z_]*)
79		*(.data..L*)
80	}
81
82	.rodata : {
83		*(.rodata.._start)
84		*(.rodata .rodata.[0-9a-zA-Z_]*)
85		*(.rodata..L*)
86		*(.rodata.._end)
87	}
88
89	.text : {
90		*(.text.._start)
91		*(.text .text.[0-9a-zA-Z_]*)
92		*(.text.._end)
93		*(.text.._fips140_unchecked)
94	}
95#endif
96}
97
98/* bring in arch-specific sections */
99#include <asm/module.lds.h>
100