From 2f05de2d6d768d0c4be18f43328ab5e3eecbbd5f Mon Sep 17 00:00:00 2001 From: nicolas rolland Date: Fri, 21 Aug 2020 12:02:02 +0200 Subject: [PATCH] use updated syntax llvm_asm cf https://github.com/rust-lang/rfcs/blob/master/text/2843-llvm-asm.md --- benches/syscall.rs | 4 ++-- src/arch/aarch64.rs | 8 ++++---- src/arch/or1k.rs | 8 ++++---- src/arch/x86.rs | 8 ++++---- src/arch/x86_64.rs | 8 ++++---- src/lib.rs | 2 +- tests/fpe.rs | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/benches/syscall.rs b/benches/syscall.rs index 94d721f0..233d2128 100644 --- a/benches/syscall.rs +++ b/benches/syscall.rs @@ -5,14 +5,14 @@ // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except according to those terms. #![cfg(target_os = "linux")] -#![feature(asm, test)] +#![feature(llvm_asm, test)] extern crate test; #[cfg(target_arch = "x86_64")] #[bench] fn syscall(b: &mut test::Bencher) { b.iter(|| unsafe { - asm!("movq $$102, %rax\n\ + llvm_asm!("movq $$102, %rax\n\ syscall" : : diff --git a/src/arch/aarch64.rs b/src/arch/aarch64.rs index c3547f4d..abe423a7 100644 --- a/src/arch/aarch64.rs +++ b/src/arch/aarch64.rs @@ -59,7 +59,7 @@ pub unsafe fn init(stack: &Stack, f: unsafe extern "C" fn(usize, StackPointer) - #[cfg(not(target_vendor = "apple"))] #[naked] unsafe extern "C" fn trampoline_1() { - asm!( + llvm_asm!( r#" # gdb has a hardcoded check that rejects backtraces where frame addresses # do not monotonically decrease. It is turned off if the function is called @@ -95,7 +95,7 @@ pub unsafe fn init(stack: &Stack, f: unsafe extern "C" fn(usize, StackPointer) - #[cfg(target_vendor = "apple")] #[naked] unsafe extern "C" fn trampoline_1() { - asm!( + llvm_asm!( r#" # Identical to the above, except avoids .local/.size that aren't available on Mach-O. __morestack: @@ -110,7 +110,7 @@ pub unsafe fn init(stack: &Stack, f: unsafe extern "C" fn(usize, StackPointer) - #[naked] unsafe extern "C" fn trampoline_2() { - asm!( + llvm_asm!( r#" # Set up the second part of our DWARF CFI. # When unwinding the frame corresponding to this function, a DWARF unwinder @@ -180,7 +180,7 @@ pub unsafe fn swap(arg: usize, new_sp: StackPointer, let ret: usize; let ret_sp: *mut usize; - asm!( + llvm_asm!( r#" # Set up the link register adr lr, 0f diff --git a/src/arch/or1k.rs b/src/arch/or1k.rs index bb192da2..4d8cf772 100644 --- a/src/arch/or1k.rs +++ b/src/arch/or1k.rs @@ -53,7 +53,7 @@ pub struct StackPointer(*mut usize); pub unsafe fn init(stack: &Stack, f: unsafe extern "C" fn(usize, StackPointer) -> !) -> StackPointer { #[naked] unsafe extern "C" fn trampoline_1() { - asm!( + llvm_asm!( r#" # gdb has a hardcoded check that rejects backtraces where frame addresses # do not monotonically decrease. It is turned off if the function is called @@ -88,7 +88,7 @@ pub unsafe fn init(stack: &Stack, f: unsafe extern "C" fn(usize, StackPointer) - #[naked] unsafe extern "C" fn trampoline_2() { - asm!( + llvm_asm!( r#" # Set up the second part of our DWARF CFI. # When unwinding the frame corresponding to this function, a DWARF unwinder @@ -160,7 +160,7 @@ pub unsafe fn swap(arg: usize, new_sp: StackPointer, #[naked] unsafe extern "C" fn trampoline() { - asm!( + llvm_asm!( r#" # Save the frame pointer and link register; the unwinder uses them to find # the CFA of the caller, and so they have to have the correct value immediately @@ -194,7 +194,7 @@ pub unsafe fn swap(arg: usize, new_sp: StackPointer, let ret: usize; let ret_sp: *mut usize; - asm!( + llvm_asm!( r#" # Call the trampoline to switch to the new context. l.jal ${2} diff --git a/src/arch/x86.rs b/src/arch/x86.rs index 79b2904e..46d67d19 100644 --- a/src/arch/x86.rs +++ b/src/arch/x86.rs @@ -54,7 +54,7 @@ pub unsafe fn init(stack: &Stack, f: unsafe extern "C" fn(usize, StackPointer) - #[cfg(not(target_vendor = "apple"))] #[naked] unsafe extern "C" fn trampoline_1() { - asm!( + llvm_asm!( r#" # gdb has a hardcoded check that rejects backtraces where frame addresses # do not monotonically decrease. It is turned off if the function is called @@ -109,7 +109,7 @@ pub unsafe fn init(stack: &Stack, f: unsafe extern "C" fn(usize, StackPointer) - #[naked] unsafe extern "C" fn trampoline_2() { - asm!( + llvm_asm!( r#" # Set up the second part of our DWARF CFI. # When unwinding the frame corresponding to this function, a DWARF unwinder @@ -182,7 +182,7 @@ pub unsafe fn swap(arg: usize, new_sp: StackPointer, #[naked] unsafe extern "C" fn trampoline() { - asm!( + llvm_asm!( r#" # Save frame pointer explicitly; the unwinder uses it to find CFA of # the caller, and so it has to have the correct value immediately after @@ -217,7 +217,7 @@ pub unsafe fn swap(arg: usize, new_sp: StackPointer, let ret: usize; let ret_sp: *mut usize; - asm!( + llvm_asm!( r#" # Push instruction pointer of the old context and switch to # the new context. diff --git a/src/arch/x86_64.rs b/src/arch/x86_64.rs index edd7255e..fa15edff 100644 --- a/src/arch/x86_64.rs +++ b/src/arch/x86_64.rs @@ -59,7 +59,7 @@ pub unsafe fn init(stack: &Stack, f: unsafe extern "C" fn(usize, StackPointer) - #[cfg(not(target_vendor = "apple"))] #[naked] unsafe extern "C" fn trampoline_1() { - asm!( + llvm_asm!( r#" # gdb has a hardcoded check that rejects backtraces where frame addresses # do not monotonically decrease. It is turned off if the function is called @@ -99,7 +99,7 @@ pub unsafe fn init(stack: &Stack, f: unsafe extern "C" fn(usize, StackPointer) - #[cfg(target_vendor = "apple")] #[naked] unsafe extern "C" fn trampoline_1() { - asm!( + llvm_asm!( r#" # Identical to the above, except avoids .local/.size that aren't available on Mach-O. __morestack: @@ -114,7 +114,7 @@ pub unsafe fn init(stack: &Stack, f: unsafe extern "C" fn(usize, StackPointer) - #[naked] unsafe extern "C" fn trampoline_2() { - asm!( + llvm_asm!( r#" # Set up the second part of our DWARF CFI. # When unwinding the frame corresponding to this function, a DWARF unwinder @@ -182,7 +182,7 @@ pub unsafe fn swap(arg: usize, new_sp: StackPointer, let ret: usize; let ret_sp: *mut usize; - asm!( + llvm_asm!( r#" # Push the return address leaq 0f(%rip), %rax diff --git a/src/lib.rs b/src/lib.rs index c0b6cda8..29e2a192 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,7 @@ // http://apache.org/licenses/LICENSE-2.0> or the MIT license , at your option. This file may not be // copied, modified, or distributed except according to those terms. -#![feature(asm, naked_functions, untagged_unions)] +#![feature(llvm_asm, naked_functions, untagged_unions)] #![cfg_attr(feature = "alloc", feature(alloc, allocator_api))] #![cfg_attr(test, feature(test))] #![no_std] diff --git a/tests/fpe.rs b/tests/fpe.rs index b9e97f01..74a5258f 100644 --- a/tests/fpe.rs +++ b/tests/fpe.rs @@ -8,7 +8,7 @@ #![cfg(target_os = "linux")] #![feature(test)] #![feature(thread_local)] -#![feature(asm)] +#![feature(llvm_asm)] extern crate fringe; extern crate test; use fringe::{OsStack, Generator};