diff options
| author | bors <bors@rust-lang.org> | 2021-10-27 09:19:42 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-10-27 09:19:42 +0000 |
| commit | a8f6e614f86be429b5862f30e023063f619aeed2 (patch) | |
| tree | 329266e75828737d5cd8f66a7b27bb02379f9308 /compiler/rustc_codegen_llvm/src/llvm/ffi.rs | |
| parent | 47aeac648ed56095688c1c20972c9b72bd0da7ce (diff) | |
| parent | c5708caf6a858b76b5519f81d2061ef85d9976b6 (diff) | |
| download | rust-a8f6e614f86be429b5862f30e023063f619aeed2.tar.gz rust-a8f6e614f86be429b5862f30e023063f619aeed2.zip | |
Auto merge of #89652 - rcvalle:rust-cfi, r=nagisa
Add LLVM CFI support to the Rust compiler This PR 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). Thank you, `@eddyb` and `@pcc,` for all the help!
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 d57573558da..21d2388fc30 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -416,6 +416,7 @@ pub enum MetadataType { MD_nontemporal = 9, MD_mem_parallel_loop_access = 10, MD_nonnull = 11, + MD_type = 19, } /// LLVMRustAsmDialect @@ -1002,6 +1003,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; |
