#semantics #query #instructions #command-line #server #manipulate #lib-lisa

app liblisa-semantics-tool

A command-line tool that can query and manipulate libLISA's semantics

2 releases

0.1.1 Sep 2, 2024
0.1.0 Aug 30, 2024

#350 in Encoding

Download history 116/week @ 2024-08-26 143/week @ 2024-09-02

259 downloads per month

AGPL-3.0-only

1.5MB
37K SLoC

The liblisa-semantics-tool

The liblisa-semantics-tool is a command-line program that can be used to query libLISA's semantics. It requires the raw semantics that can be downloaded from here.

Installation

Through cargo:

cargo +nightly install liblisa-semantics-tool

Usage

Run the tool with the --help flag to see all possible commands.

Semantics server

One of the main features of the liblisa-semantics-tool is the semantics server. This allows semantics to be queried programmatically via stdin and stdout. The semantics server instantiates semantics: it fills in the correct registers, flags and immediate values from parts in the encoding. If you were using the raw semantics directly, you would have to implement this instantiation yourself.

You can start the server with:

liblisa-semantics-tool server amd-3900x.json

It may take a while to build the lookup table. This process can be cached by passing the --cache lookup-table.cache flag. However, note that no verification is performed to ensure that the loaded cache matches the original semantics.

In order to query the semantics, provide an instruction in hexadecimal form followed by a newline to stdin. A JSON representation of the semantics will be printed to stdout.

The --debug flag enables printing of debugging information to stderr. The JSON schema will be printed to stderr when the binary starts. A human-readable representation of the queried semantics is also printed to stderr.

Other examples

Obtaining the JSON schema of the raw semantics:

liblisa-semantics-tool schema

General statistics of the semantics:

liblisa-semantics-tool get amd-3900x.json stats

Print a single encoding:

liblisa-semantics-tool get amd-3900x.json encoding 00d3

Print all encodings (Note: this prints over a million lines of text):

liblisa-semantics-tool get amd-3900x.json full-encodings

Print only the bitpatterns of all encodings:

liblisa-semantics-tool get amd-3900x.json bitpatterns

Building

Clone the repository and run:

cargo build --release --bin liblisa-semantics-tool

Dependencies

~34MB
~675K SLoC