wire / wire-format / elf-header

ELF64 header (Executable and Linkable Format)

The ELF64 header is the first 64 bytes of every ELF object/executable/shared object/core dump. It identifies the file (magic \x7fELF), declares the class (32/64-bit), endianness, OS/ABI, type (relocatable/executable/shared/core), machine architecture, and offsets to the program and section header tables.

wire-format kind wire-format status standard verification verified tier B wire-format@1

aka: ELF64 header (Executable and Linkable Format)

wire format

spec: System V ABI / ELF-64 Object File Format specification

The ELF64 header is the first 64 bytes of every ELF object/executable/shared object/core dump. It identifies the file (magic \x7fELF), declares the class (32/64-bit), endianness, OS/ABI, type (relocatable/executable/shared/core), machine architecture, and offsets to the program and section header tables.

fieldsizemeaning
Magic4 bytes0x7F 'E' 'L' 'F' (0x7F 0x45 0x4C 0x46).
EI_CLASS1 byte1 = 32-bit (ELF32), 2 = 64-bit (ELF64).
EI_DATA1 byte1 = little-endian, 2 = big-endian.
EI_VERSION1 byteELF version (always 1).
EI_OSABI1 byteTarget OS/ABI (0 System V, 3 Linux, 6 Solaris, 9 FreeBSD, 12 OpenBSD, ...).
EI_ABIVERSION1 byteABI version (usually 0).
Padding7 bytesZero padding to 16-byte boundary.
e_type2 bytesObject type: 1 relocatable, 2 executable, 3 shared object (DSO), 4 core.
e_machine2 bytesArchitecture: 0x03 x86, 0x28 ARM, 0x3E x86-64, 0xB7 AArch64, 0xF3 RISC-V.
e_version4 bytesObject version (always 1).
e_entry8 bytesVirtual address of entry point (0 if none).
e_phoff8 bytesFile offset to program header table.
e_shoff8 bytesFile offset to section header table.
e_flags4 bytesProcessor-specific flags.
e_ehsize2 bytesELF header size (64 for ELF64).
e_phentsize2 bytesProgram header entry size (56 for ELF64).
e_phnum2 bytesNumber of program header entries.
e_shentsize2 bytesSection header entry size (64 for ELF64).
e_shnum2 bytesNumber of section header entries.
e_shstrndx2 bytesSection name string table index.

example:

7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 02 00 3e 00 01 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 00 38 00 01 00 00 00 00 00 00 00

ELF64 little-endian executable for x86-64


provenance

agent: curl -H 'accept: application/json' wire.phall.io/wire-format/elf-header or /wire-format/elf-header.json