Michael.Kang
2011-Mar-14 09:09 UTC
[LLVMdev] How to load a data from the address of unsiged long type
Now I have an address that present in a unsigned long address like the following format: Value* addr = CONST(0xc0008000) But I do not know how to read the data from the above addr varaible. I tried the following three kind of code: 1. Code: Value* addr = CONST(0xc0008000); Value* data = new LoadInst(addr, "", false, bb); Error: Segmentation fault 2. Code( use BotVastInst to vern): Value* addr = CONST(0xc0008000); a = new BitCastInst(a, PointerType::get(XgetType(Int32Ty), 0), "", bb); Value* data = new LoadInst(addr, "", false, bb); Error: Bitcast requires types of same width 3. Code: Type const *intptr_type cpu->dyncom_engine->exec_engine->getTargetData()->getIntPtrType(_CTX()); Value* ptr = new IntToPtrInst(a, intptr_type, "", bb); Value* data = new LoadInst(ptr, "", false, bb); Error: Segmentation fault Any person can give me some hints for my case? Thanks MK -- www.skyeye.org
Duncan Sands
2011-Mar-14 10:57 UTC
[LLVMdev] How to load a data from the address of unsiged long type
Hi Michael,> Now I have an address that present in a unsigned long address like the > following format: > Value* addr = CONST(0xc0008000)what is the type of addr? For that matter, what is CONST - what does it do? Ciao, Duncan.> > But I do not know how to read the data from the above addr varaible. I > tried the following three kind of code: > 1. Code: > Value* addr = CONST(0xc0008000); > Value* data = new LoadInst(addr, "", false, bb); > Error: > Segmentation fault > 2. Code( use BotVastInst to vern): > Value* addr = CONST(0xc0008000); > a = new BitCastInst(a, PointerType::get(XgetType(Int32Ty), 0), "", bb); > Value* data = new LoadInst(addr, "", false, bb); > Error: > Bitcast requires types of same width > 3. Code: > Type const *intptr_type > cpu->dyncom_engine->exec_engine->getTargetData()->getIntPtrType(_CTX()); > Value* ptr = new IntToPtrInst(a, intptr_type, "", bb); > Value* data = new LoadInst(ptr, "", false, bb); > Error: > Segmentation fault > > > Any person can give me some hints for my case? > > Thanks > MK >
Michael.Kang
2011-Mar-15 01:36 UTC
[LLVMdev] How to load a data from the address of unsiged long type
On Mon, Mar 14, 2011 at 6:57 PM, Duncan Sands <baldrick at free.fr> wrote:> Hi Michael, > >> Now I have an address that present in a unsigned long address like the >> following format: >> Value* addr = CONST(0xc0008000) > > what is the type of addr? For that matter, what is CONST - what does it do? > > Ciao, Duncan.I forget to interpret the CONST macro .It is defined as the following: ConstantInt::get(getIntegerType(s), v) It is used to transform a C language int type to llvm Integer type. Thanks MK> >> >> But I do not know how to read the data from the above addr varaible. I >> tried the following three kind of code: >> 1. Code: >> Value* addr = CONST(0xc0008000); >> Value* data = new LoadInst(addr, "", false, bb); >> Error: >> Segmentation fault >> 2. Code( use BotVastInst to vern): >> Value* addr = CONST(0xc0008000); >> a = new BitCastInst(a, PointerType::get(XgetType(Int32Ty), 0), "", bb); >> Value* data = new LoadInst(addr, "", false, bb); >> Error: >> Bitcast requires types of same width >> 3. Code: >> Type const *intptr_type >> cpu->dyncom_engine->exec_engine->getTargetData()->getIntPtrType(_CTX()); >> Value* ptr = new IntToPtrInst(a, intptr_type, "", bb); >> Value* data = new LoadInst(ptr, "", false, bb); >> Error: >> Segmentation fault >> >> >> Any person can give me some hints for my case? >> >> Thanks >> MK >> > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-- www.skyeye.org
Maybe Matching Threads
- [LLVMdev] How to load a data from the address of unsiged long type
- [LLVMdev] How to read memory data througn adress of unsigned long
- [LLVMdev] How to read memory data througn adress of unsigned long
- runStaticConstructorsDestructors() causes crash on exit
- creating a callinst to an external function