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 /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 'src')
| -rw-r--r-- | src/test/assembly/x86_64-naked-fn-no-cet-prolog.rs | 24 | ||||
| -rw-r--r-- | src/test/codegen/naked-noinline.rs | 2 |
2 files changed, 25 insertions, 1 deletions
diff --git a/src/test/assembly/x86_64-naked-fn-no-cet-prolog.rs b/src/test/assembly/x86_64-naked-fn-no-cet-prolog.rs new file mode 100644 index 00000000000..bedcded731d --- /dev/null +++ b/src/test/assembly/x86_64-naked-fn-no-cet-prolog.rs @@ -0,0 +1,24 @@ +// compile-flags: -C no-prepopulate-passes -Zcf-protection=full +// assembly-output: emit-asm +// needs-asm-support +// only-x86_64 + +#![crate_type = "lib"] +#![feature(naked_functions)] +use std::arch::asm; + +// The problem at hand: Rust has adopted a fairly strict meaning for "naked functions", +// meaning "no prologue whatsoever, no, really, not one instruction." +// Unfortunately, x86's control-flow enforcement, specifically indirect branch protection, +// works by using an instruction for each possible landing site, +// and LLVM implements this via making sure of that. +#[no_mangle] +#[naked] +pub unsafe extern "sysv64" fn will_halt() -> ! { + // CHECK-NOT: endbr{{32|64}} + // CHECK: hlt + asm!("hlt", options(noreturn)) +} + +// what about aarch64? +// "branch-protection"=false diff --git a/src/test/codegen/naked-noinline.rs b/src/test/codegen/naked-noinline.rs index 13bc139ecd0..c0ac69f4ed7 100644 --- a/src/test/codegen/naked-noinline.rs +++ b/src/test/codegen/naked-noinline.rs @@ -28,4 +28,4 @@ pub unsafe fn g() { f(); } -// CHECK: attributes [[ATTR]] = { naked noinline{{.*}} } +// CHECK: attributes [[ATTR]] = { naked{{.*}}noinline{{.*}} } |
