-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | An Elf parser -- -- Parser for ELF object format @package melf @version 1.3.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 -- | Standalone (embedded) application pattern ELFOSABI_STANDALONE :: ElfOSABI -- | ARM pattern ELFOSABI_ARM :: ElfOSABI -- | Amiga Research OS pattern ELFOSABI_AROS :: ElfOSABI -- | Hewlett-Packard Non-Stop Kernel pattern ELFOSABI_NSK :: ElfOSABI -- | Open VMS pattern ELFOSABI_OPENVMS :: ElfOSABI -- | Open BSD pattern ELFOSABI_OPENBSD :: ElfOSABI -- | Novell Modesto pattern ELFOSABI_MODESTO :: ElfOSABI -- | Compaq TRU64 UNIX pattern ELFOSABI_TRU64 :: ElfOSABI -- | FreeBSD pattern ELFOSABI_FREEBSD :: ElfOSABI -- | IRIX pattern ELFOSABI_IRIX :: ElfOSABI -- | AIX pattern ELFOSABI_AIX :: ElfOSABI -- | Sun Solaris pattern ELFOSABI_SOLARIS :: ElfOSABI -- | Linux pattern ELFOSABI_LINUX :: ElfOSABI -- | NetBSD pattern ELFOSABI_NETBSD :: ElfOSABI -- | Hewlett-Packard HP-UX pattern ELFOSABI_HPUX :: ElfOSABI -- | No extensions or unspecified pattern ELFOSABI_SYSV :: ElfOSABI -- | Object file type newtype ElfType ElfType :: Word16 -> ElfType -- | Core dump object file pattern ET_CORE :: ElfType -- | Shared object file pattern ET_DYN :: ElfType -- | Executable object file pattern ET_EXEC :: ElfType -- | Relocatable object file pattern ET_REL :: ElfType -- | Unspecified type pattern ET_NONE :: ElfType -- | Target architecture newtype ElfMachine ElfMachine :: Word16 -> ElfMachine -- | ELF for the Arm 64-bit Architecture (AArch64) pattern EM_AARCH64 :: ElfMachine -- | Microprocessor series from PKU-Unity Ltd. and MPRC of Peking -- University pattern EM_UNICORE :: ElfMachine -- | Arca RISC Microprocessor pattern EM_ARCA :: ElfMachine -- | Sharp embedded microprocessor pattern EM_SEP :: ElfMachine -- | S1C33 Family of Seiko Epson processors pattern EM_SE_C33 :: ElfMachine -- | Analog Devices Blackfin (DSP) processor pattern EM_BLACKFIN :: ElfMachine -- | Texas Instruments embedded microcontroller msp430 pattern EM_MSP430 :: ElfMachine -- | Fujitsu F2MC16 pattern EM_F2MC16 :: ElfMachine -- | National Semiconductor CompactRISC microprocessor pattern EM_CR :: ElfMachine -- | MAX Processor pattern EM_MAX :: ElfMachine -- | Ubicom IP2xxx microcontroller family pattern EM_IP2K :: ElfMachine -- | STMicroelectronics (www.st.com) ST200 microcontroller pattern EM_ST200 :: ElfMachine -- | Trebia SNP 1000 processor pattern EM_SNP1K :: ElfMachine -- | Tenor Network TPC processor pattern EM_TPC :: ElfMachine -- | National Semiconductor 32000 series pattern EM_NS32K :: ElfMachine -- | Thompson Multimedia General Purpose Processor pattern EM_TMM_GPP :: ElfMachine -- | Alphamosaic VideoCore processor pattern EM_VIDEOCORE :: ElfMachine -- | Tensilica Xtensa Architecture pattern EM_XTENSA :: ElfMachine -- | ARC Cores Tangent-A5 pattern EM_ARC_A5 :: ElfMachine -- | OpenRISC 32-bit embedded processor pattern EM_OPENRISC :: ElfMachine -- | picoJava pattern EM_PJ :: ElfMachine -- | Matsushita MN10200 pattern EM_MN10200 :: ElfMachine -- | Matsushita MN10300 pattern EM_MN10300 :: ElfMachine -- | Mitsubishi M32R pattern EM_M32R :: ElfMachine -- | NEC v850 pattern EM_V850 :: ElfMachine -- | Mitsubishi D30V pattern EM_D30V :: ElfMachine -- | Mitsubishi D10V pattern EM_D10V :: ElfMachine -- | Fujitsu FR30 pattern EM_FR30 :: ElfMachine -- | Atmel AVR 8-bit microcontroller pattern EM_AVR :: ElfMachine -- | SiTera Prism pattern EM_PRISM :: ElfMachine -- | Harvard University machine-independent object files pattern EM_HUANY :: ElfMachine -- | Donald Knuth's educational 64-bit processor pattern EM_MMIX :: ElfMachine -- | LSI Logic 16-bit DSP Processor pattern EM_ZSP :: ElfMachine -- | Element 14 64-bit DSP Processor pattern EM_FIREPATH :: ElfMachine -- | Infineon Technologies 32-bit embedded processor pattern EM_JAVELIN :: ElfMachine -- | Axis Communications 32-bit embedded processor pattern EM_CRIS :: ElfMachine -- | Digital VAX pattern EM_VAX :: ElfMachine -- | STMicroelectronics ST19 8-bit microcontroller pattern EM_ST19 :: ElfMachine -- | Silicon Graphics SVx pattern EM_SVX :: ElfMachine -- | Motorola MC68HC05 Microcontroller pattern EM_68HC05 :: ElfMachine -- | Motorola MC68HC08 Microcontroller pattern EM_68HC08 :: ElfMachine -- | Motorola MC68HC11 Microcontroller pattern EM_68HC11 :: ElfMachine -- | Motorola MC68HC16 Microcontroller pattern EM_68HC16 :: ElfMachine -- | STMicroelectronics ST7 8-bit microcontroller pattern EM_ST7 :: ElfMachine -- | STMicroelectronics ST9+ 8/16 bit microcontroller pattern EM_ST9PLUS :: ElfMachine -- | Siemens FX66 microcontroller pattern EM_FX66 :: ElfMachine -- | Sony DSP Processor pattern EM_PDSP :: ElfMachine -- | AMD x86-64 architecture pattern EM_X86_64 :: ElfMachine -- | Advanced Logic Corp. TinyJ embedded processor family pattern EM_TINYJ :: ElfMachine -- | STMicroelectronics ST100 processor pattern EM_ST100 :: ElfMachine -- | Toyota ME16 processor pattern EM_ME16 :: ElfMachine -- | Motorola Star*Core processor pattern EM_STARCORE :: ElfMachine -- | Denso NDR1 microprocessor pattern EM_NDR1 :: ElfMachine -- | Sony nCPU embedded RISC processor pattern EM_NCPU :: ElfMachine -- | Siemens PCP pattern EM_PCP :: ElfMachine -- | Fujitsu MMA Multimedia Accelerator pattern EM_MMA :: ElfMachine -- | Motorola M68HC12 pattern EM_68HC12 :: ElfMachine -- | Motorola ColdFire pattern EM_COLDFIRE :: ElfMachine -- | Stanford MIPS-X pattern EM_MIPS_X :: ElfMachine -- | Intel IA-64 processor architecture pattern EM_IA_64 :: ElfMachine -- | Hitachi H8/500 pattern EM_H8_500 :: ElfMachine -- | Hitachi H8S pattern EM_H8S :: ElfMachine -- | Hitachi H8/300H pattern EM_H8_300H :: ElfMachine -- | Hitachi H8/300 pattern EM_H8_300 :: ElfMachine -- | Argonaut RISC Core, Argonaut Technologies Inc. pattern EM_ARC :: ElfMachine -- | Siemens TriCore embedded processor pattern EM_TRICORE :: ElfMachine -- | SPARC Version 9 pattern EM_SPARCV9 :: ElfMachine -- | Hitachi SH pattern EM_SH :: ElfMachine -- | Digital Alpha pattern EM_ALPHA :: ElfMachine -- | Advanced RISC Machines ARM pattern EM_ARM :: ElfMachine -- | Motorola RCE pattern EM_RCE :: ElfMachine -- | TRW RH-32 pattern EM_RH32 :: ElfMachine -- | Fujitsu FR20 pattern EM_FR20 :: ElfMachine -- | NEC V800 pattern EM_V800 :: ElfMachine -- | Cell SPU pattern EM_SPU :: ElfMachine -- | IBM System/390 Processor pattern EM_S390 :: ElfMachine -- | 64-bit PowerPC pattern EM_PPC64 :: ElfMachine -- | PowerPC pattern EM_PPC :: ElfMachine -- | Intel 80960 pattern EM_960 :: ElfMachine -- | Enhanced instruction set SPARC pattern EM_SPARC32PLUS :: ElfMachine -- | Fujitsu VPP500 pattern EM_VPP500 :: ElfMachine -- | Hewlett-Packard PA-RISC pattern EM_PARISC :: ElfMachine -- | SPARC 64-bit pattern EM_SPARC64 :: ElfMachine -- | MIPS RS3000 Little-endian pattern EM_MIPS_RS3_LE :: ElfMachine -- | IBM System/370 Processor pattern EM_S370 :: ElfMachine -- | MIPS I Architecture pattern EM_MIPS :: ElfMachine -- | Intel 80860 pattern EM_860 :: ElfMachine -- | Intel i486 (DO NOT USE THIS ONE) pattern EM_486 :: ElfMachine -- | Motorola 88000 pattern EM_88K :: ElfMachine -- | Motorola 68000 pattern EM_68K :: ElfMachine -- | Intel 80386 pattern EM_386 :: ElfMachine -- | SPARC pattern EM_SPARC :: ElfMachine -- | AT&T WE 32100 pattern EM_M32 :: ElfMachine -- | No machine pattern EM_NONE :: ElfMachine -- | Section type newtype ElfSectionType ElfSectionType :: Word32 -> ElfSectionType -- | Contains a dynamic loader symbol table pattern SHT_DYNSYM :: ElfSectionType -- | Reserved pattern SHT_SHLIB :: ElfSectionType -- | Contains Rel type relocation entries pattern SHT_REL :: ElfSectionType -- | Contains uninitialized space; does not occupy any space in the file pattern SHT_NOBITS :: ElfSectionType -- | Contains note information pattern SHT_NOTE :: ElfSectionType -- | Contains dynamic linking tables pattern SHT_DYNAMIC :: ElfSectionType -- | Contains a symbol hash table pattern SHT_HASH :: ElfSectionType -- | Contains Rela type relocation entries pattern SHT_RELA :: ElfSectionType -- | Contains a string table pattern SHT_STRTAB :: ElfSectionType -- | Contains a linker symbol table pattern SHT_SYMTAB :: ElfSectionType -- | Contains information defined by the program pattern SHT_PROGBITS :: ElfSectionType -- | Identifies an empty section header. pattern SHT_NULL :: ElfSectionType -- | Segment type newtype ElfSegmentType ElfSegmentType :: Word32 -> ElfSegmentType -- | Program header table pattern PT_PHDR :: ElfSegmentType -- | Reserved pattern PT_SHLIB :: ElfSegmentType -- | Note section pattern PT_NOTE :: ElfSegmentType -- | Program interpreter path name pattern PT_INTERP :: ElfSegmentType -- | Dynamic linking tables pattern PT_DYNAMIC :: ElfSegmentType -- | Loadable segment pattern PT_LOAD :: ElfSegmentType -- | Unused entry pattern PT_NULL :: ElfSegmentType -- | Attributes of the section newtype ElfSectionFlag ElfSectionFlag :: Word64 -> ElfSectionFlag -- | Section contains executable instructions pattern SHF_EXECINSTR :: ElfSectionFlag -- | Section is allocated in memory image of program pattern SHF_ALLOC :: ElfSectionFlag -- | Section contains writable data pattern SHF_WRITE :: ElfSectionFlag -- | Attributes of the segment newtype ElfSegmentFlag ElfSegmentFlag :: Word32 -> ElfSegmentFlag -- | Read permission pattern PF_R :: ElfSegmentFlag -- | Write permission pattern PF_W :: ElfSegmentFlag -- | Execute permission pattern PF_X :: ElfSegmentFlag -- | Symbol type newtype ElfSymbolType ElfSymbolType :: Word8 -> ElfSymbolType -- | HiProc pattern STT_HiProc :: ElfSymbolType -- | LoProc pattern STT_LoProc :: ElfSymbolType -- | HiOS pattern STT_HiOS :: ElfSymbolType -- | LoOS pattern STT_LoOS :: ElfSymbolType -- | TLS pattern STT_TLS :: ElfSymbolType -- | Common pattern STT_Common :: ElfSymbolType -- | File pattern STT_File :: ElfSymbolType -- | Section pattern STT_Section :: ElfSymbolType -- | Func pattern STT_Func :: ElfSymbolType -- | Object pattern STT_Object :: ElfSymbolType -- | NoType pattern STT_NoType :: ElfSymbolType -- | Symbol binding newtype ElfSymbolBinding ElfSymbolBinding :: 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_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 -- | Indirect(Delta(S) + A) pattern R_AARCH64_IRELATIVE :: ElfRelocationType_AARCH64 -- | TLSDESC(S + A) pattern R_AARCH64_TLSDESC :: ElfRelocationType_AARCH64 -- | TPREL(S + A) pattern R_AARCH64_TLS_TPREL :: ElfRelocationType_AARCH64 -- | LDM(S) pattern R_AARCH64_TLS_DTPREL :: ElfRelocationType_AARCH64 -- | DTPREL(S + A) pattern R_AARCH64_TLS_DTPMOD :: ElfRelocationType_AARCH64 -- | Delta(S + A) pattern R_AARCH64_RELATIVE :: ElfRelocationType_AARCH64 -- | S + A pattern R_AARCH64_JUMP_SLOT :: ElfRelocationType_AARCH64 -- | S + A pattern R_AARCH64_GLOB_DAT :: ElfRelocationType_AARCH64 pattern R_AARCH64_COPY :: ElfRelocationType_AARCH64 -- | None | For relaxation only. Must be used to identify a BLR instruction -- which performs an indirect call to the TLS descriptor function for S + -- A pattern R_AARCH64_TLSDESC_CALL :: ElfRelocationType_AARCH64 -- | None | For relaxation only. Must be used to identify an ADD -- instruction which computes the address of the TLS Descriptor for S + A -- if it has no other relocation pattern R_AARCH64_TLSDESC_ADD :: ElfRelocationType_AARCH64 -- | None | For relaxation only. Must be used to identify an LDR -- instruction which loads the TLS descriptor function pointer for S + A -- if it has no other relocation pattern R_AARCH64_TLSDESC_LDR :: ElfRelocationType_AARCH64 -- | G(GTLSDESC(S+A)) - GOT | Set a MOVK immediate field to bits [15:0] of -- X. No overflow check pattern R_AARCH64_TLSDESC_OFF_G0_NC :: ElfRelocationType_AARCH64 -- | G(GTLSDESC(S+A)) - GOT | Set a MOV[NZ] immediate field to bits [31:16] -- of X; check -2^32 <= X < 2^32 pattern R_AARCH64_TLSDESC_OFF_G1 :: ElfRelocationType_AARCH64 -- | G(GTLSDESC(S+A)) | Set an ADD immediate field to bits [11:0] of X. No -- overflow check pattern R_AARCH64_TLSDESC_ADD_LO12 :: ElfRelocationType_AARCH64 -- | G(GTLSDESC(S+A)) | Set an LD offset field to bits [11:3] of X. No -- overflow check; check X & 7 = 0 pattern R_AARCH64_TLSDESC_LD64_LO12 :: ElfRelocationType_AARCH64 -- | Page(G(GTLSDESC(S+A))) - Page(P) | Set an ADRP immediate field to bits -- [32:12] of X; check -2^32 <= X < 2^32 pattern R_AARCH64_TLSDESC_ADR_PAGE21 :: ElfRelocationType_AARCH64 -- | G(GTLSDESC(S+A)) - P | Set an ADR immediate field to bits [20:0]; -- check -2^20 <= X < 2^20 pattern R_AARCH64_TLSDESC_ADR_PREL21 :: ElfRelocationType_AARCH64 -- | G(GTLSDESC(S+A)) - P | Set a load-literal immediate to bits [20:2]; -- check -2^20 <= X < 2^20 ; check X & 3 = 0 pattern R_AARCH64_TLSDESC_LD_PREL19 :: ElfRelocationType_AARCH64 -- | TPREL(S+A) | Set a LD/ST offset field to bits [11:4] of X. No overflow -- check pattern R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC :: ElfRelocationType_AARCH64 -- | TPREL(S+A) | Set a LD/ST offset field to bits [11:4] of X; check 0 -- <= X < 2^12 pattern R_AARCH64_TLSLE_LDST128_TPREL_LO12 :: ElfRelocationType_AARCH64 -- | TPREL(S+A) | Set a LD/ST offset field to bits [11:3] of X. No overflow -- check pattern R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC :: ElfRelocationType_AARCH64 -- | TPREL(S+A) | Set a LD/ST offset field to bits [11:3] of X; check 0 -- <= X < 2^12 pattern R_AARCH64_TLSLE_LDST64_TPREL_LO12 :: ElfRelocationType_AARCH64 -- | TPREL(S+A) | Set a LD/ST offset field to bits [11:2] of X. No overflow -- check pattern R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC :: ElfRelocationType_AARCH64 -- | TPREL(S+A) | Set a LD/ST offset field to bits [11:2] of X; check 0 -- <= X < 2^12 pattern R_AARCH64_TLSLE_LDST32_TPREL_LO12 :: ElfRelocationType_AARCH64 -- | TPREL(S+A) | Set a LD/ST offset field to bits [11:1] of X. No overflow -- check pattern R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC :: ElfRelocationType_AARCH64 -- | TPREL(S+A) | Set a LD/ST offset field to bits [11:1] of X; check 0 -- <= X < 2^12 pattern R_AARCH64_TLSLE_LDST16_TPREL_LO12 :: ElfRelocationType_AARCH64 -- | TPREL(S+A) | Set a LD/ST offset field to bits [11:0] of X. No overflow -- check pattern R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC :: ElfRelocationType_AARCH64 -- | TPREL(S+A) | Set a LD/ST offset field to bits [11:0] of X; check 0 -- <= X < 2^12 pattern R_AARCH64_TLSLE_LDST8_TPREL_LO12 :: ElfRelocationType_AARCH64 -- | TPREL(S+A) | Set an ADD immediate field to bits [11:0] of X. No -- overflow check pattern R_AARCH64_TLSLE_ADD_TPREL_LO12_NC :: ElfRelocationType_AARCH64 -- | TPREL(S+A) | Set an ADD immediate field to bits [11:0] of X; check 0 -- <= X < 2^12 pattern R_AARCH64_TLSLE_ADD_TPREL_LO12 :: ElfRelocationType_AARCH64 -- | TPREL(S+A) | Set an ADD immediate field to bits [23:12] of X; check 0 -- <= X < 2^24 pattern R_AARCH64_TLSLE_ADD_TPREL_HI12 :: ElfRelocationType_AARCH64 -- | TPREL(S+A) | Set a MOVK immediate field to bits [15:0] of X. No -- overflow check pattern R_AARCH64_TLSLE_MOVW_TPREL_G0_NC :: ElfRelocationType_AARCH64 -- | TPREL(S+A) | Set a MOV[NZ] immediate field to bits [15:0] of X pattern R_AARCH64_TLSLE_MOVW_TPREL_G0 :: ElfRelocationType_AARCH64 -- | TPREL(S+A) | Set a MOVK immediate field to bits [31:16] of X. No -- overflow check pattern R_AARCH64_TLSLE_MOVW_TPREL_G1_NC :: ElfRelocationType_AARCH64 -- | TPREL(S+A) | Set a MOV[NZ] immediate field to bits [31:16] of X pattern R_AARCH64_TLSLE_MOVW_TPREL_G1 :: ElfRelocationType_AARCH64 -- | TPREL(S+A) | Set a MOV[NZ] immediate field to bits [47:32] of X pattern R_AARCH64_TLSLE_MOVW_TPREL_G2 :: ElfRelocationType_AARCH64 -- | G(GTPREL(S+A)) - P | Set a load-literal immediate to bits [20:2] of X; -- check –2^20 <= X < 2^20 pattern R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 :: ElfRelocationType_AARCH64 -- | G(GTPREL(S+A)) | Set an LD offset field to bits [11:3] of X. No -- overflow check; check that X&7=0 pattern R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC :: ElfRelocationType_AARCH64 -- | Page(G(GTPREL(S+A))) - Page(P) | Set an ADRP immediate field to bits -- [32:12] of X; check –2^32 <= X < 2^32 pattern R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 :: ElfRelocationType_AARCH64 -- | G(GTPREL(S+A)) - | GOT Set MOVK immediate to bits [15:0] of X. No -- overflow check pattern R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC :: ElfRelocationType_AARCH64 -- | G(GTPREL(S+A)) - | GOT Set a MOV[NZ] immediate field to bits [31:16] -- of X pattern R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 :: ElfRelocationType_AARCH64 -- | DTPREL(S+A) | Set a LD/ST offset field to bits [11:4] of X. No -- overflow check pattern R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC :: ElfRelocationType_AARCH64 -- | DTPREL(S+A) | Set a LD/ST offset field to bits [11:4] of X; check 0 -- <= X < 2^12 pattern R_AARCH64_TLSLD_LDST128_DTPREL_LO12 :: ElfRelocationType_AARCH64 -- | DTPREL(S+A) | Set a LD/ST offset field to bits [11:3] of X. No -- overflow check pattern R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC :: ElfRelocationType_AARCH64 -- | DTPREL(S+A) | Set a LD/ST offset field to bits [11:3] of X; check 0 -- <= X < 2^12 pattern R_AARCH64_TLSLD_LDST64_DTPREL_LO12 :: ElfRelocationType_AARCH64 -- | DTPREL(S+A) | Set a LD/ST offset field to bits [11:2] of X. No -- overflow check pattern R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC :: ElfRelocationType_AARCH64 -- | DTPREL(S+A) | Set a LD/ST offset field to bits [11:2] of X; check 0 -- <= X < 2^12 pattern R_AARCH64_TLSLD_LDST32_DTPREL_LO12 :: ElfRelocationType_AARCH64 -- | DTPREL(S+A) | Set a LD/ST offset field to bits [11:1] of X. No -- overflow check pattern R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC :: ElfRelocationType_AARCH64 -- | DTPREL(S+A) | Set a LD/ST offset field to bits [11:1] of X; check 0 -- <= X < 2^12 pattern R_AARCH64_TLSLD_LDST16_DTPREL_LO12 :: ElfRelocationType_AARCH64 -- | DTPREL(S+A) | Set a LD/ST offset field to bits [11:0] of X. No -- overflow check pattern R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC :: ElfRelocationType_AARCH64 -- | DTPREL(S+A) | Set a LD/ST offset field to bits [11:0] of X; check 0 -- <= X < 2^12 pattern R_AARCH64_TLSLD_LDST8_DTPREL_LO12 :: ElfRelocationType_AARCH64 -- | DTPREL(S+A) | Set an ADD immediate field to bits [11:0] of X. No -- overflow check pattern R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC :: ElfRelocationType_AARCH64 -- | DTPREL(S+A) | Set an ADD immediate field to bits [11:0] of X; check 0 -- <= X < 2^12 pattern R_AARCH64_TLSLD_ADD_DTPREL_LO12 :: ElfRelocationType_AARCH64 -- | DTPREL(S+A) | Set an ADD immediate field to bits [23:12] of X; check 0 -- <= X < 2^24 pattern R_AARCH64_TLSLD_ADD_DTPREL_HI12 :: ElfRelocationType_AARCH64 -- | DTPREL(S+A) | Set a MOVK immediate field to bits [15:0] of X. No -- overflow check pattern R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC :: ElfRelocationType_AARCH64 -- | DTPREL(S+A) | Set a MOV[NZ] immediate field to bits [15:0] of X pattern R_AARCH64_TLSLD_MOVW_DTPREL_G0 :: ElfRelocationType_AARCH64 -- | DTPREL(S+A) | Set a MOVK immediate field to bits [31:16] of X. No -- overflow check pattern R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC :: ElfRelocationType_AARCH64 -- | DTPREL(S+A) | Set a MOV[NZ] immediate field to bits [31:16] of X pattern R_AARCH64_TLSLD_MOVW_DTPREL_G1 :: ElfRelocationType_AARCH64 -- | DTPREL(S+A) | Set a MOV[NZ] immediate field to bits [47:32] of X pattern R_AARCH64_TLSLD_MOVW_DTPREL_G2 :: ElfRelocationType_AARCH64 -- | G(GLDM(S)) - P | Set a load-literal immediate field to bits [20:2] of -- X; check –2^20 <= X < 2^20 pattern R_AARCH64_TLSLD_LD_PREL19 :: ElfRelocationType_AARCH64 -- | G(GLDM(S)) - GOT | Set a MOVK immediate field to bits [15:0] of X. No -- overflow check pattern R_AARCH64_TLSLD_MOVW_G0_NC :: ElfRelocationType_AARCH64 -- | G(GLDM(S)) - GOT | Set a MOV[NZ] immediate field to bits [31:16] of X pattern R_AARCH64_TLSLD_MOVW_G1 :: ElfRelocationType_AARCH64 -- | G(GLDM(S)) | Set an ADD immediate field to bits [11:0] of X. No -- overflow check pattern R_AARCH64_TLSLD_ADD_LO12_NC :: ElfRelocationType_AARCH64 -- | Page(G(GLDM(S))) - Page(P) | Set an ADRP immediate field to bits -- [32:12] of X; check –2^32 <= X < 2^32 pattern R_AARCH64_TLSLD_ADR_PAGE21 :: ElfRelocationType_AARCH64 -- | G(GLDM(S))) - P | Set an ADR immediate field to bits [20:0] of X; -- check –2^20 <= X < 2^20 pattern R_AARCH64_TLSLD_ADR_PREL21 :: ElfRelocationType_AARCH64 -- | G(GDAT(S + A))- Page(GOT) | Set the LD/ST immediate field to bits -- [14:3] of X; check that 0 <= X < 2^15, X&7 = 0 pattern R_AARCH64_LD64_GOTPAGE_LO15 :: ElfRelocationType_AARCH64 -- | G(GDAT(S + A)) | Set the LD/ST immediate field to bits [11:3] of X. No -- overflow check; check that X&7 = 0 pattern R_AARCH64_LD64_GOT_LO12_NC :: ElfRelocationType_AARCH64 -- | Page(G(GDAT(S + A)))- Page(P) | Set the immediate value of an ADRP to -- bits [32:12] of X; check that –2^32 <= X < 2^32 pattern R_AARCH64_ADR_GOT_PAGE :: ElfRelocationType_AARCH64 -- | G(GDAT(S + A))- GOT | Set a LD/ST immediate field to bits [14:3] of X; -- check that 0 <= X < 2^15 , X&7 = 0 pattern R_AARCH64_LD64_GOTOFF_LO15 :: ElfRelocationType_AARCH64 -- | G(GDAT(S + A))- P | Set a load-literal immediate field to bits [20:2] -- of X; check –2^20 <= X < 2^20 pattern R_AARCH64_GOT_LD_PREL19 :: ElfRelocationType_AARCH64 -- | S + A - GOT | Set the data to a 32-bit offset relative to GOT, treated -- as signed; check that -2^31 <= X < 2^31 pattern R_AARCH64_GOTREL32 :: ElfRelocationType_AARCH64 -- | S + A - GOT | Set the data to a 64-bit offset relative to the GOT pattern R_AARCH64_GOTREL64 :: ElfRelocationType_AARCH64 -- | G(GDAT(S + A)) - GOT | Set a MOV[NZ] immediate value to bits [63:48] -- of X pattern R_AARCH64_MOVW_GOTOFF_G3 :: ElfRelocationType_AARCH64 -- | G(GDAT(S + A)) - GOT | Set a MOVK immediate value to bits [47:32] of -- X. No overflow check pattern R_AARCH64_MOVW_GOTOFF_G2_NC :: ElfRelocationType_AARCH64 -- | G(GDAT(S + A)) - GOT | Set a MOV[NZ] immediate value to bits [47:32] -- of X pattern R_AARCH64_MOVW_GOTOFF_G2 :: ElfRelocationType_AARCH64 -- | G(GDAT(S + A)) - GOT | Set a MOVK immediate value to bits [31:16] of -- X. No overflow check pattern R_AARCH64_MOVW_GOTOFF_G1_NC :: ElfRelocationType_AARCH64 -- | G(GDAT(S + A)) - GOT | Set a MOV[NZ] immediate value to bits [31:16] -- of X pattern R_AARCH64_MOVW_GOTOFF_G1 :: ElfRelocationType_AARCH64 -- | G(GDAT(S + A)) - GOT | Set a MOVK immediate field to bits [15:0] of X. -- No overflow check pattern R_AARCH64_MOVW_GOTOFF_G0_NC :: ElfRelocationType_AARCH64 -- | G(GDAT(S + A)) - GOT | Set a MOV[NZ] immediate field to bits [15:0] of -- X pattern R_AARCH64_MOVW_GOTOFF_G0 :: ElfRelocationType_AARCH64 -- | S + A - P | Set a MOV[NZ]immediate value to bits [63:48] of X pattern R_AARCH64_MOVW_PREL_G3 :: ElfRelocationType_AARCH64 -- | S + A - P | Set a MOVK immediate field to bits [47:32] of X. No -- overflow check pattern R_AARCH64_MOVW_PREL_G2_NC :: ElfRelocationType_AARCH64 -- | S + A - P | Set a MOV[NZ]immediate value to bits [47:32] of X pattern R_AARCH64_MOVW_PREL_G2 :: ElfRelocationType_AARCH64 -- | S + A - P | Set a MOVK immediate field to bits [31:16] of X. No -- overflow check pattern R_AARCH64_MOVW_PREL_G1_NC :: ElfRelocationType_AARCH64 -- | S + A - P | Set a MOV[NZ]immediate field to bits [31:16] of X pattern R_AARCH64_MOVW_PREL_G1 :: ElfRelocationType_AARCH64 -- | S + A - P | Set a MOVK immediate field to bits [15:0] of X. No -- overflow check pattern R_AARCH64_MOVW_PREL_G0_NC :: ElfRelocationType_AARCH64 -- | S + A - P | Set a MOV[NZ]immediate field to bits [15:0] of X pattern R_AARCH64_MOVW_PREL_G0 :: ElfRelocationType_AARCH64 -- | S + A - P | Set a CALL immediate field to bits [27:2] of X; check that -- -2^27 <= X < 2^27 pattern R_AARCH64_CALL26 :: ElfRelocationType_AARCH64 -- | S + A - P | Set a B immediate field to bits [27:2] of X; check that -- -2^27 <= X < 2^27 pattern R_AARCH64_JUMP26 :: ElfRelocationType_AARCH64 -- | S + A - P | Set the immediate field of a conditional branch -- instruction to bits [20:2] of X; check -2^20 <= X< 2^20 pattern R_AARCH64_CONDBR19 :: ElfRelocationType_AARCH64 -- | S + A - P | Set the immediate field of a TBZ/TBNZ instruction to bits -- [15:2] of X; check -2^15 <= X < 2^15 pattern R_AARCH64_TSTBR14 :: ElfRelocationType_AARCH64 -- | S + A | Set the LD/ST immediate value to bits [11:4] of X. No overflow -- check pattern R_AARCH64_LDST128_ABS_LO12_NC :: ElfRelocationType_AARCH64 -- | S + A | Set the LD/ST immediate value to bits [11:3] of X. No overflow -- check pattern R_AARCH64_LDST64_ABS_LO12_NC :: ElfRelocationType_AARCH64 -- | S + A | Set the LD/ST immediate value to bits [11:2] of X. No overflow -- check pattern R_AARCH64_LDST32_ABS_LO12_NC :: ElfRelocationType_AARCH64 -- | S + A | Set an LD/ST immediate value to bits [11:1] of X. No overflow -- check pattern R_AARCH64_LDST16_ABS_LO12_NC :: ElfRelocationType_AARCH64 -- | S + A | Set an LD/ST immediate value to bits [11:0] of X. No overflow -- check. Used with relocations ADR_PREL_PG_HI21 and ADR_PREL_PG_HI21_NC pattern R_AARCH64_LDST8_ABS_LO12_NC :: ElfRelocationType_AARCH64 -- | S + A | Set an ADD immediate value to bits [11:0] of X. No overflow -- check. Used with relocations ADR_PREL_PG_HI21 and ADR_PREL_PG_HI21_NC pattern R_AARCH64_ADD_ABS_LO12_NC :: ElfRelocationType_AARCH64 -- | Page(S + A) - Page(P) | Set an ADRP immediate value to bits [32:12] of -- the X. No overflow check pattern R_AARCH64_ADR_PREL_PG_HI21_NC :: ElfRelocationType_AARCH64 -- | Page(S + A) - Page(P) | Set an ADRP immediate value to bits [32:12] of -- the X; check that -2^32 <= X < 2^32 pattern R_AARCH64_ADR_PREL_PG_HI21 :: ElfRelocationType_AARCH64 -- | S + A - P | Set an ADR immediate value to bits [20:0] of X; check that -- -2^20 <= X < 2^20 pattern R_AARCH64_ADR_PREL_LO21 :: ElfRelocationType_AARCH64 -- | S + A - P | Set a load-literal immediate value to bits [20:2] of X; -- check that -2^20 <= X < 2^20 pattern R_AARCH64_LD_PREL_LO19 :: ElfRelocationType_AARCH64 -- | S + A | Set a MOV[NZ] immediate field using bits [47:32] of X; check -- -2^48 <= X < 2^48 pattern R_AARCH64_MOVW_SABS_G2 :: ElfRelocationType_AARCH64 -- | S + A | Set a MOV[NZ] immediate field using bits [31:16] of X; check -- -2^32 <= X < 2^32 pattern R_AARCH64_MOVW_SABS_G1 :: ElfRelocationType_AARCH64 -- | S + A | Set a MOV[NZ] immediate field using bits [15: 0] of X; check -- -2^16 <= X < 2^16 pattern R_AARCH64_MOVW_SABS_G0 :: ElfRelocationType_AARCH64 -- | S + A | Set a MOV[KZ] immediate field to bits [63:48] of X (no -- overflow check needed) pattern R_AARCH64_MOVW_UABS_G3 :: ElfRelocationType_AARCH64 -- | S + A | Set a MOV[KZ] immediate field to bits [47:32] of X. No -- overflow check pattern R_AARCH64_MOVW_UABS_G2_NC :: ElfRelocationType_AARCH64 -- | S + A | Set a MOV[KZ] immediate field to bits [47:32] of X; check that -- 0 <= X < 2^48 pattern R_AARCH64_MOVW_UABS_G2 :: ElfRelocationType_AARCH64 -- | S + A | Set a MOV[KZ] immediate field to bits [31:16] of X. No -- overflow check pattern R_AARCH64_MOVW_UABS_G1_NC :: ElfRelocationType_AARCH64 -- | S + A | Set a MOV[KZ] immediate field to bits [31:16] of X; check that -- 0 <= X < 2^32 pattern R_AARCH64_MOVW_UABS_G1 :: ElfRelocationType_AARCH64 -- | S + A | Set a MOV[KZ] immediate field to bits [15: 0] of X. No -- overflow check pattern R_AARCH64_MOVW_UABS_G0_NC :: ElfRelocationType_AARCH64 -- | S + A | Set a MOV[KZ] immediate field to bits [15: 0] of X; check that -- 0 <= X < 2^16 pattern R_AARCH64_MOVW_UABS_G0 :: ElfRelocationType_AARCH64 -- | S + A - P | Check that -2^31 <= X < 2^31 see call and jump -- relocations pattern R_AARCH64_PLT32 :: ElfRelocationType_AARCH64 -- | S + A - P | Check that -2^15 <= X < 2^16 pattern R_AARCH64_PREL16 :: ElfRelocationType_AARCH64 -- | S + A - P | Check that -2^31 <= X < 2^32 pattern R_AARCH64_PREL32 :: ElfRelocationType_AARCH64 -- | S + A - P | No overflow check pattern R_AARCH64_PREL64 :: ElfRelocationType_AARCH64 -- | S + A | Check that -2^15 <= X < 2^16 pattern R_AARCH64_ABS16 :: ElfRelocationType_AARCH64 -- | S + A | Check that -2^31 <= X < 2^32 pattern R_AARCH64_ABS32 :: ElfRelocationType_AARCH64 -- | S + A | No overflow check pattern R_AARCH64_ABS64 :: ElfRelocationType_AARCH64 -- | None pattern R_AARCH64_NONE_ :: ElfRelocationType_AARCH64 -- | None 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 -- | 32-bit ELF format ELFCLASS32 :: ElfClass -- | 64-bit ELF format 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 -- | Singletons for ElfClass data SingElfClass :: ElfClass -> Type [SELFCLASS32] :: SingElfClass 'ELFCLASS32 [SELFCLASS64] :: SingElfClass 'ELFCLASS64 -- | SingElfClassI a is defined for each constructor of -- ElfClass. It defines WordXX a, which is Word32 -- for ELFCLASS32 and Word64 for ELFCLASS64. Also it -- defines singletons for each of the ElfClass type. class (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))) => SingElfClassI (c :: ElfClass) where { type WordXX c = r | r -> c; } singElfClass :: SingElfClassI c => SingElfClass c -- | A convenience function useful when we need to name a singleton value -- multiple times. Without this function, each use of sing could -- potentially refer to a different singleton, and one has to use type -- signatures (often with ScopedTypeVariables) to ensure that they are -- the same. See also withSingI withSingElfClass :: SingElfClassI c => (SingElfClass c -> r) -> r -- | Convenience function for creating a context with an implicit singleton -- available. See also withSing withSingElfClassI :: SingElfClass c -> (SingElfClassI c => r) -> r -- | Convert a singleton to its unrefined version. See also -- fromSing fromSingElfClass :: SingElfClass c -> ElfClass -- | Use this instead of toSing withElfClass :: ElfClass -> (forall c. SingElfClassI c => SingElfClass c -> r) -> r -- | 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 -- | Header is a sigma type where the first entry defines the type of the -- second one data Header Header :: SingElfClass a -> HeaderXX a -> Header -- | Parsed ELF section table entry data SectionXX c SectionXX :: Word32 -> ElfSectionType -> WordXX c -> WordXX c -> WordXX c -> WordXX c -> Word32 -> Word32 -> WordXX c -> WordXX c -> SectionXX c -- | Section name [sName] :: SectionXX c -> Word32 -- | Section type [sType] :: SectionXX c -> ElfSectionType -- | Section attributes [sFlags] :: SectionXX c -> WordXX c -- | Virtual address in memory [sAddr] :: SectionXX c -> WordXX c -- | Offset in file [sOffset] :: SectionXX c -> WordXX c -- | Size of section [sSize] :: SectionXX c -> WordXX c -- | Link to other section [sLink] :: SectionXX c -> Word32 -- | Miscellaneous information [sInfo] :: SectionXX c -> Word32 -- | Address alignment boundary [sAddrAlign] :: SectionXX c -> WordXX c -- | Size of entries, if section has table [sEntSize] :: SectionXX c -> WordXX c -- | Size of section table entry. sectionTableEntrySize :: Num a => ElfClass -> a -- | Parsed ELF segment table entry data SegmentXX c SegmentXX :: ElfSegmentType -> ElfSegmentFlag -> WordXX c -> WordXX c -> WordXX c -> WordXX c -> WordXX c -> WordXX c -> SegmentXX c -- | Type of segment [pType] :: SegmentXX c -> ElfSegmentType -- | Segment attributes [pFlags] :: SegmentXX c -> ElfSegmentFlag -- | Offset in file [pOffset] :: SegmentXX c -> WordXX c -- | Virtual address in memory [pVirtAddr] :: SegmentXX c -> WordXX c -- | Physical address [pPhysAddr] :: SegmentXX c -> WordXX c -- | Size of segment in file [pFileSize] :: SegmentXX c -> WordXX c -- | Size of segment in memory [pMemSize] :: SegmentXX c -> WordXX c -- | Alignment of segment [pAlign] :: SegmentXX c -> WordXX c -- | Size of segment table entry. segmentTableEntrySize :: Num a => ElfClass -> a -- | Parsed ELF symbol table entry data SymbolXX c SymbolXX :: Word32 -> Word8 -> Word8 -> ElfSectionIndex -> WordXX c -> WordXX c -> SymbolXX c -- | Symbol name [stName] :: SymbolXX c -> Word32 -- | Type and Binding attributes [stInfo] :: SymbolXX c -> Word8 -- | Reserved [stOther] :: SymbolXX c -> Word8 -- | Section table index [stShNdx] :: SymbolXX c -> ElfSectionIndex -- | Symbol value [stValue] :: SymbolXX c -> WordXX c -- | Size of object [stSize] :: SymbolXX c -> WordXX c -- | Size of symbol table entry. symbolTableEntrySize :: Num a => ElfClass -> a -- | Parsed relocation table entry (ElfXX_Rela) data RelaXX c RelaXX :: WordXX c -> Word32 -> Word32 -> WordXX c -> RelaXX c -- | Address of reference [relaOffset] :: RelaXX c -> WordXX c -- | Symbol table index [relaSym] :: RelaXX c -> Word32 -- | Relocation type [relaType] :: RelaXX c -> Word32 -- | Constant part of expression [relaAddend] :: RelaXX c -> WordXX c -- | Size of RelaXX a in bytes. relocationTableAEntrySize :: forall a. SingElfClassI a => WordXX a -- | Sigma type to hold the ELF header and section and segment tables for a -- given ElfClass. data Headers Headers :: SingElfClass a -> HeaderXX a -> [SectionXX a] -> [SegmentXX a] -> Headers -- | Parse ELF file and produce header and section and segment tables parseHeaders :: MonadThrow m => ByteString -> m Headers -- | 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 -- | Get section data getSectionData :: SingElfClassI a => ByteString -> SectionXX a -> ByteString -- | Get string from string table getString :: ByteString -> Int64 -> String -- | Size of WordXX a in bytes. wordSize :: Num a => ElfClass -> a 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.Elf.Headers.SingElfClassI a => Data.Binary.Class.Binary (Data.Endian.Be (Data.Elf.Headers.RelaXX a)) instance Data.Elf.Headers.SingElfClassI a => Data.Binary.Class.Binary (Data.Endian.Le (Data.Elf.Headers.RelaXX a)) instance Data.Elf.Headers.SingElfClassI a => Data.Binary.Class.Binary (Data.Endian.Be (Data.Elf.Headers.SymbolXX a)) instance Data.Elf.Headers.SingElfClassI a => Data.Binary.Class.Binary (Data.Endian.Le (Data.Elf.Headers.SymbolXX a)) instance Data.Elf.Headers.SingElfClassI a => Data.Binary.Class.Binary (Data.Endian.Be (Data.Elf.Headers.SegmentXX a)) instance Data.Elf.Headers.SingElfClassI a => Data.Binary.Class.Binary (Data.Endian.Le (Data.Elf.Headers.SegmentXX a)) instance Data.Elf.Headers.SingElfClassI a => Data.Binary.Class.Binary (Data.Endian.Be (Data.Elf.Headers.SectionXX a)) instance Data.Elf.Headers.SingElfClassI 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.SingElfClassI 'Data.Elf.Headers.ELFCLASS32 instance Data.Elf.Headers.SingElfClassI 'Data.Elf.Headers.ELFCLASS64 instance Data.Binary.Class.Binary Data.Elf.Headers.ElfData instance Data.Binary.Class.Binary Data.Elf.Headers.ElfClass -- | Parse/serialize ELF files into structured data module Data.Elf -- | List of ELF nodes. data ElfListXX c [ElfListCons] :: ElfXX t c -> ElfListXX c -> ElfListXX c [ElfListNull] :: ElfListXX c -- | Helper for ElfListCons (~:) :: ElfXX t a -> ElfListXX a -> ElfListXX a infixr 9 ~: -- | Elf is a forrest of trees of type ElfXX. Trees are -- composed of ElfXX nodes, ElfSegment can contain subtrees data ElfNodeType Header :: ElfNodeType SectionTable :: ElfNodeType SegmentTable :: ElfNodeType Section :: ElfNodeType Segment :: ElfNodeType RawData :: ElfNodeType RawAlign :: ElfNodeType -- | 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 c -- | Regular section data ElfSectionData :: ByteString -> ElfSectionData c -- | The content of the section [esdData] :: ElfSectionData c -> ByteString -- | Section data will be generated from section names ElfSectionDataStringTable :: ElfSectionData c -- | SHT_NOBITS uninitialized section data: section has size but no content ElfSectionDataNoBits :: WordXX c -> ElfSectionData c -- | Size of the section [esdSize] :: ElfSectionData c -> WordXX c -- | The type of node that defines Elf structure. data ElfXX t c [ElfHeader] :: ElfData -> ElfOSABI -> Word8 -> ElfType -> ElfMachine -> WordXX c -> Word32 -> ElfXX 'Header c [ElfSectionTable] :: ElfXX 'SectionTable c [ElfSegmentTable] :: ElfXX 'SegmentTable c [ElfSection] :: String -> ElfSectionType -> ElfSectionFlag -> WordXX c -> WordXX c -> WordXX c -> ElfSectionIndex -> Word32 -> Word32 -> ElfSectionData c -> ElfXX 'Section c [ElfSegment] :: ElfSegmentType -> ElfSegmentFlag -> WordXX c -> WordXX c -> WordXX c -> WordXX c -> ElfListXX c -> ElfXX 'Segment c -- | Some ELF files (some executables) don't bother to define sections for -- linking and have just raw data in segments. [ElfRawData] :: ByteString -> ElfXX 'RawData c -- | 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 'RawAlign c -- | Elf is a sigma type where the first entry defines the type of the -- second one data Elf Elf :: SingElfClass a -> ElfListXX a -> Elf -- | Parse ELF file parseElf :: MonadCatch m => ByteString -> m Elf -- | Serialze ELF file serializeElf :: MonadCatch m => Elf -> m ByteString -- | Find section with a given number elfFindSection :: forall a m b. (SingElfClassI a, MonadThrow m, Integral b, Show b) => ElfListXX a -> b -> m (ElfXX 'Section a) -- | Find section with a given name elfFindSectionByName :: forall a m. (SingElfClassI a, MonadThrow m) => ElfListXX a -> String -> m (ElfXX 'Section a) -- | Find ELF header elfFindHeader :: forall a m. (SingElfClassI a, MonadThrow m) => ElfListXX a -> m (ElfXX 'Header a) -- | Parsed ELF symbol table entry. NB: This is work in progress data ElfSymbolXX c ElfSymbolXX :: String -> ElfSymbolBinding -> ElfSymbolType -> ElfSectionIndex -> WordXX c -> WordXX c -> ElfSymbolXX c -- | Symbol name (NB: String, not string index) [steName] :: ElfSymbolXX c -> String -- | Symbol binding attributes [steBind] :: ElfSymbolXX c -> ElfSymbolBinding -- | Symbol Type [steType] :: ElfSymbolXX c -> ElfSymbolType -- | Section table index [steShNdx] :: ElfSymbolXX c -> ElfSectionIndex -- | Symbol value [steValue] :: ElfSymbolXX c -> WordXX c -- | Size of object [steSize] :: ElfSymbolXX c -> WordXX c -- | Parse symbol table parseSymbolTable :: (MonadThrow m, SingElfClassI a) => ElfData -> ElfXX 'Section a -> ElfListXX a -> m [ElfSymbolXX a] -- | Serialize symbol table serializeSymbolTable :: (MonadThrow m, SingElfClassI 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 header, section table and segment table. It's used in -- golden tests printHeaders :: SingElfClassI 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 => Headers -> 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 ()) -- | Print ELF header. It's used in golden tests printHeader :: forall a. SingElfClassI 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]