java.lang.Object
com.ibm.j9ddr.corereaders.elf.ELFFileReader
- Direct Known Subclasses:
ELF32FileReader
,ELF64FileReader
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final byte
static final byte
static final short
static final short
static final short
static final int
static final int
static final int
static final int
static final short
static final short
static final short
protected ImageInputStream
static final int
static final int
static final int
static final int
protected String
-
Constructor Summary
ModifierConstructorDescriptionprotected
ELFFileReader
(File file, ByteOrder byteOrder) protected
ELFFileReader
(ImageInputStream in, long offset, long size) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract int
boolean
canResolveAddress
(long address) Search the program header table to see whether it can successfully resolve an address into a file offset.void
close()
Search the program header table for the dynamic entry.static ELFFileReader
getELFFileReader
(File file) static ELFFileReader
static ELFFileReader
getELFFileReaderWithOffset
(ImageInputStream in, long offset, long limit) getFile()
Returns the file from which this reader is reading.short
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> List
<com.ibm.j9ddr.corereaders.elf.SectionHeaderEntry> Gets the data stream for this readergetSymbols
(long baseAddress, boolean useUnallocatedSections) Obtain the symbols from a core reader, offset by baseAddress.boolean
is64Bit()
boolean
isCompatibleWith
(ELFFileReader otherReader) Perform a quick check on two ELF readers to see if they represent the same library.static boolean
isELF
(byte[] signature) boolean
Examine the ELF header to determine if this file is an executable or not.boolean
Are any parts of the core file known to be missing?protected abstract long
padToWordBoundary
(long address) byte
readByte()
byte[]
readBytes
(int len) protected abstract long
protected abstract com.ibm.j9ddr.corereaders.elf.Address
void
readFully
(byte[] b, int off, int len) int
readInt()
long
readLong()
protected abstract ProgramHeaderEntry
short
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.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) boolean
sectionHeaderMapsToProgramHeader
(com.ibm.j9ddr.corereaders.elf.SectionHeaderEntry section) void
seek
(long pos)
-
Field Details
-
ELF_NOTE_HEADER_SIZE
public static final int ELF_NOTE_HEADER_SIZE- See Also:
-
EI_NIDENT
public static final int EI_NIDENT- See Also:
-
ELFDATA2LSB
public static final byte ELFDATA2LSB- See Also:
-
ELFDATA2MSB
public static final byte ELFDATA2MSB- See Also:
-
ELFCLASS32
public static final int ELFCLASS32- See Also:
-
ELFCLASS64
public static final int ELFCLASS64- See Also:
-
ELF_PRARGSZ
public static final int ELF_PRARGSZ- See Also:
-
ARCH_IA32
public static final int ARCH_IA32- See Also:
-
ARCH_PPC32
public static final int ARCH_PPC32- See Also:
-
ARCH_PPC64
public static final int ARCH_PPC64- See Also:
-
ARCH_S390
public static final int ARCH_S390- See Also:
-
ARCH_ARM
public static final int ARCH_ARM- See Also:
-
ARCH_IA64
public static final int ARCH_IA64- See Also:
-
ARCH_AMD64
public static final int ARCH_AMD64- See Also:
-
ARCH_AARCH64
public static final int ARCH_AARCH64- See Also:
-
ARCH_RISCV64
public static final int ARCH_RISCV64- See Also:
-
DT_NULL
public static final int DT_NULL- See Also:
-
DT_DEBUG
public static final int DT_DEBUG- See Also:
-
DT_SONAME
public static final int DT_SONAME- See Also:
-
DT_STRTAB
public static final int DT_STRTAB- See Also:
-
ET_NONE
public static final short ET_NONE- See Also:
-
ET_REL
public static final short ET_REL- See Also:
-
ET_EXEC
public static final short ET_EXEC- See Also:
-
ET_DYN
public static final short ET_DYN- See Also:
-
ET_CORE
public static final short ET_CORE- See Also:
-
ET_NUM
public static final short ET_NUM- See Also:
-
ET_LOOS
public static final int ET_LOOS- See Also:
-
ET_HIOS
public static final int ET_HIOS- See Also:
-
ET_LOPROC
public static final int ET_LOPROC- See Also:
-
ET_HIPROC
public static final int ET_HIPROC- See Also:
-
NT_PRSTATUS
public static final int NT_PRSTATUS- See Also:
-
NT_PRPSINFO
public static final int NT_PRPSINFO- See Also:
-
NT_AUXV
public static final int NT_AUXV- See Also:
-
NT_HGPRS
public static final int NT_HGPRS- See Also:
-
AT_NULL
public static final int AT_NULL- See Also:
-
AT_ENTRY
public static final int AT_ENTRY- See Also:
-
AT_PLATFORM
public static final int AT_PLATFORM- See Also:
-
AT_HWCAP
public static final int AT_HWCAP- See Also:
-
is
-
sourceName
-
-
Constructor Details
-
ELFFileReader
protected ELFFileReader(File file, ByteOrder byteOrder) throws IOException, InvalidDumpFormatException -
ELFFileReader
protected ELFFileReader(ImageInputStream in, long offset, long size) throws IOException, InvalidDumpFormatException
-
-
Method Details
-
padToWordBoundary
protected abstract long padToWordBoundary(long address) -
readProgramHeaderEntry
- Throws:
IOException
-
readElfWord
- Throws:
IOException
-
readElfWordAsAddress
- Throws:
IOException
-
readSymbolsAt
protected abstract List<com.ibm.j9ddr.corereaders.elf.ELFSymbol> readSymbolsAt(com.ibm.j9ddr.corereaders.elf.SectionHeaderEntry entry) throws IOException - Throws:
IOException
-
addressSizeBits
protected abstract int addressSizeBits() -
close
- Throws:
IOException
-
getSourceName
-
getELFFileReader
public static ELFFileReader getELFFileReader(File file) throws IOException, InvalidDumpFormatException -
getELFFileReader
public static ELFFileReader getELFFileReader(ImageInputStream in) throws IOException, InvalidDumpFormatException -
getELFFileReaderWithOffset
public static ELFFileReader getELFFileReaderWithOffset(ImageInputStream in, long offset, long limit) throws IOException, InvalidDumpFormatException -
isELF
public static boolean isELF(byte[] signature) -
canResolveAddress
public 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
-
getSymbols
public 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
-
getMemoryRanges
public Collection<? extends IMemorySource> getMemoryRanges(long baseAddress, List<com.ibm.j9ddr.corereaders.elf.SectionHeaderEntry> sectionHeaderEntries, Map<Long, String> sectionHeaderStringTable) throws IOExceptionIterate 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
-
sectionHeaderMapsToProgramHeader
public boolean sectionHeaderMapsToProgramHeader(com.ibm.j9ddr.corereaders.elf.SectionHeaderEntry section) -
getSectionHeaderStringTable
- Throws:
IOException
-
is64Bit
public boolean is64Bit() -
readBytes
- Throws:
IOException
-
getMachineType
public short getMachineType() -
getProgramHeaderEntries
-
getSectionHeaderEntries
-
getStream
Gets the data stream for this reader- Returns:
- an ImageInputStream for this reader
- Throws:
IOException
-
getFile
Returns the file from which this reader is reading.- Returns:
- File or null if this reader is reading from a stream
-
getProperties
-
readInt
- Throws:
IOException
-
readByte
- Throws:
IOException
-
seek
- Throws:
IOException
-
getByteOrder
-
readShort
- Throws:
IOException
-
readLong
- Throws:
IOException
-
readFully
- Throws:
IOException
-
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
-
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
-
isExecutable
public 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
-
isTruncated
public boolean isTruncated()Are any parts of the core file known to be missing? -
readSONAME
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
-
isCompatibleWith
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.
-