diff --git a/scripts/module.lds.S b/scripts/module.lds.S index 18d5b8423635..a1e1f95c1f0d 100644 --- a/scripts/module.lds.S +++ b/scripts/module.lds.S @@ -3,10 +3,17 @@ * Archs are free to supply their own linker scripts. ld will * combine them automatically. */ +#include + SECTIONS { /DISCARD/ : { *(.discard) *(.discard.*) + /* + * LLD may emit .eh_frame with CONFIG_CFI_CLANG despite + * -fno-asynchronous-unwind-tables. Discard the section. + */ + *(.eh_frame) } __ksymtab 0 : { *(SORT(___ksymtab+*)) } @@ -46,7 +53,16 @@ SECTIONS { *(.rodata..L*) } - .text : { *(.text .text.[0-9a-zA-Z_]*) } +#ifdef CONFIG_CFI_CLANG + /* + * With CFI_CLANG, ensure __cfi_check is at the beginning of the + * .text section, and that the section is aligned to page size. + */ + .text : ALIGN(PAGE_SIZE) { + *(.text.__cfi_check) + *(.text .text.[0-9a-zA-Z_]* .text..L.cfi*) + } +#endif } /* bring in arch-specific sections */