because it cannot create valid ElfSegment instances without access to the ElfFile. Use getSegmentByIndex() instead.
ddn.elf.segments
ELF program header (segment) handling functionality.
This module provides utilities for reading and manipulating ELF program headers (segments). Segments contain information about how the program is loaded into memory.
Types 4
structElfSegment
Represents an ELF segment (program header).
This struct provides lazy access to segment information.
Fields
ElfFile _filesize_t _indexgelf.ProgramHeader _headerbool _headerLoadedconst(ubyte)[] _databool _dataLoadedMethods
void _loadHeader()Load the program header from the ELF file.void _loadData()Load the segment data from the ELF file.gelf.ProgramHeader getHeader()Get the program header for this segment.types.SegmentType getType()Get the segment type.types.SegmentFlags getFlags()Get the segment flags.const(ubyte)[] getData()Get the segment data from the file.ulong getFileOffset()Get the segment's file offset.ulong getVirtualAddress()Get the segment's virtual address.ulong getPhysicalAddress()Get the segment's physical address.ulong getFileSize()Get the segment's size in the file.ulong getMemorySize()Get the segment's size in memory.ulong getAlignment()Get the segment's alignment.bool isLoadable()Check if this segment is loadable (PT_LOAD).bool isDynamic()Check if this segment contains dynamic linking information.bool isInterpreter()Check if this segment contains the interpreter path.bool isReadable()Check if this segment is readable.bool isWritable()Check if this segment is writable.bool isExecutable()Check if this segment is executable.structSegmentTypeRange
Range for iterating over segments of a specific type.
Note
This range does not implement full InputRange interface
Fields
types.SegmentType _typegelf.ProgramHeader[] _headerssize_t[] _originalIndicessize_t _currentIndexElfFile _fileMethods
ElfSegment front()Get the current segment.void popFront()Advances to the next segment of the target type.typeof(this) save()Saves the current state of the range.Constructors
this(types.SegmentType type, gelf.ProgramHeader[] headers,
size_t[] originalIndices, size_t currentIndex, ElfFile file)Constructor for creating a saved copy of the range.this(ElfFile file, types.SegmentType type)Constructor for creating a range that filters segments by type.structSegmentRange
Range for iterating over all segments.
Note
This range does not implement full InputRange interface
because it cannot create valid ElfSegment instances without access to the ElfFile. Use getSegmentByIndex() instead.
Methods
typeof(this) save()Save the current state of the range.ElfSegment front()Get the current segment.void popFront()Advance to the next segment.structProgramHeaderBuilder
Builder for creating ELF program headers (segments).
This struct allows incremental construction of a program header table.
Fields
gelf.ProgramHeader[] _segmentsMethods
ProgramHeaderBuilder create()Create a new empty program header builder.size_t addSegment(types.SegmentType type, types.SegmentFlags flags,
ulong offset, ulong vaddr, ulong paddr,
ulong fileSize, ulong memSize, ulong alignment)Add a segment to the program header table.gelf.ProgramHeader getSegment(size_t index)Get a segment by index.ubyte[] build()Build the final program header table byte array.void clear()Clear all segments from the builder.Constructors
this(gelf.ProgramHeader[] segments)Private constructor with segment array.Functions 6
fn
SegmentTypeRange getSegmentsByType(ElfFile file, types.SegmentType type)Get a range for iterating over segments of a specific type.fn
SegmentTypeRange getLoadableSegments(ElfFile file)Get a range for iterating over loadable segments (PT_LOAD).fn
SegmentTypeRange getSegmentsContainingSection(ElfFile file, ElfSection section)Get segments that contain a specific section.