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