ddn.elf.gelf

GELF (Generic ELF) abstraction layer.

This module provides a unified interface for both ELF32 and ELF64 formats. GELF structures use 64-bit fields to accommodate both formats, following the pattern established by libelf's gelf_* functions.

Types 14

Generic ELF file header.

Uses 64-bit fields to accommodate both ELF32 and ELF64.

Fields
ubyte[EI_NIDENT] e_identELF identification bytes
ushort e_typeObject file type (ElfType)
ushort e_machineArchitecture (ElfMachine)
uint e_versionObject file version (ElfVersion)
ulong e_entryEntry point virtual address (64-bit)
ulong e_phoffProgram header table file offset (64-bit)
ulong e_shoffSection header table file offset (64-bit)
uint e_flagsProcessor-specific flags
ushort e_ehsizeELF header size in bytes
ushort e_phentsizeProgram header table entry size
ushort e_phnumProgram header table entry count
ushort e_shentsizeSection header table entry size
ushort e_shnumSection header table entry count
ushort e_shstrndxSection header string table index
Methods
ElfClass getClass() pure nothrow @nogc @safe constGet the ELF class from identification bytes.
void setClass(ElfClass class_) pure nothrow @nogc @safeSet the ELF class in identification bytes.
ElfData getDataEncoding() pure nothrow @nogc @safe constGet the data encoding from identification bytes.
void setDataEncoding(ElfData data) pure nothrow @nogc @safeSet the data encoding in identification bytes.
ElfVersion getVersion() pure nothrow @nogc @safe constGet the ELF version from identification bytes.
void setVersion(ElfVersion ver) pure nothrow @nogc @safeSet ELF version in identification bytes.
ElfOsAbi getOsAbi() pure nothrow @nogc @safe constGet the OS/ABI from identification bytes.
void setOsAbi(ElfOsAbi osabi) pure nothrow @nogc @safeSet the OS/ABI in identification bytes.
ubyte getAbiVersion() pure nothrow @nogc @safe constGet the ABI version from identification bytes.
void setAbiVersion(ubyte ver) pure nothrow @nogc @safeSet ABI version in identification bytes.
ElfType getType() pure nothrow @nogc @safe constGet the object file type.
void setType(ElfType type) pure nothrow @nogc @safeSet the object file type.
ElfMachine getMachine() pure nothrow @nogc @safe constGet the machine architecture.
void setMachine(ElfMachine machine) pure nothrow @nogc @safeSet the machine architecture.

Alias for backward compatibility.

Generic ELF section header.

Uses 64-bit fields to accommodate both ELF32 and ELF64.

Fields
uint sh_nameSection name (string table index)
uint sh_typeSection type (SectionType)
ulong sh_flagsSection flags (SectionFlags, 64-bit)
ulong sh_addrSection virtual address at execution (64-bit)
ulong sh_offsetSection file offset (64-bit)
ulong sh_sizeSection size in bytes (64-bit)
uint sh_linkLink to another section
uint sh_infoAdditional section information
ulong sh_addralignSection alignment (64-bit)
ulong sh_entsizeEntry size if section holds table (64-bit)
Methods
SectionType getType() pure nothrow @nogc @safe constGet the section type.
void setType(SectionType type) pure nothrow @nogc @safeSet the section type.
SectionFlags getFlags() pure nothrow @nogc @safe constGet the section flags.
void setFlags(SectionFlags flags) pure nothrow @nogc @safeSet the section flags.
bool isAllocatable() pure nothrow @nogc @safe constCheck if this section is allocatable.
bool isWritable() pure nothrow @nogc @safe constCheck if this section is writable.
bool isExecutable() pure nothrow @nogc @safe constCheck if this section is executable.
bool isNoBits() pure nothrow @nogc @safe constCheck if this section is NOBITS.

Alias for backward compatibility.

Generic ELF program header.

Uses 64-bit fields to accommodate both ELF32 and ELF64.

Note

Field order follows ELF64 convention (p_type, p_flags).
Fields
uint p_typeSegment type (SegmentType)
uint p_flagsSegment flags (SegmentFlags)
ulong p_offsetSegment file offset (64-bit)
ulong p_vaddrSegment virtual address (64-bit)
ulong p_paddrSegment physical address (64-bit)
ulong p_fileszSegment size in file (64-bit)
ulong p_memszSegment size in memory (64-bit)
ulong p_alignSegment alignment (64-bit)
Methods
SegmentType getType() pure nothrow @nogc @safe constGet the segment type.
void setType(SegmentType type) pure nothrow @nogc @safeSet the segment type.
SegmentFlags getFlags() pure nothrow @nogc @safe constGet the segment flags.
void setFlags(SegmentFlags flags) pure nothrow @nogc @safeSet the segment flags.
bool isReadable() pure nothrow @nogc @safe constCheck if this segment is readable.
bool isWritable() pure nothrow @nogc @safe constCheck if this segment is writable.
bool isExecutable() pure nothrow @nogc @safe constCheck if this segment is executable.
bool isLoadable() pure nothrow @nogc @safe constCheck if this is a loadable segment.
bool isDynamic() pure nothrow @nogc @safe constCheck if this is a dynamic segment.
bool isInterp() pure nothrow @nogc @safe constCheck if this is an interpreter segment.

Alias for backward compatibility.

Generic ELF symbol table entry.

Uses 64-bit fields to accommodate both ELF32 and ELF64.

Note

Field order follows ELF64 convention for better alignment.
Fields
uint st_nameSymbol name (string table index)
ubyte st_infoSymbol info (st_info)
ubyte st_otherSymbol visibility (st_other)
ushort st_shndxSection index
ulong st_valueSymbol value/address (64-bit)
ulong st_sizeSymbol size (64-bit)
Methods
SymbolBinding getBinding() pure nothrow @nogc @safe constExtract symbol binding from st_info field.
void setBinding(SymbolBinding binding) pure nothrow @nogc @safeSet symbol binding in st_info field.
SymbolType getType() pure nothrow @nogc @safe constExtract symbol type from st_info field.
void setType(SymbolType type) pure nothrow @nogc @safeSet symbol type in st_info field.
SymbolVisibility getVisibility() pure nothrow @nogc @safe constExtract symbol visibility from st_other field.
void setVisibility(SymbolVisibility visibility) pure nothrow @nogc @safeSet symbol visibility in st_other field.
bool isLocal() pure nothrow @nogc @safe constCheck if this is a local symbol.
bool isGlobal() pure nothrow @nogc @safe constCheck if this is a global symbol.
bool isWeak() pure nothrow @nogc @safe constCheck if this is a weak symbol.
bool isFunction() pure nothrow @nogc @safe constCheck if this is a function symbol.
bool isObject() pure nothrow @nogc @safe constCheck if this is an object symbol.
bool isSection() pure nothrow @nogc @safe constCheck if this is a section symbol.
bool isFile() pure nothrow @nogc @safe constCheck if this is a file symbol.
bool isDefined() pure nothrow @nogc @safe constCheck if this symbol is defined.
bool isCommon() pure nothrow @nogc @safe constCheck if this is a common symbol.
bool isAbsolute() pure nothrow @nogc @safe constCheck if this is an absolute symbol.

Alias for backward compatibility.

Generic ELF relocation entry without addend.

Uses 64-bit fields to accommodate both ELF32 and ELF64.

Fields
ulong r_offsetLocation where to apply relocation (64-bit)
ulong r_infoRelocation type and symbol index (64-bit)
Methods
uint getSymbolIndex() pure nothrow @nogc @safe constExtract symbol index from r_info field.
void setSymbolIndex(uint index) pure nothrow @nogc @safeSet symbol index in r_info field.
uint getType() pure nothrow @nogc @safe constExtract relocation type from r_info field.
void setType(uint type) pure nothrow @nogc @safeSet relocation type in r_info field.

Alias for backward compatibility.

Generic ELF relocation entry with addend.

Uses 64-bit fields to accommodate both ELF32 and ELF64.

Fields
ulong r_offsetLocation where to apply relocation (64-bit)
ulong r_infoRelocation type and symbol index (64-bit)
long r_addendAddend (64-bit)
Methods
uint getSymbolIndex() pure nothrow @nogc @safe constExtract symbol index from r_info field.
void setSymbolIndex(uint index) pure nothrow @nogc @safeSet symbol index in r_info field.
uint getType() pure nothrow @nogc @safe constExtract relocation type from r_info field.
void setType(uint type) pure nothrow @nogc @safeSet relocation type in r_info field.
long getAddend() pure nothrow @nogc @safe constGet the addend value.
void setAddend(long addend) pure nothrow @nogc @safeSet the addend value.

Alias for backward compatibility.

Generic ELF dynamic array entry.

Uses 64-bit fields to accommodate both ELF32 and ELF64.

Fields
long d_tagDynamic entry type (DynamicTag) — 64-bit to hold both ELF32 and ELF64 values
Methods
DynamicTag getTag() pure nothrow @nogc @safe constGet the dynamic tag.
void setTag(DynamicTag tag) pure nothrow @nogc @safeSet the dynamic tag.
ulong getValue() pure nothrow @nogc @safe constGet the integer value.
void setValue(ulong val) pure nothrow @nogc @safeSet the integer value.
ulong getPointer() pure nothrow @nogc @safe constGet the pointer value.
void setPointer(ulong ptr) pure nothrow @nogc @safeSet the pointer value.

Alias for backward compatibility.

Functions 28

fnFileHeader toGelf(ref const elf32.FileHeader ehdr32) pure @safeConvert ELF32 file header to GELF file header.
fnFileHeader toGelf(ref const elf64.FileHeader ehdr64) pure @safeConvert ELF64 file header to GELF file header.
fnSectionHeader toGelf(ref const elf32.SectionHeader shdr32) pure @safeConvert ELF32 section header to GELF section header.
fnSectionHeader toGelf(ref const elf64.SectionHeader shdr64) pure @safeConvert ELF64 section header to GELF section header.
fnProgramHeader toGelf(ref const elf32.ProgramHeader phdr32) pure @safeConvert ELF32 program header to GELF program header.
fnProgramHeader toGelf(ref const elf64.ProgramHeader phdr64) pure @safeConvert ELF64 program header to GELF program header.
fnSymbolTableEntry toGelf(ref const elf32.SymbolTableEntry sym32) pure @safeConvert ELF32 symbol to GELF symbol.
fnSymbolTableEntry toGelf(ref const elf64.SymbolTableEntry sym64) pure @safeConvert ELF64 symbol to GELF symbol.
fnRelocation toGelf(ref const elf32.Relocation rel32) pure @safeConvert ELF32 relocation to GELF relocation.
fnRelocation toGelf(ref const elf64.Relocation rel64) pure @safeConvert ELF64 relocation to GELF relocation.
fnRelocationWithAddend toGelf(ref const elf32.RelocationWithAddend rela32) pure @safeConvert ELF32 relocation with addend to GELF relocation with addend.
fnRelocationWithAddend toGelf(ref const elf64.RelocationWithAddend rela64) pure @safeConvert ELF64 relocation with addend to GELF relocation with addend.
fnDynamicEntry toGelf(ref const elf32.DynamicEntry dyn32) pure @safeConvert ELF32 dynamic entry to GELF dynamic entry.
fnDynamicEntry toGelf(ref const elf64.DynamicEntry dyn64) pure @safeConvert ELF64 dynamic entry to GELF dynamic entry.
fnelf32.FileHeader toElf32(ref const FileHeader ghdr) pure @safeConvert GELF file header to ELF32 file header.
fnelf32.SectionHeader toElf32(ref const SectionHeader gshdr) pure @safeConvert GELF section header to ELF32 section header.
fnelf32.ProgramHeader toElf32(ref const ProgramHeader gphdr) pure @safeConvert GELF program header to ELF32 program header.
fnelf32.SymbolTableEntry toElf32(ref const SymbolTableEntry gsym) pure @safeConvert GELF symbol to ELF32 symbol.
fnelf32.Relocation toElf32(ref const Relocation grel) pure @safeConvert GELF relocation to ELF32 relocation.
fnelf32.RelocationWithAddend toElf32(ref const RelocationWithAddend grela) pure @safeConvert GELF relocation with addend to ELF32 relocation with addend.
fnelf32.DynamicEntry toElf32(ref const DynamicEntry gdyn) pure @safeConvert GELF dynamic entry to ELF32 dynamic entry.
fnelf64.FileHeader toElf64(ref const FileHeader ghdr) pure @safeConvert GELF file header to ELF64 file header.
fnelf64.SectionHeader toElf64(ref const SectionHeader gshdr) pure @safeConvert GELF section header to ELF64 section header.
fnelf64.ProgramHeader toElf64(ref const ProgramHeader gphdr) pure @safeConvert GELF program header to ELF64 program header.
fnelf64.SymbolTableEntry toElf64(ref const SymbolTableEntry gsym) pure @safeConvert GELF symbol to ELF64 symbol.
fnelf64.Relocation toElf64(ref const Relocation grel) pure @safeConvert GELF relocation to ELF64 relocation.
fnelf64.RelocationWithAddend toElf64(ref const RelocationWithAddend grela) pure @safeConvert GELF relocation with addend to ELF64 relocation with addend.
fnelf64.DynamicEntry toElf64(ref const DynamicEntry gdyn) pure @safeConvert GELF dynamic entry to ELF64 dynamic entry.