Class OmfFileHeader

java.lang.Object
ghidra.app.util.bin.format.omf.OmfRecord
ghidra.app.util.bin.format.omf.omf.OmfFileHeader
All Implemented Interfaces:
StructConverter

public class OmfFileHeader extends OmfRecord
  • Constructor Details

  • Method Details

    • parseData

      public void parseData() throws IOException, OmfException
      Description copied from class: OmfRecord
      Parses this OmfRecord's type-spefic data
      Specified by:
      parseData in class OmfRecord
      Throws:
      IOException - if there was an IO-related error
      OmfException - if there was a problem with the OMF specification
    • getRecords

      public List<OmfRecord> getRecords()
      Returns the list of records.
      Returns:
      the list of records
    • getName

      public String getName()
      This is usually the original source filename
      Returns:
      the name
    • getLibraryModuleName

      public String getLibraryModuleName()
      The name of the object module (within a library)
      Returns:
      the name
    • getMachineName

      public String getMachineName()
      Returns:
      the string identifying the architecture this object was compiled for
    • getTranslator

      public String getTranslator()
      If the OMF file contains a "translator" record, this is usually a string indicating the compiler which produced the file.
      Returns:
      the translator for this file
    • isLittleEndian

      public boolean isLittleEndian()
      Returns:
      true if the file describes the load image for a little endian architecture
    • getSegments

      public List<OmfSegmentHeader> getSegments()
      Returns:
      the list of segments in this file
    • getExtraSegments

      public List<OmfSegmentHeader> getExtraSegments()
      Returns:
      the list of segments which are Borland extensions
    • getGroups

      public List<OmfGroupRecord> getGroups()
      Returns:
      the list of group records for this file
    • getExternalSymbols

      public List<OmfExternalSymbol> getExternalSymbols()
      Returns:
      the list of symbols that are external to this file
    • getPublicSymbols

      public List<OmfSymbolRecord> getPublicSymbols()
      Returns:
      the list of public symbols exported by this file
    • getLocalSymbols

      public List<OmfSymbolRecord> getLocalSymbols()
      Returns:
      the list of local symbols in this file
    • getFixups

      public List<OmfFixupRecord> getFixups()
      Returns:
      the list of relocation records for this file
    • sortSegmentDataBlocks

      public void sortSegmentDataBlocks()
      Sort the explicit data-blocks for each segment into address order.
    • resolveSegment

      public OmfSegmentHeader resolveSegment(int index) throws OmfException
      Given an index, retrieve the specific segment it refers to. This incorporates the special Borland segments, where the index has the bit 0x4000 set.
      Parameters:
      index - identifies the segment
      Returns:
      the corresponding OmfSegmentHeader
      Throws:
      OmfException - if the index is malformed
    • resolveNames

      public void resolveNames() throws OmfException
      Resolve special names associated with each segment: segment, class, overlay names and group: group name For each segment, the read/write/execute permissions are also determined
      Throws:
      OmfException - if any name indices are malformed
    • scan

      public static OmfFileHeader scan(AbstractOmfRecordFactory factory, TaskMonitor monitor, boolean fastscan) throws IOException, OmfException
      Scan the object file, for the main header and comment records. Other records are parsed but not saved
      Parameters:
      factory - the AbstractOmfRecordFactory
      monitor - is checked for cancellation
      fastscan - is true if we only want to scan the header until first seghead,
      Returns:
      the header record
      Throws:
      IOException - for problems reading program data
      OmfException - for malformed records
    • parse

      public static OmfFileHeader parse(AbstractOmfRecordFactory factory, TaskMonitor monitor, MessageLog log) throws IOException, OmfException
      Parse the entire object file
      Parameters:
      factory - the AbstractOmfRecordFactory
      monitor - is checked for cancel button
      log - the log
      Returns:
      the header record as root of object
      Throws:
      IOException - for problems reading data
      OmfException - for malformed records
    • doLinking

      public static void doLinking(long startAddress, List<OmfSegmentHeader> segments, List<OmfGroupRecord> groups) throws OmfException
      Assign a load image address to each segment. Follow OMF rules for grouping and ordering the segments in memory.
      Parameters:
      startAddress - is the base memory address for the load image
      segments - is the list of segments
      groups - is the list of specific segments that are grouped together in memory
      Throws:
      OmfException - for malformed index/alignment/combining fields
    • checkMagicNumber

      public static boolean checkMagicNumber(BinaryReader reader) throws IOException
      Check that the file has the specific OMF magic number
      Parameters:
      reader - accesses the bytes of the file
      Returns:
      true if the magic number matches
      Throws:
      IOException - for problems reading bytes
    • toDataType

      public DataType toDataType() throws DuplicateNameException, IOException
      Description copied from interface: StructConverter
      Returns a structure datatype representing the contents of the implementor of this interface.

      For example, given:

       class A {
           int foo;
           double bar;
       }
       

      The return value should be a structure data type with two data type components; an INT and a DOUBLE. The structure should contain field names and, if possible, field comments.

      Specified by:
      toDataType in interface StructConverter
      Specified by:
      toDataType in class OmfRecord
      Returns:
      returns a structure datatype representing the implementor of this interface
      Throws:
      DuplicateNameException - when a datatype of the same name already exists
      IOException - if an IO-related error occurs
      See Also: