Tejun Heo | 405d967 | 2009-06-24 15:13:38 +0900 | [diff] [blame] | 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 | */ |
Sami Tolvanen | 08f67ef | 2020-03-31 11:10:15 -0700 | [diff] [blame] | 6 | #include <asm/page.h> |
| 7 | |
Tejun Heo | 405d967 | 2009-06-24 15:13:38 +0900 | [diff] [blame] | 8 | SECTIONS { |
Josh Poimboeuf | e390f9a | 2017-03-01 12:04:44 -0600 | [diff] [blame] | 9 | /DISCARD/ : { |
| 10 | *(.discard) |
| 11 | *(.discard.*) |
Sami Tolvanen | 08f67ef | 2020-03-31 11:10:15 -0700 | [diff] [blame] | 12 | /* |
| 13 | * LLD may emit .eh_frame with CONFIG_CFI_CLANG despite |
| 14 | * -fno-asynchronous-unwind-tables. Discard the section. |
| 15 | */ |
| 16 | *(.eh_frame) |
Josh Poimboeuf | e390f9a | 2017-03-01 12:04:44 -0600 | [diff] [blame] | 17 | } |
Alessio Igor Bogani | f02e8a6 | 2011-04-14 14:59:39 +0200 | [diff] [blame] | 18 | |
Rabin Vincent | 5d8591b | 2015-02-06 15:09:57 +1030 | [diff] [blame] | 19 | __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 Ryabinin | 9ddf825 | 2015-02-13 14:40:10 -0800 | [diff] [blame] | 29 | |
David Daney | 5bd933f | 2017-03-07 17:31:08 -0800 | [diff] [blame] | 30 | .init_array 0 : ALIGN(8) { *(SORT(.init_array.*)) *(.init_array) } |
David Daney | ab42632 | 2017-03-01 14:04:53 -0800 | [diff] [blame] | 31 | |
| 32 | __jump_table 0 : ALIGN(8) { KEEP(*(__jump_table)) } |
Sami Tolvanen | 76df447 | 2019-12-03 15:56:24 -0800 | [diff] [blame] | 33 | |
| 34 | __patchable_function_entries : { *(__patchable_function_entries) } |
| 35 | |
Sean Christopherson | 3ddee7b | 2021-03-22 16:44:38 -0700 | [diff] [blame] | 36 | #ifdef CONFIG_LTO_CLANG |
Sami Tolvanen | 76df447 | 2019-12-03 15:56:24 -0800 | [diff] [blame] | 37 | /* |
| 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 Biesheuvel | 6be141e | 2021-03-23 10:54:38 +0100 | [diff] [blame] | 53 | *(.rodata.._start) |
Sami Tolvanen | 76df447 | 2019-12-03 15:56:24 -0800 | [diff] [blame] | 54 | *(.rodata .rodata.[0-9a-zA-Z_]*) |
| 55 | *(.rodata..L*) |
Ard Biesheuvel | 6be141e | 2021-03-23 10:54:38 +0100 | [diff] [blame] | 56 | *(.rodata.._end) |
Sami Tolvanen | 76df447 | 2019-12-03 15:56:24 -0800 | [diff] [blame] | 57 | } |
| 58 | |
Sami Tolvanen | 08f67ef | 2020-03-31 11:10:15 -0700 | [diff] [blame] | 59 | .text : ALIGN(PAGE_SIZE) { |
Ard Biesheuvel | 6be141e | 2021-03-23 10:54:38 +0100 | [diff] [blame] | 60 | *(.text.._start) |
Ard Biesheuvel | e8d56bd | 2021-10-04 11:33:03 +0000 | [diff] [blame] | 61 | #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 Tolvanen | 08f67ef | 2020-03-31 11:10:15 -0700 | [diff] [blame] | 67 | *(.text.__cfi_check) |
Ard Biesheuvel | e8d56bd | 2021-10-04 11:33:03 +0000 | [diff] [blame] | 68 | #endif |
Sami Tolvanen | 27eb5ff | 2021-04-26 17:13:46 -0700 | [diff] [blame] | 69 | *(.text .text.[0-9a-zA-Z_]*) |
| 70 | __cfi_jt_start = .; |
| 71 | *(.text..L.cfi.jumptable .text..L.cfi.jumptable.*) |
| 72 | __cfi_jt_end = .; |
Ard Biesheuvel | 6be141e | 2021-03-23 10:54:38 +0100 | [diff] [blame] | 73 | *(.text.._end) |
Eric Biggers | 109f31a | 2021-11-18 16:09:11 -0800 | [diff] [blame] | 74 | *(.text.._fips140_unchecked) |
Sami Tolvanen | 08f67ef | 2020-03-31 11:10:15 -0700 | [diff] [blame] | 75 | } |
| 76 | #endif |
Tejun Heo | 405d967 | 2009-06-24 15:13:38 +0900 | [diff] [blame] | 77 | } |
Masahiro Yamada | 596b047 | 2020-09-08 13:27:08 +0900 | [diff] [blame] | 78 | |
| 79 | /* bring in arch-specific sections */ |
| 80 | #include <asm/module.lds.h> |