Rollup merge of #138368 - rcvalle:rust-kcfi-arity, r=davidtwco
KCFI: Add KCFI arity indicator support Adds KCFI arity indicator support to the Rust compiler (see https://github.com/rust-lang/rust/issues/138311, https://github.com/llvm/llvm-project/pull/121070, and https://lore.kernel.org/lkml/CANiq72=3ghFxy8E=AU9p+0imFxKr5iU3sd0hVUXed5BA+KjdNQ@mail.gmail.com/).
This commit is contained in:
commit
543160dd62
14 changed files with 148 additions and 0 deletions
|
@ -328,6 +328,22 @@ pub(crate) unsafe fn create_module<'ll>(
|
|||
pfe.prefix().into(),
|
||||
);
|
||||
}
|
||||
|
||||
// Add "kcfi-arity" module flag if KCFI arity indicator is enabled. (See
|
||||
// https://github.com/llvm/llvm-project/pull/117121.)
|
||||
if sess.is_sanitizer_kcfi_arity_enabled() {
|
||||
// KCFI arity indicator requires LLVM 21.0.0 or later.
|
||||
if llvm_version < (21, 0, 0) {
|
||||
tcx.dcx().emit_err(crate::errors::SanitizerKcfiArityRequiresLLVM2100);
|
||||
}
|
||||
|
||||
llvm::add_module_flag_u32(
|
||||
llmod,
|
||||
llvm::ModuleFlagMergeBehavior::Override,
|
||||
"kcfi-arity",
|
||||
1,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Control Flow Guard is currently only supported by MSVC and LLVM on Windows.
|
||||
|
|
|
@ -217,3 +217,7 @@ pub(crate) struct MismatchedDataLayout<'a> {
|
|||
pub(crate) struct FixedX18InvalidArch<'a> {
|
||||
pub arch: &'a str,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_llvm_sanitizer_kcfi_arity_requires_llvm_21_0_0)]
|
||||
pub(crate) struct SanitizerKcfiArityRequiresLLVM2100;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue