Open source binary analysis tools.
Go to file
Ryan Scott 98290062a7 macaw-ppc-symbolic: Add support for simulating syscalls
This adds the necessary changes to `macaw-ppc-symbolic` and `macaw-ppc` in
order to simulate system calls, similarly to how it is done when simulating
x86-64 and AArch32 code:

* In `macaw-ppc`, remove `PPCSyscall` from `TermStmt` and instead make it a
  constructor for `PPCPrimFn`. (Note that there are some minor discrepancies
  between which registers are used in PPC32 versus PPC64, which we explain in
  the Haddocks for the new `PPCSyscall` constructor.)
* Update `macaw-ppc`'s `ppcInstructionMatcher` function so that calls to the
  `sc` (system call) instruction make use of `PPCSyscall`.
* Update `macaw-ppc-symbolic`'s `ppcGenFn` function to make it possible to hook
  into PPC system calls using `MacawLookupSyscallHandle`.

Fixes #387.
2024-08-01 10:34:44 -04:00
.github Implement macaw-riscv-symbolic 2024-07-26 15:25:29 -04:00
base macaw-base: Resolve RISC-V relocations 2024-07-31 10:11:53 -04:00
deps macaw-base: Resolve RISC-V relocations 2024-07-31 10:11:53 -04:00
doc Add some additional documentation (#303) 2022-08-09 18:40:55 -07:00
macaw-aarch32 macaw-{aarch32,ppc}: Remove vestigial InstructionAtUnmappedAddr error types 2023-11-14 13:03:52 -05:00
macaw-aarch32-symbolic aarch32-symbolic: Export AArch32Exception 2024-01-24 11:03:37 -05:00
macaw-ppc macaw-ppc-symbolic: Add support for simulating syscalls 2024-08-01 10:34:44 -04:00
macaw-ppc-symbolic macaw-ppc-symbolic: Add support for simulating syscalls 2024-08-01 10:34:44 -04:00
macaw-riscv macaw-riscv: Add riscvPLTStubInfo 2024-07-31 10:11:53 -04:00
macaw-riscv-symbolic macaw-riscv: Add riscvPLTStubInfo 2024-07-31 10:11:53 -04:00
macaw-semmc Bump submodules to allow building with what4-1.6.* 2024-06-13 04:25:12 -04:00
refinement Fix refinement panic caused by duplicate cfg edges 2024-05-10 15:40:11 -07:00
scripts Add a script for regenerating CI freeze files 2022-06-30 13:44:35 -07:00
symbolic Use Crucible goal-proving helpers in testing code 2024-07-16 15:30:35 -04:00
symbolic-syntax Bump Crucible submodule, adapt to crucible-syntax changes 2023-12-08 09:46:20 -05:00
utils/compare-dwarfdump Cleanup compare-dwarfdump; bump submodules. 2021-05-26 07:25:51 -07:00
x86 Add semantics for prefetch instructions. (#365) 2024-01-10 11:31:36 -08:00
x86_symbolic symbolic: Make {lookup,update}Reg implementations panic rather than error 2024-07-26 15:25:29 -04:00
.gitignore Fix .gitignore update. 2021-04-03 18:16:25 -07:00
.gitmodules Update llvm-pretty submodule target 2024-05-23 16:23:39 -07:00
cabal.project.dist Implement macaw-riscv-symbolic 2024-07-26 15:25:29 -04:00
cabal.project.freeze.ghc-9.2.8 CI: Regenerate freeze files using latest GHC minor versions 2024-06-13 04:25:12 -04:00
cabal.project.freeze.ghc-9.4.8 CI: Regenerate freeze files using latest GHC minor versions 2024-06-13 04:25:12 -04:00
cabal.project.freeze.ghc-9.6.5 CI: Regenerate freeze files using latest GHC minor versions 2024-06-13 04:25:12 -04:00
cabal.project.werror macaw-symbolic-syntax: Concrete syntax for macaw-symbolic CFGs 2023-11-01 17:19:13 -04:00
LICENSE Update license dates 2020-11-12 23:43:38 -08:00
README.md Cite Macaw paper and blog post in the README 2024-07-16 13:17:44 -04:00

This is the main repository for the Macaw binary analysis framework with two key goals: binary code discovery and symbolic execution of machine code. This framework is implemented to offer extensible support for architectures (i.e., library clients can add their own architectures and opt in to the architecture support they need).

Overview

The code discovery algorithm is based on forced execution and is able to discovery code from one or more entry points. Symbols are optional but can significantly improve the quality of the results. Stripped binaries can pose a challenge for macaw (especially static stripped binaries). Macaw provides support for lifting discovered machine code into an IR suitable for symbolic execution via the Crucible library.

Currently, macaw supports:

  • x86-64
  • PowerPC (32 and 64 bit)
  • ARM (32 bit)
  • RISC-V

Repository Structure

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

Documentation

A set of high-level design documents can be found in the doc subdirectory. Documentation for individual API functions and data types can be found in the Haddock comments throughout the code.

We have also written some other resources about Macaw:

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 or collectively built with Cabal:

$ ln -s cabal.project.dist cabal.project
$ cabal configure
$ cabal 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 build macaw-refinement

or

$ cd refinement
$ cabal build

Notes on Freeze Files

We use the cabal.project.freeze.ghc-* files to constrain dependency versions in CI. To build with a known-working set of Hackage dependencies:

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

These freeze files were generated using the scripts/regenerate-freeze-files.sh 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

Note that if any of the macaw packages fail to build without the freeze files, it is a bug in the dependency version bounds specified in the .cabal files that should be reported (https://github.com/GaloisInc/macaw/issues).

License

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