Home

Awesome

Capstone2LlvmIR

A C++ library and tool for translating binary instructions to LLVM IR using Capstone disassembler.

At the moment, the library can translate the following instruction sets:

This repository contains the following libraries:

This repository contains the following tools:

Usage Example

Capstone2LlvmIR Library

For usage examples of Capstone2LlvmIR library, see implementation of capstone2llvmirtool (in src/capstone2llvmirtool) and capstone2llvmir unit tests (in tests/capstone2llvmir).

Capstone2LlvmIR Tool

To translate two x86 instructions add eax, eax; mov ebx, eax in 32-bit mode located at address 0x1234 into LLVM IR code in file out.ll run:

./capstone2llvmir -a x86 -m 32 -b 0x1234 -t "add eax, eax; mov ebx, eax" -o out.ll

To translate an ARM instruction, in ARM mode, encoded as 04 10 81 e2 located at the default address into LLVM IR code in file out.ll run:

./capstone2llvmir -a arm -m arm -c "04 10 81 e2" -o out.ll

Run ./capstone2llvmir --help to list all the available options.

Requirements

Build and Installation

You must pass the following parameters to cmake:

You can pass the following additional parameters to cmake:

Library Use

Adding Capstone2LlvmIR to your project via git submodule

A single target named capstone2llvmir is exposed. It can be used as follows:

target_link_libraries(project-that-needs-capstone2llvmir capstone2llvmir)

Using Capstone2LlvmIR via CMake find_package command

Not supported at the moment.

API Documentation

You can generate the API documentation by yourself. Pass -DCAPSTONE2LLVMIR_DOC=ON to cmake and run make doc.

License

Copyright (c) 2017 Avast Software, licensed under the MIT license. See the LICENSE file for more details.

Capstone2LlvmIR uses third-party libraries or other resources listed, along with their licenses, in the LICENSE-THIRD-PARTY file.

Contributing

See RetDec contribution guidelines.