context-rs
context-rs copied to clipboard
Inline assembly code
Right now the assembly is in a stand alone .S
file with AT&T style. To easily make it compilable under windows without depending on gcc, i think those code could be inlined inside a Rust function.
Encountered problems:
- Every Rust function will first push
%rbp
onto the stack to save the frame pointer
That's not Rust-specific thing. AFAIK almost any compiler adds code to push/pop stack frame base. It's used mostly to reference arguments located on stack. I wouldn't depend on Rust compiler generating exactly this code every time. For inline assembly to work something like #[naked] is necessary.
And #[inline(always)]
isn't an option - there should be function call, so we'll have return IP on top of stack.