mirror of
https://github.com/GaloisInc/macaw.git
synced 2024-12-18 03:21:49 +03:00
9664914923
The new binary loading interface does manage to simplify things
20 lines
636 B
Haskell
20 lines
636 B
Haskell
{-# LANGUAGE DataKinds #-}
|
|
module Shared (
|
|
withELF
|
|
) where
|
|
|
|
import qualified Data.ByteString as B
|
|
|
|
import qualified Data.ElfEdit as E
|
|
|
|
withELF :: FilePath -> (E.Elf 64 -> IO ()) -> IO ()
|
|
withELF fp k = do
|
|
bytes <- B.readFile fp
|
|
case E.parseElf bytes of
|
|
E.ElfHeaderError off msg ->
|
|
error ("Error parsing ELF header at offset " ++ show off ++ ": " ++ msg)
|
|
E.Elf32Res [] _e32 -> error "ELF32 is unsupported in the test suite"
|
|
E.Elf64Res [] e64 -> k e64
|
|
E.Elf32Res errs _ -> error ("Errors while parsing ELF file: " ++ show errs)
|
|
E.Elf64Res errs _ -> error ("Errors while parsing ELF file: " ++ show errs)
|