diff --git a/src/unwinder/arch/aarch64.rs b/src/unwinder/arch/aarch64.rs index c2bfc35..25eaee6 100644 --- a/src/unwinder/arch/aarch64.rs +++ b/src/unwinder/arch/aarch64.rs @@ -63,6 +63,7 @@ macro_rules! save { (gp$(, $fp:ident)?) => { // No need to save caller-saved registers here. core::arch::naked_asm!( + maybe_cfi!(".cfi_startproc"), "stp x29, x30, [sp, -16]!", maybe_cfi!(" .cfi_def_cfa_offset 16 @@ -98,6 +99,7 @@ macro_rules! save { .cfi_restore x30 "), "ret", + maybe_cfi!(".cfi_endproc"), ); }; (maybesavefp(fp)) => { diff --git a/src/unwinder/arch/riscv32.rs b/src/unwinder/arch/riscv32.rs index b26cb4f..e3581b8 100644 --- a/src/unwinder/arch/riscv32.rs +++ b/src/unwinder/arch/riscv32.rs @@ -83,6 +83,8 @@ macro_rules! code { }; (save_fp) => { " + .option push // Work around Rust issue #80608 + .option arch, +d // Work around Rust issue #80608 fsd fs0, 0xC0(sp) fsd fs1, 0xC8(sp) fsd fs2, 0x110(sp) @@ -95,6 +97,7 @@ macro_rules! code { fsd fs9, 0x148(sp) fsd fs10, 0x150(sp) fsd fs11, 0x158(sp) + .option pop // Work around Rust issue #80608 " }; (restore_gp) => { @@ -133,6 +136,8 @@ macro_rules! code { }; (restore_fp) => { " + .option push // Work around Rust issue #80608 + .option arch, +d // Work around Rust issue #80608 fld ft0, 0x80(a0) fld ft1, 0x88(a0) fld ft2, 0x90(a0) @@ -165,6 +170,7 @@ macro_rules! code { fld ft9, 0x168(a0) fld ft10, 0x170(a0) fld ft11, 0x178(a0) + .option pop // Work around Rust issue #80608 " }; } @@ -175,6 +181,7 @@ pub extern "C-unwind" fn save_context(f: extern "C" fn(&mut Context, *mut ()), p #[cfg(target_feature = "d")] unsafe { core::arch::naked_asm!( + maybe_cfi!(".cfi_startproc"), " mv t0, sp add sp, sp, -0x190 @@ -194,11 +201,13 @@ pub extern "C-unwind" fn save_context(f: extern "C" fn(&mut Context, *mut ()), p maybe_cfi!(".cfi_def_cfa_offset 0"), maybe_cfi!(".cfi_restore ra"), "ret", + maybe_cfi!(".cfi_endproc"), ); } #[cfg(not(target_feature = "d"))] unsafe { core::arch::naked_asm!( + maybe_cfi!(".cfi_startproc"), " mv t0, sp add sp, sp, -0x90 @@ -217,6 +226,7 @@ pub extern "C-unwind" fn save_context(f: extern "C" fn(&mut Context, *mut ()), p maybe_cfi!(".cfi_def_cfa_offset 0"), maybe_cfi!(".cfi_restore ra"), "ret", + maybe_cfi!(".cfi_endproc") ); } } diff --git a/src/unwinder/arch/riscv64.rs b/src/unwinder/arch/riscv64.rs index 30d3131..4b512fb 100644 --- a/src/unwinder/arch/riscv64.rs +++ b/src/unwinder/arch/riscv64.rs @@ -83,6 +83,8 @@ macro_rules! code { }; (save_fp) => { " + .option push // Work around Rust issue #80608 + .option arch, +d // Work around Rust issue #80608 fsd fs0, 0x140(sp) fsd fs1, 0x148(sp) fsd fs2, 0x190(sp) @@ -95,6 +97,7 @@ macro_rules! code { fsd fs9, 0x1C8(sp) fsd fs10, 0x1D0(sp) fsd fs11, 0x1D8(sp) + .option pop // Work around Rust issue #80608 " }; (restore_gp) => { @@ -133,6 +136,8 @@ macro_rules! code { }; (restore_fp) => { " + .option push // Work around Rust issue #80608 + .option arch, +d // Work around Rust issue #80608 fld ft0, 0x100(a0) fld ft1, 0x108(a0) fld ft2, 0x110(a0) @@ -165,6 +170,7 @@ macro_rules! code { fld ft9, 0x1E8(a0) fld ft10, 0x1F0(a0) fld ft11, 0x1F8(a0) + .option pop // Work around Rust issue #80608 " }; } @@ -175,6 +181,7 @@ pub extern "C-unwind" fn save_context(f: extern "C" fn(&mut Context, *mut ()), p #[cfg(target_feature = "d")] unsafe { core::arch::naked_asm!( + maybe_cfi!(".cfi_startproc"), " mv t0, sp add sp, sp, -0x210 @@ -194,11 +201,13 @@ pub extern "C-unwind" fn save_context(f: extern "C" fn(&mut Context, *mut ()), p maybe_cfi!(".cfi_def_cfa_offset 0"), maybe_cfi!(".cfi_restore ra"), "ret", + maybe_cfi!(".cfi_endproc"), ); } #[cfg(not(target_feature = "d"))] unsafe { core::arch::naked_asm!( + maybe_cfi!(".cfi_startproc"), " mv t0, sp add sp, sp, -0x110 @@ -217,6 +226,7 @@ pub extern "C-unwind" fn save_context(f: extern "C" fn(&mut Context, *mut ()), p maybe_cfi!(".cfi_def_cfa_offset 0"), maybe_cfi!(".cfi_restore ra"), "ret", + maybe_cfi!(".cfi_endproc"), ); } } diff --git a/src/unwinder/arch/x86.rs b/src/unwinder/arch/x86.rs index 5b471a5..f576add 100644 --- a/src/unwinder/arch/x86.rs +++ b/src/unwinder/arch/x86.rs @@ -61,6 +61,7 @@ pub extern "C-unwind" fn save_context(f: extern "C" fn(&mut Context, *mut ()), p // No need to save caller-saved registers here. unsafe { core::arch::naked_asm!( + maybe_cfi!(".cfi_startproc"), "sub esp, 52", maybe_cfi!(".cfi_def_cfa_offset 56"), " @@ -97,6 +98,7 @@ pub extern "C-unwind" fn save_context(f: extern "C" fn(&mut Context, *mut ()), p ", maybe_cfi!(".cfi_def_cfa_offset 4"), "ret", + maybe_cfi!(".cfi_endproc"), ); } } diff --git a/src/unwinder/arch/x86_64.rs b/src/unwinder/arch/x86_64.rs index 1e9bc21..0c819aa 100644 --- a/src/unwinder/arch/x86_64.rs +++ b/src/unwinder/arch/x86_64.rs @@ -63,6 +63,7 @@ pub extern "C-unwind" fn save_context(f: extern "C" fn(&mut Context, *mut ()), p // No need to save caller-saved registers here. unsafe { core::arch::naked_asm!( + maybe_cfi!(".cfi_startproc"), "sub rsp, 0x98", maybe_cfi!(".cfi_def_cfa_offset 0xA0"), " @@ -91,7 +92,8 @@ pub extern "C-unwind" fn save_context(f: extern "C" fn(&mut Context, *mut ()), p add rsp, 0x98 ", maybe_cfi!(".cfi_def_cfa_offset 8"), - "ret" + "ret", + maybe_cfi!(".cfi_endproc"), ); } }