Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Source-to-source compilation with LLVM [closed]

I need to convert x86 assembly source code to LLVM human-readable .ll file (aka LLVM assembly language). How can I do this? If there is no direct solution would it be possible to implement one within the LLVM infrastructure with as less efforts as possible?

I guess, the solution I'm looking for should be some kind of llc's counterpart that converts .s file back to .ll representation.

like image 848
bsa2000 Avatar asked Jan 26 '12 05:01

bsa2000


1 Answers

Just for those who are still seeking for more information on this topic, I want to share the information about one ongoing project (http://dslab.epfl.ch/proj/s2e) that I've found on the web. The project has two components:

  1. x86-to-LLVM backend for dynamic translation of x86 machine code to LLVM IR
  2. RevGen tool for static analysis of x86 binaries, capable of translating inline x86 assembly to LLVM IR

Here is RevGen prototype: RevGen takes as input an x86 binary and outputs an equivalent LLVM module in three steps. First, RevGen looks for all executable blocks of code and converts them to LLVM translation blocks. Second, when there are no more translation blocks to cover, RevGen transforms them into basic blocks and rebuilds the control flow graph of the original binary in LLVM format. Third, RevGen resolves external function calls to build the final LLVM module. For dynamic analysis, a last step links the LLVM module with a run-time library that allows the execution of the LLVM module.

like image 63
bsa2000 Avatar answered Nov 14 '22 19:11

bsa2000