]> git.ipfire.org Git - thirdparty/kernel/stable.git/blobdiff - include/asm-generic/vmlinux.lds.h
add support for Clang CFI
[thirdparty/kernel/stable.git] / include / asm-generic / vmlinux.lds.h
index 0331d5d49551a305b92a628f4e20e8f5a7cd72a3..40a9c101565ebe120e537eb0e12b471f25a6612a 100644 (file)
        . = ALIGN((align));                                             \
        __end_rodata = .;
 
+
+/*
+ * .text..L.cfi.jumptable.* contain Control-Flow Integrity (CFI)
+ * jump table entries.
+ */
+#ifdef CONFIG_CFI_CLANG
+#define TEXT_CFI_JT                                                    \
+               . = ALIGN(PMD_SIZE);                                    \
+               __cfi_jt_start = .;                                     \
+               *(.text..L.cfi.jumptable .text..L.cfi.jumptable.*)      \
+               . = ALIGN(PMD_SIZE);                                    \
+               __cfi_jt_end = .;
+#else
+#define TEXT_CFI_JT
+#endif
+
 /*
  * Non-instrumentable text section
  */
                NOINSTR_TEXT                                            \
                *(.text..refcount)                                      \
                *(.ref.text)                                            \
+               TEXT_CFI_JT                                             \
        MEM_KEEP(init.text*)                                            \
        MEM_KEEP(exit.text*)                                            \
 
  * keep any .init_array.* sections.
  * https://bugs.llvm.org/show_bug.cgi?id=46478
  */
-#if defined(CONFIG_GCOV_KERNEL) || defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KCSAN)
+#if defined(CONFIG_GCOV_KERNEL) || defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KCSAN) || \
+       defined(CONFIG_CFI_CLANG)
 # ifdef CONFIG_CONSTRUCTORS
 #  define SANITIZER_DISCARDS                                           \
        *(.eh_frame)