elf-0.28: Parser for ELF object format.

Safe HaskellNone
LanguageHaskell98

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.

data Elf Source #

Constructors

Elf 

Fields

Instances

Eq Elf Source # 

Methods

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

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

Show Elf Source # 

Methods

showsPrec :: Int -> Elf -> ShowS #

show :: Elf -> String #

showList :: [Elf] -> ShowS #

data ElfSection Source #

Constructors

ElfSection 

Fields

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

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

data ElfSegment Source #

Constructors

ElfSegment 

Fields

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

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.

data ElfClass Source #

Constructors

ELFCLASS32

32-bit ELF format

ELFCLASS64

64-bit ELF format

data ElfData Source #

Constructors

ELFDATA2LSB

Little-endian ELF format

ELFDATA2MSB

Big-endian ELF format

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

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

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

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 ElfSymbolBinding Source #

data ElfSectionIndex Source #