ddn.elf.types

ELF type definitions and constants.

This module provides all core ELF (Executable and Linkable Format) type definitions and constants as specified by the ELF specification. All enumerations follow the UPPER_CASE naming convention for their fields.

Types 16

enumElfClass : ubyte

ELF file class (32-bit or 64-bit).

NONE = 0No class (invalid)
CLASS32 = 132-bit ELF file
CLASS64 = 264-bit ELF file
enumElfData : ubyte

ELF data encoding (endianness).

NONE = 0Invalid data encoding
LSB = 12's complement, little endian
MSB = 22's complement, big endian
enumElfVersion : ubyte

ELF file version.

NONE = 0Invalid version
CURRENT = 1Current ELF version (1)
enumElfOsAbi : ubyte

Operating system and ABI identification.

NONE = 0No extensions or unspecified
HPUX = 1Hewlett-Packard HP-UX
NETBSD = 2NetBSD
LINUX = 3GNU/Linux
HURD = 4GNU Hurd
SOLARIS = 6Sun Solaris
AIX = 7AIX
IRIX = 8IRIX
FREEBSD = 9FreeBSD
TRU64 = 10Tru64 UNIX
MODESTO = 11Novell Modesto
OPENBSD = 12OpenBSD
OPENVMS = 13Open VMS
NSK = 14Hewlett-Packard Non-Stop UX
AROS = 15Amiga Research OS
FENIXOS = 16Fenix OS
CLOUDABI = 17CloudABI
OPENVOS = 18Stratus Technologies OpenVOS
enumElfType : ushort

ELF object file type.

NONE = 0No file type (invalid)
REL = 1Relocatable object file
EXEC = 2Executable file
DYN = 3Shared object file
CORE = 4Core dump file
LOPROC = 0xff00Processor-specific value
HIPROC = 0xffffProcessor-specific value
enumElfMachine : ushort

ELF machine (architecture) type.

NONE = 0No machine
M32 = 1AT&T WE 32100
SPARC = 2SUN SPARC
I386 = 3Intel 80386
M68K = 4Motorola m68k family
M88K = 5Motorola m88k family
IAMCU = 6Intel MCU
I860 = 7Intel 80860
MIPS = 8MIPS I Architecture
S370 = 9IBM System/370
RS3000 = 10MIPS RS3000 Little-endian
PARISC = 15Hewlett-Packard PA-RISC
VPP500 = 17Fujitsu VPP500
SPARC32PLUS = 18Enhanced instruction set SPARC
I960 = 19Intel 80960
PPC = 20PowerPC
PPC64 = 21PowerPC 64-bit
S390 = 22IBM System/390
SPU = 23IBM SPU/SPU
V800 = 36NEC V800 series
FR20 = 37Fujitsu FR20
RH32 = 38TRW RH-32
RCE = 39Motorola RCE
ARM = 40ARM 32-bit architecture (AARCH32)
ALPHA = 0x9026Digital Alpha (old identifier 41 is deprecated in favour of this value)
SH = 42Hitachi SH
SPARCV9 = 43SPARC-V9 64-bit
TRICORE = 44Siemens TriCore embedded processor
ARC = 45Argonaut RISC Core, Argonaut Technologies Ltd.
H8_300 = 46Hitachi H8/300
H8_300H = 47Hitachi H8/300H
H8S = 48Hitachi H8S
H8_500 = 49Hitachi H8/500
IA_64 = 50Intel Merced Processor
MIPS_X = 51Stanford MIPS-X
COLDFIRE = 52Motorola ColdFire
M68HC12 = 53Motorola M68HC12
MMA = 54Fujitsu MMA Multimedia Accelerator
PCP = 55Siemens PCP
NCPU = 56Sony nCPU embedded RISC
NDR1 = 57Denso NDR1 microprocessor
STARCORE = 58Motorola Star*Core processor
ME16 = 59Toyota ME16 processor
ST100 = 60STMicroelectronics ST100 processor
TINYJ = 61Advanced Logic Corp. TinyJ embedded processor family
X86_64 = 62AMD x86-64 architecture
DSP = 63Sony DSP Processor
PDP10 = 64Digital Equipment Corp. PDP-10
PDP11 = 65Digital Equipment Corp. PDP-11
FX66 = 66Siemens FX66 microcontroller
ST9PLUS = 67STMicroelectronics ST9+ 8/16 bit microcontroller
ST7 = 68STMicroelectronics ST7 8-bit microcontroller
MC68HC16 = 69Motorola MC68HC16 Microcontroller
MC68HC11 = 70Motorola MC68HC11 Microcontroller
MC68HC08 = 71Motorola MC68HC08 Microcontroller
MC68HC05 = 72Motorola MC68HC05 Microcontroller
SVX = 73Silicon Graphics SVx
ST19 = 74STMicroelectronics ST19 8-bit microcontroller
VAX = 75Digital VAX
CRIS = 76Axis Communications 32-bit embedded processor
JAVELIN = 77Infineon Technologies 32-bit embedded processor
FIREPATH = 78Element 14 64-bit DSP Processor
ZSP = 79LSI Logic 16-bit DSP Processor
MMIX = 80Donald Knuth's educational 64-bit processor
HUANY = 81Harvard University machine-independent object format
PRISM = 82SiTera Prism
AVR = 83Atmel AVR 8-bit microcontroller
FR30 = 84Fujitsu FR30
D10V = 85D10V
D30V = 86D30V
V850 = 87NEC v850
M32R = 88Mitsubishi M32R
MN10300 = 89Matsushita MN10300
MN10200 = 90Matsushita MN10200
PICOJAVA = 91picoJava
OPENRISC = 92OpenRISC 32-bit embedded processor
ARC_COMPACT = 93ARC International ARCompact processor
XTENSA = 94Tensilica Xtensa Architecture
VIDEOCORE = 95Alphamosaic VideoCore processor
TMM_GPP = 96Thompson Multimedia General Purpose Processor
NS32K = 97National Semiconductor 32000 series
TPC = 98Tenor Network TPC processor
SNP1K = 99Trebia SNP 1000 processor
ST200 = 100STMicroelectronics ST200
IP2K = 101Ubicom IP2022 micro controller
MAX = 102MAX Processor
COMPACTRISC = 103National Semiconductor CompactRISC microprocessor
F2MC16 = 104Fujitsu F2MC16
MSP430 = 105Texas Instruments MSP430 microcontroller
BLACKFIN = 106Analog Devices Blackfin (DSP) processor
SE_C33 = 107S1C33 Family of Seiko Epson processors
SEP = 108Sharp embedded microprocessor
ARCA = 109Arca RISC Microprocessor
UNICORE = 110Microprocessor series from PKU-Unity Ltd. and MPRC of Peking University
EXCESS = 111eXcess: 64-bit RISC CPU from S&S Labs
AVR32 = 185Atmel Corporation 32-bit microprocessor family
OPEN8 = 196Open8 RISC
NIOS2 = 113Altera Nios II soft-core processor
SE_C17 = 139Seiko Epson C17 family
TI_C6000 = 140Texas Instruments TMS320C6000 DSP family
TI_C2000 = 141Texas Instruments TMS320C2000 DSP family
TI_C5500 = 142Texas Instruments TMS320C55x DSP family
RISCV = 243RISC-V
RX = 173Renesas RX family
METAG = 174Imagination Technologies META processor architecture
MCST_ELBRUS = 175MCST Elbrus general purpose architecture
AARCH64 = 183AArch64 (ARM 64-bit)
LOONGARCH = 258LoongArch
enumSectionType : uint

ELF section header types.

NULL = 0Inactive section
PROGBITS = 1Program-defined contents
SYMTAB = 2Symbol table
STRTAB = 3String table
RELA = 4Relocation entries with explicit addends
HASH = 5Symbol hash table
DYNAMIC = 6Dynamic linking information
NOTE = 7Note section
NOBITS = 8Program space with no data (bss)
REL = 9Relocation entries without addends
SHLIB = 10Reserved
DYNSYM = 11Dynamic symbol table
INIT_ARRAY = 14Array of constructors
FINI_ARRAY = 15Array of destructors
PREINIT_ARRAY = 16Array of pre-constructors
GROUP = 17Section group
SYMTAB_SHNDX = 18Extended section index
GNU_ATTRIBUTES = 0x6ffffff5OS-specific
GNU_HASH = 0x6ffffff6GNU object-specific
GNU_LIBLIST = 0x6ffffff7GNU version definitions
CHECKSUM = 0x6ffffff8Object section data check
SUNW_MOVE = 0x6ffffffaSUN compatibility versioning
SUNW_COMDAT = 0x6ffffffbSUN compatibility versioning
SUNW_SYMINFO = 0x6ffffffcSUN debug info
GNU_VERDEF = 0x6ffffffdGNU version symbol table
GNU_VERNEED = 0x6ffffffeGNU version needs
GNU_VERSYM = 0x6fffffffGNU version symbol table
LOOS = 0x60000000OS-specific range start
LOPROC = 0x70000000Processor-specific range start
HIPROC = 0x7fffffffProcessor-specific range end
LOSTART = 0xff00Reserved value
HIEND = 0xffffReserved value
enumSectionFlags : ulong

ELF section header flags.

These flags can be bitwise OR'd together.

NONE = 0x0Unused
WRITE = 0x1Writable
ALLOC = 0x2Occupies memory during execution
EXECINSTR = 0x4Executable
MERGE = 0x10Might be merged
STRINGS = 0x20Contains nul-terminated strings
INFO_LINK = 0x40`sh_info' holds SHT index
LINK_ORDER = 0x80Preserve order for combining sections
OS_NONCONFORMING = 0x100Non-standard OS specific handling required
GROUP = 0x200Section is member of a group
TLS = 0x400Section holds thread-local storage
MASKOS = 0x0ff00000OS-specific (mask is for ELF32; ELF64 uses a wider range)
MASKPROC = 0xf0000000Processor-specific (mask is for ELF32; ELF64 uses a wider range)
enumSegmentType : uint

ELF program header types (segment types).

NULL = 0Unused entry
LOAD = 1Loadable segment
DYNAMIC = 2Dynamic linking information
INTERP = 3Interpreter program path
NOTE = 4Auxiliary information
SHLIB = 5Reserved
PHDR = 6Segment containing program header table
TLS = 7Thread-local storage template
GNU_STACK = 0x6474e551GNU stack segment (indicates stack executability)
GNU_RELRO = 0x6474e552GNU read-only after relocation segment
GNU_PROPERTY = 0x6474e553GNU property segment
GNU_EH_FRAME = 0x6474e550GNU exception handling frame segment
LOPROC = 0x70000000Processor-specific range start
HIPROC = 0x7fffffffProcessor-specific range end
LOOS = 0x60000000OS-specific range start
HIOS = 0x6fffffffOS-specific range end
enumSegmentFlags : uint

ELF program header segment flags.

These flags can be bitwise OR'd together.

X = 0x1Segment is executable
W = 0x2Segment is writable
R = 0x4Segment is readable
NONE = 0x0Unused flag
MASKOS = 0x0ff00000OS-specific
MASKPROC = 0xf0000000Processor-specific
enumSymbolBinding : ubyte

ELF symbol binding.

The binding is encoded in the st_info field as the upper 4 bits.

LOCAL = 0Local symbol
GLOBAL = 1Global symbol
WEAK = 2Weak symbol
NUM = 3Number of defined types.
LOOS = 10Start of OS-specific
UNIQUE = 10Unique symbol
HIOS = 12End of OS-specific
LOPROC = 13Start of processor-specific
HIPROC = 15End of processor-specific
enumSymbolType : ubyte

ELF symbol types.

The type is encoded in the st_info field as the lower 4 bits.

NOTYPE = 0No type specified
OBJECT = 1Object (variable, array, etc.)
FUNC = 2Function
SECTION = 3Section
FILE = 4File name
COMMON = 5Common object
TLS = 6Thread-local data object
NUM = 7Number of defined types
LOOS = 10Start of OS-specific
HIOS = 12End of OS-specific
LOPROC = 13Start of processor-specific
HIPROC = 15End of processor-specific
enumSymbolVisibility : ubyte

ELF symbol visibility.

Visibility is encoded in the st_other field. The values follow the ELF ABI (STV_DEFAULT, STV_INTERNAL, STV_HIDDEN, STV_PROTECTED).

DEFAULT = 0Default visibility
INTERNAL = 1Processor specific hidden class
HIDDEN = 2Sym unavailable in other modules
PROTECTED = 3Not preemptible, not exported
enumSpecialSectionIndex : ushort

Special section indices.

Values follow the ELF ABI (SHN_* constants). Note that SHN_LOPROC and SHN_LORESERVE share the value 0xff00, and SHN_XINDEX and SHN_HIRESERVE share the value 0xffff.

UNDEF = 0Undefined section index
LORESERVE = 0xff00Start of reserved indices and of processor-specific indices
LOPROC = 0xff00Start of processor-specific
HIPROC = 0xff1fEnd of processor-specific
LOOS = 0xff20Start of OS-specific
HIOS = 0xff3fEnd of OS-specific
ABS = 0xfff1Absolute symbol value
COMMON = 0xfff2Common symbol
XINDEX = 0xffffIndex is an escape value: real index is in the extra table
HIRESERVE = 0xffffEnd of reserved indices
enumDynamicTag : uint

ELF dynamic array tags.

NULL = 0End of dynamic array
NEEDED = 1Name of needed library
PLTRELSZ = 2Size in bytes of PLT entries
PLTGOT = 3Processor-dependent value
HASH = 4Address of symbol hash table
STRTAB = 5Address of string table
SYMTAB = 6Address of symbol table
RELA = 7Address of Rela relocation entries
RELASZ = 8Total size of Rela entries
RELAENT = 9Size of one Rela entry
STRSZ = 10Size of string table
SYMENT = 11Size of one symbol table entry
INIT = 12Address of initialization function
FINI = 13Address of termination function
SONAME = 14Name of shared object
RPATH = 15Library search path (deprecated)
SYMBOLIC = 16Start of symbol search range
REL = 17Address of Rel entries
RELSZ = 18Total size of Rel entries
RELENT = 19Size of one Rel entry
PLTREL = 20Type of relocation table entries
DEBUG = 21Debugging (unused)
TEXTREL = 22Relocation may modify text
JMPREL = 23Address of jump table
BIND_NOW = 24Process-dependent
INIT_ARRAY = 25Array with addresses of init functions
FINI_ARRAY = 26Array with addresses of fini functions
INIT_ARRAYSZ = 27Size of INIT_ARRAY
FINI_ARRAYSZ = 28Size of FINI_ARRAY
RUNPATH = 29Run-time search path
FLAGS = 30Flags for dynamic loading
PREINIT_ARRAY = 32Array with addresses of preinit functions
PREINIT_ARRAYSZ = 33Size in bytes of PREINIT_ARRAY
SYMTAB_SHNDX = 34Address of SYMTAB_SHNDX section
RELRSZ = 35Total size of RELR relative relocations
RELR = 36Address of RELR relative relocations
RELRENT = 37Size of one RELR relative relocation
GNU_HASH = 0x6ffffef5GNU hash table
GNU_VERSYM = 0x6ffffff0GNU version symbol table
GNU_VERNEED = 0x6ffffffeGNU version requirements
GNU_VERNEEDNUM = 0x6fffffffGNU version requirements count
GNU_VERDEF = 0x6ffffffcGNU version definitions
GNU_VERDEFNUM = 0x6ffffffdGNU version definitions count
RELACOUNT = 0x6ffffff9Relative relocation count
RELCOUNT = 0x6ffffffaRelative relocation count
FLAGS_1 = 0x6ffffffbState flags, see DF_1_*
GNU_PRELINKED = 0x6ffffdf5GNU prelink timestamp
GNU_CONFLICTSZ = 0x6ffffdf6GNU conflict relocations size
GNU_LIBLISTSZ = 0x6ffffdf7GNU library list size
CHECKSUM = 0x6ffffdf8Checksum of dynamic contents
GNU_CONFLICT = 0x6ffffef8GNU conflict relocations
GNU_LIBLIST = 0x6ffffef9GNU library list
AUXILIARY = 0x7ffffffdShared object to load before self
FILTER = 0x7fffffffShared object to get values from
LOOS = 0x6000000dOS-specific range start
HIOS = 0x6ffff000OS-specific range end
LOPROC = 0x70000000Processor-specific range start
HIPROC = 0x7fffffffProcessor-specific range end
enumDynamicFlags : uint

Dynamic section flags (DF_*).

These flags appear in the d_val field of a DT_FLAGS dynamic entry.

ORIGIN = 0x00000001Object may use DF_ORIGIN
SYMBOLIC = 0x00000002Symbol resolution starts here
TEXTREL = 0x00000004Object contains text relocations
BIND_NOW = 0x00000008No lazy binding for this object
STATIC_TLS = 0x00000010Module uses the static TLS model

Functions 19

fnubyte[4] elfMagic() pure nothrow @nogc @safeGet the ELF magic number as a byte array.
fnbool isElfMagic(const(ubyte)[] data) pure nothrow @nogc @safeCheck if data starts with ELF magic number.
fnubyte makeStInfo(SymbolBinding binding, SymbolType type) pure nothrow @nogc @safeEncode symbol binding and type into st_info field.
fnSymbolBinding getStBinding(ubyte info) pure nothrow @nogc @safeExtract symbol binding from st_info field.
fnSymbolType getStType(ubyte info) pure nothrow @nogc @safeExtract symbol type from st_info field.
fnubyte makeStOther(SymbolVisibility visibility) pure nothrow @nogc @safeEncode symbol visibility into st_other field.
fnSymbolVisibility getStVisibility(ubyte other) pure nothrow @nogc @safeExtract symbol visibility from st_other field.
fnbool isOsSpecificSection(SectionType type) pure nothrow @nogc @safeCheck if a section type is a valid OS-specific value.
fnbool isProcSpecificSection(SectionType type) pure nothrow @nogc @safeCheck if a section type is a valid processor-specific value.
fnbool isOsSpecificSegment(SegmentType type) pure nothrow @nogc @safeCheck if a segment type is a valid OS-specific value.
fnbool isProcSpecificSegment(SegmentType type) pure nothrow @nogc @safeCheck if a segment type is a valid processor-specific value.
fnbool isValidSymbolBinding(SymbolBinding binding) pure nothrow @nogc @safeCheck if a symbol binding is valid.
fnbool isValidSymbolType(SymbolType type) pure nothrow @nogc @safeCheck if a symbol type is valid.
fnbool isValidDynamicTag(DynamicTag tag) pure nothrow @nogc @safeCheck if a dynamic tag is valid.
fnstring getMachineName(ElfMachine machine) pure @safeGet the name of an ELF machine architecture.
fnstring getSectionTypeName(SectionType type) pure @safeGet the name of an ELF section type.
fnstring getSegmentTypeName(SegmentType type) pure @safeGet the name of an ELF segment type.
fnstring getElfTypeName(ElfType type) pure @safeGet the name of an ELF file type.
fnstring getElfClassName(ElfClass class_) pure @safeGet the name of an ELF class.

Variables 16

enumvarEI_MAG0 = 0

ELF identification array indices.

These indices correspond to positions in the e_ident array of the ELF header. File identification byte 0 (0x7F).

enumvarEI_MAG1 = 1

File identification byte 1 ('E').

enumvarEI_MAG2 = 2

File identification byte 2 ('L').

enumvarEI_MAG3 = 3

File identification byte 3 ('F').

enumvarEI_CLASS = 4

File class (32-bit or 64-bit).

enumvarEI_DATA = 5

Data encoding (little or big endian).

enumvarEI_VERSION = 6

File version.

enumvarEI_OSABI = 7

Operating system/ABI identification.

enumvarEI_ABIVERSION = 8

ABI version.

enumvarEI_PAD = 9

Start of padding bytes.

enumvarEI_NIDENT = 16

Size of e_ident array.

enumvarELFMAG0 = 0x7f

ELF magic number bytes.

These form the string "\x7fELF" which identifies an ELF file. Magic byte 0 (0x7F).

enumvarELFMAG1 = 'E'

Magic byte 1 ('E').

enumvarELFMAG2 = 'L'

Magic byte 2 ('L').

enumvarELFMAG3 = 'F'

Magic byte 3 ('F').

enumvarPN_XNUM = 0xffff

Escape value for e_phnum: the real program header count is stored in the sh_info field of section header zero.