Coder Social home page Coder Social logo

llvm-mctoll's Introduction

Introduction

This tool statically (AOT) translates (or raises) binaries to LLVM IR.

Getting Started (Linux)

Building as part of LLVM tree

  1. mkdir $PWD/src && mkdir -p $PWD/build/llvm && cd src

  2. git clone https://github.com/llvm-mirror/llvm && pushd llvm && git checkout master && popd

  3. pushd llvm/tools && git clone https://github.com/llvm-mirror/clang && git checkout master && popd

  4. pushd llvm/tools && git clone https://github.com/Microsoft/llvm-mctoll && git checkout master && popd

  5. cd ../build/llvm

  6. Run cmake command to create build files (make or ninja) with default build type (Debug).

    Support for X86-64 and ARM raisers will be built into the tool based on the LLVM build targets. There is no interdependency. Consequently, support to raise only X86-64 binaries is built during X86-only LLVM builds; support to raise only ARM binaries is built during ARM-only LLVM builds. The tool is not built during an LLVM build with targets that do not include either X86 or ARM.

    For e.g., either of the following cmake commands is known to build the tool and its dependencies.

    cmake -G "Ninja" -DCMAKE_INSTALL_PREFIX=</full/path/to/github/install/llvm> </full/path/to/github/src/llvm> -DLLVM_TARGETS_TO_BUILD="TARGET_ARCH"

    cmake -G "Ninja" -DCMAKE_INSTALL_PREFIX=</full/path/to/github/install/llvm> </full/path/to/github/src/llvm>

    The corresponding cmake commands known to work for Release builds are as follows:

    cmake -G "Ninja" -DCMAKE_INSTALL_PREFIX=</full/path/to/github/install/llvm> </full/path/to/github/src/llvm> -DLLVM_TARGETS_TO_BUILD="TARGET_ARCH" -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_DUMP=ON -DLLVM_ENABLE_ASSERTIONS=ON

    cmake -G "Ninja" -DCMAKE_INSTALL_PREFIX=</full/path/to/github/install/llvm> </full/path/to/github/src/llvm> -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_DUMP=ON -DLLVM_ENABLE_ASSERTIONS=ON

    You may also use the option -G "Unix Makefiles" instead of -G "Ninja".

  7. Run make llvm-mctoll or ninja llvm-mctoll

Note :

  1. The current tip of llvm-mctoll is tested using the commits recorded in LLVMVersion.txt. Make sure the corresponding repos used in your build correspond to those listed.

Usage

To generate LLVM IR for a binary:

llvm-mctoll -d <binary>

The raised result is generated as <binary>-dis.ll.

To check the correctness of <binary>-dis.ll

  1. compile <binary>-dis.ll to an executable (or to a shared library if <binary> is a shared library) using clang.
  2. run the resulting executable (or use the resulting shared library <binary>-dis in place of <binary>) to verify that its execution behavior is identical to that of the original <binary>.

Tests in the tool repository are written following the above described methodology.

To print debug output:

llvm-mctoll -d -print-after-all <binary>

Build and Test

Run the tests by invoking make check-mctoll or ninja check-mctoll

At present, the development and testing are done on Ubuntu 18.04. It is expected that build and test would work on Ubuntu 16.04, 17.04 and 17.10.

The tool is also known to build and run tests successfully on CentOS 7.5.

Current Status

At present, the tool is capable of raising Linux X86-64 and Arm32 shared libraries and executables with function calls that have variable arguments (such as printf) to LLVM IR.

Raising of C++ binaries needs to be added.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

llvm-mctoll's People

Contributors

bharadwajy avatar aaronsm avatar yaoxiaocc avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.