llvm-project/llvm/test/Instrumentation/AddressSanitizer/kcfi.ll
Sami Tolvanen 3b14862f0a [ModuleUtils][KCFI] Set !kcfi_type metadata for sanitizer constructors
Set KCFI type metadata for the sanitizer constructors to prevent
runtime failures when these functions are indirectly called in
instrumented code. This fixes a compatibility issue with KASAN and
-fsanitize=kcfi in the Linux kernel.

Link: https://github.com/ClangBuiltLinux/linux/issues/1742

Reviewed By: nickdesaulniers, MaskRay

Differential Revision: https://reviews.llvm.org/D138945
2022-12-09 00:26:08 +00:00

12 lines
347 B
LLVM

;; Test that we emit kcfi_type metadata for asan.module_ctor with KCFI.
; RUN: opt < %s -passes=asan -S | FileCheck %s
; CHECK: @llvm.global_ctors = {{.*}}{ i32 1, ptr @asan.module_ctor, ptr @asan.module_ctor }
; CHECK: define internal void @asan.module_ctor()
; CHECK-SAME: !kcfi_type
!llvm.module.flags = !{!0}
!0 = !{i32 4, !"kcfi", i32 1}