[LLVMdev] How could I get memory address for each assemble instruction?
John Criswell
criswell at cs.uiuc.edu
Mon Sep 13 13:39:39 PDT 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.
>
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. *
*********************************************************************
More information about the llvm-dev
mailing list