# package elf

`import "debug/elf"`

Package elf implements access to ELF object files.

elf.go file.go reader.go

## Constants

Indexes into the Header.Ident array.

Magic number for the elf trampoline, chosen wisely to be an immediate value.

Initial magic number for ELF files.

## Variables

ErrNoSymbols is returned by File.Symbols and File.DynamicSymbols if there is no such section in the File.

## func R_INFO

## func R_INFO32

## func R_SYM32

## func R_SYM64

## func R_TYPE32

## func R_TYPE64

## func ST_INFO

## type Chdr32

ELF32 Compression header.

## type Chdr64

ELF64 Compression header.

## type Class

Class is found in Header.Ident[EI_CLASS] and Header.Class.

### func (Class) GoString

### func (Class) String

## type CompressionType

Section compression type.

### func (CompressionType) GoString

### func (CompressionType) String

## type Data

Data is found in Header.Ident[EI_DATA] and Header.Data.

### func (Data) GoString

### func (Data) String

## type Dyn32

ELF32 Dynamic structure. The ".dynamic" section contains an array of them.

## type Dyn64

ELF64 Dynamic structure. The ".dynamic" section contains an array of them.

## type DynFlag

DT_FLAGS values.

### func (DynFlag) GoString

### func (DynFlag) String

## type DynTag

Dyn.Tag

### func (DynTag) GoString

### func (DynTag) String

## type File

A File represents an open ELF file.

### func NewFile

NewFile creates a new File for accessing an ELF binary in an underlying reader. The ELF binary is expected to start at position 0 in the ReaderAt.

### func Open

Open opens the named file using os.Open and prepares it for use as an ELF binary.

### func (*File) Close

Close closes the File. If the File was created using NewFile directly instead of Open, Close has no effect.

### func (*File) DWARF

### func (*File) DynString

DynString returns the strings listed for the given tag in the file's dynamic section.

The tag must be one that takes string values: DT_NEEDED, DT_SONAME, DT_RPATH, or DT_RUNPATH.

### func (*File) DynamicSymbols

DynamicSymbols returns the dynamic symbol table for f. The symbols will be listed in the order they appear in f.

For compatibility with Symbols, DynamicSymbols omits the null symbol at index 0. After retrieving the symbols as symtab, an externally supplied index x corresponds to symtab[x-1], not symtab[x].

### func (*File) ImportedLibraries

ImportedLibraries returns the names of all libraries referred to by the binary f that are expected to be linked with the binary at dynamic link time.

### func (*File) ImportedSymbols

ImportedSymbols returns the names of all symbols referred to by the binary f that are expected to be satisfied by other libraries at dynamic load time. It does not return weak symbols.

### func (*File) Section

Section returns a section with the given name, or nil if no such section exists.

### func (*File) SectionByType

SectionByType returns the first section in f with the given type, or nil if there is no such section.

### func (*File) Symbols

Symbols returns the symbol table for f. The symbols will be listed in the order they appear in f.

For compatibility with Go 1.0, Symbols omits the null symbol at index 0. After retrieving the symbols as symtab, an externally supplied index x corresponds to symtab[x-1], not symtab[x].

## type FileHeader

A FileHeader represents an ELF file header.

## type FormatError

### func (*FormatError) Error

## type Header32

ELF32 File header.

## type Header64

ELF64 file header.

## type ImportedSymbol

## type Machine

Machine is found in Header.Machine.

### func (Machine) GoString

### func (Machine) String

## type NType

NType values; used in core files.

### func (NType) GoString

### func (NType) String

## type OSABI

OSABI is found in Header.Ident[EI_OSABI] and Header.OSABI.

### func (OSABI) GoString

### func (OSABI) String

## type Prog

A Prog represents a single ELF program header in an ELF binary.

### func (*Prog) Open

Open returns a new ReadSeeker reading the ELF program body.

## type Prog32

ELF32 Program header.

## type Prog64

ELF64 Program header.

## type ProgFlag

Prog.Flag

### func (ProgFlag) GoString

### func (ProgFlag) String

## type ProgHeader

A ProgHeader represents a single ELF program header.

## type ProgType

Prog.Type

### func (ProgType) GoString

### func (ProgType) String

## type R_386

Relocation types for 386.

### func (R_386) GoString

### func (R_386) String

## type R_390

Relocation types for s390x processors.

### func (R_390) GoString

### func (R_390) String

## type R_AARCH64

Relocation types for AArch64 (aka arm64)

### func (R_AARCH64) GoString

### func (R_AARCH64) String

## type R_ALPHA

Relocation types for Alpha.

### func (R_ALPHA) GoString

### func (R_ALPHA) String

## type R_ARM

Relocation types for ARM.

### func (R_ARM) GoString

### func (R_ARM) String

## type R_MIPS

Relocation types for MIPS.

### func (R_MIPS) GoString

### func (R_MIPS) String

## type R_PPC

Relocation types for PowerPC.

### func (R_PPC) GoString

### func (R_PPC) String

## type R_PPC64

Relocation types for 64-bit PowerPC or Power Architecture processors.

### func (R_PPC64) GoString

### func (R_PPC64) String

## type R_SPARC

Relocation types for SPARC.

### func (R_SPARC) GoString

### func (R_SPARC) String

## type R_X86_64

Relocation types for x86-64.

### func (R_X86_64) GoString

### func (R_X86_64) String

## type Rel32

ELF32 Relocations that don't need an addend field.

## type Rel64

ELF64 relocations that don't need an addend field.

## type Rela32

ELF32 Relocations that need an addend field.

## type Rela64

ELF64 relocations that need an addend field.

## type Section

A Section represents a single section in an ELF file.

### func (*Section) Data

Data reads and returns the contents of the ELF section. Even if the section is stored compressed in the ELF file, Data returns uncompressed data.

### func (*Section) Open

Open returns a new ReadSeeker reading the ELF section. Even if the section is stored compressed in the ELF file, the ReadSeeker reads uncompressed data.

## type Section32

ELF32 Section header.

## type Section64

ELF64 Section header.

## type SectionFlag

Section flags.

### func (SectionFlag) GoString

### func (SectionFlag) String

## type SectionHeader

A SectionHeader represents a single ELF section header.

## type SectionIndex

Special section indices.

### func (SectionIndex) GoString

### func (SectionIndex) String

## type SectionType

Section type.

### func (SectionType) GoString

### func (SectionType) String

## type Sym32

ELF32 Symbol.

## type Sym64

ELF64 symbol table entries.

## type SymBind

Symbol Binding - ELFNN_ST_BIND - st_info

### func ST_BIND

### func (SymBind) GoString

### func (SymBind) String

## type SymType

Symbol type - ELFNN_ST_TYPE - st_info

### func ST_TYPE

### func (SymType) GoString

### func (SymType) String

## type SymVis

Symbol visibility - ELFNN_ST_VISIBILITY - st_other

### func ST_VISIBILITY

### func (SymVis) GoString

### func (SymVis) String

## type Symbol

A Symbol represents an entry in an ELF symbol table section.

## type Type

Type is found in Header.Type.

### func (Type) GoString

### func (Type) String

## type Version

Version is found in Header.Ident[EI_VERSION] and Header.Version.

### func (Version) GoString

### func (Version) String