Description
I'm trying to port some Unix asm!
code, using the .cfi_*
directives inside naked functions to provide information to the unwinder/debugger about call frames, to Windows.
The following code compiles on MacOs and Linux under rustc 1.47.0-nightly (f44c6e4e2 2020-08-24)
:
#[naked]
unsafe extern "C" fn a() {
asm!(".cfi_def_cfa rbp, 16")
}
If I try to do something similar on Windows:
#[naked]
unsafe extern "C" fn a() {
asm!(".seh_setframe rbp, 16")
}
I get: error: .seh_ directive must appear within an active frame
. Only if I add .seh_proc a
, .seh_endproc
and declare the function #[no_mangle]
the code compiles:
#[naked]
#[no_mangle]
unsafe extern "C" fn a() {
asm!(
".seh_proc a",
".seh_setframe rbp, 16",
".seh_endproc"
)
}
I don't think this is correct though, as the return statement in the naked function happens after .seh_endproc
and is excluded from the frame information.
I expect the #[naked]
function to behave the same way on Windows as on Unix platforms, where a cfi_startproc
is implicitly added to #[naked]
functions.