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 thatElf.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 int
ELF32_ADDR_SIZE
static int
ELF32_OFF_SIZE
static int
ELF64_ADDR_SIZE
static int
ELF64_OFF_SIZE
protected String
EMPTY_STRING
protected String
file
protected byte[]
section_strtab
protected 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 String file
-
section_strtab
protected byte[] section_strtab
-
EMPTY_STRING
protected String EMPTY_STRING
-
-
Constructor Detail
-
Elf
protected Elf()
-
Elf
public Elf(String file, long offset) throws IOException
- Throws:
IOException
-
Elf
public Elf(String file) throws IOException
- Throws:
IOException
-
-
Method Detail
-
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 interfaceAutoCloseable
-
dispose
public void dispose()
-
finalize
protected void finalize() throws Throwable
Make sure we do not leak the fds.
-
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
- ifElf.ELFhdr.ELFCLASSNONE
header is readIOException
-
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()
-
makeUnsignedLong
public static long makeUnsignedLong(byte[] val, int offset, boolean isle) throws IOException
- Throws:
IOException
- Since:
- 5.4
-
-