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:kallsyms

From ReverseEngineering.wiki
Format
On this wiki Facts · Code · Notes · Topics

The Linux kernel's built-in symbol table (CONFIG_KALLSYMS): a token-compressed name stream, markers every 256 symbols and an address table (absolute or relative); tools like vmlinux-to-elf rebuild it from a raw kernel image.

What it is

scripts/kallsyms.c runs at build time on the symbols of the linked kernel and emits assembly that becomes read-only data in vmlinux. At run time it serves /proc/kallsyms, oops traces and kallsyms_lookup_name.

Layout

Tables emitted by scripts/kallsyms.c (kernel master): see Fact:Kallsyms/behavior/Emitted tables and order. kallsyms_num_syms (u32), kallsyms_names, kallsyms_markers (one u32 per 256 symbols), kallsyms_token_table (256 NUL-terminated strings), kallsyms_token_index (256 u16) and kallsyms_offsets, in the newest sources also kallsyms_seqs_of_names. Older kernels emit kallsyms_addresses (absolute, pointer sized) or kallsyms_offsets plus kallsyms_relative_base (CONFIG_KALLSYMS_BASE_RELATIVE, kernel 4.6 and later on most architectures). The order of the address table relative to the others changed across versions: vmlinux-to-elf treats 6.4 and later separately.

Name encoding

Fact:Kallsyms/struct/Name record encoding: a length (one byte, or two when above 0x7F), then token codes. The first expanded character is the nm type letter (T, t, D, d, B, b, R, r, A, W, V), the rest is the name. The token table maps byte codes to strings (byte-pair merges); codes of characters used in some symbol hold that character, which is what makes the table findable.

Recovering it from a raw image

Fact:Kallsyms/identification/Finding the token table in a raw image. vmlinux-to-elf (GPL-3.0) works in this order: token table, token index (its 256 offsets reveal endianness), markers (increasing offsets starting at 0), names (before the markers), number of symbols, then addresses (absolute, or u32 offsets with a relative base). Pointer size, endianness and kernel version come from the ISA prologue scan and the Linux version banner. It then writes an ELF with the symbols; it first unpacks bzImage, zImage, uImage and Android boot images (Format:Linux x86 boot image (bzImage)).

Pitfalls

  • No table when CONFIG_KALLSYMS is off. Without CONFIG_KALLSYMS_ALL only text symbols exist.
  • With relative addressing, address = relative_base + offset (negative values encode absolute per-cpu symbols); reading them as absolute gives garbage.
  • Unverified: vmlinux-to-elf mentions a kernel 7.0 change making offsets relative to their own slot, and scripts/kallsyms.c --pc-relative matches that (_text - . + offset); test on a 7.x image.
  • OpenWrt builds can store names uncompressed.

Code & repositories

vmlinux-to-elf vmlinux_to_elf/core/kallsyms.py; kernel scripts/kallsyms.c, kernel/kallsyms.c. See Platform:Linux kernel.

  • https://github.com/marin-m/vmlinux-to-elf @ 2d094bc9c220b6b50f8215cbc3c9e581210ce1a6 · license: GPL-3.0
    Recovers kallsyms and rebuilds an ELF from raw or compressed kernel images (GPL-3.0); vmlinux_to_elf/core/kallsyms.py documents the heuristics
    Tested on: source read, not run: not run; source read at the pinned commit · checked 2026-10-18; last activity 2026-10-16