I am wrapping a low-level ABI in Rust using a function function naked. Here is my code and related disassembly
#![feature(asm)]
#![feature(naked_functions)]
struct MyStruct {
someVar: i64,
}
impl MyStruct {
#[naked]
extern "C" fn wrap(&self) {
unsafe {
asm!("NOP" :::: "volatile");
}
}
}
Parsing with LLDB:
ABIWrap`ABIWrap::{{impl}}::wrap:
* 0x100001310 <+0>: movq %rdi, -0x10(%rbp)
* 0x100001314 <+4>: movq %rsi, -0x8(%rbp)
* 0x100001318 <+8>: movq -0x10(%rbp), %rax
* 0x10000131c <+12>: movq -0x8(%rbp), %rcx
* 0x100001320 <+16>: movq %rax, -0x20(%rbp)
* 0x100001324 <+20>: movq %rcx, -0x18(%rbp)
0x100001328 <+24>: nop
0x100001329 <+25>: retq
0x10000132a <+26>: nopw (%rax,%rax)
6 lines preceding NOP (I marked *), I am confused. Should the directive nakedgo away due to the lack of a better term, a bare function?
I am trying to allow the arguments to simply go through this function in the ABI, since this roughly corresponds to the same call as Rust, I just need to change one or two registers, hence the built-in assembly.
6 ? ABI, , , . , , - , .
: "" ? , .