ddn.elf.symtab

ELF symbol table handling functionality.

This module provides utilities for reading, searching, and building ELF symbol tables. Symbol tables contain information about the symbols (functions, variables, etc.) defined in an ELF file.

Types 4

structElfSymbol

Represents a symbol in an ELF file.

This struct provides lazy access to symbol information from a symbol table.

Fields
const(ubyte)[] _data
size_t _index
bool _entryCached
Methods
size_t index() pure nothrow @nogc @safe constGet the symbol's index in the symbol table.
gelf.SymbolTableEntry getEntry()Get the symbol's raw GELF entry.
string getName()Get the symbol's name from the associated string table.
ulong getValue()Get the symbol's value (address or offset).
ulong getSize()Get the symbol's size.
types.SymbolBinding getBinding()Get the symbol's binding (local, global, or weak).
types.SymbolType getType()Get the symbol's type (notype, object, function, etc.).
types.SymbolVisibility getVisibility()Get the symbol's visibility (default, hidden, protected, or internal).
ushort getSection()Get the section index this symbol is associated with.
bool isUndefined()Check if this symbol is undefined (no associated section).
bool isAbsolute()Check if this symbol is absolute (not associated with any section).
bool isCommon()Check if this symbol is a common symbol.
bool isFunction()Check if this symbol is a function.
bool isObject()Check if this symbol is an object (variable, array, etc.).
bool isLocal()Check if this symbol has local binding.
bool isGlobal()Check if this symbol has global binding.
bool isWeak()Check if this symbol has weak binding.
bool opEquals(const ref ElfSymbol other) const
bool opEquals(const ElfSymbol other) const
size_t toHash() const nothrow @nogcCompute a hash of this symbol for use in associative arrays.
bool isEmpty() const
Constructors
this(const(ubyte)[] data, size_t index, ElfStringTable strtab, types.ElfClass elfClass)Constructor from raw symbol table data.

Range for iterating over symbols in a symbol table.

Implements the D InputRange interface.

Fields
const(ubyte)[] _data
size_t _currentIndex
size_t _totalSymbols
Methods
bool empty() pure nothrow @nogc @safe constCheck if the range is empty.
ElfSymbol front()Get the current symbol.
void popFront()Advance to the next symbol.
typeof(this) save()Save the current state of the range.
Constructors
this()Constructor for creating an empty range.
this(const(ubyte)[] data, size_t totalSymbols, ElfStringTable strtab, types.ElfClass elfClass)Constructor from symbol table data.
this(const(ubyte)[] data, size_t currentIndex, size_t totalSymbols, ElfStringTable strtab, types.ElfClass elfClass)Private constructor for creating saved copies.

Represents an ELF symbol table.

This struct provides access to symbols in either the .symtab (static) or .dynsym (dynamic) sections of an ELF file.

Fields
const(ubyte)[] _data
size_t _numSymbols
size_t _info
Methods
size_t numSymbols() pure nothrow @nogc @safe constGet the number of symbols in the table.
ElfSymbol getSymbol(size_t index)Get a symbol by its index.
ElfSymbol findSymbolByName(string name)Find a symbol by its name.
ElfSymbol findSymbolByAddress(ulong addr)Find a symbol containing the given address.
SymbolRange symbols()Iterate over all symbols.
SymbolRange localSymbols()Iterate over local symbols.
SymbolRange globalSymbols()Iterate over global and weak symbols.
const(ElfStringTable) getStringTable() ref const return @safeGet the associated string table.
Constructors
this(ElfFile file, size_t sectionIndex)Constructor from an ELF section index.

Builder for creating ELF symbol tables.

This struct allows incremental construction of a symbol table with automatic ordering (local symbols before global symbols).

Fields
Methods
size_t addSymbol(uint name, ulong value, ulong size, types.SymbolBinding binding, types.SymbolType type, ushort section, types.SymbolVisibility visibility = types.SymbolVisibility.DEFAULT)Add a symbol to the symbol table.
ubyte[] build()Build the final symbol table byte array.
size_t count() pure nothrow @nogc @safe constGet the number of symbols in the table.
void clear(gelf.SymbolTableEntry initialEntry)Clear all symbols from the builder.
Constructors
this(gelf.SymbolTableEntry initialEntry)Default constructor - creates an empty builder with initial entry.

Functions 2

fnElfSymbolTable getSymbolTable(ElfFile file)Get the static symbol table (.symtab) from an ELF file.
fnElfSymbolTable getDynamicSymbolTable(ElfFile file)Get the dynamic symbol table (.dynsym) from an ELF file.