Direct C function call using GCC's inline assembly
I got the answer from GCC's mailing list:
asm("call %P0" : : "i"(callee));
Now I just need to find out what %P0
actually means because it seems to be an undocumented feature...
Edit: After looking at the GCC source code, it's not exactly clear what the code P
in front of a constraint means. But, among other things, it prevents GCC from putting a $
in front of constant values. Which is exactly what I need in this case.
Maybe I am missing something here, but
extern "C" void callee(void)
{
}
void caller(void)
{
asm("call callee\n");
}
should work fine. You need extern "C" so that the name won't be decorated based on C++ naming mangling rules.