Binary translation to LLVM bitcode

I'm looking for methods for generating LLVM bitcode from binaries (binary translation). I found two projects that seem to be related: vmkit and llvm-qemu

a) Could someone shed some light on how the recently released vmkit works? Can vmkit be used for statically translating JVM or MSIL code to LLVM bitcode? Or is vmkit simply reusing LLVM's JIT execution engine, without ever generating LLVM bitcode?

b) What is the state of llvm-qemu (Google Code Archive - Long-term storage for Google Code Project Hosting.)? Could llvm-qemu be used for binary translation of x86 binaries to LLVM bitcode?

I would appreciate any comment.

Best regards,
  Christian

Christian Plessl wrote:

I'm looking for methods for generating LLVM bitcode from binaries (binary translation). I found two projects that seem to be related: vmkit and llvm-qemu

a) Could someone shed some light on how the recently released vmkit works?

vmkit is two things. First, it translates JVM and MSIL bytecodes to LLVM IR. Second, it is a runtime environment for Java apps (a JVM) or .Net apps.

Can vmkit be used for statically translating JVM or MSIL code to LLVM bitcode?

Yes it could. It would require to rewrite the JVM/MSIL to LLVM IR translator as a library (following the LLVM philosophy). The resulting LLVM bitcode file will however need a runtime environment for runtime calls (e.g. malloc) and Java/C# class references.

Or is vmkit simply reusing LLVM's JIT execution engine, without ever generating LLVM bitcode?
  
To use LLVM's JIT execution engine, one needs to emit LLVM bitcode.

Good luck!
Nicolas

llvm-qemu currently translates from ARM machine code to LLVM IR (at
basic block level)
and via the LLVM JIT to x86 machine code. Basically all source
architectures supported by qemu (x86, x86-64, ARM, SPARC, PowerPC, MIPS, m68k)
can be translated to LLVM IR this
way (e.g. adding support for x86 to llvm-qemu should be almost trivial).

For more information I suggest taking a look at this thread which
describes the current state and some of the internals of llvm-qemu:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2008-April/013689.html

Greetings,

Tilmann Scheller