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
private const(ubyte)[] _dataprivate size_t _indexprivate ElfStringTable _strtabprivate types.ElfClass _classprivate ElfEndian _endianprivate gelf.SymbolTableEntry _cachedEntryprivate bool _entryCachedMethods
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.Constructors
this(const(ubyte)[] data, size_t index, ElfStringTable strtab,
types.ElfClass elfClass, ElfEndian endianness)Constructor from raw symbol table data.structSymbolRange
Range for iterating over symbols in a symbol table.
Implements the D InputRange interface.
Fields
private const(ubyte)[] _dataprivate size_t _currentIndexprivate size_t _totalSymbolsprivate ElfStringTable _strtabprivate types.ElfClass _classprivate ElfEndian _endianMethods
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, ElfEndian endianness)Constructor from symbol table data.this(const(ubyte)[] data, size_t currentIndex, size_t totalSymbols,
ElfStringTable strtab, types.ElfClass elfClass, ElfEndian endianness)Private constructor for creating saved copies.structElfSymbolTable
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
private const(ubyte)[] _dataprivate ElfStringTable _strtabprivate size_t _numSymbolsprivate types.ElfClass _classprivate ElfEndian _endianprivate size_t _infoMethods
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.structSymbolTableBuilder
Builder for creating ELF symbol tables.
This struct allows incremental construction of a symbol table with automatic ordering (local symbols before global symbols).
Fields
private Record[] _recordsprivate size_t[size_t] _handleToIndexprivate bool _finalizedMethods
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.private
void _ensureFinalized()Finalize the symbol table order (locals before globals) and build the handle-to-index mapping.size_t getIndex(size_t handle)Get the finalized symbol table index for a handle.size_t[size_t] getIndexMap()Get the mapping from stable handles to finalized table indices.ubyte[] build(types.ElfClass cls = types.ElfClass.CLASS64,
ElfEndian endian = ElfEndian.LITTLE)Build the final symbol table byte array.size_t entrySize(types.ElfClass cls = types.ElfClass.CLASS64) const pure nothrow @nogc @safeGet the size of a symbol entry for the given class.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.Nested Templates
RecordFunctions 2
fn
ElfSymbolTable getSymbolTable(ElfFile file)Get the static symbol table (.symtab) from an ELF file.fn
ElfSymbolTable getDynamicSymbolTable(ElfFile file)Get the dynamic symbol table (.dynsym) from an ELF file.