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

Data.Elf.PrettyPrint

Description

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

Synopsis

Documentation

printHeaders :: forall (a :: ElfClass). SingElfClassI 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 => Headers -> 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 :: ElfClass). SingElfClassI 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 ]