format::elf+x86_64 +linux

An implementation of the ELF64 file format. Best accompanied with a reading of the ELF-64 Object Format (Version 1.5).

Index

Types

type at = enum u64 {
	NULL = 0, // End of vector
	IGNORE = 1, // Entry should be ignored
	EXECFD = 2, // File descriptor of program
	PHDR = 3, // Program headers for program
	PHENT = 4, // Size of program header entry
	PHNUM = 5, // Number of program headers
	PAGESZ = 6, // System page size
	BASE = 7, // Base address of interpreter
	FLAGS = 8, // Flags
	ENTRY = 9, // Entry point of program
	NOTELF = 10, // Program is not ELF
	UID = 11, // Real uid
	EUID = 12, // Effective uid
	GID = 13, // Real gid
	EGID = 14, // Effective gid
	CLKTCK = 17, // Frequency of times()
	PLATFORM = 15, // String identifying platform.
	HWCAP = 16, // Machine-dependent hints about processor capabilities.
	FPUCW = 18, // Used FPU control word.
	DCACHEBSIZE = 19, // Data cache block size.
	ICACHEBSIZE = 20, // Instruction cache block size.
	UCACHEBSIZE = 21, // Unified cache block size.
	// A special ignored value for PPC, used by the kernel to control the
	// interpretation of the AUXV. Must be > 16.
	// Entry should be ignored.
	IGNOREPPC = 22,
	SECURE = 23, // Boolean, was exec setuid-like?
	BASE_PLATFORM = 24, // String identifying real platforms.
	RANDOM = 25, // Address of 16 random bytes.
	HWCAP2 = 26, // More machine-dependent hints about processor capabilities.
	EXECFN = 31, // Filename of executable.
	// Pointer to the global system page used for system calls and other
	// nice things.
	SYSINFO = 32,
	SYSINFO_EHDR = 33,
	// Shapes of the caches.  Bits 0-3 contains associativity, bits 4-7 contains
	// log2 of line size, mask those to get cache size.
	L1I_CACHESHAPE = 34,
	L1D_CACHESHAPE = 35,
	L2_CACHESHAPE = 36,
	L3_CACHESHAPE = 37,
	// Shapes of the caches, with more room to describe them.
	// *GEOMETRY are comprised of cache line size in bytes in the bottom 16 bits
	// and the cache associativity in the next 16 bits.
	L1I_CACHESIZE = 40,
	L1I_CACHEGEOMETRY = 41,
	L1D_CACHESIZE = 42,
	L1D_CACHEGEOMETRY = 43,
	L2_CACHESIZE = 44,
	L2_CACHEGEOMETRY = 45,
	L3_CACHESIZE = 46,
	L3_CACHEGEOMETRY = 47,
	MINSIGSTKSZ = 51, // Stack needed for signal delivery (AArch64).
};
type auxv64 = struct {
	// Entry type
	a_type: at,
	union {
		// Integer value
		a_val: u64,
		a_ptr: *opaque,
		a_fnc: *fn() void,
	},
};
type dt = enum i64 {
	NULL = 0, // Marks the end of the dynamic array.
	NEEDED = 1, // The string table offset of the name of a needed library.
	// Total size, in bytes, of the relocation entries associated with the
	// procedure linkage table.
	PLTRELSZ = 2,
	// Contains an address associated with the linkage table. The specific
	// meaning of this field is processor-dependent.
	PLTGOT = 3,
	HASH = 4, // Address of the symbol hash table.
	STRTAB = 5, // Address of the dynamic string table.
	SYMTAB = 6, // Address of the dynamic symbol table.
	RELA = 7, // Address of a relocation table with rela64 entries.
	RELASZ = 8, // Total size, in bytes, of the RELA relocation table.
	RELAENT = 9, // Size, in bytes, of each RELA relocation entry.
	STRSZ = 10, // Total size, in bytes, of the string table.
	SYMENT = 11, // Size, in bytes, of each symbol table entry.
	INIT = 12, // Address of the initialization function.
	FINI = 13, // Address of the termination function.
	SONAME = 14, // The string table offset of the name of this shared object.
	RPATH = 15, // The string table offset of a shared library search path string.
	// The presence of this dynamic table entry modifies the symbol
	// resolution algorithm for references within the library. Symbols
	// defined within the library are used to resolve references before the
	// dynamic linker searches the usual search path.
	SYMBOLIC = 16,
	REL = 17, // Address of a relocation table with rel64 entries.
	RELSZ = 18, // Total size, in bytes, of the REL relocation table.
	RELENT = 19, // Size, in bytes, of each REL relocation entry.
	// Type of relocation entry used for the procedure linkage table. The
	// d_val member contains either [dt::REL] or [dt::RELA].
	PLTREL = 20,
	DEBUG = 21, // Reserved for debugger use.
	// The presence of this dynamic table entry signals that the relocation
	// table contains relocations for a non-writable segment.
	TEXTREL = 22,
	// Address of the relocations associated with the procedure linkage
	// table.
	JMPREL = 23,
	// The presence of this dynamic table entry signals that the dynamic
	// loader should process all relocations for this object before
	// transferring control to the program.
	BIND_NOW = 24,
	INIT_ARRAY = 25, // Pointer to an array of initialiation functions.
	FINI_ARRAY = 26, // Pointer to an array of termination functions.
	INIT_ARRAYSZ = 27, // Size, in bytes, of the array of initialization functions.
	FINI_ARRAYSZ = 28, // Size, in bytes, of the array of termination functions.
	LOOS = 1610612736, // Reserved for environment-specific use.
	// Symbol versioning entry types, GNU extension
	// Version table records
	// .gnu.version  section address
	VERSYM = 1879048176,
	VERDEF = 1879048188, // .gnu.version_d section address
	VERDEFNUM = 1879048189, // Number of version definitions
	VERNEED = 1879048190, // .gnu.version_r section address
	VERNEEDNUM = 1879048191, // Number of needed versions
	HIOS = 1879048191, // Reserved for environment-specific use.
	LOPROC = 1879048192, // Reserved for processor-specific use.
	HIPROC = 2147483647, // Reserved for processor-specific use.
};
type dyn64 = struct {
	// The type of this entry
	d_tag: dt,
	// Additional data associated with this entry. The value which is valid
	// is selected based on the entry type.
	union {
		d_val: u64,
		d_ptr: u64,
	},
};
type elf_machine = enum u16 {
	NONE = 0, // Unknown machine
	M32 = 1, // AT&T WE32100
	SPARC = 2, // Sun SPARC
	I386 = 3, // Intel i386
	M68K = 4, // Motorola 68000
	M88K = 5, // Motorola 88000
	M860 = 7, // Intel i860
	MIPS = 8, // MIPS R3000 Big-Endian only
	S370 = 9, // IBM System/370
	MIPS_RS3_LE = 10, // MIPS R3000 Little-Endian
	PARISC = 15, // HP PA-RISC
	VPP500 = 17, // Fujitsu VPP500
	SPARC32PLUS = 18, // SPARC v8plus
	I960 = 19, // Intel 80960
	PPC = 20, // PowerPC 32-bit
	PPC64 = 21, // PowerPC 64-bit
	S390 = 22, // IBM System/390
	V800 = 36, // NEC V800
	FR20 = 37, // Fujitsu FR20
	RH32 = 38, // TRW RH-32
	RCE = 39, // Motorola RCE
	ARM = 40, // ARM
	SH = 42, // Hitachi SH
	SPARCV9 = 43, // SPARC v9 64-bit
	TRICORE = 44, // Siemens TriCore embedded processor
	ARC = 45, // Argonaut RISC Core
	H8_300 = 46, // Hitachi H8/300
	H8_300H = 47, // Hitachi H8/300H
	H8S = 48, // Hitachi H8S
	H8_500 = 49, // Hitachi H8/500
	IA_64 = 50, // Intel IA-64 Processor
	MIPS_X = 51, // Stanford MIPS-X
	COLDFIRE = 52, // Motorola ColdFire
	M68HC12 = 53, // Motorola M68HC12
	MMA = 54, // Fujitsu MMA
	PCP = 55, // Siemens PCP
	NCPU = 56, // Sony nCPU
	NDR1 = 57, // Denso NDR1 microprocessor
	STARCORE = 58, // Motorola Star*Core processor
	ME16 = 59, // Toyota ME16 processor
	ST100 = 60, // STMicroelectronics ST100 processor
	TINYJ = 61, // Advanced Logic Corp. TinyJ processor
	X86_64 = 62, // Advanced Micro Devices x86-64
	PDSP = 63, // Sony DSP Processor
	PDP10 = 64, // Digital Equipment Corp. PDP-10
	PDP11 = 65, // Digital Equipment Corp. PDP-11
	FX66 = 66, // Siemens FX66 microcontroller
	ST9PLUS = 67, // STMicroelectronics ST9+ 8/16 bit microcontroller
	ST7 = 68, // STMicroelectronics ST7 8-bit microcontroller
	M68HC16 = 69, // Motorola MC68HC16 Microcontroller
	M68HC11 = 70, // Motorola MC68HC11 Microcontroller
	M68HC08 = 71, // Motorola MC68HC08 Microcontroller
	M68HC05 = 72, // Motorola MC68HC05 Microcontroller
	SVX = 73, // Silicon Graphics SVx
	ST19 = 74, // STMicroelectronics ST19 8-bit microcontroller
	VAX = 75, // Digital VAX
	CRIS = 76, // Axis Communications 32-bit embedded processor
	JAVELIN = 77, // Infineon Technologies 32-bit embedded processor
	FIREPATH = 78, // Element 14 64-bit DSP Processor
	ZSP = 79, // LSI Logic 16-bit DSP Processor
	MMIX = 80, // Donald Knuth's educational 64-bit processor
	HUANY = 81, // Harvard University machine-independent object files
	PRISM = 82, // SiTera Prism
	AVR = 83, // Atmel AVR 8-bit microcontroller
	FR30 = 84, // Fujitsu FR30
	D10V = 85, // Mitsubishi D10V
	D30V = 86, // Mitsubishi D30V
	V850 = 87, // NEC v850
	M32R = 88, // Mitsubishi M32R
	MN10300 = 89, // Matsushita MN10300
	MN10200 = 90, // Matsushita MN10200
	PJ = 91, // picoJava
	OPENRISC = 92, // OpenRISC 32-bit embedded processor
	ARC_COMPACT = 93, // ARC International ARCompact processor
	XTENSA = 94, // Tensilica Xtensa Architecture
	VIDEOCORE = 95, // Alphamosaic VideoCore processor
	TMM_GPP = 96, // Thompson Multimedia General Purpose Processor
	NS32K = 97, // National Semiconductor 32000 series
	TPC = 98, // Tenor Network TPC processor
	SNP1K = 99, // Trebia SNP 1000 processor
	ST200 = 100, // STMicroelectronics (www.st.com) ST200 microcontroller
	IP2K = 101, // Ubicom IP2xxx microcontroller family
	MAX = 102, // MAX Processor
	CR = 103, // National Semiconductor CompactRISC microprocessor
	F2MC16 = 104, // Fujitsu F2MC16
	MSP430 = 105, // Texas Instruments embedded microcontroller msp430
	BLACKFIN = 106, // Analog Devices Blackfin (DSP) processor
	SE_C33 = 107, // S1C33 Family of Seiko Epson processors
	SEP = 108, // Sharp embedded microprocessor
	ARCA = 109, // Arca RISC Microprocessor
	UNICORE = 110, // Microprocessor series from PKU-Unity Ltd. and MPRC of Peking University
	EXCESS = 111, // eXcess: 16/32/64-bit configurable embedded CPU
	DXP = 112, // Icera Semiconductor Inc. Deep Execution Processor
	ALTERA_NIOS2 = 113, // Altera Nios II soft-core processor
	CRX = 114, // National Semiconductor CompactRISC CRX microprocessor
	XGATE = 115, // Motorola XGATE embedded processor
	C166 = 116, // Infineon C16x/XC16x processor
	M16C = 117, // Renesas M16C series microprocessors
	DSPIC30F = 118, // Microchip Technology dsPIC30F Digital Signal Controller
	CE = 119, // Freescale Communication Engine RISC core
	M32C = 120, // Renesas M32C series microprocessors
	TSK3000 = 131, // Altium TSK3000 core
	RS08 = 132, // Freescale RS08 embedded processor
	SHARC = 133, // Analog Devices SHARC family of 32-bit DSP processors
	ECOG2 = 134, // Cyan Technology eCOG2 microprocessor
	SCORE7 = 135, // Sunplus S+core7 RISC processor
	DSP24 = 136, // New Japan Radio (NJR) 24-bit DSP Processor
	VIDEOCORE3 = 137, // Broadcom VideoCore III processor
	LATTICEMICO32 = 138, // RISC processor for Lattice FPGA architecture
	SE_C17 = 139, // Seiko Epson C17 family
	TI_C6000 = 140, // The Texas Instruments TMS320C6000 DSP family
	TI_C2000 = 141, // The Texas Instruments TMS320C2000 DSP family
	TI_C5500 = 142, // The Texas Instruments TMS320C55x DSP family
	TI_ARP32 = 143, // Texas Instruments Application Specific RISC Processor, 32bit fetch
	TI_PRU = 144, // Texas Instruments Programmable Realtime Unit
	MMDSP_PLUS = 160, // STMicroelectronics 64bit VLIW Data Signal Processor
	CYPRESS_M8C = 161, // Cypress M8C microprocessor
	R32C = 162, // Renesas R32C series microprocessors
	TRIMEDIA = 163, // NXP Semiconductors TriMedia architecture family
	QDSP6 = 164, // QUALCOMM DSP6 Processor
	I8051 = 165, // Intel 8051 and variants
	STXP7X = 166, // STMicroelectronics STxP7x family of configurable and extensible RISC processors
	NDS32 = 167, // Andes Technology compact code size embedded RISC processor family
	ECOG1 = 168, // Cyan Technology eCOG1X family
	ECOG1X = 168, // Cyan Technology eCOG1X family
	MAXQ30 = 169, // Dallas Semiconductor MAXQ30 Core Micro-controllers
	XIMO16 = 170, // New Japan Radio (NJR) 16-bit DSP Processor
	MANIK = 171, // M2000 Reconfigurable RISC Microprocessor
	CRAYNV2 = 172, // Cray Inc. NV2 vector architecture
	RX = 173, // Renesas RX family
	METAG = 174, // Imagination Technologies META processor architecture
	MCST_ELBRUS = 175, // MCST Elbrus general purpose hardware architecture
	ECOG16 = 176, // Cyan Technology eCOG16 family
	CR16 = 177, // National Semiconductor CompactRISC CR16 16-bit microprocessor
	ETPU = 178, // Freescale Extended Time Processing Unit
	SLE9X = 179, // Infineon Technologies SLE9X core
	L10M = 180, // Intel L10M
	K10M = 181, // Intel K10M
	AARCH64 = 183, // ARM 64-bit Architecture (AArch64)
	AVR32 = 185, // Atmel Corporation 32-bit microprocessor family
	STM8 = 186, // STMicroeletronics STM8 8-bit microcontroller
	TILE64 = 187, // Tilera TILE64 multicore architecture family
	TILEPRO = 188, // Tilera TILEPro multicore architecture family
	MICROBLAZE = 189, // Xilinx MicroBlaze 32-bit RISC soft processor core
	CUDA = 190, // NVIDIA CUDA architecture
	TILEGX = 191, // Tilera TILE-Gx multicore architecture family
	CLOUDSHIELD = 192, // CloudShield architecture family
	COREA_1ST = 193, // KIPO-KAIST Core-A 1st generation processor family
	COREA_2ND = 194, // KIPO-KAIST Core-A 2nd generation processor family
	ARC_COMPACT2 = 195, // Synopsys ARCompact V2
	OPEN8 = 196, // Open8 8-bit RISC soft processor core
	RL78 = 197, // Renesas RL78 family
	VIDEOCORE5 = 198, // Broadcom VideoCore V processor
	R78KOR = 199, // Renesas 78KOR family
	F56800EX = 200, // Freescale 56800EX Digital Signal Controller (DSC)
	BA1 = 201, // Beyond BA1 CPU architecture
	BA2 = 202, // Beyond BA2 CPU architecture
	XCORE = 203, // XMOS xCORE processor family
	MCHP_PIC = 204, // Microchip 8-bit PIC(r) family
	INTEL205 = 205, // Reserved by Intel
	INTEL206 = 206, // Reserved by Intel
	INTEL207 = 207, // Reserved by Intel
	INTEL208 = 208, // Reserved by Intel
	INTEL209 = 209, // Reserved by Intel
	KM32 = 210, // KM211 KM32 32-bit processor
	KMX32 = 211, // KM211 KMX32 32-bit processor
	KMX16 = 212, // KM211 KMX16 16-bit processor
	KMX8 = 213, // KM211 KMX8 8-bit processor
	KVARC = 214, // KM211 KVARC processor
	CDP = 215, // Paneve CDP architecture family
	COGE = 216, // Cognitive Smart Memory Processor
	COOL = 217, // Bluechip Systems CoolEngine
	NORC = 218, // Nanoradio Optimized RISC
	CSR_KALIMBA = 219, // CSR Kalimba architecture family
	Z80 = 220, // Zilog Z80
	VISIUM = 221, // Controls and Data Services VISIUMcore processor
	FT32 = 222, // FTDI Chip FT32 high performance 32-bit RISC architecture
	MOXIE = 223, // Moxie processor family
	AMDGPU = 224, // AMD GPU architecture
	RISCV = 243, // RISC-V
	LANAI = 244, // Lanai 32-bit processor
	BPF = 247, // Linux BPF โ€“ in-kernel virtual machine
	I486 = 6, // Intel i486 (deprecated)
	MIPS_RS4_BE = 10, // MIPS R4000 Big-Endian (deprecated)
	ALPHA_STD = 41, // Digital Alpha (deprecated)
	ALPHA = 36902, // Alpha (deprecated)
};
type elf_type = enum u16 {
	NONE = 0, // No file type
	REL = 1, // Relocatable object file
	EXEC = 2, // Executable file
	DYN = 3, // Shared object file
	CORE = 4, // Core file
	LOOS = 65024, // Environment-specific use
	HIOS = 65279, // Environment-specific use
	LOPROC = 65280, // Processor-specific use
	HIPROC = 65535, // Processor-specific use
};
type hashhdr = struct {
	nbucket: u32,
	nchain: u32,
};
type header64 = struct {
	// ELF identification
	e_ident: [EI_NIDENT]u8,
	// Object file type
	e_type: elf_type,
	// Machine type
	e_machine: elf_machine,
	// Object file version ([EV_CURRENT])
	e_version: u32,
	// Entry point address
	e_entry: u64,
	// Program header offset
	e_phoff: u64,
	// Section header offset
	e_shoff: u64,
	// Processor-specific flags
	e_flags: u32,
	// ELF header size
	e_ehsize: u16,
	// Size of program header entry
	e_phentsize: u16,
	// Number of program header entries
	e_phnum: u16,
	// Size of section header entry
	e_shentsize: u16,
	// Number of section header entries
	e_shnum: u16,
	// Section name string table index, or [shn::UNDEF]
	e_shstrndx: u16,
};
type ident_abi = enum u8 {
	SYSV = 0, // System-V ABI
	HPUX = 1, // HP-UX operating system
	STANDALONE = 255, // Standalone (embedded) application
};
type ident_class = enum u8 {
	ELF32 = 1, // 32-bit objects
	ELF64 = 2, // 64-bit objects
};
type ident_data = enum u8 {
	LSB = 1, // Object file data structures are little-endian
	MSB = 2, // Object file data structures are big-endian
};
type pf = enum u32 {
	NONE = 0, // No permission
	X = 1, // Execute permission
	W = 2, // Write permission
	R = 4, // Read permission
	MASKOS = 16711680, // Reserved for environment-specific use
	MASKPROC = 4278190080, // Reserved for processor-specific use
};
type phdr64 = struct {
	// Type of segment
	p_type: pt,
	// Segment attributes
	p_flags: u32,
	// Offset in file
	p_offset: u64,
	// Virtual address in memory
	p_vaddr: u64,
	// Reserved
	p_paddr: u64,
	// Size of segment in file
	p_filesz: u64,
	// Size of segment in memory
	p_memsz: u64,
	// Alignment of segment
	p_align: u64,
};
type pt = enum u32 {
	NULL = 0, // Unused entry
	LOAD = 1, // Loadable segment
	DYNAMIC = 2, // Dynamic linking tables
	INTERP = 3, // Program interpreter path name
	NOTE = 4, // Note sections
	SHLIB = 5, // Reserved
	PHDR = 6, // Program header table
	LOOS = 1610612736, // Environment-specific use
	HIOS = 1879048191, // Environment-specific use
	LOPROC = 1879048192, // Processor-specific use
	HIPROC = 2147483647, // Processor-specific use
};
type rel64 = struct {
	// Address of reference
	r_offset: u64,
	// Symbol table index and type of relocation
	r_info: u64,
};
type rela64 = struct {
	// Address of reference
	r_offset: u64,
	// Symbol table index and type of relocation
	r_info: u64,
	// Constant part of expression
	r_addend: i64,
};
type section64 = struct {
	// Section name
	sh_name: u32,
	// Section type
	sh_type: u32,
	// Section attributes
	sh_flags: u64,
	// Virtual address in memory
	sh_addr: u64,
	// Offset in file
	sh_offset: u64,
	// Size of section
	sh_size: u64,
	// Link to other section
	sh_link: u32,
	// Miscellaenous information
	sh_info: u32,
	// Address alignment boundary
	sh_addralign: u64,
	// Size of entries, if section has table
	sh_entsize: u64,
};
type shf = enum u32 {
	NONE = 0, // Section contains no data
	WRITE = 1, // Section contains writable data
	ALLOC = 2, // Section is allocated in memory image of program
	EXECINSTR = 4, // Section contains executable instructions
	MASKOS = 251658240, // Environment-specific use
	MASKPROC = 4026531840, // Processor-specific use
};
type shn = enum u16 {
	UNDEF = 0, // Used to mark an undefined or meaningless section reference
	LOPROC = 65280, // Processor-specific use
	HIPROC = 65311, // Processor-specific use
	LOOS = 65312, // Environment-specific-use
	HIOS = 65343, // Environment-specific-use
	ABS = 65521, // Indicates that the corresponding reference is an absolute value
	COMMON = 65522, // Indicates a symbol that has been declared as a common block
};
type sht = enum u32 {
	NULL = 0, // Marks an unused section header
	PROGBITS = 1, // Contains information defined by the program
	SYMTAB = 2, // Contains a linker symbol table
	STRTAB = 3, // Contains a string table
	RELA = 4, // Contains "Rela" type relocation entries
	HASH = 5, // Contains a symbol hash table
	DYNAMIC = 6, // Contains dynamic linking tables
	NOTE = 7, // Contains note information
	NOBITS = 8, // Contains uninitialized space; does not occupy any space in the file
	REL = 9, // Contains "Rel" type relocation entries
	SHLIB = 10, // Reserved
	DYNSYM = 11, // Contains a dynamic loader symbol table
	LOOS = 1610612736, // Environment-specific use
	HIOS = 1879048191, // Environment-specific use
	LOPROC = 1879048192, // Processor-specific use
	HIPROC = 2147483647, // Processor-specific use
};
type stb = enum u8 {
	LOCAL = 0, // Not visible outside the object file
	GLOBAL = 1, // Global symbol, visible to all object files
	WEAK = 2, // Global scope, but with lower precedence than global symbols
	LOOS = 10, // Environment-specific use
	HIOS = 12, // Environment-specific use
	LOPROC = 13, // Processor-specific use
	HIPROC = 15, // Processor-specific use
};
type stt = enum u8 {
	NOTYPE = 0, // No type specified (e.g. an absolute symbol)
	OBJECT = 1, // Data object
	FUNC = 2, // Function entry point
	SECTION = 3, // Symbol is associated with a section
	FILE = 4, // Source file associated with the object
	COMMON = 5, // Symbol is a common data object
	LOOS = 10, // Environment-specific use
	HIOS = 12, // Environment-specific use
	LOPROC = 13, // Processor-specific use
	HIPROC = 15, // Processor-specific use
};
type sym64 = struct {
	// Symbol name offset
	st_name: u32,
	// Type and binding attributes
	st_info: u8,
	// Reserved
	st_other: u8,
	// Section table index
	st_shndx: u16,
	// Symbol value
	st_value: u64,
	// Size of object
	st_size: u64,
};
type ver_def = enum u16 {
	NONE = 0,
	CURRENT = 1,
	NUM = 2,
};
type ver_flg = enum u16 {
	BASE = 1,
	WEAK = 2,
};
type ver_ndx = enum u16 {
	LOCAL = 0,
	GLOBAL = 1,
	LORESERVE = 65280,
	ELIMINATE = 65281,
};
type verdaux64 = struct {
	vda_name: u32,
	vda_next: u32,
};
type verdef64 = struct {
	// Version revision
	vd_version: u16,
	// Version information
	vd_flags: u16,
	// Version Index
	vd_ndx: u16,
	// Number of associated aux entries
	vd_cnt: u16,
	// Version name hash value
	vd_hash: u32,
	// Offset in bytes to verdaux array
	vd_aux: u32,
	// Offset in bytes to next verdef entry
	vd_next: u32,
};

Constants

def TARGET_ABI: ident_abi = ident_abi::SYSV;
def TARGET_MACHINE: elf_machine = elf_machine::X86_64;

// Undocumented constants:
def EI_ABIVERSION: uint = 8;
def EI_CLASS: uint = 4;
def EI_DATA: uint = 5;
def EI_MAG0: uint = 0;
def EI_MAG1: uint = 1;
def EI_MAG2: uint = 2;
def EI_MAG3: uint = 3;
def EI_NIDENT: uint = 16;
def EI_OSABI: uint = 7;
def EI_PAD: uint = 9;
def EI_VERSION: uint = 6;
def EV_CURRENT: u32 = 1;
def MAGIC: str = "ELF";

Functions

fn r64_info(sym: u64, stype: u64) u64;
fn r64_sym(info: u64) u64;
fn r64_type(info: u64) u64;
fn st_bind(i: u8) stb;
fn st_info(b: stb, t: stt) u8;
fn st_type(i: u8) stt;

Types

type at[link]

type at = enum u64 {
	NULL = 0, // End of vector
	IGNORE = 1, // Entry should be ignored
	EXECFD = 2, // File descriptor of program
	PHDR = 3, // Program headers for program
	PHENT = 4, // Size of program header entry
	PHNUM = 5, // Number of program headers
	PAGESZ = 6, // System page size
	BASE = 7, // Base address of interpreter
	FLAGS = 8, // Flags
	ENTRY = 9, // Entry point of program
	NOTELF = 10, // Program is not ELF
	UID = 11, // Real uid
	EUID = 12, // Effective uid
	GID = 13, // Real gid
	EGID = 14, // Effective gid
	CLKTCK = 17, // Frequency of times()
	PLATFORM = 15, // String identifying platform.
	HWCAP = 16, // Machine-dependent hints about processor capabilities.
	FPUCW = 18, // Used FPU control word.
	DCACHEBSIZE = 19, // Data cache block size.
	ICACHEBSIZE = 20, // Instruction cache block size.
	UCACHEBSIZE = 21, // Unified cache block size.
	// A special ignored value for PPC, used by the kernel to control the
	// interpretation of the AUXV. Must be > 16.
	// Entry should be ignored.
	IGNOREPPC = 22,
	SECURE = 23, // Boolean, was exec setuid-like?
	BASE_PLATFORM = 24, // String identifying real platforms.
	RANDOM = 25, // Address of 16 random bytes.
	HWCAP2 = 26, // More machine-dependent hints about processor capabilities.
	EXECFN = 31, // Filename of executable.
	// Pointer to the global system page used for system calls and other
	// nice things.
	SYSINFO = 32,
	SYSINFO_EHDR = 33,
	// Shapes of the caches.  Bits 0-3 contains associativity, bits 4-7 contains
	// log2 of line size, mask those to get cache size.
	L1I_CACHESHAPE = 34,
	L1D_CACHESHAPE = 35,
	L2_CACHESHAPE = 36,
	L3_CACHESHAPE = 37,
	// Shapes of the caches, with more room to describe them.
	// *GEOMETRY are comprised of cache line size in bytes in the bottom 16 bits
	// and the cache associativity in the next 16 bits.
	L1I_CACHESIZE = 40,
	L1I_CACHEGEOMETRY = 41,
	L1D_CACHESIZE = 42,
	L1D_CACHEGEOMETRY = 43,
	L2_CACHESIZE = 44,
	L2_CACHEGEOMETRY = 45,
	L3_CACHESIZE = 46,
	L3_CACHEGEOMETRY = 47,
	MINSIGSTKSZ = 51, // Stack needed for signal delivery (AArch64).
};

Legal auxiliary vector entry types

type auxv64[link]

type auxv64 = struct {
	// Entry type
	a_type: at,
	union {
		// Integer value
		a_val: u64,
		a_ptr: *opaque,
		a_fnc: *fn() void,
	},
};

Auxiliary vector

type dt[link]

type dt = enum i64 {
	NULL = 0, // Marks the end of the dynamic array.
	NEEDED = 1, // The string table offset of the name of a needed library.
	// Total size, in bytes, of the relocation entries associated with the
	// procedure linkage table.
	PLTRELSZ = 2,
	// Contains an address associated with the linkage table. The specific
	// meaning of this field is processor-dependent.
	PLTGOT = 3,
	HASH = 4, // Address of the symbol hash table.
	STRTAB = 5, // Address of the dynamic string table.
	SYMTAB = 6, // Address of the dynamic symbol table.
	RELA = 7, // Address of a relocation table with rela64 entries.
	RELASZ = 8, // Total size, in bytes, of the RELA relocation table.
	RELAENT = 9, // Size, in bytes, of each RELA relocation entry.
	STRSZ = 10, // Total size, in bytes, of the string table.
	SYMENT = 11, // Size, in bytes, of each symbol table entry.
	INIT = 12, // Address of the initialization function.
	FINI = 13, // Address of the termination function.
	SONAME = 14, // The string table offset of the name of this shared object.
	RPATH = 15, // The string table offset of a shared library search path string.
	// The presence of this dynamic table entry modifies the symbol
	// resolution algorithm for references within the library. Symbols
	// defined within the library are used to resolve references before the
	// dynamic linker searches the usual search path.
	SYMBOLIC = 16,
	REL = 17, // Address of a relocation table with rel64 entries.
	RELSZ = 18, // Total size, in bytes, of the REL relocation table.
	RELENT = 19, // Size, in bytes, of each REL relocation entry.
	// Type of relocation entry used for the procedure linkage table. The
	// d_val member contains either [dt::REL] or [dt::RELA].
	PLTREL = 20,
	DEBUG = 21, // Reserved for debugger use.
	// The presence of this dynamic table entry signals that the relocation
	// table contains relocations for a non-writable segment.
	TEXTREL = 22,
	// Address of the relocations associated with the procedure linkage
	// table.
	JMPREL = 23,
	// The presence of this dynamic table entry signals that the dynamic
	// loader should process all relocations for this object before
	// transferring control to the program.
	BIND_NOW = 24,
	INIT_ARRAY = 25, // Pointer to an array of initialiation functions.
	FINI_ARRAY = 26, // Pointer to an array of termination functions.
	INIT_ARRAYSZ = 27, // Size, in bytes, of the array of initialization functions.
	FINI_ARRAYSZ = 28, // Size, in bytes, of the array of termination functions.
	LOOS = 1610612736, // Reserved for environment-specific use.
	// Symbol versioning entry types, GNU extension
	// Version table records
	// .gnu.version  section address
	VERSYM = 1879048176,
	VERDEF = 1879048188, // .gnu.version_d section address
	VERDEFNUM = 1879048189, // Number of version definitions
	VERNEED = 1879048190, // .gnu.version_r section address
	VERNEEDNUM = 1879048191, // Number of needed versions
	HIOS = 1879048191, // Reserved for environment-specific use.
	LOPROC = 1879048192, // Reserved for processor-specific use.
	HIPROC = 2147483647, // Reserved for processor-specific use.
};

Dynamic table entry type

type dyn64[link]

type dyn64 = struct {
	// The type of this entry
	d_tag: dt,
	// Additional data associated with this entry. The value which is valid
	// is selected based on the entry type.
	union {
		d_val: u64,
		d_ptr: u64,
	},
};

Dynamic table entry

type elf_machine[link]

type elf_machine = enum u16 {
	NONE = 0, // Unknown machine
	M32 = 1, // AT&T WE32100
	SPARC = 2, // Sun SPARC
	I386 = 3, // Intel i386
	M68K = 4, // Motorola 68000
	M88K = 5, // Motorola 88000
	M860 = 7, // Intel i860
	MIPS = 8, // MIPS R3000 Big-Endian only
	S370 = 9, // IBM System/370
	MIPS_RS3_LE = 10, // MIPS R3000 Little-Endian
	PARISC = 15, // HP PA-RISC
	VPP500 = 17, // Fujitsu VPP500
	SPARC32PLUS = 18, // SPARC v8plus
	I960 = 19, // Intel 80960
	PPC = 20, // PowerPC 32-bit
	PPC64 = 21, // PowerPC 64-bit
	S390 = 22, // IBM System/390
	V800 = 36, // NEC V800
	FR20 = 37, // Fujitsu FR20
	RH32 = 38, // TRW RH-32
	RCE = 39, // Motorola RCE
	ARM = 40, // ARM
	SH = 42, // Hitachi SH
	SPARCV9 = 43, // SPARC v9 64-bit
	TRICORE = 44, // Siemens TriCore embedded processor
	ARC = 45, // Argonaut RISC Core
	H8_300 = 46, // Hitachi H8/300
	H8_300H = 47, // Hitachi H8/300H
	H8S = 48, // Hitachi H8S
	H8_500 = 49, // Hitachi H8/500
	IA_64 = 50, // Intel IA-64 Processor
	MIPS_X = 51, // Stanford MIPS-X
	COLDFIRE = 52, // Motorola ColdFire
	M68HC12 = 53, // Motorola M68HC12
	MMA = 54, // Fujitsu MMA
	PCP = 55, // Siemens PCP
	NCPU = 56, // Sony nCPU
	NDR1 = 57, // Denso NDR1 microprocessor
	STARCORE = 58, // Motorola Star*Core processor
	ME16 = 59, // Toyota ME16 processor
	ST100 = 60, // STMicroelectronics ST100 processor
	TINYJ = 61, // Advanced Logic Corp. TinyJ processor
	X86_64 = 62, // Advanced Micro Devices x86-64
	PDSP = 63, // Sony DSP Processor
	PDP10 = 64, // Digital Equipment Corp. PDP-10
	PDP11 = 65, // Digital Equipment Corp. PDP-11
	FX66 = 66, // Siemens FX66 microcontroller
	ST9PLUS = 67, // STMicroelectronics ST9+ 8/16 bit microcontroller
	ST7 = 68, // STMicroelectronics ST7 8-bit microcontroller
	M68HC16 = 69, // Motorola MC68HC16 Microcontroller
	M68HC11 = 70, // Motorola MC68HC11 Microcontroller
	M68HC08 = 71, // Motorola MC68HC08 Microcontroller
	M68HC05 = 72, // Motorola MC68HC05 Microcontroller
	SVX = 73, // Silicon Graphics SVx
	ST19 = 74, // STMicroelectronics ST19 8-bit microcontroller
	VAX = 75, // Digital VAX
	CRIS = 76, // Axis Communications 32-bit embedded processor
	JAVELIN = 77, // Infineon Technologies 32-bit embedded processor
	FIREPATH = 78, // Element 14 64-bit DSP Processor
	ZSP = 79, // LSI Logic 16-bit DSP Processor
	MMIX = 80, // Donald Knuth's educational 64-bit processor
	HUANY = 81, // Harvard University machine-independent object files
	PRISM = 82, // SiTera Prism
	AVR = 83, // Atmel AVR 8-bit microcontroller
	FR30 = 84, // Fujitsu FR30
	D10V = 85, // Mitsubishi D10V
	D30V = 86, // Mitsubishi D30V
	V850 = 87, // NEC v850
	M32R = 88, // Mitsubishi M32R
	MN10300 = 89, // Matsushita MN10300
	MN10200 = 90, // Matsushita MN10200
	PJ = 91, // picoJava
	OPENRISC = 92, // OpenRISC 32-bit embedded processor
	ARC_COMPACT = 93, // ARC International ARCompact processor
	XTENSA = 94, // Tensilica Xtensa Architecture
	VIDEOCORE = 95, // Alphamosaic VideoCore processor
	TMM_GPP = 96, // Thompson Multimedia General Purpose Processor
	NS32K = 97, // National Semiconductor 32000 series
	TPC = 98, // Tenor Network TPC processor
	SNP1K = 99, // Trebia SNP 1000 processor
	ST200 = 100, // STMicroelectronics (www.st.com) ST200 microcontroller
	IP2K = 101, // Ubicom IP2xxx microcontroller family
	MAX = 102, // MAX Processor
	CR = 103, // National Semiconductor CompactRISC microprocessor
	F2MC16 = 104, // Fujitsu F2MC16
	MSP430 = 105, // Texas Instruments embedded microcontroller msp430
	BLACKFIN = 106, // Analog Devices Blackfin (DSP) processor
	SE_C33 = 107, // S1C33 Family of Seiko Epson processors
	SEP = 108, // Sharp embedded microprocessor
	ARCA = 109, // Arca RISC Microprocessor
	UNICORE = 110, // Microprocessor series from PKU-Unity Ltd. and MPRC of Peking University
	EXCESS = 111, // eXcess: 16/32/64-bit configurable embedded CPU
	DXP = 112, // Icera Semiconductor Inc. Deep Execution Processor
	ALTERA_NIOS2 = 113, // Altera Nios II soft-core processor
	CRX = 114, // National Semiconductor CompactRISC CRX microprocessor
	XGATE = 115, // Motorola XGATE embedded processor
	C166 = 116, // Infineon C16x/XC16x processor
	M16C = 117, // Renesas M16C series microprocessors
	DSPIC30F = 118, // Microchip Technology dsPIC30F Digital Signal Controller
	CE = 119, // Freescale Communication Engine RISC core
	M32C = 120, // Renesas M32C series microprocessors
	TSK3000 = 131, // Altium TSK3000 core
	RS08 = 132, // Freescale RS08 embedded processor
	SHARC = 133, // Analog Devices SHARC family of 32-bit DSP processors
	ECOG2 = 134, // Cyan Technology eCOG2 microprocessor
	SCORE7 = 135, // Sunplus S+core7 RISC processor
	DSP24 = 136, // New Japan Radio (NJR) 24-bit DSP Processor
	VIDEOCORE3 = 137, // Broadcom VideoCore III processor
	LATTICEMICO32 = 138, // RISC processor for Lattice FPGA architecture
	SE_C17 = 139, // Seiko Epson C17 family
	TI_C6000 = 140, // The Texas Instruments TMS320C6000 DSP family
	TI_C2000 = 141, // The Texas Instruments TMS320C2000 DSP family
	TI_C5500 = 142, // The Texas Instruments TMS320C55x DSP family
	TI_ARP32 = 143, // Texas Instruments Application Specific RISC Processor, 32bit fetch
	TI_PRU = 144, // Texas Instruments Programmable Realtime Unit
	MMDSP_PLUS = 160, // STMicroelectronics 64bit VLIW Data Signal Processor
	CYPRESS_M8C = 161, // Cypress M8C microprocessor
	R32C = 162, // Renesas R32C series microprocessors
	TRIMEDIA = 163, // NXP Semiconductors TriMedia architecture family
	QDSP6 = 164, // QUALCOMM DSP6 Processor
	I8051 = 165, // Intel 8051 and variants
	STXP7X = 166, // STMicroelectronics STxP7x family of configurable and extensible RISC processors
	NDS32 = 167, // Andes Technology compact code size embedded RISC processor family
	ECOG1 = 168, // Cyan Technology eCOG1X family
	ECOG1X = 168, // Cyan Technology eCOG1X family
	MAXQ30 = 169, // Dallas Semiconductor MAXQ30 Core Micro-controllers
	XIMO16 = 170, // New Japan Radio (NJR) 16-bit DSP Processor
	MANIK = 171, // M2000 Reconfigurable RISC Microprocessor
	CRAYNV2 = 172, // Cray Inc. NV2 vector architecture
	RX = 173, // Renesas RX family
	METAG = 174, // Imagination Technologies META processor architecture
	MCST_ELBRUS = 175, // MCST Elbrus general purpose hardware architecture
	ECOG16 = 176, // Cyan Technology eCOG16 family
	CR16 = 177, // National Semiconductor CompactRISC CR16 16-bit microprocessor
	ETPU = 178, // Freescale Extended Time Processing Unit
	SLE9X = 179, // Infineon Technologies SLE9X core
	L10M = 180, // Intel L10M
	K10M = 181, // Intel K10M
	AARCH64 = 183, // ARM 64-bit Architecture (AArch64)
	AVR32 = 185, // Atmel Corporation 32-bit microprocessor family
	STM8 = 186, // STMicroeletronics STM8 8-bit microcontroller
	TILE64 = 187, // Tilera TILE64 multicore architecture family
	TILEPRO = 188, // Tilera TILEPro multicore architecture family
	MICROBLAZE = 189, // Xilinx MicroBlaze 32-bit RISC soft processor core
	CUDA = 190, // NVIDIA CUDA architecture
	TILEGX = 191, // Tilera TILE-Gx multicore architecture family
	CLOUDSHIELD = 192, // CloudShield architecture family
	COREA_1ST = 193, // KIPO-KAIST Core-A 1st generation processor family
	COREA_2ND = 194, // KIPO-KAIST Core-A 2nd generation processor family
	ARC_COMPACT2 = 195, // Synopsys ARCompact V2
	OPEN8 = 196, // Open8 8-bit RISC soft processor core
	RL78 = 197, // Renesas RL78 family
	VIDEOCORE5 = 198, // Broadcom VideoCore V processor
	R78KOR = 199, // Renesas 78KOR family
	F56800EX = 200, // Freescale 56800EX Digital Signal Controller (DSC)
	BA1 = 201, // Beyond BA1 CPU architecture
	BA2 = 202, // Beyond BA2 CPU architecture
	XCORE = 203, // XMOS xCORE processor family
	MCHP_PIC = 204, // Microchip 8-bit PIC(r) family
	INTEL205 = 205, // Reserved by Intel
	INTEL206 = 206, // Reserved by Intel
	INTEL207 = 207, // Reserved by Intel
	INTEL208 = 208, // Reserved by Intel
	INTEL209 = 209, // Reserved by Intel
	KM32 = 210, // KM211 KM32 32-bit processor
	KMX32 = 211, // KM211 KMX32 32-bit processor
	KMX16 = 212, // KM211 KMX16 16-bit processor
	KMX8 = 213, // KM211 KMX8 8-bit processor
	KVARC = 214, // KM211 KVARC processor
	CDP = 215, // Paneve CDP architecture family
	COGE = 216, // Cognitive Smart Memory Processor
	COOL = 217, // Bluechip Systems CoolEngine
	NORC = 218, // Nanoradio Optimized RISC
	CSR_KALIMBA = 219, // CSR Kalimba architecture family
	Z80 = 220, // Zilog Z80
	VISIUM = 221, // Controls and Data Services VISIUMcore processor
	FT32 = 222, // FTDI Chip FT32 high performance 32-bit RISC architecture
	MOXIE = 223, // Moxie processor family
	AMDGPU = 224, // AMD GPU architecture
	RISCV = 243, // RISC-V
	LANAI = 244, // Lanai 32-bit processor
	BPF = 247, // Linux BPF โ€“ in-kernel virtual machine
	I486 = 6, // Intel i486 (deprecated)
	MIPS_RS4_BE = 10, // MIPS R4000 Big-Endian (deprecated)
	ALPHA_STD = 41, // Digital Alpha (deprecated)
	ALPHA = 36902, // Alpha (deprecated)
};

Machine architecture

type elf_type[link]

type elf_type = enum u16 {
	NONE = 0, // No file type
	REL = 1, // Relocatable object file
	EXEC = 2, // Executable file
	DYN = 3, // Shared object file
	CORE = 4, // Core file
	LOOS = 65024, // Environment-specific use
	HIOS = 65279, // Environment-specific use
	LOPROC = 65280, // Processor-specific use
	HIPROC = 65535, // Processor-specific use
};

ELF file type

type hashhdr[link]

type hashhdr = struct {
	nbucket: u32,
	nchain: u32,
};

DT_HASH section header

type header64[link]

type header64 = struct {
	// ELF identification
	e_ident: [EI_NIDENT]u8,
	// Object file type
	e_type: elf_type,
	// Machine type
	e_machine: elf_machine,
	// Object file version ([EV_CURRENT])
	e_version: u32,
	// Entry point address
	e_entry: u64,
	// Program header offset
	e_phoff: u64,
	// Section header offset
	e_shoff: u64,
	// Processor-specific flags
	e_flags: u32,
	// ELF header size
	e_ehsize: u16,
	// Size of program header entry
	e_phentsize: u16,
	// Number of program header entries
	e_phnum: u16,
	// Size of section header entry
	e_shentsize: u16,
	// Number of section header entries
	e_shnum: u16,
	// Section name string table index, or [shn::UNDEF]
	e_shstrndx: u16,
};

ELF header for ELF64

type ident_abi[link]

type ident_abi = enum u8 {
	SYSV = 0, // System-V ABI
	HPUX = 1, // HP-UX operating system
	STANDALONE = 255, // Standalone (embedded) application
};

Application binary interface

type ident_class[link]

type ident_class = enum u8 {
	ELF32 = 1, // 32-bit objects
	ELF64 = 2, // 64-bit objects
};

ELF file class

type ident_data[link]

type ident_data = enum u8 {
	LSB = 1, // Object file data structures are little-endian
	MSB = 2, // Object file data structures are big-endian
};

Byte ordering

type pf[link]

type pf = enum u32 {
	NONE = 0, // No permission
	X = 1, // Execute permission
	W = 2, // Write permission
	R = 4, // Read permission
	MASKOS = 16711680, // Reserved for environment-specific use
	MASKPROC = 4278190080, // Reserved for processor-specific use
};

Segment attributes

type phdr64[link]

type phdr64 = struct {
	// Type of segment
	p_type: pt,
	// Segment attributes
	p_flags: u32,
	// Offset in file
	p_offset: u64,
	// Virtual address in memory
	p_vaddr: u64,
	// Reserved
	p_paddr: u64,
	// Size of segment in file
	p_filesz: u64,
	// Size of segment in memory
	p_memsz: u64,
	// Alignment of segment
	p_align: u64,
};

Program header table entry (segment)

type pt[link]

type pt = enum u32 {
	NULL = 0, // Unused entry
	LOAD = 1, // Loadable segment
	DYNAMIC = 2, // Dynamic linking tables
	INTERP = 3, // Program interpreter path name
	NOTE = 4, // Note sections
	SHLIB = 5, // Reserved
	PHDR = 6, // Program header table
	LOOS = 1610612736, // Environment-specific use
	HIOS = 1879048191, // Environment-specific use
	LOPROC = 1879048192, // Processor-specific use
	HIPROC = 2147483647, // Processor-specific use
};

Segment types

type rel64[link]

type rel64 = struct {
	// Address of reference
	r_offset: u64,
	// Symbol table index and type of relocation
	r_info: u64,
};

Relocation entry

type rela64[link]

type rela64 = struct {
	// Address of reference
	r_offset: u64,
	// Symbol table index and type of relocation
	r_info: u64,
	// Constant part of expression
	r_addend: i64,
};

Relocation entry with explicit addend

type section64[link]

type section64 = struct {
	// Section name
	sh_name: u32,
	// Section type
	sh_type: u32,
	// Section attributes
	sh_flags: u64,
	// Virtual address in memory
	sh_addr: u64,
	// Offset in file
	sh_offset: u64,
	// Size of section
	sh_size: u64,
	// Link to other section
	sh_link: u32,
	// Miscellaenous information
	sh_info: u32,
	// Address alignment boundary
	sh_addralign: u64,
	// Size of entries, if section has table
	sh_entsize: u64,
};

Section header for ELF64

type shf[link]

type shf = enum u32 {
	NONE = 0, // Section contains no data
	WRITE = 1, // Section contains writable data
	ALLOC = 2, // Section is allocated in memory image of program
	EXECINSTR = 4, // Section contains executable instructions
	MASKOS = 251658240, // Environment-specific use
	MASKPROC = 4026531840, // Processor-specific use
};

Section flags

type shn[link]

type shn = enum u16 {
	UNDEF = 0, // Used to mark an undefined or meaningless section reference
	LOPROC = 65280, // Processor-specific use
	HIPROC = 65311, // Processor-specific use
	LOOS = 65312, // Environment-specific-use
	HIOS = 65343, // Environment-specific-use
	ABS = 65521, // Indicates that the corresponding reference is an absolute value
	COMMON = 65522, // Indicates a symbol that has been declared as a common block
};

Special section indicies

type sht[link]

type sht = enum u32 {
	NULL = 0, // Marks an unused section header
	PROGBITS = 1, // Contains information defined by the program
	SYMTAB = 2, // Contains a linker symbol table
	STRTAB = 3, // Contains a string table
	RELA = 4, // Contains "Rela" type relocation entries
	HASH = 5, // Contains a symbol hash table
	DYNAMIC = 6, // Contains dynamic linking tables
	NOTE = 7, // Contains note information
	NOBITS = 8, // Contains uninitialized space; does not occupy any space in the file
	REL = 9, // Contains "Rel" type relocation entries
	SHLIB = 10, // Reserved
	DYNSYM = 11, // Contains a dynamic loader symbol table
	LOOS = 1610612736, // Environment-specific use
	HIOS = 1879048191, // Environment-specific use
	LOPROC = 1879048192, // Processor-specific use
	HIPROC = 2147483647, // Processor-specific use
};

Section type

type stb[link]

type stb = enum u8 {
	LOCAL = 0, // Not visible outside the object file
	GLOBAL = 1, // Global symbol, visible to all object files
	WEAK = 2, // Global scope, but with lower precedence than global symbols
	LOOS = 10, // Environment-specific use
	HIOS = 12, // Environment-specific use
	LOPROC = 13, // Processor-specific use
	HIPROC = 15, // Processor-specific use
};

Symbol bindings

type stt[link]

type stt = enum u8 {
	NOTYPE = 0, // No type specified (e.g. an absolute symbol)
	OBJECT = 1, // Data object
	FUNC = 2, // Function entry point
	SECTION = 3, // Symbol is associated with a section
	FILE = 4, // Source file associated with the object
	COMMON = 5, // Symbol is a common data object
	LOOS = 10, // Environment-specific use
	HIOS = 12, // Environment-specific use
	LOPROC = 13, // Processor-specific use
	HIPROC = 15, // Processor-specific use
};

Symbol types

type sym64[link]

type sym64 = struct {
	// Symbol name offset
	st_name: u32,
	// Type and binding attributes
	st_info: u8,
	// Reserved
	st_other: u8,
	// Section table index
	st_shndx: u16,
	// Symbol value
	st_value: u64,
	// Size of object
	st_size: u64,
};

Symbol table entry

type ver_def[link]

type ver_def = enum u16 {
	NONE = 0,
	CURRENT = 1,
	NUM = 2,
};

Version revision values

type ver_flg[link]

type ver_flg = enum u16 {
	BASE = 1,
	WEAK = 2,
};

Version information flags

type ver_ndx[link]

type ver_ndx = enum u16 {
	LOCAL = 0,
	GLOBAL = 1,
	LORESERVE = 65280,
	ELIMINATE = 65281,
};

Versym index values

type verdaux64[link]

type verdaux64 = struct {
	vda_name: u32,
	vda_next: u32,
};

Auxiliary version information

type verdef64[link]

type verdef64 = struct {
	// Version revision
	vd_version: u16,
	// Version information
	vd_flags: u16,
	// Version Index
	vd_ndx: u16,
	// Number of associated aux entries
	vd_cnt: u16,
	// Version name hash value
	vd_hash: u32,
	// Offset in bytes to verdaux array
	vd_aux: u32,
	// Offset in bytes to next verdef entry
	vd_next: u32,
};

Version definition section

Constants

def TARGET_ABI[link]

def TARGET_ABI: ident_abi = ident_abi::SYSV;

The ABI of the target.

def TARGET_MACHINE[link]

def TARGET_MACHINE: elf_machine = elf_machine::X86_64;

The machine (architecture) of the target.

def EI_ABIVERSION[link]

Show undocumented member
def EI_ABIVERSION: uint = 8;

def EI_CLASS[link]

Show undocumented member
def EI_CLASS: uint = 4;

def EI_DATA[link]

Show undocumented member
def EI_DATA: uint = 5;

def EI_MAG0[link]

Show undocumented member
def EI_MAG0: uint = 0;

def EI_MAG1[link]

Show undocumented member
def EI_MAG1: uint = 1;

def EI_MAG2[link]

Show undocumented member
def EI_MAG2: uint = 2;

def EI_MAG3[link]

Show undocumented member
def EI_MAG3: uint = 3;

def EI_NIDENT[link]

Show undocumented member
def EI_NIDENT: uint = 16;

def EI_OSABI[link]

Show undocumented member
def EI_OSABI: uint = 7;

def EI_PAD[link]

Show undocumented member
def EI_PAD: uint = 9;

def EI_VERSION[link]

Show undocumented member
def EI_VERSION: uint = 6;

def EV_CURRENT[link]

Show undocumented member
def EV_CURRENT: u32 = 1;

def MAGIC[link]

Show undocumented member
def MAGIC: str = "ELF";

Functions

fn r64_info[link]

fn r64_info(sym: u64, stype: u64) u64;

Converts symbol table index and a relocation type into [rel64.r_info].

Equivalent to the ELF64_R_INFO macro.

fn r64_sym[link]

fn r64_sym(info: u64) u64;

Obtains the symbol table index part of [rel64.r_info].

Equivalent to the ELF64_R_SYM macro.

fn r64_type[link]

fn r64_type(info: u64) u64;

Obtains the relocation type part of [rel64.r_info].

Equivalent to the ELF64_R_TYPE macro.

fn st_bind[link]

fn st_bind(i: u8) stb;

Obtains the binding part of [sym64.st_info].

Equivalent to the ELF64_ST_BIND macro.

fn st_info[link]

fn st_info(b: stb, t: stt) u8;

Converts symbol bindings and type into [sym64.st_info].

Equivalent to the ELF64_ST_INFO macro.

fn st_type[link]

fn st_type(i: u8) stt;

Obtains the type part of [sym64.st_info].

Equivalent to the ELF64_ST_TYPE macro.