Skip to content

Experiments with opcodes

License

GPL-2.0, Unknown licenses found

Licenses found

GPL-2.0
COPYING
Unknown
COPYING.LIB
Notifications You must be signed in to change notification settings

kromych/opcodes-lab

Repository files navigation

Experiments with binutils'es libopcode

About this project

This repo contains code derived from binutils'es libopcodes, v.2.42. That said, if you fork the code, be sure to license the fork under the GPL v3.

The goal is to generate a JSON file describing ARM64 instructions to be able to decode some in a way that might be not as pretty as what a disassembler produces yet accurate enough for hobbyist/non-professional/educational use.

Building a backend for TableGen or fiddling with the capstone's fork of it felt like a larger investment than it is needed for achieving that goal.

The result JSON file is generated by aarch64-insn-dump.cpp, a quick'n'dirty C++ script-like program (with manual JSON serialization, a shame, really) whose output is formatted with jq. This utility can be used for filtering and queries, too.

To produce the result file, you'll need to use Cmake, no special sauce has been needed at least under macOS and Fedora Linux when using llvm-clang. There are no guarantees of any kind about the content of the result file. You are using it at your own risk; any losses related to using it are on you and you only. You sure can keep the profits to yourself either :).

How to use

Build

mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=c++ ..
make

Run

./tools/dump/aarch64-insn-dump | jq "."

Related art

These are very mature projects with a much broader scope, rigorous testing, overwhelming coverage, and bindings in various languages:

Not a library/API-centric, yet the one and only

Although only x86_64 targeted, nonetheless an incredible one: