elf-0.31: An Elf parser
Safe HaskellNone
LanguageHaskell2010

Data.Elf

Description

Data.Elf is a module for parsing a ByteString of an ELF file into an Elf record.

Synopsis

Documentation

parseElf :: ByteString -> Elf Source #

Parses a ByteString into an Elf record. Parse failures call error. 32-bit ELF objects have their fields promoted to 64-bit so that the 32- and 64-bit ELF records can be the same.

parseSymbolTables :: Elf -> [[ElfSymbolTableEntry]] Source #

Parse the symbol table section into a list of symbol table entries. If no symbol table is found then an empty list is returned. This function does not consult flags to look for SHT_STRTAB (when naming symbols), it just looks for particular sections of ".strtab" and ".shstrtab".

findSymbolDefinition :: ElfSymbolTableEntry -> Maybe ByteString Source #

Use the symbol offset and size to extract its definition (in the form of a ByteString). If the size is zero, or the offset larger than the elfSectionData, then Nothing is returned.

Top-level header

data Elf Source #

Constructors

Elf 

Fields

Instances

Instances details
Eq Elf Source # 
Instance details

Defined in Data.Elf

Methods

(==) :: Elf -> Elf -> Bool #

(/=) :: Elf -> Elf -> Bool #

Show Elf Source # 
Instance details

Defined in Data.Elf

Methods

showsPrec :: Int -> Elf -> ShowS #

show :: Elf -> String #

showList :: [Elf] -> ShowS #

data ElfClass Source #

Constructors

ELFCLASS32

32-bit ELF format

ELFCLASS64

64-bit ELF format

Instances

Instances details
Eq ElfClass Source # 
Instance details

Defined in Data.Elf

Show ElfClass Source # 
Instance details

Defined in Data.Elf

data ElfData Source #

Constructors

ELFDATA2LSB

Little-endian ELF format

ELFDATA2MSB

Big-endian ELF format

Instances

Instances details
Eq ElfData Source # 
Instance details

Defined in Data.Elf

Methods

(==) :: ElfData -> ElfData -> Bool #

(/=) :: ElfData -> ElfData -> Bool #

Show ElfData Source # 
Instance details

Defined in Data.Elf

data ElfOSABI Source #

Constructors

ELFOSABI_SYSV

No extensions or unspecified

ELFOSABI_HPUX

Hewlett-Packard HP-UX

ELFOSABI_NETBSD

NetBSD

ELFOSABI_LINUX

Linux

ELFOSABI_SOLARIS

Sun Solaris

ELFOSABI_AIX

AIX

ELFOSABI_IRIX

IRIX

ELFOSABI_FREEBSD

FreeBSD

ELFOSABI_TRU64

Compaq TRU64 UNIX

ELFOSABI_MODESTO

Novell Modesto

ELFOSABI_OPENBSD

Open BSD

ELFOSABI_OPENVMS

Open VMS

ELFOSABI_NSK

Hewlett-Packard Non-Stop Kernel

ELFOSABI_AROS

Amiga Research OS

ELFOSABI_ARM

ARM

ELFOSABI_STANDALONE

Standalone (embedded) application

ELFOSABI_EXT Word8

Other

Instances

Instances details
Eq ElfOSABI Source # 
Instance details

Defined in Data.Elf

Show ElfOSABI Source # 
Instance details

Defined in Data.Elf

data ElfType Source #

Constructors

ET_NONE

Unspecified type

ET_REL

Relocatable object file

ET_EXEC

Executable object file

ET_DYN

Shared object file

ET_CORE

Core dump object file

ET_EXT Word16

Other

Instances

Instances details
Eq ElfType Source # 
Instance details

Defined in Data.Elf

Methods

(==) :: ElfType -> ElfType -> Bool #

(/=) :: ElfType -> ElfType -> Bool #

Show ElfType Source # 
Instance details

Defined in Data.Elf

data ElfMachine Source #

Constructors

EM_NONE

No machine

EM_M32

AT&T WE 32100

EM_SPARC

SPARC

EM_386

Intel 80386

EM_68K

Motorola 68000

EM_88K

Motorola 88000

EM_486

Intel i486 (DO NOT USE THIS ONE)

EM_860

Intel 80860

EM_MIPS

MIPS I Architecture

EM_S370

IBM System/370 Processor

EM_MIPS_RS3_LE

MIPS RS3000 Little-endian

EM_SPARC64

SPARC 64-bit

EM_PARISC

Hewlett-Packard PA-RISC

EM_VPP500

Fujitsu VPP500

EM_SPARC32PLUS

Enhanced instruction set SPARC

EM_960

Intel 80960

EM_PPC

PowerPC

EM_PPC64

64-bit PowerPC

EM_S390

IBM System/390 Processor

EM_SPU

Cell SPU

EM_V800

NEC V800

EM_FR20

Fujitsu FR20

EM_RH32

TRW RH-32

EM_RCE

Motorola RCE

EM_ARM

Advanced RISC Machines ARM

EM_ALPHA

Digital Alpha

EM_SH

Hitachi SH

EM_SPARCV9

SPARC Version 9

EM_TRICORE

Siemens TriCore embedded processor

EM_ARC

Argonaut RISC Core, Argonaut Technologies Inc.

EM_H8_300

Hitachi H8/300

EM_H8_300H

Hitachi H8/300H

EM_H8S

Hitachi H8S

EM_H8_500

Hitachi H8/500

EM_IA_64

Intel IA-64 processor architecture

EM_MIPS_X

Stanford MIPS-X

EM_COLDFIRE

Motorola ColdFire

EM_68HC12

Motorola M68HC12

EM_MMA

Fujitsu MMA Multimedia Accelerator

EM_PCP

Siemens PCP

EM_NCPU

Sony nCPU embedded RISC processor

EM_NDR1

Denso NDR1 microprocessor

EM_STARCORE

Motorola Star*Core processor

EM_ME16

Toyota ME16 processor

EM_ST100

STMicroelectronics ST100 processor

EM_TINYJ

Advanced Logic Corp. TinyJ embedded processor family

EM_X86_64

AMD x86-64 architecture

EM_PDSP

Sony DSP Processor

EM_FX66

Siemens FX66 microcontroller

EM_ST9PLUS

STMicroelectronics ST9+ 8/16 bit microcontroller

EM_ST7

STMicroelectronics ST7 8-bit microcontroller

EM_68HC16

Motorola MC68HC16 Microcontroller

EM_68HC11

Motorola MC68HC11 Microcontroller

EM_68HC08

Motorola MC68HC08 Microcontroller

EM_68HC05

Motorola MC68HC05 Microcontroller

EM_SVX

Silicon Graphics SVx

EM_ST19

STMicroelectronics ST19 8-bit microcontroller

EM_VAX

Digital VAX

EM_CRIS

Axis Communications 32-bit embedded processor

EM_JAVELIN

Infineon Technologies 32-bit embedded processor

EM_FIREPATH

Element 14 64-bit DSP Processor

EM_ZSP

LSI Logic 16-bit DSP Processor

EM_MMIX

Donald Knuth's educational 64-bit processor

EM_HUANY

Harvard University machine-independent object files

EM_PRISM

SiTera Prism

EM_AVR

Atmel AVR 8-bit microcontroller

EM_FR30

Fujitsu FR30

EM_D10V

Mitsubishi D10V

EM_D30V

Mitsubishi D30V

EM_V850

NEC v850

EM_M32R

Mitsubishi M32R

EM_MN10300

Matsushita MN10300

EM_MN10200

Matsushita MN10200

EM_PJ

picoJava

EM_OPENRISC

OpenRISC 32-bit embedded processor

EM_ARC_A5

ARC Cores Tangent-A5

EM_XTENSA

Tensilica Xtensa Architecture

EM_VIDEOCORE

Alphamosaic VideoCore processor

EM_TMM_GPP

Thompson Multimedia General Purpose Processor

EM_NS32K

National Semiconductor 32000 series

EM_TPC

Tenor Network TPC processor

EM_SNP1K

Trebia SNP 1000 processor

EM_ST200

STMicroelectronics (www.st.com) ST200 microcontroller

EM_IP2K

Ubicom IP2xxx microcontroller family

EM_MAX

MAX Processor

EM_CR

National Semiconductor CompactRISC microprocessor

EM_F2MC16

Fujitsu F2MC16

EM_MSP430

Texas Instruments embedded microcontroller msp430

EM_BLACKFIN

Analog Devices Blackfin (DSP) processor

EM_SE_C33

S1C33 Family of Seiko Epson processors

EM_SEP

Sharp embedded microprocessor

EM_ARCA

Arca RISC Microprocessor

EM_UNICORE

Microprocessor series from PKU-Unity Ltd. and MPRC of Peking University

EM_EXT Word16

Other

Instances

Instances details
Eq ElfMachine Source # 
Instance details

Defined in Data.Elf

Show ElfMachine Source # 
Instance details

Defined in Data.Elf

Sections

data ElfSection Source #

Constructors

ElfSection 

Fields

Instances

Instances details
Eq ElfSection Source # 
Instance details

Defined in Data.Elf

Show ElfSection Source # 
Instance details

Defined in Data.Elf

data ElfSectionType Source #

Constructors

SHT_NULL

Identifies an empty section header.

SHT_PROGBITS

Contains information defined by the program

SHT_SYMTAB

Contains a linker symbol table

SHT_STRTAB

Contains a string table

SHT_RELA

Contains Rela type relocation entries

SHT_HASH

Contains a symbol hash table

SHT_DYNAMIC

Contains dynamic linking tables

SHT_NOTE

Contains note information

SHT_NOBITS

Contains uninitialized space; does not occupy any space in the file

SHT_REL

Contains Rel type relocation entries

SHT_SHLIB

Reserved

SHT_DYNSYM

Contains a dynamic loader symbol table

SHT_EXT Word32

Processor- or environment-specific type

Instances

Instances details
Eq ElfSectionType Source # 
Instance details

Defined in Data.Elf

Show ElfSectionType Source # 
Instance details

Defined in Data.Elf

data ElfSectionFlags Source #

Constructors

SHF_WRITE

Section contains writable data

SHF_ALLOC

Section is allocated in memory image of program

SHF_EXECINSTR

Section contains executable instructions

SHF_EXT Int

Processor- or environment-specific flag

Instances

Instances details
Eq ElfSectionFlags Source # 
Instance details

Defined in Data.Elf

Show ElfSectionFlags Source # 
Instance details

Defined in Data.Elf

Segments

data ElfSegment Source #

Constructors

ElfSegment 

Fields

Instances

Instances details
Eq ElfSegment Source # 
Instance details

Defined in Data.Elf

Show ElfSegment Source # 
Instance details

Defined in Data.Elf

data ElfSegmentType Source #

Segment Types.

Constructors

PT_NULL

Unused entry

PT_LOAD

Loadable segment

PT_DYNAMIC

Dynamic linking tables

PT_INTERP

Program interpreter path name

PT_NOTE

Note sectionks

PT_SHLIB

Reserved

PT_PHDR

Program header table

PT_Other Word32

Some other type

Instances

Instances details
Eq ElfSegmentType Source # 
Instance details

Defined in Data.Elf

Show ElfSegmentType Source # 
Instance details

Defined in Data.Elf

data ElfSegmentFlag Source #

Constructors

PF_X

Execute permission

PF_W

Write permission

PF_R

Read permission

PF_Ext Int

Some other flag, the Int is the bit number for the flag.

Instances

Instances details
Eq ElfSegmentFlag Source # 
Instance details

Defined in Data.Elf

Show ElfSegmentFlag Source # 
Instance details

Defined in Data.Elf

Symbols

data ElfSymbolTableEntry Source #

The symbol table entries consist of index information to be read from other parts of the ELF file. Some of this information is automatically retrieved for your convenience (including symbol name, description of the enclosing section, and definition).

Constructors

EST 

data ElfSymbolType Source #

Instances

Instances details
Enum ElfSymbolType Source # 
Instance details

Defined in Data.Elf

Eq ElfSymbolType Source # 
Instance details

Defined in Data.Elf

Ord ElfSymbolType Source # 
Instance details

Defined in Data.Elf

Read ElfSymbolType Source # 
Instance details

Defined in Data.Elf

Show ElfSymbolType Source # 
Instance details

Defined in Data.Elf

data ElfSymbolBinding Source #

Instances

Instances details
Enum ElfSymbolBinding Source # 
Instance details

Defined in Data.Elf

Eq ElfSymbolBinding Source # 
Instance details

Defined in Data.Elf

Ord ElfSymbolBinding Source # 
Instance details

Defined in Data.Elf

Read ElfSymbolBinding Source # 
Instance details

Defined in Data.Elf

Show ElfSymbolBinding Source # 
Instance details

Defined in Data.Elf

data ElfSectionIndex Source #

Instances

Instances details
Enum ElfSectionIndex Source # 
Instance details

Defined in Data.Elf

Eq ElfSectionIndex Source # 
Instance details

Defined in Data.Elf

Ord ElfSectionIndex Source # 
Instance details

Defined in Data.Elf

Read ElfSectionIndex Source # 
Instance details

Defined in Data.Elf

Show ElfSectionIndex Source # 
Instance details

Defined in Data.Elf

Relocations

data ElfRel Source #

Instances

Instances details
Eq ElfRel Source # 
Instance details

Defined in Data.Elf

Methods

(==) :: ElfRel -> ElfRel -> Bool #

(/=) :: ElfRel -> ElfRel -> Bool #

Show ElfRel Source # 
Instance details

Defined in Data.Elf