Class CoffSectionHeader

java.lang.Object
ghidra.app.util.bin.format.coff.CoffSectionHeader
All Implemented Interfaces:
StructConverter

public class CoffSectionHeader extends Object implements StructConverter
A 0x28 byte COFF section header
  • Field Details

    • s_name

      protected String s_name
    • s_paddr

      protected int s_paddr
    • s_vaddr

      protected int s_vaddr
    • s_size

      protected int s_size
    • s_scnptr

      protected int s_scnptr
    • s_relptr

      protected int s_relptr
    • s_lnnoptr

      protected int s_lnnoptr
    • s_nreloc

      protected int s_nreloc
    • s_nlnno

      protected int s_nlnno
    • s_flags

      protected int s_flags
    • s_reserved

      protected short s_reserved
    • s_page

      protected short s_page
    • _header

      protected CoffFileHeader _header
    • _relocations

      protected List<CoffRelocation> _relocations
    • _lineNumbers

      protected List<CoffLineNumber> _lineNumbers
  • Constructor Details

    • CoffSectionHeader

      protected CoffSectionHeader()
  • Method Details

    • readName

      protected void readName(BinaryReader reader) throws IOException
      Throws:
      IOException
    • getName

      public String getName()
      Returns the section name. The section name will never be more than eight characters.
      Returns:
      the section name
    • getPhysicalAddress

      public int getPhysicalAddress()
      Returns the physical address offset. This is the address at which the section should be loaded into memory and reflects a addressable word offset. For linked executables, this is the absolute address within the program space. For unlinked objects, this address is relative to the object's address space (i.e. the first section is always at offset zero).
      Returns:
      the physical address
    • move

      public void move(int offset)
      Adds offset to the physical address; this must be performed before relocations in order to achieve the proper result.
      Parameters:
      offset - the offset to add to the physical address
    • getPhysicalAddress

      public Address getPhysicalAddress(Language language)
      Returns the physical address. This is the address at which the section should be loaded into memory. For linked executables, this is the absolute address within the program space. For unlinked objects, this address is relative to the object's address space (i.e. the first section is always at offset zero).
      Returns:
      the physical address
    • getVirtualAddress

      public int getVirtualAddress()
      Returns the virtual address. This value is always the same as s_paddr.
      Returns:
      the virtual address
    • isExplicitlyByteAligned

      public boolean isExplicitlyByteAligned()
      Returns true if this section is byte oriented and aligned and should assume an addressable unit size of 1.
      Returns:
      true if byte aligned, false if word aligned
    • getSize

      public int getSize(Language language)
      Returns the number of bytes of data stored in the file for this section. NOTE: This value does not strictly indicate size in bytes. For word-oriented machines, this value is represents size in words.
      Returns:
      the number of bytes of data stored in the file for this section
    • getPointerToRawData

      public int getPointerToRawData()
      Returns the file offset to the section data.
      Returns:
      the file offset to the section data
    • getPointerToRelocations

      public int getPointerToRelocations()
      Returns the file offset to the relocations for this section.
      Returns:
      the file offset to the relocations for this section
    • getPointerToLineNumbers

      public int getPointerToLineNumbers()
      Returns the file offset to the line numbers for this section.
      Returns:
      the file offset to the line numbers for this section
    • getRelocationCount

      public int getRelocationCount()
      Returns the number of relocations for this section.
      Returns:
      the number of relocations for this section
    • getLineNumberCount

      public int getLineNumberCount()
      Returns the number of line number entries for this section.
      Returns:
      the number of line number entries for this section
    • getFlags

      public int getFlags()
      Returns the flags for this section.
      Returns:
      the flags for this section
    • getReserved

      public short getReserved()
    • getPage

      public short getPage()
    • getRawDataStream

      public InputStream getRawDataStream(ByteProvider provider, Language language) throws IOException
      Returns an input stream that will supply the bytes for this section.
      Returns:
      the input stream
      Throws:
      IOException - if an I/O error occurs
    • isProcessedBytes

      public boolean isProcessedBytes(Language language)
    • 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
      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:
    • isUninitializedData

      public boolean isUninitializedData()
    • isInitializedData

      public boolean isInitializedData()
    • isData

      public boolean isData()
    • isReadable

      public boolean isReadable()
    • isGroup

      public boolean isGroup()
    • isWritable

      public boolean isWritable()
    • isExecutable

      public boolean isExecutable()
    • isAllocated

      public boolean isAllocated()
    • getRelocations

      public List<CoffRelocation> getRelocations()
    • getLineNumbers

      public List<CoffLineNumber> getLineNumbers()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getAddress

      public static Address getAddress(Language language, long offset, CoffSectionHeader section)
      Convert address offset to an Address object. The default data space (defined by pspec) will be used if section is null or corresponds to a data section. The language default space (defined by slaspec) will be used for all non-data sections. If pspec does not specify a default data space, the default language space is used.
      Parameters:
      language -
      offset - address offset (byte offset assumed if section is null or is not explicitly byte aligned, otherwise word offset assumed).
      section - section which contains the specified offset or null (data space assumed)
      Returns:
      address object
    • getAddress

      public static Address getAddress(Language language, long offset, AddressSpace space)
      Convert address offset to an Address in the specified space (defined by pspec). If pspec does not specify a default data space, the default language space is used.
      Parameters:
      language -
      offset - address offset (word offset assumed).
      space - address space
      Returns:
      address object