Package ghidra.app.util.bin.format.coff
Class CoffSectionHeader
- java.lang.Object
-
- ghidra.app.util.bin.format.coff.CoffSectionHeader
-
- All Implemented Interfaces:
StructConverter
public class CoffSectionHeader extends java.lang.Object implements StructConverter
A 0x28 byte COFF section header
-
-
Field Summary
Fields Modifier and Type Field Description protected CoffFileHeader
_header
protected java.util.List<CoffLineNumber>
_lineNumbers
protected java.util.List<CoffRelocation>
_relocations
protected int
s_flags
protected int
s_lnnoptr
protected java.lang.String
s_name
protected int
s_nlnno
protected int
s_nreloc
protected int
s_paddr
protected short
s_page
protected int
s_relptr
protected short
s_reserved
protected int
s_scnptr
protected int
s_size
protected int
s_vaddr
-
Constructor Summary
Constructors Modifier Constructor Description protected
CoffSectionHeader()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Address
getAddress(Language language, long offset, CoffSectionHeader section)
Convert address offset to an Address object.static Address
getAddress(Language language, long offset, AddressSpace space)
Convert address offset to an Address in the specified space (defined by pspec).int
getFlags()
Returns the flags for this section.int
getLineNumberCount()
Returns the number of line number entries for this section.java.util.List<CoffLineNumber>
getLineNumbers()
java.lang.String
getName()
Returns the section name.short
getPage()
int
getPhysicalAddress()
Returns the physical address offset.Address
getPhysicalAddress(Language language)
Returns the physical address.int
getPointerToLineNumbers()
Returns the file offset to the line numbers for this section.int
getPointerToRawData()
Returns the file offset to the section data.int
getPointerToRelocations()
Returns the file offset to the relocations for this section.java.io.InputStream
getRawDataStream(ByteProvider provider, Language language)
Returns an input stream that will supply the bytes for this section.int
getRelocationCount()
Returns the number of relocations for this section.java.util.List<CoffRelocation>
getRelocations()
short
getReserved()
int
getSize(Language language)
Returns the number of bytes of data stored in the file for this section.int
getVirtualAddress()
Returns the virtual address.boolean
isAllocated()
boolean
isData()
boolean
isExecutable()
boolean
isExplicitlyByteAligned()
Returns true if this section is byte oriented and aligned and should assume an addressable unit size of 1.boolean
isGroup()
boolean
isInitializedData()
boolean
isProcessedBytes(Language language)
boolean
isReadable()
boolean
isUninitializedData()
boolean
isWritable()
void
move(int offset)
Adds offset to the physical address; this must be performed before relocations in order to achieve the proper result.protected void
readName(BinaryReader reader)
DataType
toDataType()
Returns a structure datatype representing the contents of the implementor of this interface.java.lang.String
toString()
-
-
-
Field Detail
-
s_name
protected java.lang.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 java.util.List<CoffRelocation> _relocations
-
_lineNumbers
protected java.util.List<CoffLineNumber> _lineNumbers
-
-
Method Detail
-
readName
protected void readName(BinaryReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
getName
public java.lang.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 java.io.InputStream getRawDataStream(ByteProvider provider, Language language) throws java.io.IOException
Returns an input stream that will supply the bytes for this section.- Returns:
- the input stream
- Throws:
java.io.IOException
- if an I/O error occurs
-
isProcessedBytes
public boolean isProcessedBytes(Language language)
-
toDataType
public DataType toDataType() throws DuplicateNameException, java.io.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 interfaceStructConverter
- Returns:
- returns a structure datatype representing the implementor of this interface
- Throws:
DuplicateNameException
- when a datatype of the same name already existsjava.io.IOException
- See Also:
StructureDataType
-
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 java.util.List<CoffRelocation> getRelocations()
-
getLineNumbers
public java.util.List<CoffLineNumber> getLineNumbers()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.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
-
-