GrammaTech / ddisasm

A fast and accurate disassembler
https://grammatech.github.io/ddisasm/
GNU Affero General Public License v3.0
645 stars 60 forks source link

Question: How to perform "reduce" on the binary #32

Closed swang206 closed 3 years ago

swang206 commented 3 years ago

I just saw in an introduction of gtirb and ddisasm that they can perform "reduce" that remove some features in the binary, or debloat binary. How to use "reduce" and "debloating" with ddisasm???

swang206 commented 3 years ago

https://eschulte.github.io/data/debloat-datasheet.pdf

kwarrick commented 3 years ago

Hi @swang206,

Binary transforms (i.e. "reduce") aren't part of ddisasm proper. They are implemented independently with the GTIRB API.

You might consider it a pipeline:

binary -> [ ddisasm ] -> gtirb -> [ transform ] -> gtirb' -> [ gtirb-pprinter ] -> assembly ...

You can write [ transform ]s to arbitrarily manipulate the GTIRB file in the API of your choice (i.e. Python, C++, CL), but there is also a higher-level "rewriting" API: gtirb-rewriting.

These examples might interest you as well: