ddn.elf

ddn.elf - High-Level ELF Library Package

This module provides a high-level, user-friendly API for working with ELF files. It re-exports commonly used types and provides convenience functions for common tasks.

Example:

// Read an ELF file
auto file = openElf("my_program.elf");

// Get file information
auto info = getElfInfo("my_program.elf");
writeln("Class: ", info.class_);
writeln("Machine: ", info.machine);

// List symbols
foreach (sym; listSymbols(file))
{
  writeln(sym.name, " @ ", sym.address);
}

Types 3

structElfInfo

Summary information about an ELF file.

Fields
ElfClass class_ELF class (32-bit or 64-bit)
ElfData endianEndianness (little or big)
ElfType typeFile type (relocatable, executable, shared object, etc.)
ElfMachine machineMachine architecture
ulong entryEntry point address
uint sectionCountNumber of sections
uint segmentCountNumber of program headers (segments)
size_t fileSizeFile size in bytes
Methods
string toString() const

A symbol with additional display information.

Fields
ElfSymbol symbolThe symbol
string nameThe symbol name
ulong addressThe symbol value (address)
ulong sizeThe symbol size
SymbolBinding bindingThe symbol binding
SymbolType typeThe symbol type

A section with additional display information.

Fields
uint indexThe section index
string nameThe section name
SectionType typeThe section type
SectionFlags flagsThe section flags
ulong addressThe section address
ulong sizeThe section size
const(ubyte)[] dataThe section data

Functions 13

fnElfFile openElf(string path)Open an ELF file from disk.
fnElfFile openElf(const(ubyte)[] data)Open an ELF file from a byte array.
fnElfBuilder createElf(ElfClass class_, ElfEndian endian)Create a new ELF file builder.
fnElfEditor editElf(string path)Edit an existing ELF file.
fnbool isElf(string path)Check if a file is a valid ELF file.
fnElfInfo getElfInfo(string path)Get summary information about an ELF file.
fnauto listSymbols(ElfFile file)List all symbols in an ELF file.
fnauto listSections(ElfFile file)List all sections in an ELF file.
fnstring[] listDependencies(ElfFile file)List the dynamic dependencies (needed libraries) of an ELF file.
fnstring getInterpreter(ElfFile file)Get the interpreter path from an ELF file.
fnstring dumpHeader(ElfFile file)Dump the ELF file header as a formatted string.
fnstring dumpSections(ElfFile file)Dump section headers as a formatted string.
fnstring dumpSymbols(ElfFile file)Dump symbols as a formatted string.