I'm just experimenting with some JIT compilation, using the asmjit
library.
Specifically, I want to call a member function of a class instance using the address of that instance as an argument for the jitted function.
I understand that I have to use the address as the first parameter of the object (given a member function without any arguments, the address will be the only parameter).
For that reason, I mov
the address into rdi
.
The problem is, that I do not know how the compiler (clang-12
in my case) named the function I want to call.
Calling global functions (or static ones) seems simple by getting the function pointer and call
ing that one (tried that successfully), but what about (non-static) member functions?
Looks like clang
does not name those functions regularly. I found that the compiler uses addresses to call those functions like call 407180 <_ZNK3Foo5printEv>
(where Foo::print()
is the function I want to call, located at 407180
). Is there any way to call the function by name or get the function pointer to the class?