Package ghidra.app.util.bin.format.omf

# Class OmfFileHeader

java.lang.Object
ghidra.app.util.bin.format.omf.OmfRecord
ghidra.app.util.bin.format.omf.OmfFileHeader

public class OmfFileHeader extends OmfRecord

- ## Field Summary

  ### Fields inherited from class ghidra.app.util.bin.format.omf.OmfRecord

  `ALIAS, BAKPAT, BLKDEF, BLKEND, CEXTDEF, checkSum, COMDAT, COMDEF, COMENT, DEBSYM, END, ENDREC, EXTDEF, FIXUPP, GRPDEF, LCOMDEF, LEDATA, LEXTDEF, LHEADR, LIBDIC, LIBHED, LIBLOC, LIBNAM, LIDATA, LINNUM, LINSYM, LLNAMES, LNAMES, LOCSYM, LPUBDEF, MODEND, NBKPAT, OVLDEF, PEDATA, PIDATA, PUBDEF, recordLength, recordOffset, recordType, REDATA, REGINT, RHEADR, RIDATA, SEGDEF, START, THEADR, TYPDEF, VENDEXT, VERNUM`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `OmfFileHeader(BinaryReader reader)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static boolean`
  `checkMagicNumber(BinaryReader reader)`
  Check that the file has the specific OMF magic number
  `static BinaryReader`
  `createReader(ByteProvider provider)`
  Create a reader for a specific OMF file
  `static void`
  `doLinking(long startAddress, ArrayList<OmfSegmentHeader> segments, ArrayList<OmfGroupRecord> groups)`
  Assign a load image address to each segment.
  `ArrayList<OmfExternalSymbol>`
  `getExternalSymbols()`
  `ArrayList<OmfSegmentHeader>`
  `getExtraSegments()`
  `ArrayList<OmfFixupRecord>`
  `getFixups()`
  `ArrayList<OmfGroupRecord>`
  `getGroups()`
  `String`
  `getLibraryModuleName()`
  The name of the object module (within a library)
  `String`
  `getMachineName()`
  `String`
  `getName()`
  This is usually the original source filename
  `ArrayList<OmfSymbolRecord>`
  `getPublicSymbols()`
  `ArrayList<OmfSegmentHeader>`
  `getSegments()`
  `String`
  `getTranslator()`
  If the OMF file contains a "translator" record, this is usually a string indicating the compiler which produced the file.
  `boolean`
  `isLittleEndian()`
  `static OmfFileHeader`
  `parse(BinaryReader reader, TaskMonitor monitor, MessageLog log)`
  Parse the entire object file
  `void`
  `resolveNames()`
  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
  `OmfSegmentHeader`
  `resolveSegment(int index)`
  Given an index, retrieve the specific segment it refers to.
  `static OmfFileHeader`
  `scan(BinaryReader reader, TaskMonitor monitor, boolean fastscan)`
  Scan the object file, for the main header and comment records.
  `void`
  `sortSegmentDataBlocks()`
  Sort the explicit data-blocks for each segment into address order.

  ### Methods inherited from class ghidra.app.util.bin.format.omf.OmfRecord

  `calcCheckSum, getRecordLength, getRecordName, getRecordOffset, getRecordType, hasBigFields, readCheckSumByte, readIndex, readInt1Or2, readInt2Or4, readRecord, readRecordHeader, readString, toString, validCheckSum`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### OmfFileHeader

    public OmfFileHeader(BinaryReader reader) throws IOException
    Throws:
      `IOException`

- ## Method Details

  - ### 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 ArrayList<OmfSegmentHeader> getSegments()
    Returns:
      the list of segments in this file

  - ### getExtraSegments

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

  - ### getGroups

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

  - ### getExternalSymbols

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

  - ### getPublicSymbols

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

  - ### getFixups

    public ArrayList<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(BinaryReader reader, 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:
      `reader` - is the byte stream
      `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(BinaryReader reader, TaskMonitor monitor, MessageLog log) throws IOException, OmfException
    Parse the entire object file
    Parameters:
      `reader` - is the byte stream
      `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, ArrayList<OmfSegmentHeader> segments, ArrayList<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

  - ### createReader

    public static BinaryReader createReader(ByteProvider provider)
    Create a reader for a specific OMF file
    Parameters:
      `provider` - is the underlying ByteProvider
    Returns:
      the new reader