Open source binary analysis tools.
Go to file
Brett Boston a5796fc955
Reverse syscall override return register ordering (#284)
When a user overrides a system call on an architecture that supports returning two values from a system call and they provide a context containing the result of the system call in the form

```
empty :> v0 :> v1
```

macaw will perform the register assignment

```
r0 := v1
r1 := v0
```

This change reverses this behavior so that the assignment becomes

```
r0 := v0
r1 := v1
```

This brings the expected ordering of the result context in agreement
with the left-to-right ordering of the argument context:

```
empty :> arg1 :> arg2 :> ...
```
2022-05-04 12:41:02 -07:00
.github generalize treatment for terminal statements in CFG slicing code (#278) 2022-04-20 10:08:15 -07:00
base Adapt to dynSymEntry being definition-aware in elf-edit 2022-04-19 12:47:24 -04:00
deps Bump ASL revision to handle slicing issues with UBFX instruction on ARM (#280) 2022-04-20 10:08:36 -07:00
doc Documentation updates 2018-05-21 17:53:01 -07:00
macaw-aarch32 Reverse syscall override return register ordering (#284) 2022-05-04 12:41:02 -07:00
macaw-aarch32-symbolic Bump ASL revision to handle slicing issues with UBFX instruction on ARM (#280) 2022-04-20 10:08:36 -07:00
macaw-ppc Update with changes flowing from GaloicInc/crucible#945. 2022-01-24 16:24:07 -08:00
macaw-ppc-symbolic Only fix personality to (MS.MacawSimulatorState sym) where required. 2022-02-21 13:27:20 -05:00
macaw-riscv Reverse syscall override return register ordering (#284) 2022-05-04 12:41:02 -07:00
macaw-semmc Update with changes flowing from GaloicInc/crucible#945. 2022-01-24 16:24:07 -08:00
refinement generalize treatment for terminal statements in CFG slicing code (#278) 2022-04-20 10:08:15 -07:00
scripts update test script to use asl-lite 2020-03-25 15:40:42 -07:00
symbolic generalize treatment for terminal statements in CFG slicing code (#278) 2022-04-20 10:08:15 -07:00
utils/compare-dwarfdump Cleanup compare-dwarfdump; bump submodules. 2021-05-26 07:25:51 -07:00
x86 Reverse syscall override return register ordering (#284) 2022-05-04 12:41:02 -07:00
x86_symbolic generalize treatment for terminal statements in CFG slicing code (#278) 2022-04-20 10:08:15 -07:00
.gitignore Fix .gitignore update. 2021-04-03 18:16:25 -07:00
.gitmodules Add RISC-V backend (#259) 2022-03-04 12:44:46 -08:00
cabal.project.dist Add RISC-V backend (#259) 2022-03-04 12:44:46 -08:00
cabal.project.freeze.ghc-8.8.4 Add RISC-V backend (#259) 2022-03-04 12:44:46 -08:00
cabal.project.freeze.ghc-8.10.7 Add RISC-V backend (#259) 2022-03-04 12:44:46 -08:00
cabal.project.freeze.ghc-9.0.2 Add RISC-V backend (#259) 2022-03-04 12:44:46 -08:00
cabal.project.werror ci: Have the CI build and test more things (#181) 2020-12-19 17:16:04 -08:00
LICENSE Update license dates 2020-11-12 23:43:38 -08:00
README.md Add RV32GC support to macaw-riscv (#269) 2022-03-21 14:08:50 -07:00

This is the main repository for the Macaw binary analysis framework. This framework is implemented to offer extensible support for architectures.

Overview

The main algorithm implemented so far is a code discovery procedure which will discover reachable code in the binary given one or more entry points such as _start or the current symbols.

The Macaw libraries are:

  • macaw-base -- The core architecture-independent operations and algorithms.
  • macaw-symbolic -- Library that provides symbolic simulation of Macaw programs via Crucible.
  • macaw-x86 -- Provides definitions enabling Macaw to be used on X86_64 programs.
  • macaw-x86-symbolic -- Adds Macaw-symbolic extensions needed to support x86.
  • macaw-semmc -- Contains the architecture-independent components of the translation from semmc semantics into macaw IR. This provides the shared infrastructure for all of our backends; this will include the Template Haskell function to create a state transformer function from learned semantics files provided by the semmc library.
  • macaw-arm -- Enables macaw for ARM (32-bit) binaries by reading the semantics files generated by semmc and using Template Haskell to generate a function that transforms machine states according to the learned semantics.
  • macaw-arm-symbolic -- Enables macaw/crucible symbolic simulation for ARM (32-bit) architectures.
  • macaw-ppc -- Enables macaw for PPC (32-bit and 64-bit) binaries by reading the semantics files generated by semmc and using Template Haskell to generate a function that transforms machine states according to the learned semantics..
  • macaw-ppc-symbolic -- Enables macaw/crucible symbolic simulation for PPC architectures
  • macaw-riscv -- Enables macaw for RISC-V (RV32GC and RV64GC variants) binaries.
  • macaw-refinement -- Enables additional architecture-independent refinement of code discovery. This can enable discovery of more functionality than is revealed by the analysis in macaw-base.

The libraries that make up Macaw are released under the BSD license.

These Macaw core libraries depend on a number of different supporting libraries, including:

  • elf-edit -- loading and parsing of ELF binary files
  • galois-dwarf -- retrieval of Dwarf debugging information from binary files
  • flexdis86 -- disassembly and semantics for x86 architectures
  • dismantle -- disassembly for ARM and PPC architectures
  • semmc -- semantics definitions for ARM and PPC architectures
  • crucible -- Symbolic execution and analysis
  • what4 -- Symbolic representation for the crucible backend
  • parameterized-utils -- utilities for working with parameterized types

Building

Preparation

Dependencies for building Macaw that are not obtained from Hackage are supported via Git submodules:

$ git submodule update --init

Preparing Softfloat for RISC-V Backend

The RISC-V backend depends on softfloat-hs, which in turn depends on the softfloat library. Macaw's build system will automatically build softfloat, but the softfloat-hs repo must be recursively cloned to enable this. If you are not building macaw-riscv you can skip this step. To recursively clone softfloat-hs, run:

$ cd deps/softfloat-hs
$ git submodule update --init --recursive

Building with Cabal

The Macaw libraries can be individually built with Cabal v1, but as a group and more easily with Cabal v2:

$ ln -s cabal.project.dist cabal.project
$ cabal v2-configure
$ cabal v2-build all

To build a single library, either specify that library name instaed of all, or change to that library's subdirectory before building:

$ cabal v2-build macaw-refinement

or

$ cd refinement
$ cabal v2-build

Building with Stack

To build with Stack, first create a top-level stack.yaml file by symlinking to one of the provided stack-ghc-<version>.yaml files. E.g.

$ ln -s stack-ghc-8.6.3.yaml stack.yaml
$ stack build

Status

This codebase is a work in progress. Support for PowerPC support (both 32 and 64 bit) and X86_64 is reasonably robust. Support for ARM is ongoing.

Notes on Freeze Files

We use the cabal.project.freeze.ghc-* files to constrain dependency versions in CI. We recommand using the following command for best results before building locally:

ln -s cabal.GHC-<VER>.config cabal.project.freeze

These freeze files were generated using the .github/update-freeze script. Note that at present, these configuration files assume a Unix-like operating system, as we do not currently test Windows on CI. If you would like to use these configuration files on Windows, you will need to make some manual changes to remove certain packages and flags:

regex-posix
tasty +unix
unix
unix-compat

License

This code is made available under the BSD3 license and without any support.