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
-
-
Field Summary
Fields Modifier and Type Field Description protected CoffFileHeader_headerprotected java.util.List<CoffLineNumber>_lineNumbersprotected java.util.List<CoffRelocation>_relocationsprotected ints_flagsprotected ints_lnnoptrprotected java.lang.Strings_nameprotected ints_nlnnoprotected ints_nrelocprotected ints_paddrprotected shorts_pageprotected ints_relptrprotected shorts_reservedprotected ints_scnptrprotected ints_sizeprotected ints_vaddr
-
Constructor Summary
Constructors Modifier Constructor Description protectedCoffSectionHeader()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static AddressgetAddress(Language language, long offset, CoffSectionHeader section)Convert address offset to an Address object.static AddressgetAddress(Language language, long offset, AddressSpace space)Convert address offset to an Address in the specified space (defined by pspec).intgetFlags()Returns the flags for this section.intgetLineNumberCount()Returns the number of line number entries for this section.java.util.List<CoffLineNumber>getLineNumbers()java.lang.StringgetName()Returns the section name.shortgetPage()intgetPhysicalAddress()Returns the physical address offset.AddressgetPhysicalAddress(Language language)Returns the physical address.intgetPointerToLineNumbers()Returns the file offset to the line numbers for this section.intgetPointerToRawData()Returns the file offset to the section data.intgetPointerToRelocations()Returns the file offset to the relocations for this section.java.io.InputStreamgetRawDataStream(ByteProvider provider, Language language)Returns an input stream that will supply the bytes for this section.intgetRelocationCount()Returns the number of relocations for this section.java.util.List<CoffRelocation>getRelocations()shortgetReserved()intgetSize(Language language)Returns the number of bytes of data stored in the file for this section.intgetVirtualAddress()Returns the virtual address.booleanisAllocated()booleanisData()booleanisExecutable()booleanisExplicitlyByteAligned()Returns true if this section is byte oriented and aligned and should assume an addressable unit size of 1.booleanisGroup()booleanisInitializedData()booleanisProcessedBytes(Language language)booleanisReadable()booleanisUninitializedData()booleanisWritable()voidmove(int offset)Adds offset to the physical address; this must be performed before relocations in order to achieve the proper result.protected voidreadName(BinaryReader reader)DataTypetoDataType()Returns a structure datatype representing the contents of the implementor of this interface.java.lang.StringtoString()
-
-
-
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.
-
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:StructConverterReturns 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:
toDataTypein 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:
toStringin 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
-
-