[llvm-dev] Can I use the JIT interface to create trampolines? (For functions and global values)
Gaier, Bjoern via llvm-dev
llvm-dev at lists.llvm.org
Thu May 9 02:04:49 PDT 2019
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");
llvm::ConstantInt::get(llvm::IntegerType::get(context, 64), 0xF),
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
Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Takashi Nagano, Takeshi Fukushima. Junichi Tajika
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev