Module openj9.dtfj

Class ELFFileReader

    • Method Detail

      • padToWordBoundary

        protected abstract long padToWordBoundary​(long address)
      • readElfWordAsAddress

        protected abstract com.ibm.j9ddr.corereaders.elf.Address readElfWordAsAddress()
                                                                               throws IOException
        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()
      • getSourceName

        public String getSourceName()
      • 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 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
      • sectionHeaderMapsToProgramHeader

        public boolean sectionHeaderMapsToProgramHeader​(com.ibm.j9ddr.corereaders.elf.SectionHeaderEntry section)
      • is64Bit

        public boolean is64Bit()
      • getMachineType

        public short getMachineType()
      • getSectionHeaderEntries

        public List<com.ibm.j9ddr.corereaders.elf.SectionHeaderEntry> getSectionHeaderEntries()
      • getFile

        public File getFile()
        Returns the file from which this reader is reading.
        Returns:
        File or null if this reader is reading from a stream
      • getProperties

        public Properties getProperties()
      • getByteOrder

        public ByteOrder getByteOrder()
      • readString

        public 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
      • getDynamicTableEntry

        public 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
      • 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

        public 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
      • isCompatibleWith

        public 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.