ddn.elf.reloc
ELF relocation handling functionality.
This module provides utilities for reading, searching, and building ELF relocation entries. Relocations describe how to modify the code and data when linking or loading an ELF file.
Types 4
structElfRelocation
Represents a relocation entry in an ELF file.
This struct provides unified access to both REL (without addend) and RELA (with addend) relocation formats.
Methods
bool hasAddend() pure nothrow @nogc @safe constCheck if this relocation has an addend (RELA format).ulong getOffset()Get the offset where the relocation should be applied.uint getSymbol()Get the symbol table index this relocation refers to.uint getType()Get the relocation type.long getAddend()Get the addend value (only for RELA entries).bool isUndefined()Check if this is an undefined symbol relocation.Constructors
this(const(ubyte)[] data, size_t index, bool hasAddend,
types.ElfClass elfClass)Constructor from raw relocation table data.structRelocationRange
Range for iterating over relocations in a relocation table.
Implements the D InputRange interface.
Fields
const(ubyte)[] _datasize_t _currentIndexsize_t _totalRelocationsbool _hasAddendtypes.ElfClass _classMethods
ElfRelocation front()Get the current relocation.void popFront()Advance to the next relocation.typeof(this) save()Save the current state of the range.Constructors
this()Default constructor for creating an empty range.this(const(ubyte)[] data, size_t totalRelocations, bool hasAddend,
types.ElfClass elfClass)Constructor from relocation table data.this(const(ubyte)[] data, size_t currentIndex, size_t totalRelocations,
bool hasAddend, types.ElfClass elfClass)Private constructor for creating saved copies.structElfRelocationTable
Represents an ELF relocation table (.rel or .rela section).
This struct provides access to relocations that modify code and data when linking or loading an ELF file.
Fields
const(ubyte)[] _datasize_t _numRelocationsbool _hasAddendtypes.ElfClass _classsize_t _appliesToSectionMethods
ElfRelocation getRelocation(size_t index)Get a relocation by its index.RelocationRange relocations()Iterate over all relocations.RelocationRange getRelocationsForSection(size_t sectionIndex)Get relocations that apply to a specific section.structRelocationTableBuilder
Builder for creating ELF relocation tables.
This struct allows incremental construction of a relocation table.
Methods
RelocationTableBuilder create()Create a new empty relocation table builder.size_t addRelRelocation(ulong offset, uint symbolIndex, uint type)Add a REL relocation (without addend).size_t addRelaRelocation(ulong offset, uint symbolIndex, uint type, long addend)Add a RELA relocation (with addend).ubyte[] buildRel()Build the REL relocation table byte array.ubyte[] buildRela()Build the RELA relocation table byte array.void clear()Clear all relocations from the builder.Constructors
this(gelf.Relocation[] relEntries, gelf.RelocationWithAddend[] relaEntries)Private constructor with entry arrays.Functions 1
fn
ElfRelocationTable getRelocationTableByName(ElfFile file, string name)Get a relocation table by section name from an ELF file.