I'm trying to call a golang function from my C code. Golang does not use the standard x86_64 calling convention, so I have to resort to implementing the transition myself. As gcc does not want to mix cdecl with the x86_64 convention, I'm trying to call the function using inline assembly:
void go_func(struct go_String filename, void* key, int error){
void* f_address = (void*)SAVEECDSA;
asm volatile(" sub rsp, 0xe0; \t
\
mov [rsp+0xe0], rbp; \t
\
mov [rsp], %0; \t
\
mov [rsp+0x8], %1; \t
\
mov [rsp+0x18], %2; \t
\
call %3; \t
\
mov rbp, [rsp+0xe0]; \t
\
add rsp, 0xe0;"
:
: "g"(filename.str), "g"(filename.len), "g"(key), "g"(f_address)
: );
return;
}
Sadly the compiler always throws an error at me that I dont understand:
./code.c:241: Error: too many memory references for `mov'
mov [rsp+0x18], %2; \t
\
I'm compiling with the -masm=intel flag so I use Intel syntax. Can someone please help me?