[LLVMdev] hexcode from llvm
Dale Johannesen
dalej at apple.com
Thu May 20 20:29:56 PDT 2010
On May 20, 2010, at 6:18 PM, JayaSus wrote:
>
> Hi Bill Wendling.
> I am trying to get a hexcode as shown below for mips processor using
> llvm
>
> Disassembly of section .text:
>
> 00000000 <main>:
> 0: 27bdffe8 addiu sp,sp,-24
> 4: afbe0010 sw s8,16(sp)
> 8: 03a0f021 move s8,sp
> c: 24020004 li v0,4
> 10: afc20008 sw v0,8(s8)
> 14: 24020005 li v0,5
> 18: afc20004 sw v0,4(s8)
> 1c: 8fc30008 lw v1,8(s8)
> 20: 8fc20004 lw v0,4(s8)
> 24: 00000000 nop
> 28: 00621021 addu v0,v1,v0
> 2c: afc20000 sw v0,0(s8)
> 30: 03c0e821 move sp,s8
> ....
>
> Is there any pass or buildin command for llvm to generate this. llvm-
> dis
> will only generate the assembly code and not the hexcode.
I think what you want is to generate object code (.o file) and
simultaneously produce a dump of the assembly code and the
corresponding object code in hex; I've seen compilers that do that.
llvm does not currently generate object code directly; it only
generates assembly. There are people working on generating object
code directly. I don't know of anybody working on generating the dump
you want, but it should be easy enough once direct object code
generation is in place.
The usual toolchain for what you want is
llvm-gcc -S -> assembler source (.s)
assembler source -> as -> object file (.o)
object file -> disassembler
This can be conveniently hidden in a script. I don't know what the
disassembler is called on mips, though.
llvm-gcc -c generates an object file, but it does this by generating
an assembler source file and invoking the assembler.
> Moreover how can I compile c code for mips using llvm-gcc? llvm-gcc -
> b mips
> t.c complains it wouldn't know the -b option.
Neither do I:) You need to build llvm-gcc so it targets mips.
More information about the llvm-dev
mailing list