mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
feature/python-trace
Add support for tracing onto the PipelineC. This is done by: 1. Creating wrapper functions for each PipelineC function with the script in `scripts/PipelineC_add_tracing.py`. These will call a special function called `wrap` which will ultimately call a method with a `_` prepended to the name 2. Conversion of all PipelineC methods in `PipelineC.cpp` to `static` and their rename with a `_` in front, in order for them to work with the wrapper function in (1) 3. Generation of 2 additional include files, one for types and one for functions, to be used by users of tracing files in order to have introspection. These steps allow the creation of a trace file with the use of the `REVNG_C_API_TRACE_PATH` environment variable. The traces can then be used in conjunction with the `revng trace run` and `revng trace inspect` commands.
Purpose
revng is a static binary translator. Given a input ELF binary for one of the supported architectures (currently i386, x86-64, MIPS, ARM, AArch64 and s390x) it will analyze it and emit an equivalent LLVM IR. To do so, revng employs the QEMU intermediate representation (a series of TCG instructions) and then translates them to LLVM IR.
How to build
revng employs CMake as a build system.
In order to build revng, use orchestra and make sure you're building revng from source.
You can install as follows:
orc install revng
Remember to enter an orc shell to run revng:
orc shell
revng --help
You can run the test suite as follows:
orc install --test revng
Example run
The simplest possible example consists in the following:
# Install revng
orc install revng
# Install the ARM toolchain
orc install toolchain/arm/gcc
# Enter in the build directory
orc shell -c revng
# Build
ninja
# Create hello world program
cat > hello.c <<EOF
#include <stdio.h>
int main(int argc, char *argv[]) {
printf("Hello, world!\n");
}
EOF
# Compile
armv7a-hardfloat-linux-uclibceabi-gcc \
-Wl,-Ttext-segment=0x20000 \
-static hello.c \
-o hello.arm
# Translate
./bin/revng translate hello.arm
# Run translated version
./hello.arm.translated
# Hello, world!
Languages
C++
77.1%
Python
12.6%
MLIR
4.4%
CMake
1.9%
LLVM
1.4%
Other
2.5%