Stop emitting CET prologues for naked functions

We can apply nocf_check as a hack for now.
This commit is contained in:
Jubilee Young 2022-07-06 19:07:52 -07:00
parent 8824d13161
commit 92174f988b
6 changed files with 33 additions and 1 deletions

View file

@ -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)