I need to make an interface (say, a wrapper) that allows calling from X86_64 assembler code, using its calling convention for function C, with a different calling convention. It would be best to be "compiler independent" (juste modifying the wrapper), so I'm looking for something that adds registry / stack elements to the compiler. I already look here: The user calling convention for P / Invoke and C # , and it comes close to what I have to do. I am currently using GCC, but hints from other compilers are welcome!
So, here's what, for a better overview of the problem (weird conditional coding):
pushq %r11
movq 64bits_address %r11
callq *8(%r11)
popq %r11
I need to be able to call the "special" (wrapping) function C; here the task will direct calls between other functions of C. Therefore, this shell needs to find% r11, save all the registers and prepare the stack for further calls. Is there a proper way to do this in C (with some built-in asm)?
thanks a lot
source
share