diff options
| author | Jubilee Young <workingjubilee@gmail.com> | 2022-07-06 19:07:52 -0700 |
|---|---|---|
| committer | Jubilee Young <workingjubilee@gmail.com> | 2022-07-06 22:44:54 -0700 |
| commit | 92174f988b0cde631ffac0dbcc9f8fca413d566e (patch) | |
| tree | 5f7cba58113c5d756c09e837a9375e558a55b061 /compiler/rustc_codegen_llvm/src | |
| parent | 8824d131619e58a38bde8bcf56401629b91a204a (diff) | |
| download | rust-92174f988b0cde631ffac0dbcc9f8fca413d566e.tar.gz rust-92174f988b0cde631ffac0dbcc9f8fca413d566e.zip | |
Stop emitting CET prologues for naked functions
We can apply nocf_check as a hack for now.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/attributes.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/llvm/ffi.rs | 1 |
2 files changed, 5 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs index 9394d60134f..8c72f7dc06f 100644 --- a/compiler/rustc_codegen_llvm/src/attributes.rs +++ b/compiler/rustc_codegen_llvm/src/attributes.rs @@ -299,6 +299,10 @@ pub fn from_fn_attrs<'ll, 'tcx>( } if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::NAKED) { to_add.push(AttributeKind::Naked.create_attr(cx.llcx)); + // HACK(jubilee): "indirect branch tracking" works by attaching prologues to functions. + // And it is a module-level attribute, so the alternative is pulling naked functions into new LLVM modules. + // Otherwise LLVM's "naked" functions come with endbr prefixes per https://github.com/rust-lang/rust/issues/98768 + to_add.push(AttributeKind::NoCfCheck.create_attr(cx.llcx)); } if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::ALLOCATOR) { // apply to return place instead of function (unlike all other attributes applied in this function) diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index 5ebc2d6139f..2c8e804fff5 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -191,6 +191,7 @@ pub enum AttributeKind { StackProtect = 32, NoUndef = 33, SanitizeMemTag = 34, + NoCfCheck = 35, } /// LLVMIntPredicate |
