COFF model cleanup

This commit is contained in:
Matt Nadareski
2025-10-30 21:29:24 -04:00
parent ad0f01c3ef
commit 3ee88793da
11 changed files with 36 additions and 36 deletions

View File

@@ -3,18 +3,18 @@ namespace SabreTools.Data.Models.COFF
public static class Constants
{
/// <summary>
/// Fixed size of <see cref="FileHeader"/>
/// Fixed size of <see cref="FileHeader"/>
/// </summary>
public const int FileHeaderSize = 20;
/// <summary>
/// Fixed size of <see cref="SectionHeader"/>
/// Fixed size of <see cref="SectionHeader"/>
/// </summary>
public const int SectionHeaderSize = 40;
/// <summary>
/// Fixed size of <see cref="SymbolTableEntries.BaseEntry"/>
/// Fixed size of <see cref="SymbolTableEntries.BaseEntry"/>
/// </summary>
public const int SymbolTableEntrySize = 18;
}
}
}

View File

@@ -45,14 +45,14 @@ namespace SabreTools.Data.Models.COFF
IMAGE_FILE_LARGE_ADDRESS_AWARE = 0x0020,
/// <summary>
/// This flag is reserved for future use.
/// This flag is reserved for future use.
/// </summary>
RESERVED = 0x0040,
/// <summary>
/// Little endian: the least significant bit (LSB) precedes the most
/// significant bit (MSB) in memory. This flag is deprecated and
/// should be zero.
/// should be zero.
/// </summary>
IMAGE_FILE_BYTES_REVERSED_LO = 0x0080,
@@ -86,7 +86,7 @@ namespace SabreTools.Data.Models.COFF
/// <summary>
/// The image file is a dynamic-link library (DLL). Such files
/// are considered executable files for almost all purposes,
/// although they cannot be directly run.
/// although they cannot be directly run.
/// </summary>
IMAGE_FILE_DLL = 0x2000,
@@ -338,7 +338,7 @@ namespace SabreTools.Data.Models.COFF
IMAGE_REL_AMD64_PAIR = 0x000F,
/// <summary>
/// A 32-bit signed span-dependent value that is applied at link time.
/// A 32-bit signed span-dependent value that is applied at link time.
/// </summary>
IMAGE_REL_AMD64_SSPAN32 = 0x0010,
@@ -1435,7 +1435,7 @@ namespace SabreTools.Data.Models.COFF
IMAGE_SCN_MEM_READ = 0x40000000,
/// <summary>
/// The section can be written to.
/// The section can be written to.
/// </summary>
IMAGE_SCN_MEM_WRITE = 0x80000000,
}
@@ -1446,20 +1446,20 @@ namespace SabreTools.Data.Models.COFF
/// The symbol record is not yet assigned a section. A value of
/// zero indicates that a reference to an external symbol is
/// defined elsewhere. A value of non-zero is a common symbol
/// with a size that is specified by the value.
/// with a size that is specified by the value.
/// </summary>
IMAGE_SYM_UNDEFINED = 0,
/// <summary>
/// The symbol has an absolute (non-relocatable) value and
/// is not an address.
/// is not an address.
/// </summary>
IMAGE_SYM_ABSOLUTE = -1,
/// <summary>
/// The symbol provides general type or debugging information
/// but does not correspond to a section. Microsoft tools use
/// this setting along with .file records (storage class FILE).
/// this setting along with .file records (storage class FILE).
/// </summary>
IMAGE_SYM_DEBUG = -2,
}

View File

@@ -19,13 +19,13 @@ namespace SabreTools.Data.Models.COFF
/// <summary>
/// The number of sections. This indicates the size of the section table,
/// which immediately follows the headers.
/// which immediately follows the headers.
/// </summary>
public ushort NumberOfSections;
/// <summary>
/// The low 32 bits of the number of seconds since 00:00 January 1, 1970
/// (a C run-time time_t value), which indicates when the file was created.
/// (a C run-time time_t value), which indicates when the file was created.
/// </summary>
public uint TimeDateStamp;

View File

@@ -5,12 +5,12 @@ namespace SabreTools.Data.Models.COFF
/// <summary>
/// COFF line numbers are no longer produced and, in the future, will
/// not be consumed.
///
///
/// COFF line numbers indicate the relationship between code and line
/// numbers in source files. The Microsoft format for COFF line numbers
/// is similar to standard COFF, but it has been extended to allow a
/// single section to relate to line numbers in multiple source files.
///
///
/// COFF line numbers consist of an array of fixed-length records.
/// The location (file offset) and size of the array are specified in
/// the section header.

View File

@@ -6,22 +6,22 @@ namespace SabreTools.Data.Models.COFF
/// do not have it. For image files, this header is required. An object file can have
/// an optional header, but generally this header has no function in an object file
/// except to increase its size.
///
///
/// Note that the size of the optional header is not fixed. The SizeOfOptionalHeader
/// field in the COFF header must be used to validate that a probe into the file for
/// a particular data directory does not go beyond SizeOfOptionalHeader.
///
///
/// The NumberOfRvaAndSizes field of the optional header should also be used to ensure
/// that no probe for a particular data directory entry goes beyond the optional header.
/// In addition, it is important to validate the optional header magic number for format
/// compatibility.
///
///
/// The optional header magic number determines whether an image is a PE32 or
/// PE32+ executable.
///
///
/// PE32+ images allow for a 64-bit address space while limiting the image size to
/// 2 gigabytes. Other PE32+ modifications are addressed in their respective sections.
///
///
/// The first eight fields of the optional header are standard fields that are defined
/// for every implementation of COFF. These fields contain general information that is
/// useful for loading and running an executable file. They are unchanged for the
@@ -33,7 +33,7 @@ namespace SabreTools.Data.Models.COFF
/// <summary>
/// The unsigned integer that identifies the state of the image file. The most
/// common number is 0x10B, which identifies it as a normal executable file.
/// 0x107 identifies it as a ROM image, and 0x20B identifies it as a PE32+ executable.
/// 0x107 identifies it as a ROM image, and 0x20B identifies it as a PE32+ executable.
/// </summary>
public OptionalHeaderMagicNumber Magic { get; set; }
@@ -75,13 +75,13 @@ namespace SabreTools.Data.Models.COFF
/// <summary>
/// The address that is relative to the image base of the beginning-of-code section when
/// it is loaded into memory.
/// it is loaded into memory.
/// </summary>
public uint BaseOfCode { get; set; }
/// <summary>
/// The address that is relative to the image base of the beginning-of-data section when
/// it is loaded into memory.
/// it is loaded into memory.
/// </summary>
public uint BaseOfData { get; set; }
}

View File

@@ -6,12 +6,12 @@ namespace SabreTools.Data.Models.COFF
/// Object files contain COFF relocations, which specify how the section data
/// should be modified when placed in the image file and subsequently loaded
/// into memory.
///
///
/// Image files do not contain COFF relocations, because all referenced symbols
/// have already been assigned addresses in a flat address space. An image
/// contains relocation information in the form of base relocations in the
/// .reloc section (unless the image has the IMAGE_FILE_RELOCS_STRIPPED attribute).
///
///
/// For each section in an object file, an array of fixed-length records holds
/// the section's COFF relocations. The position and length of the array are
/// specified in the section header.

View File

@@ -101,11 +101,11 @@
/// <summary>
/// COFF Relocations (Object Only)
/// </summary>
public Relocation[]? COFFRelocations { get; set; }
public Relocation[] COFFRelocations { get; set; }
/// <summary>
/// COFF Line Numbers (Deprecated)
/// </summary>
public LineNumber[]? COFFLineNumbers { get; set; }
public LineNumber[] COFFLineNumbers { get; set; }
}
}

View File

@@ -20,6 +20,6 @@
/// Following the size are null-terminated strings that are pointed to by symbols
/// in the COFF symbol table.
/// </summary>
public string[]? Strings { get; set; }
public string[] Strings { get; set; }
}
}

View File

@@ -8,13 +8,13 @@
/// the symbol table for limited but important purposes, such as
/// communicating COMDAT information to the linker. Section names and file
/// names, as well as code and data symbols, are listed in the symbol table.
///
///
/// The location of the symbol table is indicated in the COFF header.
///
///
/// The symbol table is an array of records, each 18 bytes long. Each record
/// is either a standard or auxiliary symbol-table record. A standard record
/// defines a symbol or name.
///
///
/// Auxiliary symbol table records always follow, and apply to, some standard
/// symbol table record. An auxiliary record can have any format that the tools
/// can recognize, but 18 bytes must be allocated for them so that symbol table
@@ -22,7 +22,7 @@
/// recognize auxiliary formats for the following kinds of records: function
/// definitions, function begin and end symbols (.bf and .ef), weak externals,
/// file names, and section definitions.
///
///
/// The traditional COFF design also includes auxiliary-record formats for arrays
/// and structures.Microsoft tools do not use these, but instead place that
/// symbolic information in Visual C++ debug format in the debug sections.

View File

@@ -2,7 +2,7 @@ namespace SabreTools.Data.Models.COFF.SymbolTableEntries
{
/// <summary>
/// Auxiliary Format 1: Function Definitions
///
///
/// A symbol table record marks the beginning of a function definition if it
/// has all of the following: a storage class of EXTERNAL (2), a Type value
/// that indicates it is a function (0x20), and a section number that is
@@ -44,4 +44,4 @@ namespace SabreTools.Data.Models.COFF.SymbolTableEntries
/// </summary>
public ushort Unused { get; set; }
}
}
}

View File

@@ -422,7 +422,7 @@ namespace SabreTools.Serialization.Wrappers
{
builder.AppendLine(" String Table Information:");
builder.AppendLine(" -------------------------");
if (stringTable?.Strings == null || stringTable.Strings.Length == 0)
if (stringTable.Strings.Length == 0)
{
builder.AppendLine(" No string table items");
builder.AppendLine();