blob: 6cca5d88744eb401cf30079405f284e86c18db41 [file] [log] [blame]
Tejun Heo405d9672009-06-24 15:13:38 +09001/*
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 */
Sami Tolvanen08f67ef2020-03-31 11:10:15 -07006#include <asm/page.h>
7
Tejun Heo405d9672009-06-24 15:13:38 +09008SECTIONS {
Josh Poimboeufe390f9a2017-03-01 12:04:44 -06009 /DISCARD/ : {
10 *(.discard)
11 *(.discard.*)
Sami Tolvanen08f67ef2020-03-31 11:10:15 -070012 /*
13 * LLD may emit .eh_frame with CONFIG_CFI_CLANG despite
14 * -fno-asynchronous-unwind-tables. Discard the section.
15 */
16 *(.eh_frame)
Josh Poimboeufe390f9a2017-03-01 12:04:44 -060017 }
Alessio Igor Boganif02e8a62011-04-14 14:59:39 +020018
Rabin Vincent5d8591b2015-02-06 15:09:57 +103019 __ksymtab 0 : { *(SORT(___ksymtab+*)) }
20 __ksymtab_gpl 0 : { *(SORT(___ksymtab_gpl+*)) }
21 __ksymtab_unused 0 : { *(SORT(___ksymtab_unused+*)) }
22 __ksymtab_unused_gpl 0 : { *(SORT(___ksymtab_unused_gpl+*)) }
23 __ksymtab_gpl_future 0 : { *(SORT(___ksymtab_gpl_future+*)) }
24 __kcrctab 0 : { *(SORT(___kcrctab+*)) }
25 __kcrctab_gpl 0 : { *(SORT(___kcrctab_gpl+*)) }
26 __kcrctab_unused 0 : { *(SORT(___kcrctab_unused+*)) }
27 __kcrctab_unused_gpl 0 : { *(SORT(___kcrctab_unused_gpl+*)) }
28 __kcrctab_gpl_future 0 : { *(SORT(___kcrctab_gpl_future+*)) }
Andrey Ryabinin9ddf8252015-02-13 14:40:10 -080029
David Daney5bd933f2017-03-07 17:31:08 -080030 .init_array 0 : ALIGN(8) { *(SORT(.init_array.*)) *(.init_array) }
David Daneyab426322017-03-01 14:04:53 -080031
32 __jump_table 0 : ALIGN(8) { KEEP(*(__jump_table)) }
Sami Tolvanen76df4472019-12-03 15:56:24 -080033
34 __patchable_function_entries : { *(__patchable_function_entries) }
35
Sean Christopherson3ddee7b2021-03-22 16:44:38 -070036#ifdef CONFIG_LTO_CLANG
Sami Tolvanen76df4472019-12-03 15:56:24 -080037 /*
38 * With CONFIG_LTO_CLANG, LLD always enables -fdata-sections and
39 * -ffunction-sections, which increases the size of the final module.
40 * Merge the split sections in the final binary.
41 */
42 .bss : {
43 *(.bss .bss.[0-9a-zA-Z_]*)
44 *(.bss..L*)
45 }
46
47 .data : {
48 *(.data .data.[0-9a-zA-Z_]*)
49 *(.data..L*)
50 }
51
52 .rodata : {
Ard Biesheuvel6be141e2021-03-23 10:54:38 +010053 *(.rodata.._start)
Sami Tolvanen76df4472019-12-03 15:56:24 -080054 *(.rodata .rodata.[0-9a-zA-Z_]*)
55 *(.rodata..L*)
Ard Biesheuvel6be141e2021-03-23 10:54:38 +010056 *(.rodata.._end)
Sami Tolvanen76df4472019-12-03 15:56:24 -080057 }
58
Sami Tolvanen08f67ef2020-03-31 11:10:15 -070059 .text : ALIGN(PAGE_SIZE) {
Ard Biesheuvel6be141e2021-03-23 10:54:38 +010060 *(.text.._start)
Ard Biesheuvele8d56bd2021-10-04 11:33:03 +000061#ifdef CONFIG_CFI_CLANG
62 /*
63 * With CFI_CLANG, ensure __cfi_check is at the beginning of
64 * the .text section, and that the section is aligned to page
65 * size.
66 */
Sami Tolvanen08f67ef2020-03-31 11:10:15 -070067 *(.text.__cfi_check)
Ard Biesheuvele8d56bd2021-10-04 11:33:03 +000068#endif
Sami Tolvanen27eb5ff2021-04-26 17:13:46 -070069 *(.text .text.[0-9a-zA-Z_]*)
70 __cfi_jt_start = .;
71 *(.text..L.cfi.jumptable .text..L.cfi.jumptable.*)
72 __cfi_jt_end = .;
Ard Biesheuvel6be141e2021-03-23 10:54:38 +010073 *(.text.._end)
Eric Biggers109f31a2021-11-18 16:09:11 -080074 *(.text.._fips140_unchecked)
Sami Tolvanen08f67ef2020-03-31 11:10:15 -070075 }
76#endif
Tejun Heo405d9672009-06-24 15:13:38 +090077}
Masahiro Yamada596b0472020-09-08 13:27:08 +090078
79/* bring in arch-specific sections */
80#include <asm/module.lds.h>