melf-1.1.0: An Elf parser
Copyright(c) Aleksey Makarov 2021
LicenseBSD 3-Clause License
Maintaineraleksey.makarov@gmail.com
Stabilityexperimental
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Elf.PrettyPrint

Description

Pretty print the data parsed by Data.Elf. Basically these functions are used for golden testing.

Synopsis

Documentation

printHeaders :: SingI a => HeaderXX a -> [SectionXX a] -> [SegmentXX a] -> Doc () Source #

Print parsed header, section table and segment table. It's used in golden tests

printLayout :: MonadCatch m => Sigma ElfClass (TyCon1 HeadersXX) -> ByteString -> m (Doc ()) Source #

Print ELF layout. First parse ELF with parseHeaders, then use this function to format the layout.

printElf_ :: MonadThrow m => Bool -> Elf -> m (Doc ()) Source #

Print ELF. If first argument is False, don't dump all the data, print just the first two and the last lines.

printElf :: MonadThrow m => Elf -> m (Doc ()) Source #

Same as printElf_ False

printStringTable :: MonadThrow m => ByteString -> m (Doc ()) Source #

Print string table. It's used in golden tests

printHeader :: forall a. SingI a => HeaderXX a -> Doc () Source #

Print ELF header. It's used in golden tests

readFileLazy :: FilePath -> IO ByteString Source #

Read the file strictly but return lazy bytestring

writeElfDump :: FilePath -> FilePath -> IO () Source #

Read ELF from one file, printElf it into another.

writeElfLayout :: FilePath -> FilePath -> IO () Source #

Read ELF from one file, printLayout it into another.

splitBits :: (Num w, FiniteBits w) => w -> [w] Source #

Splits an integer into list of integers such that its sum equals to the argument, and each element of the list is of the form (1 << x) for some x. splitBits 5 produces [ 1, 4 ]