Package org.eclipse.cdt.utils.elf

# Class Elf

java.lang.Object
org.eclipse.cdt.utils.elf.Elf

All Implemented Interfaces:
  `AutoCloseable`

public class Elf extends Object implements AutoCloseable

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`class`
`Elf.Attribute`
`class`
`Elf.Dynamic`
`static class`
`Elf.ElfClassNoneException`
Exception indicating that `Elf.ELFhdr.ELFCLASSNONE` header is read.
`class`
`Elf.ELFhdr`
`class`
`Elf.PHdr`
`class`
`Elf.Section`
`class`
`Elf.Symbol`

## Field Summary

Fields
Modifier and Type
Field
Description
`protected ERandomAccessFile`
`efile`
`protected Elf.ELFhdr`
`ehdr`
`static final int`
`ELF32_ADDR_SIZE`
`static final int`
`ELF32_OFF_SIZE`
`static final int`
`ELF64_ADDR_SIZE`
`static final int`
`ELF64_OFF_SIZE`
`protected String`
`EMPTY_STRING`
`protected String`
`file`
`protected byte[]`
`section_strtab`
`protected Elf.Section[]`
`sections`

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`Elf()`
``
`Elf(String file)`
``
`Elf(String file, long offset)`

## Method Summary

Modifier and Type
Method
Description
`void`
`close()`
`void`
`dispose()`
`protected void`
`finalize()`
Make sure we do not leak the fds.
`Elf.Attribute`
`getAttributes()`
`static Elf.Attribute`
`getAttributes(byte[] array)`
`static Elf.Attribute`
`getAttributes(String file)`
`Elf.Dynamic[]`
`getDynamicSections(Elf.Section section)`
`Elf.Symbol[]`
`getDynamicSymbols()`
`Elf.ELFhdr`
`getELFhdr()`
`String`
`getFilename()`
`Elf.PHdr[]`
`getPHdrs()`
`Elf.Section`
`getSectionByName(String name)`
`Elf.Section[]`
`getSections()`
`Elf.Section[]`
`getSections(int type)`
`Elf.Symbol`
`getSymbol(IAddress vma)`
`ISymbolReader`
`getSymbolReader()`
Creates a new symbol reader instance on each call.
`Elf.Symbol[]`
`getSymbols()`
`Elf.Symbol[]`
`getSymtabSymbols()`
`static boolean`
`isElfHeader(byte[] e_ident)`
`void`
`loadSymbols()`
`static long`
`makeUnsignedLong(byte[] val, int offset, boolean isle)`
`protected long`
`readUnsignedLong(ERandomAccessFile file)`
`protected String`
`string_from_elf_section(Elf.Section section, int index)`
`org.eclipse.cdt.utils.elf.Elf.ElfSectionIterator`
`symbolIterator(Elf.Section section)`
Get a symbol iterator

### Methods inherited from class java.lang.Object

`clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### ELF32_ADDR_SIZE

public static final int ELF32_ADDR_SIZE

See Also:
  - Constant Field Values

### ELF32_OFF_SIZE

public static final int ELF32_OFF_SIZE

See Also:
  - Constant Field Values

### ELF64_ADDR_SIZE

public static final int ELF64_ADDR_SIZE

See Also:
  - Constant Field Values

### ELF64_OFF_SIZE

public static final int ELF64_OFF_SIZE

See Also:
  - Constant Field Values

### efile

protected ERandomAccessFile efile

### ehdr

protected Elf.ELFhdr ehdr

### sections

protected Elf.Section[] sections

### file

protected String file

### section_strtab

protected byte[] section_strtab

### EMPTY_STRING

protected String EMPTY_STRING

## Constructor Details

### Elf

protected Elf()

### Elf

public Elf(String file, long offset) throws IOException

Throws:
  `IOException`

### Elf

public Elf(String file) throws IOException

Throws:
  `IOException`

## Method Details

### string_from_elf_section

protected String string_from_elf_section(Elf.Section section, int index) throws IOException

Throws:
  `IOException`

### getPHdrs

public Elf.PHdr[] getPHdrs() throws IOException

Throws:
  `IOException`

### getDynamicSections

public Elf.Dynamic[] getDynamicSections(Elf.Section section) throws IOException

Throws:
  `IOException`

### getELFhdr

public Elf.ELFhdr getELFhdr() throws IOException

Throws:
  `IOException`

### getAttributes

public Elf.Attribute getAttributes() throws IOException

Throws:
  `IOException`

### getAttributes

public static Elf.Attribute getAttributes(String file) throws IOException

Throws:
  `IOException`

### getAttributes

public static Elf.Attribute getAttributes(byte[] array) throws IOException

Throws:
  `IOException`

### isElfHeader

public static boolean isElfHeader(byte[] e_ident)

### close

public void close()

Specified by:
  `close` in interface `AutoCloseable`

### dispose

public void dispose()

### finalize

protected void finalize() throws Throwable
Make sure we do not leak the fds.

Overrides:
  `finalize` in class `Object`
Throws:
  `Throwable`

### getSectionByName

public Elf.Section getSectionByName(String name) throws IOException

Throws:
  `IOException`

### getSections

public Elf.Section[] getSections(int type) throws IOException

Throws:
  `IOException`

### getSections

public Elf.Section[] getSections() throws IOException

Throws:
  `Elf.ElfClassNoneException` - if `Elf.ELFhdr.ELFCLASSNONE` header is read
  `IOException`

### symbolIterator

public org.eclipse.cdt.utils.elf.Elf.ElfSectionIterator symbolIterator(Elf.Section section) throws IOException
Get a symbol iterator

Parameters:
  `section` - the section to iterate over
Returns:
  an iterator that returns symbols of a given section
Throws:
  `IOException` - If the file is corrupt
Since:
  7.0

### loadSymbols

public void loadSymbols() throws IOException

Throws:
  `IOException`

### getSymbols

public Elf.Symbol[] getSymbols()

### getDynamicSymbols

public Elf.Symbol[] getDynamicSymbols()

### getSymtabSymbols

public Elf.Symbol[] getSymtabSymbols()

### getSymbol

public Elf.Symbol getSymbol(IAddress vma)

### getFilename

public String getFilename()

### readUnsignedLong

protected long readUnsignedLong(ERandomAccessFile file) throws IOException

Throws:
  `IOException`

### getSymbolReader

public ISymbolReader getSymbolReader()
Creates a new symbol reader instance on each call. Caller is responsible for closing the symbol reader

Returns:
  symbol reader or `null` if couldn't create symbol reader

### makeUnsignedLong

public static long makeUnsignedLong(byte[] val, int offset, boolean isle) throws IOException

Throws:
  `IOException`
Since:
  5.4