GaloisInc / flexdis86

A library for disassembling x86-64 binaries.
BSD 3-Clause "New" or "Revised" License
37 stars 10 forks source link

Test disassembly of .text sections of sample binaries #12

Closed langston-barrett closed 4 years ago

langston-barrett commented 4 years ago

Some tests for disassembly of some small binaries. Having a test suite like this is nice because

  1. It will benefit from any work done upstream on sample-binaries, which can benefit multiple projects across Galois
  2. It is really easy to compile a hairy binary, toss it into tests/data, increment the expected number of tests, and test that Flexdis86 can disassemble it.
travitch commented 4 years ago

Similar tests for the other disassemblers are based on this code: https://github.com/travitch/dismantle/blob/master/dismantle-tablegen/src/Dismantle/Testing.hs. It uses objdump as an oracle and makes sure that we can roundtrip every instruction that objdump knows about.

langston-barrett commented 4 years ago

@kquick suggested that we use elf-edit instead of creating the .bin files with objcopy, which seems much better.

langston-barrett commented 4 years ago

@kquick I think we'll need an update to the Hydra configuration for this branch to work. If you point me in the right direction, I'm happy to give it a shot.

langston-barrett commented 4 years ago

NTS: Kevin says that for this to move forward, we should allow an environment variable to specify the locations of the additional test binaries.

langston-barrett commented 4 years ago

I've updated this with the environment variable configuration, and there's a WIP PR to the Fryingpan config files that will let us test it: https://gitlab-int.galois.com/binary-analysis/nix/-/merge_requests/5

langston-barrett commented 4 years ago

We've merged the configuration changes, so by Monday we should have green checks from Fryingpan. Thanks to @kquick for helping me get Fryingpan configured!

langston-barrett commented 4 years ago

Build is passing on S2N, Kyber, and saw-script, failing on SFE and Macaw, seemingly due to unrelated goings-on in Renovate-x86:


src/Renovate/Arch/X86_64/ISA.hs:572:27: error:
    • Type constructor ‘R.InstructionArchReprKind’ cannot be used here
        (Perhaps you intended to use TypeInType)
    • In the kind ‘R.InstructionArchReprKind X86.X86_64’
      In the type signature:
        absToRip :: forall (tp :: R.InstructionArchReprKind X86.X86_64).
                    MM.Memory 64
                    -> R.ConcreteAddress X86.X86_64
                       -> Instruction tp TargetAddress
                          -> R.ConcreteAddress X86.X86_64 -> D.AddrRef -> Maybe D.AddrRef
    |
572 | absToRip :: forall (tp :: R.InstructionArchReprKind X86.X86_64)