ddn.elf.errors

ddn.elf.errors - ELF Error Handling and Validation Module

This module provides comprehensive error handling and validation for ELF files, including specialized exception types and validation functions at multiple levels.

Example:

try
{
  ElfFile file = ElfFile(data);
  validateElf(file, ValidationLevel.STANDARD);
}
catch (ElfValidationException e)
{
  writeln("Validation error: ", e.msg);
}

Types 6

Validation levels for ELF files.

Different levels provide different levels of strictness when validating ELF file structure.

MINIMALMinimal validation - only basic format checks.
STANDARDStandard validation - most common checks.
STRICTStrict validation - thorough checks.
PARANOIDParanoid validation - exhaustive checks.
classElfException : Exception

Base exception class for all ELF-related errors.

All other ELF exceptions inherit from this class, allowing callers to catch all ELF errors with a single catch block.

Constructors
this(string msg)Constructor with error message.
this(string msg, string file)Constructor with error message and file path.

Exception raised when ELF file format is invalid.

This is raised when file does not conform to ELF specification, such as invalid magic numbers, unknown class, or corrupted structures.

Constructors
this(string msg)Constructor with error message.
this(string msg, size_t offset)Constructor with error message and offset information.

Exception raised when ELF file validation fails.

This is raised when the file format is technically valid but fails additional consistency or logical checks.

Constructors
this(string msg)Constructor with error message.
this(string msg, ValidationLevel level)Constructor with error message and validation level.

Exception raised for I/O errors when reading/writing ELF files.

This is raised when file operations fail, such as file not found, permission denied, or read/write errors.

Constructors
this(string msg)Constructor with error message.
this(string msg, string operation)Constructor with error message and operation.

Exception raised when accessing data out of bounds.

This is raised when an attempt is made to access data beyond the bounds of the file or a section.

Constructors
this(string msg)Constructor with error message.
this(string msg, size_t index, size_t maxIndex)Constructor with error message and range information.

Functions 4

fnvoid validateElfHeader(const ref gelf.FileHeader ehdr, ValidationLevel level = ValidationLevel.STANDARD)Validate an ELF file header.
fnvoid validateSectionHeaders(ElfFile file, ValidationLevel level = ValidationLevel.STANDARD)Validate section headers.
fnvoid validateProgramHeaders(ElfFile file, ValidationLevel level = ValidationLevel.STANDARD)Validate program headers.
fnbool validateElf(ElfFile file, ValidationLevel level = ValidationLevel.STANDARD)Comprehensively validate an ELF file.