[LLVMdev] how to get and modify a global variable inside a module
hammacher at cs.uni-saarland.de
Wed Dec 5 07:40:22 PST 2012
On 12/5/12 2:49 PM, Dong Chen wrote:
> here is the thing. i want to know the exact main memory address of the
> Global Varibale's address when ExecutionEngine execut the *.ll code. further
> more, i want to change the address, is it possible?
I assume you want to adjust the value at that address, right?
Then you might want to check the ExecutionEngine::getPointerToGlobal
method. You can just cast the void* to the appropriate pointer type, and
write to it.
If you really want to change the address of the GlobalValue (i.e. the
mapping from GlobalValue to main memory address), you can use the
addGlobalMapping or updateGlobalMapping methods, but this should only be
done before JITting any function which uses the GlobalValue. Otherwise
you have to call recompileAndRelinkFunction for each function that uses
More information about the llvm-dev