- java.lang.Object
- 
- com.ibm.j9ddr.corereaders.elf.ELFFileReader
 
- 
- Direct Known Subclasses:
- ELF32FileReader,- ELF64FileReader
 
 public abstract class ELFFileReader extends Object 
- 
- 
Field SummaryFields Modifier and Type Field Description static intARCH_AARCH64static intARCH_AMD64static intARCH_ARMstatic intARCH_IA32static intARCH_IA64static intARCH_PPC32static intARCH_PPC64static intARCH_RISCV64static intARCH_S390static intAT_ENTRYstatic intAT_HWCAPstatic intAT_NULLstatic intAT_PLATFORMstatic intDT_DEBUGstatic intDT_NULLstatic intDT_SONAMEstatic intDT_STRTABstatic intEI_NIDENTstatic intELF_NOTE_HEADER_SIZEstatic intELF_PRARGSZstatic intELFCLASS32static intELFCLASS64static byteELFDATA2LSBstatic byteELFDATA2MSBstatic shortET_COREstatic shortET_DYNstatic shortET_EXECstatic intET_HIOSstatic intET_HIPROCstatic intET_LOOSstatic intET_LOPROCstatic shortET_NONEstatic shortET_NUMstatic shortET_RELprotected ImageInputStreamisstatic intNT_AUXVstatic intNT_HGPRSstatic intNT_PRPSINFOstatic intNT_PRSTATUSprotected StringsourceName
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedELFFileReader(File file, ByteOrder byteOrder)protectedELFFileReader(ImageInputStream in, long offset, long size)
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract intaddressSizeBits()booleancanResolveAddress(long address)Search the program header table to see whether it can successfully resolve an address into a file offset.voidclose()ByteOrdergetByteOrder()ProgramHeaderEntrygetDynamicTableEntry()Search the program header table for the dynamic entry.static ELFFileReadergetELFFileReader(File file)static ELFFileReadergetELFFileReader(ImageInputStream in)static ELFFileReadergetELFFileReaderWithOffset(ImageInputStream in, long offset, long limit)FilegetFile()Returns the file from which this reader is reading.shortgetMachineType()Collection<? extends IMemorySource>getMemoryRanges(long baseAddress, List<com.ibm.j9ddr.corereaders.elf.SectionHeaderEntry> sectionHeaderEntries, Map<Long,String> sectionHeaderStringTable)Iterate through the sections that were already loaded and create a list of memory source objects for them.List<? extends ProgramHeaderEntry>getProgramHeaderEntries()PropertiesgetProperties()List<com.ibm.j9ddr.corereaders.elf.SectionHeaderEntry>getSectionHeaderEntries()Map<Long,String>getSectionHeaderStringTable()StringgetSourceName()ImageInputStreamgetStream()Gets the data stream for this readerList<? extends ISymbol>getSymbols(long baseAddress, boolean useUnallocatedSections)Obtain the symbols from a core reader, offset by baseAddress.booleanis64Bit()booleanisCompatibleWith(ELFFileReader otherReader)Perform a quick check on two ELF readers to see if they represent the same library.static booleanisELF(byte[] signature)booleanisExecutable()Examine the ELF header to determine if this file is an executable or not.booleanisTruncated()Are any parts of the core file known to be missing?protected abstract longpadToWordBoundary(long address)bytereadByte()byte[]readBytes(int len)protected abstract longreadElfWord()protected abstract com.ibm.j9ddr.corereaders.elf.AddressreadElfWordAsAddress()voidreadFully(byte[] b, int off, int len)intreadInt()longreadLong()protected abstract ProgramHeaderEntryreadProgramHeaderEntry()shortreadShort()StringreadSONAME(ELFFileReader coreFileReader)Assume the entry given refers to a loaded library or program and find and return its name or null if it couldn't be determined.StringreadString()Reads a string from the readers current position until it is terminated by a null (0) byte.protected abstract List<com.ibm.j9ddr.corereaders.elf.ELFSymbol>readSymbolsAt(com.ibm.j9ddr.corereaders.elf.SectionHeaderEntry entry)booleansectionHeaderMapsToProgramHeader(com.ibm.j9ddr.corereaders.elf.SectionHeaderEntry section)voidseek(long pos)
 
- 
- 
- 
Field Detail- 
ELF_NOTE_HEADER_SIZEpublic static final int ELF_NOTE_HEADER_SIZE - See Also:
- Constant Field Values
 
 - 
EI_NIDENTpublic static final int EI_NIDENT - See Also:
- Constant Field Values
 
 - 
ELFDATA2LSBpublic static final byte ELFDATA2LSB - See Also:
- Constant Field Values
 
 - 
ELFDATA2MSBpublic static final byte ELFDATA2MSB - See Also:
- Constant Field Values
 
 - 
ELFCLASS32public static final int ELFCLASS32 - See Also:
- Constant Field Values
 
 - 
ELFCLASS64public static final int ELFCLASS64 - See Also:
- Constant Field Values
 
 - 
ELF_PRARGSZpublic static final int ELF_PRARGSZ - See Also:
- Constant Field Values
 
 - 
ARCH_IA32public static final int ARCH_IA32 - See Also:
- Constant Field Values
 
 - 
ARCH_PPC32public static final int ARCH_PPC32 - See Also:
- Constant Field Values
 
 - 
ARCH_PPC64public static final int ARCH_PPC64 - See Also:
- Constant Field Values
 
 - 
ARCH_S390public static final int ARCH_S390 - See Also:
- Constant Field Values
 
 - 
ARCH_ARMpublic static final int ARCH_ARM - See Also:
- Constant Field Values
 
 - 
ARCH_IA64public static final int ARCH_IA64 - See Also:
- Constant Field Values
 
 - 
ARCH_AMD64public static final int ARCH_AMD64 - See Also:
- Constant Field Values
 
 - 
ARCH_AARCH64public static final int ARCH_AARCH64 - See Also:
- Constant Field Values
 
 - 
ARCH_RISCV64public static final int ARCH_RISCV64 - See Also:
- Constant Field Values
 
 - 
DT_NULLpublic static final int DT_NULL - See Also:
- Constant Field Values
 
 - 
DT_DEBUGpublic static final int DT_DEBUG - See Also:
- Constant Field Values
 
 - 
DT_SONAMEpublic static final int DT_SONAME - See Also:
- Constant Field Values
 
 - 
DT_STRTABpublic static final int DT_STRTAB - See Also:
- Constant Field Values
 
 - 
ET_NONEpublic static final short ET_NONE - See Also:
- Constant Field Values
 
 - 
ET_RELpublic static final short ET_REL - See Also:
- Constant Field Values
 
 - 
ET_EXECpublic static final short ET_EXEC - See Also:
- Constant Field Values
 
 - 
ET_DYNpublic static final short ET_DYN - See Also:
- Constant Field Values
 
 - 
ET_COREpublic static final short ET_CORE - See Also:
- Constant Field Values
 
 - 
ET_NUMpublic static final short ET_NUM - See Also:
- Constant Field Values
 
 - 
ET_LOOSpublic static final int ET_LOOS - See Also:
- Constant Field Values
 
 - 
ET_HIOSpublic static final int ET_HIOS - See Also:
- Constant Field Values
 
 - 
ET_LOPROCpublic static final int ET_LOPROC - See Also:
- Constant Field Values
 
 - 
ET_HIPROCpublic static final int ET_HIPROC - See Also:
- Constant Field Values
 
 - 
NT_PRSTATUSpublic static final int NT_PRSTATUS - See Also:
- Constant Field Values
 
 - 
NT_PRPSINFOpublic static final int NT_PRPSINFO - See Also:
- Constant Field Values
 
 - 
NT_AUXVpublic static final int NT_AUXV - See Also:
- Constant Field Values
 
 - 
NT_HGPRSpublic static final int NT_HGPRS - See Also:
- Constant Field Values
 
 - 
AT_NULLpublic static final int AT_NULL - See Also:
- Constant Field Values
 
 - 
AT_ENTRYpublic static final int AT_ENTRY - See Also:
- Constant Field Values
 
 - 
AT_PLATFORMpublic static final int AT_PLATFORM - See Also:
- Constant Field Values
 
 - 
AT_HWCAPpublic static final int AT_HWCAP - See Also:
- Constant Field Values
 
 - 
isprotected ImageInputStream is 
 - 
sourceNameprotected String sourceName 
 
- 
 - 
Constructor Detail- 
ELFFileReaderprotected ELFFileReader(File file, ByteOrder byteOrder) throws IOException, InvalidDumpFormatException 
 - 
ELFFileReaderprotected ELFFileReader(ImageInputStream in, long offset, long size) throws IOException, InvalidDumpFormatException 
 
- 
 - 
Method Detail- 
padToWordBoundaryprotected abstract long padToWordBoundary(long address) 
 - 
readProgramHeaderEntryprotected abstract ProgramHeaderEntry readProgramHeaderEntry() throws IOException - Throws:
- IOException
 
 - 
readElfWordprotected abstract long readElfWord() throws IOException- Throws:
- IOException
 
 - 
readElfWordAsAddressprotected abstract com.ibm.j9ddr.corereaders.elf.Address readElfWordAsAddress() throws IOException- Throws:
- IOException
 
 - 
readSymbolsAtprotected abstract List<com.ibm.j9ddr.corereaders.elf.ELFSymbol> readSymbolsAt(com.ibm.j9ddr.corereaders.elf.SectionHeaderEntry entry) throws IOException - Throws:
- IOException
 
 - 
addressSizeBitsprotected abstract int addressSizeBits() 
 - 
closepublic void close() throws IOException- Throws:
- IOException
 
 - 
getSourceNamepublic String getSourceName() 
 - 
getELFFileReaderpublic static ELFFileReader getELFFileReader(File file) throws IOException, InvalidDumpFormatException 
 - 
getELFFileReaderpublic static ELFFileReader getELFFileReader(ImageInputStream in) throws IOException, InvalidDumpFormatException 
 - 
getELFFileReaderWithOffsetpublic static ELFFileReader getELFFileReaderWithOffset(ImageInputStream in, long offset, long limit) throws IOException, InvalidDumpFormatException 
 - 
isELFpublic static boolean isELF(byte[] signature) 
 - 
canResolveAddresspublic boolean canResolveAddress(long address) Search the program header table to see whether it can successfully resolve an address into a file offset.If it returns true then it will be safe to call seekToAddress without an IOException being thrown. If it returns false, it will not. - Parameters:
- address- virtual address
- Returns:
- true or false according to whether the address will resolve
 
 - 
getSymbolspublic List<? extends ISymbol> getSymbols(long baseAddress, boolean useUnallocatedSections) throws IOException Obtain the symbols from a core reader, offset by baseAddress.- Parameters:
- baseAddress- the base address to offset symbols from.
- useUnallocatedSections- whether to include symbols from unallocated sections. (true if reading from a library on disk, false if from a loaded library in the core file.)
- Returns:
- Throws:
- IOException
 
 - 
getMemoryRangespublic Collection<? extends IMemorySource> getMemoryRanges(long baseAddress, List<com.ibm.j9ddr.corereaders.elf.SectionHeaderEntry> sectionHeaderEntries, Map<Long,String> sectionHeaderStringTable) throws IOException Iterate through the sections that were already loaded and create a list of memory source objects for them. Abandon the process if it is not possible to find the section header string table. This is one of the last sections and if it cannot be found it is a good indicator that at least part of the section header table has been overwritten. Since it is usually impossible to say where the overwriting starts it is safest to abandon it all. This is only an issue when working with a dump that does not have the original library files attached to it.- Parameters:
- baseAddress-
- Returns:
- List of memory sources
- Throws:
- IOException
 
 - 
sectionHeaderMapsToProgramHeaderpublic boolean sectionHeaderMapsToProgramHeader(com.ibm.j9ddr.corereaders.elf.SectionHeaderEntry section) 
 - 
getSectionHeaderStringTablepublic Map<Long,String> getSectionHeaderStringTable() throws IOException - Throws:
- IOException
 
 - 
is64Bitpublic boolean is64Bit() 
 - 
readBytespublic byte[] readBytes(int len) throws IOException- Throws:
- IOException
 
 - 
getMachineTypepublic short getMachineType() 
 - 
getProgramHeaderEntriespublic List<? extends ProgramHeaderEntry> getProgramHeaderEntries() 
 - 
getSectionHeaderEntriespublic List<com.ibm.j9ddr.corereaders.elf.SectionHeaderEntry> getSectionHeaderEntries() 
 - 
getStreampublic ImageInputStream getStream() throws IOException Gets the data stream for this reader- Returns:
- an ImageInputStream for this reader
- Throws:
- IOException
 
 - 
getFilepublic File getFile() Returns the file from which this reader is reading.- Returns:
- File or null if this reader is reading from a stream
 
 - 
getPropertiespublic Properties getProperties() 
 - 
readIntpublic int readInt() throws IOException- Throws:
- IOException
 
 - 
readBytepublic byte readByte() throws IOException- Throws:
- IOException
 
 - 
seekpublic void seek(long pos) throws IOException- Throws:
- IOException
 
 - 
getByteOrderpublic ByteOrder getByteOrder() 
 - 
readShortpublic short readShort() throws IOException- Throws:
- IOException
 
 - 
readLongpublic long readLong() throws IOException- Throws:
- IOException
 
 - 
readFullypublic void readFully(byte[] b, int off, int len) throws IOException- Throws:
- IOException
 
 - 
readStringpublic String readString() Reads a string from the readers current position until it is terminated by a null (0) byte. Bytes are read and converted to an ASCII string. string. If readByte throws an exception, null will be returned.- Returns:
- the null terminated sting at the readers current position or null
- Throws:
- IOException
 
 - 
getDynamicTableEntrypublic ProgramHeaderEntry getDynamicTableEntry() Search the program header table for the dynamic entry. There should be only one of these Typically it is within the first few entries, often the third, so this is not expensive- Returns:
- the program header table entry for the dynamic table
 
 - 
isExecutablepublic boolean isExecutable() Examine the ELF header to determine if this file is an executable or not. Often it will instead be a shared library.- Returns:
- true if the file is an executable
 
 - 
isTruncatedpublic boolean isTruncated() Are any parts of the core file known to be missing?
 - 
readSONAMEpublic String readSONAME(ELFFileReader coreFileReader) Assume the entry given refers to a loaded library or program and find and return its name or null if it couldn't be determined. This method does not throw exceptions as we are seeking around the core file which could be damaged or may come from a version of linux which doesn't leave this information available, just do our best.- Parameters:
- ELFFileReader- for the core file as a whole
- Returns:
- the SONAME (library name) or null
 
 - 
isCompatibleWithpublic boolean isCompatibleWith(ELFFileReader otherReader) Perform a quick check on two ELF readers to see if they represent the same library. otherReader is the one we hope is better that this reader. This is not the same as checking they are equal as we hope the other reader actually has more information in.- Parameters:
- otherReader- another ELFFileReader to compare against this one.
 
 
- 
 
-