Zhang Qiuyu
2004-Sep-21 19:31 UTC
[LLVMdev] Re: Re: How could I get memory address for each assemble
Thanks Andrew. I still do not understand your method. Would you mind telling me more? Thanks. But for hash problem, it is common problem for hash. We cannot make sure the mapping is 1 to 1. I used a way to grab the BB address, but there is some limitation. What I did is that I rewrote some part of disassemble tool. During the disassembling, I check all the conditional/unconditional instruction, usually with 'j' and call instruction. Once disassemble tool hits the instruction I interested in, I calculate the target address from the instruction. So the target address must be a entry of BB and I also need calculate the address which follow the 'j' instruction, that is another address for BB address. In other words, for each 'j' instruction I can extract two entries for BB. But for call instruction, it is different and I can grab one address of entry for BB. That's what I did. The limitation is that for some case, for example, the instruction look like call %eax jmp %eax I cannot grab the entry address of BB :(. When I use llvm, llvm can get the entry for this case, how could llvm get. I haven't read the code. Any opinion is welcome. Hope it useful. Qiuyu> This can be done with a quick hack. Just modify the assembly printer to > emit a symbol that encodes the basic block uniquely. I have had to do > something similar, and I take the function name (with full type > information) and the label of the BB and hash them with crc32. This > gives a unique int which you can use in a label (which you output) to > uniquely identify the entry point of a basic block. There are problems > if the hash is not unique or if there is not a 1-1 mapping of BB to > machine BB or if a function is defined in multiple modules with the > exact same type. > > Anyway, it's a start. > > Andrew > > > On Mon, 2004-09-20 at 17:02, Zhang Qiuyu wrote: > > > > Thanks John and Chris. > > > > I could get the address information by the way you guys mentioned. But > > it is not what I want, because it will lose information about the > > entry of basic block. Actually what I want to get is the address of > > each entry of basic block. Now I am trying to declare the label of > > basic block as global type, hopefully I can get it from symbol table. > > Can I get it by this way? > > > > Thanks > > > > >For example, > > > > >llc -o file.s file.bc > > >gcc -o file.o file.s > > >objdump -d file.o > > > > >This would produce the list of native code instructions generated by > > >llc, including the addresses of the native code instructions. > > > > >Is this the sort of answer you're looking for? > > > > >Hi all, > > > > >I am trying to disassemble *.bc to assemble code by using llvm-dis > > command, but what I got is like the following. So how >could I get the > > assemble code like objdump? I mean the memory address for each > > instruction. > > > > >Thanks > > > > >Qiuyu > >
Apparently Analagous Threads
- [LLVMdev] Re: How could I get memory address for each assemble code?
- [LLVMdev] How could I get memory address for each assemble instruction?
- [LLVMdev] The story is for why I need grab the entry address of BB :)
- [LLVMdev] Question About inserting Instruction?
- [LLVMdev] How could I get memory address for each basic block?