Zhang Qiuyu
2004-Sep-13 20:33 UTC
[LLVMdev] How could I get memory address for each assemble instruction?
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 llvm-dis: .text .align 16 .globl adpcm_coder .type adpcm_coder, @function adpcm_coder: .LBBadpcm_coder_0: # entry sub %ESP, 116 mov DWORD PTR [%ESP + 12], %ESI mov %EAX, DWORD PTR [%ESP + 120] mov %ECX, DWORD PTR [%ESP + 124] mov %EDX, DWORD PTR [%ESP + 128] mov %ESI, DWORD PTR [%ESP + 132] mov DWORD PTR [%ESP], 0 mov DWORD PTR [%ESP + 44], %EAX mov DWORD PTR [%ESP + 40], %ECX objdump : 08048720 <adpcm_coder>: 8048720: 83 ec 74 sub $0x74,%esp 8048723: 89 74 24 0c mov %esi,0xc(%esp,1) 8048727: 8b 44 24 78 mov 0x78(%esp,1),%eax 804872b: 8b 4c 24 7c mov 0x7c(%esp,1),%ecx 804872f: 8b 94 24 80 00 00 00 mov 0x80(%esp,1),%edx 8048736: 8b b4 24 84 00 00 00 mov 0x84(%esp,1),%esi 804873d: c7 04 24 00 00 00 00 movl $0x0,(%esp,1) 8048744: 89 44 24 2c mov %eax,0x2c(%esp,1) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20040913/9ea528ab/attachment.html>
John Criswell
2004-Sep-13 20:39 UTC
[LLVMdev] How could I get memory address for each assemble instruction?
Zhang Qiuyu wrote:> > 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. >The LLVM disassembler (llvm-dis) generates a human readable list of LLVM assembly instructions representing the bytecode instructions inside of the .bc file. LLVM instructions really don't have addresses, so there is no equivalent functionality in llvm-dis. If you want to generate machine code and then disassemble it to see the native instructions, you can use llc on the bytecode to generate native assembly language. Then you can assemble and disassemble the native code with gcc (really, as) and objdump, respectively. 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? -- John T.> Thanks > > Qiuyu > > > llvm-dis: > .text > .align 16 > .globl adpcm_coder > .type adpcm_coder, @function > adpcm_coder: > .LBBadpcm_coder_0: # entry > sub %ESP, 116 > mov DWORD PTR [%ESP + 12], %ESI > mov %EAX, DWORD PTR [%ESP + 120] > mov %ECX, DWORD PTR [%ESP + 124] > mov %EDX, DWORD PTR [%ESP + 128] > mov %ESI, DWORD PTR [%ESP + 132] > mov DWORD PTR [%ESP], 0 > mov DWORD PTR [%ESP + 44], %EAX > mov DWORD PTR [%ESP + 40], %ECX > > objdump : > 08048720 <adpcm_coder>: > 8048720: 83 ec 74 sub $0x74,%esp > 8048723: 89 74 24 0c mov %esi,0xc(%esp,1) > 8048727: 8b 44 24 78 mov 0x78(%esp,1),%eax > 804872b: 8b 4c 24 7c mov 0x7c(%esp,1),%ecx > 804872f: 8b 94 24 80 00 00 00 mov 0x80(%esp,1),%edx > 8048736: 8b b4 24 84 00 00 00 mov 0x84(%esp,1),%esi > 804873d: c7 04 24 00 00 00 00 movl $0x0,(%esp,1) > 8048744: 89 44 24 2c mov %eax,0x2c(%esp,1) > > > ------------------------------------------------------------------------ > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev-- ********************************************************************* * John T. Criswell Email: criswell at uiuc.edu * * Research Programmer * * University of Illinois at Urbana-Champaign * * * * "It's today!" said Piglet. "My favorite day," said Pooh. * *********************************************************************
Chris Lattner
2004-Sep-13 20:48 UTC
[LLVMdev] How could I get memory address for each assemble instruction?
On Mon, 13 Sep 2004, Zhang Qiuyu wrote:> > 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.That looks like llc output, not llvm-dis output. In any case, you should be able to do something like this: llc x.bc -o x.s gcc x.s -o x objdump <whatever> x -Chris> llvm-dis: > .text > .align 16 > .globl adpcm_coder > .type adpcm_coder, @function > adpcm_coder: > .LBBadpcm_coder_0: # entry > sub %ESP, 116 > mov DWORD PTR [%ESP + 12], %ESI > mov %EAX, DWORD PTR [%ESP + 120] > mov %ECX, DWORD PTR [%ESP + 124] > mov %EDX, DWORD PTR [%ESP + 128] > mov %ESI, DWORD PTR [%ESP + 132] > mov DWORD PTR [%ESP], 0 > mov DWORD PTR [%ESP + 44], %EAX > mov DWORD PTR [%ESP + 40], %ECX > > > objdump : > 08048720 <adpcm_coder>: > 8048720: 83 ec 74 sub $0x74,%esp > 8048723: 89 74 24 0c mov %esi,0xc(%esp,1) > 8048727: 8b 44 24 78 mov 0x78(%esp,1),%eax > 804872b: 8b 4c 24 7c mov 0x7c(%esp,1),%ecx > 804872f: 8b 94 24 80 00 00 00 mov 0x80(%esp,1),%edx > 8048736: 8b b4 24 84 00 00 00 mov 0x84(%esp,1),%esi > 804873d: c7 04 24 00 00 00 00 movl $0x0,(%esp,1) > 8048744: 89 44 24 2c mov %eax,0x2c(%esp,1) > >-Chris -- http://llvm.org/ http://nondot.org/sabre/
Reasonably Related Threads
- [LLVMdev] Re: How could I get memory address for each assemble code?
- [LLVMdev] question about compile path
- [LLVMdev] How could I get memory address for each basic block?
- [LLVMdev] Could I get bytecode of SPEC ?
- [LLVMdev] How could I get memory address for each basic block?