Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:ELF (Executable and Linkable Format)/Core dumps

From ReverseEngineering.wiki

Linux ELF core files (e_type ET_CORE): one PT_NOTE segment of process notes (NT_PRSTATUS per thread, NT_PRPSINFO, NT_SIGINFO, NT_AUXV, NT_FILE, register-set notes) followed by PT_LOAD segments holding the memory, with the struct layouts a parser needs.

Overview

A core file is an ELF file whose e_type is 4 (ET_CORE), with no section headers and no PT_INTERP. The kernel writer (fs/binfmt_elf.c, elf_core_dump) emits one PT_NOTE program header whose segment holds all notes, then one PT_LOAD per dumped mapping (p_vaddr = virtual address, p_filesz can be smaller than p_memsz or zero for omitted pages, e.g. mapped files that were not dirtied). Load it in GDB with gdb prog core or in LLDB with target create -c core; the mapped executable and libraries are named in NT_FILE, so they can be located without the original process.

Note format

Each note is Elf_Nhdr { u32 n_namesz; u32 n_descsz; u32 n_type; } (12 bytes in both classes), then the name (n_namesz bytes including the trailing NUL, padded to 4 bytes), then the descriptor (n_descsz bytes, padded to 4). Owners: CORE for the generic notes, LINUX for the architecture register sets (the kernel warns if a register set uses another owner), GNU for NT_GNU_* build notes in executables. Type numbers (include/uapi/linux/elf.h): NT_PRSTATUS 1, NT_PRFPREG 2, NT_PRPSINFO 3, NT_TASKSTRUCT 4, NT_AUXV 6, NT_SIGINFO 0x53494749 ('SIGI'), NT_FILE 0x46494c45 ('FILE'). Register-set types by architecture: x86 NT_386_TLS 0x200, NT_386_IOPERM 0x201, NT_X86_XSTATE 0x202 (XSAVE area), NT_X86_SHSTK 0x204, NT_X86_XSAVE_LAYOUT 0x205; PowerPC NT_PPC_VMX 0x100 .. NT_PPC_HASHKEYR 0x112; s390 0x300-0x30e; ARM NT_ARM_VFP 0x400, NT_ARM_TLS 0x401, NT_ARM_HW_BREAK 0x402, NT_ARM_HW_WATCH 0x403, NT_ARM_SVE 0x405, NT_ARM_PAC_MASK 0x406, NT_ARM_TAGGED_ADDR_CTRL 0x409, NT_ARM_ZA 0x40c; MIPS 0x800-0x802; RISC-V NT_RISCV_CSR 0x900, NT_RISCV_VECTOR 0x901; LoongArch 0xa00-0xa03. Note: for the type values that carry the NT_PRFPREG name, older headers say NT_FPREGSET.

Order in a Linux core: the main thread's NT_PRSTATUS, NT_PRPSINFO, NT_SIGINFO, NT_AUXV, NT_FILE, the main thread's other register sets; then for each further thread its own NT_PRSTATUS and register-set notes. Unverified: the exact order, only the note filling code was skimmed.

NT_PRSTATUS (struct elf_prstatus)

From include/linux/elfcore.h: elf_siginfo pr_info (si_signo, si_code, si_errno: three ints), short pr_cursig, unsigned long pr_sigpend, pr_sighold, pid_t pr_pid, pr_ppid, pr_pgrp, pr_sid, four timeval (pr_utime, pr_stime, pr_cutime, pr_cstime), then elf_gregset_t pr_reg and int pr_fpvalid. Offsets I computed for x86-64 (LP64, timeval = 16 bytes): pr_info 0, pr_cursig 12, pr_sigpend 16, pr_sighold 24, pr_pid 32, pr_ppid 36, pr_pgrp 40, pr_sid 44, times 48-111, pr_reg 112 (27 x 8 = 216 bytes), pr_fpvalid 328, total 336. For 32-bit x86 the same struct is 144 bytes. pr_reg is the architecture's user_regs_struct (x86-64 order, unverified, from memory: r15 r14 r13 r12 rbp rbx r11 r10 r9 r8 rax rcx rdx rsi rdi orig_rax rip cs eflags rsp ss fs_base gs_base ds es fs gs). Because the field order differs from GDB's g packet order, convert when serving a core through a Format:GDB Remote Serial Protocol stub.

NT_PRPSINFO (struct elf_prpsinfo)

char pr_state, pr_sname, pr_zomb, pr_nice; unsigned long pr_flag; uid_t pr_uid; gid_t pr_gid; pid_t pr_pid, pr_ppid, pr_pgrp, pr_sid; char pr_fname[16]; char pr_psargs[80] (ELF_PRARGSZ = 80). x86-64 offsets (computed, uid/gid are 32-bit there): pr_flag 8, pr_uid 16, pr_gid 20, pids 24-39, pr_fname 40, pr_psargs 56, size 136. pr_fname is the executable's basename truncated to 15 characters (TASK_COMM_LEN 16), pr_psargs the start of the command line with NULs turned into spaces, so a core file tells you the program name and arguments without the binary.

NT_FILE (mapped files)

Documented in fs/binfmt_elf.c: long count; long page_size; then count entries of { long start; long end; long file_ofs; } (file_ofs in units of page_size), followed by count NUL-terminated file names in the same order. Longs are 8 bytes in a 64-bit core. This is the way to recover the list of loaded modules and their base addresses from a core with no section headers: group entries by name and take the lowest start with file_ofs 0.

NT_AUXV

The process's auxiliary vector copied from the stack: an array of { elf_addr_t a_type; elf_addr_t a_val; } pairs ended by AT_NULL (0). Useful tags (include/uapi/linux/auxvec.h): AT_PHDR 3 (address of the program headers, gives the load base of a PIE), AT_PHENT 4, AT_PHNUM 5, AT_PAGESZ 6, AT_BASE 7 (interpreter base), AT_ENTRY 9, AT_UID 11-14, AT_PLATFORM 15, AT_HWCAP 16, AT_SECURE 23, AT_RANDOM 25 (address of the 16 random bytes), AT_HWCAP2 26, AT_EXECFN 31 (address of the executable path string), AT_MINSIGSTKSZ 51. AT_ENTRY minus the file's e_entry is the ASLR slide of a PIE.

NT_SIGINFO and others

NT_SIGINFO holds the kernel siginfo_t of the fatal signal (128 bytes on current kernels; the header warns the size may grow). NT_X86_XSTATE is the raw XSAVE area (layout by CPUID leaf 0xD, described by NT_X86_XSAVE_LAYOUT when present). Android and Chromium tombstones are text, not ELF cores; Breakpad/Crashpad dumps use Format:Minidump even on Linux.

Pitfalls

  • Core files from other systems differ: FreeBSD uses owner FreeBSD with its own types (NT_FREEBSD_*), and the structures use different layouts. Unverified here.
  • A truncated core (ulimit, systemd-coredump size limit, or coredump_filter bits) has PT_LOAD headers whose p_filesz is 0 or short; read memory through the headers rather than assuming contiguity.
  • e_machine and class tell the pr_reg layout; 32-bit processes on a 64-bit kernel produce ELF32 cores.

See also Format:ELF (Executable and Linkable Format) (the generic note table is in its Notes section) and Format:Windows kernel crash dump for the Windows counterpart.

Evidence & references

torvalds/linux include/uapi/linux/elf.h, include/linux/elfcore.h, include/uapi/linux/auxvec.h, fs/binfmt_elf.c (read from the default branch, October 2026).