Libvharness is a cross-architecture and cross-platform library to create LibAFL QEMU compatible harnesses. It can be built for a large variety of target architectures, for different OSes, while sharing the same API. Two APIs are supported: LibAFL QEMU (lqemu) and Nyx.
The usual stuff for cmake projects:
mkdir build
cd build
cmake ..
make -j
cmake --install . --prefix <install_path>The library uses the cmake's toolchain files to determine the target options.
Samples are available in toolchains.
It is possible to use them as base to create your own custom toolchain file.
There are a few Cmake variables to modify to adapt the build to your needs.
CMAKE_TOOLCHAIN_FILE: points to one of the files intoolchains, to choose depending on the target arch.VHARNESS_API: eitherlqemuornyx, to choose the target API.
You may also have to configure the right compiler toolchain, using the usual cmake variables for that.
Once the build is done, <install_path> will contain 3 directories: include, lib and src.
lib: contains the static library to link with. Should be linked with your harness.include: the include files to use. there are 2 files that should be interesting to include:lqemu.hif using the LibAFL QEMU API.nyx.hif using the Nyx API.
src: the source files used to compile the library. It only contains the source files used according to the cmake options, not the whole tree.
To ensure maximum compatibility of the library across architectures, a very minimal libc implementation is available: femtolibc.
It is only used for generic toolchains by default, when a full-fledged libc is not considered to be available.
The implementation is not tailored for performance, so it is always better to use another libc when it is available in the toolchain. However, it is not expected to observe major performance overhead in most cases.