Dear LLVM-Mailing list (again),
I still have another beginners question in my mind - thank you for your patience.
Again I was playing around, but this time with llvm::Function. In an older question I learned, that I can replace a llvm::Function directly with an address.
llvm::Function *function = mainModue->getFunction(“puts”);
function->replaceAllUsesWith(
llvm::ConstantExpr::getIntToPtr(
llvm::ConstantInt::get(llvm::IntegerType::get(context, 64), 0xF),
function->getType()
)
);
With this code I ‘overloaded’ the function “puts” with the address 0xF - that is what I was taught and it is functional. I also noticed that you can do the same with a llvm::GlobalValue - as said I’m still a beginner.
Now I wonder can I replace the use of a specific function with the address of an address? (I think this is called a trampoline)
In C++ I know that I could use a function pointer instead of a function call to achieve this.
So… Deriving from that knowledge I would have to create a function pointer with the same signature as the function I want to replace.
Is this possible with the llvm JIT interface? Can I simply use that value in the “replaceAllUsesWith” function?
And would the same technique also work with a llvm::GlobalValue?
Kind greetings and thank you for the help in advance
Björn