diff options
| author | Ramon de C Valle <rcvalle@users.noreply.github.com> | 2021-10-07 15:33:13 -0700 |
|---|---|---|
| committer | Ramon de C Valle <rcvalle@users.noreply.github.com> | 2021-10-25 16:23:01 -0700 |
| commit | 5d30e9318900dd4f034c21f1378fea7b40998b07 (patch) | |
| tree | 0132f1f3b8ef91edf7c0a97c7fc7310fcc3017b0 /compiler/rustc_codegen_llvm/src/llvm/ffi.rs | |
| parent | 1067e2ca5e9cfe5c79f956e49ffc684c5142d49b (diff) | |
| download | rust-5d30e9318900dd4f034c21f1378fea7b40998b07.tar.gz rust-5d30e9318900dd4f034c21f1378fea7b40998b07.zip | |
Add LLVM CFI support to the Rust compiler
This commit adds LLVM Control Flow Integrity (CFI) support to the Rust compiler. It initially provides forward-edge control flow protection for Rust-compiled code only by aggregating function pointers in groups identified by their number of arguments. Forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space) will be provided in later work as part of this project by defining and using compatible type identifiers (see Type metadata in the design document in the tracking issue #89653). LLVM CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e., -Clto).
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/llvm/ffi.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/llvm/ffi.rs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index 63eca00de2a..b258eb36aa8 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -389,6 +389,7 @@ pub enum MetadataType { MD_nontemporal = 9, MD_mem_parallel_loop_access = 10, MD_nonnull = 11, + MD_type = 19, } /// LLVMRustAsmDialect @@ -975,6 +976,8 @@ extern "C" { pub fn LLVMSetValueName2(Val: &Value, Name: *const c_char, NameLen: size_t); pub fn LLVMReplaceAllUsesWith(OldVal: &'a Value, NewVal: &'a Value); pub fn LLVMSetMetadata(Val: &'a Value, KindID: c_uint, Node: &'a Value); + pub fn LLVMGlobalSetMetadata(Val: &'a Value, KindID: c_uint, Metadata: &'a Metadata); + pub fn LLVMValueAsMetadata(Node: &'a Value) -> &Metadata; // Operations on constants of any type pub fn LLVMConstNull(Ty: &Type) -> &Value; |
