Package org.eclipse.cdt.utils.elf
Class Elf
- java.lang.Object
-
- org.eclipse.cdt.utils.elf.Elf
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class Elf extends java.lang.Object implements java.lang.AutoCloseable
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classElf.AttributeclassElf.DynamicclassElf.ELFhdrclassElf.PHdrclassElf.SectionclassElf.Symbol
-
Field Summary
Fields Modifier and Type Field Description protected ERandomAccessFileefileprotected Elf.ELFhdrehdrstatic intELF32_ADDR_SIZEstatic intELF32_OFF_SIZEstatic intELF64_ADDR_SIZEstatic intELF64_OFF_SIZEprotected java.lang.StringEMPTY_STRINGprotected java.lang.Stringfileprotected byte[]section_strtabprotected Elf.Section[]sections
-
Method Summary
-
-
-
Field Detail
-
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 java.lang.String file
-
section_strtab
protected byte[] section_strtab
-
EMPTY_STRING
protected java.lang.String EMPTY_STRING
-
-
Method Detail
-
string_from_elf_section
protected java.lang.String string_from_elf_section(Elf.Section section, int index) throws java.io.IOException
- Throws:
java.io.IOException
-
getPHdrs
public Elf.PHdr[] getPHdrs() throws java.io.IOException
- Throws:
java.io.IOException
-
getDynamicSections
public Elf.Dynamic[] getDynamicSections(Elf.Section section) throws java.io.IOException
- Throws:
java.io.IOException
-
getELFhdr
public Elf.ELFhdr getELFhdr() throws java.io.IOException
- Throws:
java.io.IOException
-
getAttributes
public Elf.Attribute getAttributes() throws java.io.IOException
- Throws:
java.io.IOException
-
getAttributes
public static Elf.Attribute getAttributes(java.lang.String file) throws java.io.IOException
- Throws:
java.io.IOException
-
getAttributes
public static Elf.Attribute getAttributes(byte[] array) throws java.io.IOException
- Throws:
java.io.IOException
-
isElfHeader
public static boolean isElfHeader(byte[] e_ident)
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable
-
dispose
public void dispose()
-
finalize
protected void finalize() throws java.lang.ThrowableMake sure we do not leak the fds.- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
getSectionByName
public Elf.Section getSectionByName(java.lang.String name) throws java.io.IOException
- Throws:
java.io.IOException
-
getSections
public Elf.Section[] getSections(int type) throws java.io.IOException
- Throws:
java.io.IOException
-
getSections
public Elf.Section[] getSections() throws java.io.IOException
- Throws:
java.io.IOException
-
symbolIterator
public org.eclipse.cdt.utils.elf.Elf.ElfSectionIterator symbolIterator(Elf.Section section) throws java.io.IOException
Get a symbol iterator- Parameters:
section- the section to iterate over- Returns:
- an iterator that returns symbols of a given section
- Throws:
java.io.IOException- If the file is corrupt- Since:
- 7.0
-
loadSymbols
public void loadSymbols() throws java.io.IOException- Throws:
java.io.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 java.lang.String getFilename()
-
readUnsignedLong
protected long readUnsignedLong(ERandomAccessFile file) throws java.io.IOException
- Throws:
java.io.IOException
-
getSymbolReader
public ISymbolReader getSymbolReader()
-
makeUnsignedLong
public static long makeUnsignedLong(byte[] val, int offset, boolean isle) throws java.io.IOException- Throws:
java.io.IOException- Since:
- 5.4
-
-