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:ar archive

From ReverseEngineering.wiki
Format
Magic 21 3C 61 72 63 68 3E 0A (!<arch> and a linefeed)
Extensions .a, .deb, .ar
Endianness ASCII decimal fields; GNU symbol table integers big-endian
On this wiki Facts · Code · Notes · Topics

The Unix ar archive (.a static libraries, .deb packages): the 8-byte magic "!<arch>" plus linefeed, then 60-byte ASCII member headers, with BSD (#1/N) and GNU/SVR4 (// string table, /N) long-name variants.

Layout

The file starts with the 8 bytes !<arch> plus a linefeed (21 3C 61 72 63 68 3E 0A). Each member is a fixed 60-byte ASCII header followed by the member data. From the FreeBSD ar(5) manual page:

Field Bytes Meaning
ar_name 16 member name
ar_date 12 modification time, decimal seconds
ar_uid 6 user id, decimal
ar_gid 6 group id, decimal
ar_mode 8 file mode, octal
ar_size 10 size in bytes, decimal
ar_fmag 2 terminator 60 0A (backtick, linefeed)

Unused bytes of a field are spaces (0x20). Every header starts at an even offset: if a member's data has an odd size, one 0A padding byte follows it. The FreeBSD page prints the terminator as 0x96, which is a typo for 0x60 (backtick).

Long names

  • BSD: ar_name is #1/ plus the decimal length of the name. The name is the first bytes after the header (no padding) and ar_size counts name plus data.
  • GNU / SVR4: short names are stored with a trailing / (so at most 15 characters). Longer names live in a special member called // (the string table; each entry ends with / and a linefeed). A member then has ar_name / plus the decimal offset into that table, for example /768.

Special members

  • / (GNU/SVR4): the symbol table, first member if present. A 4-byte big-endian count, that many 4-byte big-endian offsets of member headers, then that many NUL-terminated symbol names.
  • // (GNU/SVR4): the long-name string table, after the symbol table if there is one.
  • __.SYMDEF (BSD): the symbol table, first member if present: a size, an array of struct ranlib (string offset, member header offset), a second size and the NUL-terminated names. The layout is machine dependent.
  • Unverified: macOS libraries use __.SYMDEF SORTED (and 64-bit variants) for the same purpose; the FreeBSD page does not mention them.

For the analyst

  • A static library (.a) is an ar archive of object files (Format:ELF (Executable and Linkable Format) on Linux, Format:Mach-O on macOS); extract the members, then analyze each object. Debian packages are ar archives too: see Format:Debian package.
  • Dates, uids and gids are often zeroed in reproducible builds; do not read meaning into them.
  • The Debian deb(5) page says dpkg supports only the common ar format without long-name extensions.

Sources

FreeBSD ar(5) manual page and Debian deb(5) manual page (documentation, read online).

Code & repositories

  • https://github.com/libarchive/libarchive @ 7f149b1076f27449a6cfcb92e5046aea8590f833 · license: BSD-2-Clause (declared by the contributor for the files used; GitHub reports BSD-2-Clause (read from COPYING; GitHub's API was busy) for the repository)
    libarchive: archive_read_support_format_cpio.c (odc, newc, binary) and _ar.c readers
    Tested on: source read, not run · checked 2026-10-19