-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | An Elf parser
--
-- Parser for ELF object format
@package melf
@version 1.0.0
-- | Exception that keeps the stack of error locations.
module Control.Exception.ChainedException
-- | Structure to organize the stack of exceptions with locations
data ChainedExceptionNext
-- | exception was initiated by chainedError
Null :: ChainedExceptionNext
-- | some context was added to SomeException by
-- addContext
Next :: SomeException -> ChainedExceptionNext
-- | some context was added to a ChainedException by
-- addContext
NextChained :: ChainedException -> ChainedExceptionNext
-- | Exception that keeps track of error locations
data ChainedException
ChainedException :: String -> Loc -> ChainedExceptionNext -> ChainedException
-- | description of the error
[err] :: ChainedException -> String
-- | location
[loc] :: ChainedException -> Loc
-- | stack of locations
[stack] :: ChainedException -> ChainedExceptionNext
-- | $chainedError results in a function of type 'chainedError
-- :: MonadThrow m => String -> m a'. It throws
-- ChainedException with its argument as error description.
chainedError :: Q Exp
-- | $chainedError' is the same as $chainedError
-- ""
chainedError' :: Q Exp
-- | $addContext results in a function of type 'addContext ::
-- MonadCatch m => String -> m a -> m a'. It runs the
-- second argument and adds ChainedException with its first
-- argument to the exceptions thrown from that monad.
addContext :: Q Exp
-- | $addContext' is the same as $addContext ""
addContext' :: Q Exp
-- | $maybeAddContext results in a function of type
-- 'maybeAddContext :: MonadThrow m => String -> Maybe a ->
-- m a'. If its second argument is Nothing, it throws
-- ChainedException with its first argument, else it returns the
-- value of Just.
maybeAddContext :: Q Exp
-- | $maybeAddContext' is the same as $maybeAddContext ""
maybeAddContext' :: Q Exp
-- | $eitherAddContext' results in a function of type
-- 'eitherAddContext' :: MonadThrow m => Either String a -> m
-- a'. If its argument is Left e, it throws
-- ChainedException with e as error description, else it
-- returns the value of Right.
eitherAddContext' :: Q Exp
instance GHC.Show.Show Control.Exception.ChainedException.ChainedException
instance GHC.Exception.Type.Exception Control.Exception.ChainedException.ChainedException
-- | Newtypes for little- and big-endian instances of Binary
module Data.Endian
-- | Be a is an instance of Binary such that a is
-- serialized as big-endian
newtype Be a
Be :: a -> Be a
[fromBe] :: Be a -> a
-- | Le a is an instance of Binary such that a is
-- serialized as little-endian
newtype Le a
Le :: a -> Le a
[fromLe] :: Le a -> a
instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Endian.Be a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Endian.Le a)
instance Data.Binary.Class.Binary (Data.Endian.Le GHC.Word.Word16)
instance Data.Binary.Class.Binary (Data.Endian.Le GHC.Word.Word32)
instance Data.Binary.Class.Binary (Data.Endian.Le GHC.Word.Word64)
instance Data.Binary.Class.Binary (Data.Endian.Be GHC.Word.Word16)
instance Data.Binary.Class.Binary (Data.Endian.Be GHC.Word.Word32)
instance Data.Binary.Class.Binary (Data.Endian.Be GHC.Word.Word64)
-- | Definitions of constants used in ELF files
module Data.Elf.Constants
-- | Operating system and ABI for which the object is prepared
newtype ElfOSABI
ElfOSABI :: Word8 -> ElfOSABI
pattern ELFOSABI_EXT :: Word8 -> ElfOSABI
pattern ELFOSABI_STANDALONE :: ElfOSABI
pattern ELFOSABI_ARM :: ElfOSABI
pattern ELFOSABI_AROS :: ElfOSABI
pattern ELFOSABI_NSK :: ElfOSABI
pattern ELFOSABI_OPENVMS :: ElfOSABI
pattern ELFOSABI_OPENBSD :: ElfOSABI
pattern ELFOSABI_MODESTO :: ElfOSABI
pattern ELFOSABI_TRU64 :: ElfOSABI
pattern ELFOSABI_FREEBSD :: ElfOSABI
pattern ELFOSABI_IRIX :: ElfOSABI
pattern ELFOSABI_AIX :: ElfOSABI
pattern ELFOSABI_SOLARIS :: ElfOSABI
pattern ELFOSABI_LINUX :: ElfOSABI
pattern ELFOSABI_NETBSD :: ElfOSABI
pattern ELFOSABI_HPUX :: ElfOSABI
pattern ELFOSABI_SYSV :: ElfOSABI
-- | Object file type
newtype ElfType
ElfType :: Word16 -> ElfType
pattern ET_EXT :: Word16 -> ElfType
pattern ET_CORE :: ElfType
pattern ET_DYN :: ElfType
pattern ET_EXEC :: ElfType
pattern ET_REL :: ElfType
pattern ET_NONE :: ElfType
-- | Target architecture
newtype ElfMachine
ElfMachine :: Word16 -> ElfMachine
pattern EM_EXT :: Word16 -> ElfMachine
pattern EM_AARCH64 :: ElfMachine
pattern EM_UNICORE :: ElfMachine
pattern EM_ARCA :: ElfMachine
pattern EM_SEP :: ElfMachine
pattern EM_SE_C33 :: ElfMachine
pattern EM_BLACKFIN :: ElfMachine
pattern EM_MSP430 :: ElfMachine
pattern EM_F2MC16 :: ElfMachine
pattern EM_CR :: ElfMachine
pattern EM_MAX :: ElfMachine
pattern EM_IP2K :: ElfMachine
pattern EM_ST200 :: ElfMachine
pattern EM_SNP1K :: ElfMachine
pattern EM_TPC :: ElfMachine
pattern EM_NS32K :: ElfMachine
pattern EM_TMM_GPP :: ElfMachine
pattern EM_VIDEOCORE :: ElfMachine
pattern EM_XTENSA :: ElfMachine
pattern EM_ARC_A5 :: ElfMachine
pattern EM_OPENRISC :: ElfMachine
pattern EM_PJ :: ElfMachine
pattern EM_MN10200 :: ElfMachine
pattern EM_MN10300 :: ElfMachine
pattern EM_M32R :: ElfMachine
pattern EM_V850 :: ElfMachine
pattern EM_D30V :: ElfMachine
pattern EM_D10V :: ElfMachine
pattern EM_FR30 :: ElfMachine
pattern EM_AVR :: ElfMachine
pattern EM_PRISM :: ElfMachine
pattern EM_HUANY :: ElfMachine
pattern EM_MMIX :: ElfMachine
pattern EM_ZSP :: ElfMachine
pattern EM_FIREPATH :: ElfMachine
pattern EM_JAVELIN :: ElfMachine
pattern EM_CRIS :: ElfMachine
pattern EM_VAX :: ElfMachine
pattern EM_ST19 :: ElfMachine
pattern EM_SVX :: ElfMachine
pattern EM_68HC05 :: ElfMachine
pattern EM_68HC08 :: ElfMachine
pattern EM_68HC11 :: ElfMachine
pattern EM_68HC16 :: ElfMachine
pattern EM_ST7 :: ElfMachine
pattern EM_ST9PLUS :: ElfMachine
pattern EM_FX66 :: ElfMachine
pattern EM_PDSP :: ElfMachine
pattern EM_X86_64 :: ElfMachine
pattern EM_TINYJ :: ElfMachine
pattern EM_ST100 :: ElfMachine
pattern EM_ME16 :: ElfMachine
pattern EM_STARCORE :: ElfMachine
pattern EM_NDR1 :: ElfMachine
pattern EM_NCPU :: ElfMachine
pattern EM_PCP :: ElfMachine
pattern EM_MMA :: ElfMachine
pattern EM_68HC12 :: ElfMachine
pattern EM_COLDFIRE :: ElfMachine
pattern EM_MIPS_X :: ElfMachine
pattern EM_IA_64 :: ElfMachine
pattern EM_H8_500 :: ElfMachine
pattern EM_H8S :: ElfMachine
pattern EM_H8_300H :: ElfMachine
pattern EM_H8_300 :: ElfMachine
pattern EM_ARC :: ElfMachine
pattern EM_TRICORE :: ElfMachine
pattern EM_SPARCV9 :: ElfMachine
pattern EM_SH :: ElfMachine
pattern EM_ALPHA :: ElfMachine
pattern EM_ARM :: ElfMachine
pattern EM_RCE :: ElfMachine
pattern EM_RH32 :: ElfMachine
pattern EM_FR20 :: ElfMachine
pattern EM_V800 :: ElfMachine
pattern EM_SPU :: ElfMachine
pattern EM_S390 :: ElfMachine
pattern EM_PPC64 :: ElfMachine
pattern EM_PPC :: ElfMachine
pattern EM_960 :: ElfMachine
pattern EM_SPARC32PLUS :: ElfMachine
pattern EM_VPP500 :: ElfMachine
pattern EM_PARISC :: ElfMachine
pattern EM_SPARC64 :: ElfMachine
pattern EM_MIPS_RS3_LE :: ElfMachine
pattern EM_S370 :: ElfMachine
pattern EM_MIPS :: ElfMachine
pattern EM_860 :: ElfMachine
pattern EM_486 :: ElfMachine
pattern EM_88K :: ElfMachine
pattern EM_68K :: ElfMachine
pattern EM_386 :: ElfMachine
pattern EM_SPARC :: ElfMachine
pattern EM_M32 :: ElfMachine
pattern EM_NONE :: ElfMachine
-- | Section type
newtype ElfSectionType
ElfSectionType :: Word32 -> ElfSectionType
pattern SHT_EXT :: Word32 -> ElfSectionType
pattern SHT_DYNSYM :: ElfSectionType
pattern SHT_SHLIB :: ElfSectionType
pattern SHT_REL :: ElfSectionType
pattern SHT_NOBITS :: ElfSectionType
pattern SHT_NOTE :: ElfSectionType
pattern SHT_DYNAMIC :: ElfSectionType
pattern SHT_HASH :: ElfSectionType
pattern SHT_RELA :: ElfSectionType
pattern SHT_STRTAB :: ElfSectionType
pattern SHT_SYMTAB :: ElfSectionType
pattern SHT_PROGBITS :: ElfSectionType
pattern SHT_NULL :: ElfSectionType
-- | Segment type
newtype ElfSegmentType
ElfSegmentType :: Word32 -> ElfSegmentType
pattern PT_EXT :: Word32 -> ElfSegmentType
pattern PT_PHDR :: ElfSegmentType
pattern PT_SHLIB :: ElfSegmentType
pattern PT_NOTE :: ElfSegmentType
pattern PT_INTERP :: ElfSegmentType
pattern PT_DYNAMIC :: ElfSegmentType
pattern PT_LOAD :: ElfSegmentType
pattern PT_NULL :: ElfSegmentType
-- | Attributes of the section
newtype ElfSectionFlag
ElfSectionFlag :: Word64 -> ElfSectionFlag
pattern SHF_EXT :: Word64 -> ElfSectionFlag
pattern SHF_EXECINSTR :: ElfSectionFlag
pattern SHF_ALLOC :: ElfSectionFlag
pattern SHF_WRITE :: ElfSectionFlag
-- | Attributes of the segment
newtype ElfSegmentFlag
ElfSegmentFlag :: Word32 -> ElfSegmentFlag
pattern PF_EXT :: Word32 -> ElfSegmentFlag
pattern PF_R :: ElfSegmentFlag
pattern PF_W :: ElfSegmentFlag
pattern PF_X :: ElfSegmentFlag
-- | Symbol type
newtype ElfSymbolType
ElfSymbolType :: Word8 -> ElfSymbolType
pattern STT_EXT :: Word8 -> ElfSymbolType
pattern STT_HiProc :: ElfSymbolType
pattern STT_LoProc :: ElfSymbolType
pattern STT_HiOS :: ElfSymbolType
pattern STT_LoOS :: ElfSymbolType
pattern STT_TLS :: ElfSymbolType
pattern STT_Common :: ElfSymbolType
pattern STT_File :: ElfSymbolType
pattern STT_Section :: ElfSymbolType
pattern STT_Func :: ElfSymbolType
pattern STT_Object :: ElfSymbolType
pattern STT_NoType :: ElfSymbolType
-- | Symbol binding
newtype ElfSymbolBinding
ElfSymbolBinding :: Word8 -> ElfSymbolBinding
pattern STB_EXT :: Word8 -> ElfSymbolBinding
pattern STB_HiProc :: ElfSymbolBinding
pattern STB_LoProc :: ElfSymbolBinding
pattern STB_HiOS :: ElfSymbolBinding
pattern STB_LoOS :: ElfSymbolBinding
pattern STB_Weak :: ElfSymbolBinding
pattern STB_Global :: ElfSymbolBinding
pattern STB_Local :: ElfSymbolBinding
-- | Section index
newtype ElfSectionIndex
ElfSectionIndex :: Word16 -> ElfSectionIndex
pattern SHN_EXT :: Word16 -> ElfSectionIndex
pattern SHN_Common :: ElfSectionIndex
pattern SHN_Abs :: ElfSectionIndex
pattern SHN_HiOS :: ElfSectionIndex
pattern SHN_LoOS :: ElfSectionIndex
pattern SHN_HiProc :: ElfSectionIndex
pattern SHN_LoProc :: ElfSectionIndex
pattern SHN_Undef :: ElfSectionIndex
-- | AARCH64 relocation type
newtype ElfRelocationType_AARCH64
ElfRelocationType_AARCH64 :: Word32 -> ElfRelocationType_AARCH64
pattern R_AARCH64_EXT :: Word32 -> ElfRelocationType_AARCH64
pattern R_AARCH64_IRELATIVE :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSDESC :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLS_TPREL :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLS_DTPREL :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLS_DTPMOD :: ElfRelocationType_AARCH64
pattern R_AARCH64_RELATIVE :: ElfRelocationType_AARCH64
pattern R_AARCH64_JUMP_SLOT :: ElfRelocationType_AARCH64
pattern R_AARCH64_GLOB_DAT :: ElfRelocationType_AARCH64
pattern R_AARCH64_COPY :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSDESC_CALL :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSDESC_ADD :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSDESC_LDR :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSDESC_OFF_G0_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSDESC_OFF_G1 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSDESC_ADD_LO12 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSDESC_LD64_LO12 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSDESC_ADR_PAGE21 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSDESC_ADR_PREL21 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSDESC_LD_PREL19 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLE_LDST128_TPREL_LO12 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLE_LDST64_TPREL_LO12 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLE_LDST32_TPREL_LO12 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLE_LDST16_TPREL_LO12 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLE_LDST8_TPREL_LO12 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLE_ADD_TPREL_LO12_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLE_ADD_TPREL_LO12 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLE_ADD_TPREL_HI12 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLE_MOVW_TPREL_G0_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLE_MOVW_TPREL_G0 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLE_MOVW_TPREL_G1_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLE_MOVW_TPREL_G1 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLE_MOVW_TPREL_G2 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLD_LDST128_DTPREL_LO12 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLD_LDST64_DTPREL_LO12 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLD_LDST32_DTPREL_LO12 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLD_LDST16_DTPREL_LO12 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLD_LDST8_DTPREL_LO12 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLD_ADD_DTPREL_LO12 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLD_ADD_DTPREL_HI12 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLD_MOVW_DTPREL_G0 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLD_MOVW_DTPREL_G1 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLD_MOVW_DTPREL_G2 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLD_LD_PREL19 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLD_MOVW_G0_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLD_MOVW_G1 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLD_ADD_LO12_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLD_ADR_PAGE21 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TLSLD_ADR_PREL21 :: ElfRelocationType_AARCH64
pattern R_AARCH64_LD64_GOTPAGE_LO15 :: ElfRelocationType_AARCH64
pattern R_AARCH64_LD64_GOT_LO12_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_ADR_GOT_PAGE :: ElfRelocationType_AARCH64
pattern R_AARCH64_LD64_GOTOFF_LO15 :: ElfRelocationType_AARCH64
pattern R_AARCH64_GOT_LD_PREL19 :: ElfRelocationType_AARCH64
pattern R_AARCH64_GOTREL32 :: ElfRelocationType_AARCH64
pattern R_AARCH64_GOTREL64 :: ElfRelocationType_AARCH64
pattern R_AARCH64_MOVW_GOTOFF_G3 :: ElfRelocationType_AARCH64
pattern R_AARCH64_MOVW_GOTOFF_G2_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_MOVW_GOTOFF_G2 :: ElfRelocationType_AARCH64
pattern R_AARCH64_MOVW_GOTOFF_G1_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_MOVW_GOTOFF_G1 :: ElfRelocationType_AARCH64
pattern R_AARCH64_MOVW_GOTOFF_G0_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_MOVW_GOTOFF_G0 :: ElfRelocationType_AARCH64
pattern R_AARCH64_MOVW_PREL_G3 :: ElfRelocationType_AARCH64
pattern R_AARCH64_MOVW_PREL_G2_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_MOVW_PREL_G2 :: ElfRelocationType_AARCH64
pattern R_AARCH64_MOVW_PREL_G1_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_MOVW_PREL_G1 :: ElfRelocationType_AARCH64
pattern R_AARCH64_MOVW_PREL_G0_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_MOVW_PREL_G0 :: ElfRelocationType_AARCH64
pattern R_AARCH64_CALL26 :: ElfRelocationType_AARCH64
pattern R_AARCH64_JUMP26 :: ElfRelocationType_AARCH64
pattern R_AARCH64_CONDBR19 :: ElfRelocationType_AARCH64
pattern R_AARCH64_TSTBR14 :: ElfRelocationType_AARCH64
pattern R_AARCH64_LDST128_ABS_LO12_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_LDST64_ABS_LO12_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_LDST32_ABS_LO12_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_LDST16_ABS_LO12_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_LDST8_ABS_LO12_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_ADD_ABS_LO12_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_ADR_PREL_PG_HI21_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_ADR_PREL_PG_HI21 :: ElfRelocationType_AARCH64
pattern R_AARCH64_ADR_PREL_LO21 :: ElfRelocationType_AARCH64
pattern R_AARCH64_LD_PREL_LO19 :: ElfRelocationType_AARCH64
pattern R_AARCH64_MOVW_SABS_G2 :: ElfRelocationType_AARCH64
pattern R_AARCH64_MOVW_SABS_G1 :: ElfRelocationType_AARCH64
pattern R_AARCH64_MOVW_SABS_G0 :: ElfRelocationType_AARCH64
pattern R_AARCH64_MOVW_UABS_G3 :: ElfRelocationType_AARCH64
pattern R_AARCH64_MOVW_UABS_G2_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_MOVW_UABS_G2 :: ElfRelocationType_AARCH64
pattern R_AARCH64_MOVW_UABS_G1_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_MOVW_UABS_G1 :: ElfRelocationType_AARCH64
pattern R_AARCH64_MOVW_UABS_G0_NC :: ElfRelocationType_AARCH64
pattern R_AARCH64_MOVW_UABS_G0 :: ElfRelocationType_AARCH64
pattern R_AARCH64_PLT32 :: ElfRelocationType_AARCH64
pattern R_AARCH64_PREL16 :: ElfRelocationType_AARCH64
pattern R_AARCH64_PREL32 :: ElfRelocationType_AARCH64
pattern R_AARCH64_PREL64 :: ElfRelocationType_AARCH64
pattern R_AARCH64_ABS16 :: ElfRelocationType_AARCH64
pattern R_AARCH64_ABS32 :: ElfRelocationType_AARCH64
pattern R_AARCH64_ABS64 :: ElfRelocationType_AARCH64
pattern R_AARCH64_NONE_ :: ElfRelocationType_AARCH64
pattern R_AARCH64_NONE :: ElfRelocationType_AARCH64
-- | Parse headers and table entries of ELF files
module Data.Elf.Headers
-- | The first 4 bytes of the ELF file
elfMagic :: Be Word32
-- | ELF class. Tells if ELF defines 32- or 64-bit objects
data ElfClass
ELFCLASS32 :: ElfClass
ELFCLASS64 :: ElfClass
data SElfClass :: ElfClass -> Type
[SELFCLASS32] :: SElfClass (ELFCLASS32 :: ElfClass)
[SELFCLASS64] :: SElfClass (ELFCLASS64 :: ElfClass)
-- | ELF data. Specifies the endianness of the ELF data
data ElfData
-- | Little-endian ELF format
ELFDATA2LSB :: ElfData
-- | Big-endian ELF format
ELFDATA2MSB :: ElfData
-- | IsElfClass a is defined for each constructor of
-- ElfClass. It defines WordXX a, which is Word32
-- for ELFCLASS32 and Word64 for ELFCLASS64.
class (SingI c, Typeable c, Typeable (WordXX c), Data (WordXX c), Show (WordXX c), Read (WordXX c), Eq (WordXX c), Ord (WordXX c), Bounded (WordXX c), Enum (WordXX c), Num (WordXX c), Integral (WordXX c), Real (WordXX c), Bits (WordXX c), FiniteBits (WordXX c), Binary (Be (WordXX c)), Binary (Le (WordXX c))) => IsElfClass c where {
type family WordXX c = r | r -> c;
}
-- | Size of WordXX a in bytes.
wordSize :: Num a => ElfClass -> a
-- | Convenience function for creating a context with an implicit ElfClass
-- available.
withElfClass :: Sing c -> (IsElfClass c => a) -> a
-- | Parsed ELF header
data HeaderXX c
HeaderXX :: ElfData -> ElfOSABI -> Word8 -> ElfType -> ElfMachine -> WordXX c -> WordXX c -> WordXX c -> Word32 -> Word16 -> Word16 -> Word16 -> Word16 -> ElfSectionIndex -> HeaderXX c
-- | Data encoding (big- or little-endian)
[hData] :: HeaderXX c -> ElfData
-- | OS/ABI identification
[hOSABI] :: HeaderXX c -> ElfOSABI
-- | ABI version
[hABIVersion] :: HeaderXX c -> Word8
-- | Object file type
[hType] :: HeaderXX c -> ElfType
-- | Machine type
[hMachine] :: HeaderXX c -> ElfMachine
-- | Entry point address
[hEntry] :: HeaderXX c -> WordXX c
-- | Program header offset
[hPhOff] :: HeaderXX c -> WordXX c
-- | Section header offset
[hShOff] :: HeaderXX c -> WordXX c
-- | Processor-specific flags
[hFlags] :: HeaderXX c -> Word32
-- | Size of program header entry
[hPhEntSize] :: HeaderXX c -> Word16
-- | Number of program header entries
[hPhNum] :: HeaderXX c -> Word16
-- | Size of section header entry
[hShEntSize] :: HeaderXX c -> Word16
-- | Number of section header entries
[hShNum] :: HeaderXX c -> Word16
-- | Section name string table index
[hShStrNdx] :: HeaderXX c -> ElfSectionIndex
-- | Size of ELF header.
headerSize :: Num a => ElfClass -> a
-- | Sigma type where ElfClass defines the type of HeaderXX
type Header = Sigma ElfClass (TyCon1 HeaderXX)
-- | Parsed ELF section table entry
data SectionXX (c :: ElfClass)
SectionXX :: Word32 -> ElfSectionType -> WordXX c -> WordXX c -> WordXX c -> WordXX c -> Word32 -> Word32 -> WordXX c -> WordXX c -> SectionXX (c :: ElfClass)
-- | Section name
[sName] :: SectionXX (c :: ElfClass) -> Word32
-- | Section type
[sType] :: SectionXX (c :: ElfClass) -> ElfSectionType
-- | Section attributes
[sFlags] :: SectionXX (c :: ElfClass) -> WordXX c
-- | Virtual address in memory
[sAddr] :: SectionXX (c :: ElfClass) -> WordXX c
-- | Offset in file
[sOffset] :: SectionXX (c :: ElfClass) -> WordXX c
-- | Size of section
[sSize] :: SectionXX (c :: ElfClass) -> WordXX c
-- | Link to other section
[sLink] :: SectionXX (c :: ElfClass) -> Word32
-- | Miscellaneous information
[sInfo] :: SectionXX (c :: ElfClass) -> Word32
-- | Address alignment boundary
[sAddrAlign] :: SectionXX (c :: ElfClass) -> WordXX c
-- | Size of entries, if section has table
[sEntSize] :: SectionXX (c :: ElfClass) -> WordXX c
-- | Size of section table entry.
sectionTableEntrySize :: Num a => ElfClass -> a
-- | Parsed ELF segment table entry
data SegmentXX (c :: ElfClass)
SegmentXX :: ElfSegmentType -> ElfSegmentFlag -> WordXX c -> WordXX c -> WordXX c -> WordXX c -> WordXX c -> WordXX c -> SegmentXX (c :: ElfClass)
-- | Type of segment
[pType] :: SegmentXX (c :: ElfClass) -> ElfSegmentType
-- | Segment attributes
[pFlags] :: SegmentXX (c :: ElfClass) -> ElfSegmentFlag
-- | Offset in file
[pOffset] :: SegmentXX (c :: ElfClass) -> WordXX c
-- | Virtual address in memory
[pVirtAddr] :: SegmentXX (c :: ElfClass) -> WordXX c
-- | Physical address
[pPhysAddr] :: SegmentXX (c :: ElfClass) -> WordXX c
-- | Size of segment in file
[pFileSize] :: SegmentXX (c :: ElfClass) -> WordXX c
-- | Size of segment in memory
[pMemSize] :: SegmentXX (c :: ElfClass) -> WordXX c
-- | Alignment of segment
[pAlign] :: SegmentXX (c :: ElfClass) -> WordXX c
-- | Size of segment table entry.
segmentTableEntrySize :: Num a => ElfClass -> a
-- | Parsed ELF symbol table entry
data SymbolXX (c :: ElfClass)
SymbolXX :: Word32 -> Word8 -> Word8 -> ElfSectionIndex -> WordXX c -> WordXX c -> SymbolXX (c :: ElfClass)
-- | Symbol name
[stName] :: SymbolXX (c :: ElfClass) -> Word32
-- | Type and Binding attributes
[stInfo] :: SymbolXX (c :: ElfClass) -> Word8
-- | Reserved
[stOther] :: SymbolXX (c :: ElfClass) -> Word8
-- | Section table index
[stShNdx] :: SymbolXX (c :: ElfClass) -> ElfSectionIndex
-- | Symbol value
[stValue] :: SymbolXX (c :: ElfClass) -> WordXX c
-- | Size of object
[stSize] :: SymbolXX (c :: ElfClass) -> WordXX c
-- | Size of symbol table entry.
symbolTableEntrySize :: Num a => ElfClass -> a
-- | Parsed relocation table entry (ElfXX_Rela)
data RelaXX (c :: ElfClass)
RelaXX :: WordXX c -> Word32 -> Word32 -> WordXX c -> RelaXX (c :: ElfClass)
-- | Address of reference
[relaOffset] :: RelaXX (c :: ElfClass) -> WordXX c
-- | Symbol table index
[relaSym] :: RelaXX (c :: ElfClass) -> Word32
-- | Relocation type
[relaType] :: RelaXX (c :: ElfClass) -> Word32
-- | Constant part of expression
[relaAddend] :: RelaXX (c :: ElfClass) -> WordXX c
-- | Size of RelaXX a in bytes.
relocationTableAEntrySize :: forall a. IsElfClass a => WordXX a
-- | The type that helps to make the sigma type of the result of the
-- parseHeaders function
newtype HeadersXX a
HeadersXX :: (HeaderXX a, [SectionXX a], [SegmentXX a]) -> HeadersXX a
-- | Parse ELF file and produce header and section and segment tables
parseHeaders :: MonadThrow m => ByteString -> m (Sigma ElfClass (TyCon1 HeadersXX))
-- | Parse an array
parseBList :: (MonadThrow m, Binary (Le a), Binary (Be a)) => ElfData -> ByteString -> m [a]
-- | Serialize an array
serializeBList :: (Binary (Le a), Binary (Be a)) => ElfData -> [a] -> ByteString
-- | Test if the section with such integer value of section type field
-- (sType) contains symbol table
sectionIsSymbolTable :: ElfSectionType -> Bool
instance GHC.Show.Show Data.Elf.Headers.ElfClass
instance GHC.Classes.Eq Data.Elf.Headers.ElfClass
instance GHC.Show.Show Data.Elf.Headers.ElfData
instance GHC.Classes.Eq Data.Elf.Headers.ElfData
instance Data.Singletons.Internal.SingI a => Data.Binary.Class.Binary (Data.Endian.Be (Data.Elf.Headers.RelaXX a))
instance Data.Singletons.Internal.SingI a => Data.Binary.Class.Binary (Data.Endian.Le (Data.Elf.Headers.RelaXX a))
instance Data.Singletons.Internal.SingI a => Data.Binary.Class.Binary (Data.Endian.Be (Data.Elf.Headers.SymbolXX a))
instance Data.Singletons.Internal.SingI a => Data.Binary.Class.Binary (Data.Endian.Le (Data.Elf.Headers.SymbolXX a))
instance Data.Singletons.Internal.SingI a => Data.Binary.Class.Binary (Data.Endian.Be (Data.Elf.Headers.SegmentXX a))
instance Data.Singletons.Internal.SingI a => Data.Binary.Class.Binary (Data.Endian.Le (Data.Elf.Headers.SegmentXX a))
instance Data.Singletons.Internal.SingI a => Data.Binary.Class.Binary (Data.Endian.Be (Data.Elf.Headers.SectionXX a))
instance Data.Singletons.Internal.SingI a => Data.Binary.Class.Binary (Data.Endian.Le (Data.Elf.Headers.SectionXX a))
instance Data.Binary.Class.Binary Data.Elf.Headers.Header
instance Data.Elf.Headers.IsElfClass 'Data.Elf.Headers.ELFCLASS32
instance Data.Elf.Headers.IsElfClass 'Data.Elf.Headers.ELFCLASS64
instance Data.Binary.Class.Binary Data.Elf.Headers.ElfData
instance Data.Singletons.Internal.SingKind Data.Elf.Headers.ElfClass
instance Data.Singletons.Prelude.Show.SShow Data.Elf.Headers.ElfClass
instance Data.Singletons.Prelude.Eq.SEq Data.Elf.Headers.ElfClass
instance Data.Singletons.Decide.SDecide Data.Elf.Headers.ElfClass
instance Data.Type.Equality.TestEquality Data.Elf.Headers.SElfClass
instance Data.Type.Coercion.TestCoercion Data.Elf.Headers.SElfClass
instance GHC.Show.Show (Data.Elf.Headers.SElfClass z)
instance Data.Singletons.Internal.SingI 'Data.Elf.Headers.ELFCLASS32
instance Data.Singletons.Internal.SingI 'Data.Elf.Headers.ELFCLASS64
instance Data.Singletons.Prelude.Eq.PEq Data.Elf.Headers.ElfClass
instance Data.Singletons.SuppressUnusedWarnings.SuppressUnusedWarnings Data.Elf.Headers.ShowsPrec_6989586621679243414Sym0
instance Data.Singletons.Prelude.Show.PShow Data.Elf.Headers.ElfClass
instance Data.Singletons.SuppressUnusedWarnings.SuppressUnusedWarnings (Data.Elf.Headers.ShowsPrec_6989586621679243414Sym1 a6989586621679243424)
instance Data.Singletons.SuppressUnusedWarnings.SuppressUnusedWarnings (Data.Elf.Headers.ShowsPrec_6989586621679243414Sym2 a6989586621679243424 a6989586621679243425)
instance Data.Binary.Class.Binary Data.Elf.Headers.ElfClass
-- | Parse/serialize ELF files into structured data
module Data.Elf
-- | Elf is a forrest of trees of type ElfXX. Trees are
-- composed of ElfXX nodes, ElfSegment can contain subtrees
newtype ElfList c
ElfList :: [ElfXX c] -> ElfList c
-- | Elf is a sigma type where ElfClass defines the type of
-- ElfList
type Elf = Sigma ElfClass (TyCon1 ElfList)
-- | Section data may contain a string table. If a section contains a
-- string table with section names, the data for such a section is
-- generated and esData should contain
-- ElfSectionDataStringTable
data ElfSectionData
-- | Regular section data
ElfSectionData :: ByteString -> ElfSectionData
-- | Section data will be generated from section names
ElfSectionDataStringTable :: ElfSectionData
-- | The type of node that defines Elf structure.
data ElfXX (c :: ElfClass)
ElfHeader :: ElfData -> ElfOSABI -> Word8 -> ElfType -> ElfMachine -> WordXX c -> Word32 -> ElfXX (c :: ElfClass)
-- | Data encoding (big- or little-endian)
[ehData] :: ElfXX (c :: ElfClass) -> ElfData
-- | OS/ABI identification
[ehOSABI] :: ElfXX (c :: ElfClass) -> ElfOSABI
-- | ABI version
[ehABIVersion] :: ElfXX (c :: ElfClass) -> Word8
-- | Object file type
[ehType] :: ElfXX (c :: ElfClass) -> ElfType
-- | Machine type
[ehMachine] :: ElfXX (c :: ElfClass) -> ElfMachine
-- | Entry point address
[ehEntry] :: ElfXX (c :: ElfClass) -> WordXX c
-- | Processor-specific flags
[ehFlags] :: ElfXX (c :: ElfClass) -> Word32
ElfSectionTable :: ElfXX (c :: ElfClass)
ElfSegmentTable :: ElfXX (c :: ElfClass)
ElfSection :: String -> ElfSectionType -> ElfSectionFlag -> WordXX c -> WordXX c -> WordXX c -> ElfSectionIndex -> Word32 -> Word32 -> ElfSectionData -> ElfXX (c :: ElfClass)
-- | Section name (NB: string, not offset in the string table)
[esName] :: ElfXX (c :: ElfClass) -> String
-- | Section type
[esType] :: ElfXX (c :: ElfClass) -> ElfSectionType
-- | Section attributes
[esFlags] :: ElfXX (c :: ElfClass) -> ElfSectionFlag
-- | Virtual address in memory
[esAddr] :: ElfXX (c :: ElfClass) -> WordXX c
-- | Address alignment boundary
[esAddrAlign] :: ElfXX (c :: ElfClass) -> WordXX c
-- | Size of entries, if section has table
[esEntSize] :: ElfXX (c :: ElfClass) -> WordXX c
-- | Section number
[esN] :: ElfXX (c :: ElfClass) -> ElfSectionIndex
-- | Miscellaneous information
[esInfo] :: ElfXX (c :: ElfClass) -> Word32
-- | Link to other section
[esLink] :: ElfXX (c :: ElfClass) -> Word32
-- | The content of the section
[esData] :: ElfXX (c :: ElfClass) -> ElfSectionData
ElfSegment :: ElfSegmentType -> ElfSegmentFlag -> WordXX c -> WordXX c -> WordXX c -> WordXX c -> [ElfXX c] -> ElfXX (c :: ElfClass)
-- | Type of segment
[epType] :: ElfXX (c :: ElfClass) -> ElfSegmentType
-- | Segment attributes
[epFlags] :: ElfXX (c :: ElfClass) -> ElfSegmentFlag
-- | Virtual address in memory
[epVirtAddr] :: ElfXX (c :: ElfClass) -> WordXX c
-- | Physical address
[epPhysAddr] :: ElfXX (c :: ElfClass) -> WordXX c
-- | Add this amount of memory after the section when the section is loaded
-- to memory by execution system. Or, in other words this is how much
-- pMemSize is bigger than pFileSize
[epAddMemSize] :: ElfXX (c :: ElfClass) -> WordXX c
-- | Alignment of segment
[epAlign] :: ElfXX (c :: ElfClass) -> WordXX c
-- | Content of the segment
[epData] :: ElfXX (c :: ElfClass) -> [ElfXX c]
-- | Some ELF files (some executables) don't bother to define sections for
-- linking and have just raw data in segments.
ElfRawData :: ByteString -> ElfXX (c :: ElfClass)
-- | Raw data in ELF file
[edData] :: ElfXX (c :: ElfClass) -> ByteString
-- | Align the next data in the ELF file. The offset of the next data in
-- the ELF file will be the minimal x such that x mod
-- eaAlign == eaOffset mod eaAlign
ElfRawAlign :: WordXX c -> WordXX c -> ElfXX (c :: ElfClass)
-- | Align value
[eaOffset] :: ElfXX (c :: ElfClass) -> WordXX c
-- | Align module
[eaAlign] :: ElfXX (c :: ElfClass) -> WordXX c
-- | Parse ELF file
parseElf :: MonadCatch m => ByteString -> m Elf
-- | Serialze ELF file
serializeElf :: MonadThrow m => Elf -> m ByteString
-- | Get section data
getSectionData :: IsElfClass a => ByteString -> SectionXX a -> ByteString
-- | Get string from string table
getString :: ByteString -> Int64 -> String
-- | Find section with a given number
elfFindSection :: forall a m b. (SingI a, MonadThrow m, Integral b, Show b) => [ElfXX a] -> b -> m (ElfXX a)
-- | Find ELF header
elfFindHeader :: forall a m. (SingI a, MonadThrow m) => [ElfXX a] -> m (ElfXX a)
-- | Parsed ELF symbol table entry. NB: This is work in progress
data ElfSymbolXX (c :: ElfClass)
ElfSymbolXX :: String -> ElfSymbolBinding -> ElfSymbolType -> ElfSectionIndex -> WordXX c -> WordXX c -> ElfSymbolXX (c :: ElfClass)
-- | Symbol name (NB: String, not string index)
[steName] :: ElfSymbolXX (c :: ElfClass) -> String
-- | Symbol binding attributes
[steBind] :: ElfSymbolXX (c :: ElfClass) -> ElfSymbolBinding
-- | Symbol Type
[steType] :: ElfSymbolXX (c :: ElfClass) -> ElfSymbolType
-- | Section table index
[steShNdx] :: ElfSymbolXX (c :: ElfClass) -> ElfSectionIndex
-- | Symbol value
[steValue] :: ElfSymbolXX (c :: ElfClass) -> WordXX c
-- | Size of object
[steSize] :: ElfSymbolXX (c :: ElfClass) -> WordXX c
-- | Parse symbol table
parseSymbolTable :: (MonadThrow m, SingI a) => ElfData -> ElfXX a -> [ElfXX a] -> m [ElfSymbolXX a]
-- | Serialize symbol table
serializeSymbolTable :: (MonadThrow m, SingI a) => ElfData -> [ElfSymbolXX a] -> m (ByteString, ByteString)
-- | Pretty print the data parsed by Data.Elf. Basically these
-- functions are used for golden testing.
module Data.Elf.PrettyPrint
-- | Print parsed headers. It's used in golden tests
printHeaders :: SingI a => HeaderXX a -> [SectionXX a] -> [SegmentXX a] -> Doc ()
-- | Print ELF layout. First parse ELF with parseHeaders, then use
-- this function to format the layout.
printLayout :: MonadCatch m => Sigma ElfClass (TyCon1 HeadersXX) -> ByteString -> m (Doc ())
-- | 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 => Bool -> Elf -> m (Doc ())
-- | Same as printElf_ False
printElf :: MonadThrow m => Elf -> m (Doc ())
-- | Print string table. It's used in golden tests
printStringTable :: MonadThrow m => ByteString -> m (Doc ())
printHeader :: forall a. SingI a => HeaderXX a -> Doc ()
-- | Read the file strictly but return lazy bytestring
readFileLazy :: FilePath -> IO ByteString
-- | Read ELF from one file, printElf it into another.
writeElfDump :: FilePath -> FilePath -> IO ()
-- | Read ELF from one file, printLayout it into another.
writeElfLayout :: FilePath -> FilePath -> IO ()
-- | 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 ]
splitBits :: (Num w, FiniteBits w) => w -> [w]